Skip to content

Commit 2bd2a74

Browse files
committed
1 parent fb04ef1 commit 2bd2a74

File tree

8 files changed

+637
-30
lines changed

8 files changed

+637
-30
lines changed

cjs/index.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class HyperHTMLElement extends HTMLElement {
127127
configurable: true,
128128
value: function aCC(name, prev, curr) {
129129
if (this._init$) {
130-
checkReady.call(this, created, attributes);
130+
checkReady.call(this, created, attributes, booleanAttributes);
131131
if (this._init$)
132132
return this._init$$.push(aCC.bind(this, name, prev, curr));
133133
}
@@ -149,7 +149,7 @@ class HyperHTMLElement extends HTMLElement {
149149
configurable: true,
150150
value: function cC() {
151151
if (this._init$) {
152-
checkReady.call(this, created, attributes);
152+
checkReady.call(this, created, attributes, booleanAttributes);
153153
if (this._init$)
154154
return this._init$$.push(cC.bind(this));
155155
}
@@ -355,12 +355,16 @@ if (!dom.ready()) {
355355
document.addEventListener(dom.type, dom, false);
356356
}
357357

358-
function checkReady(created, attributes) {
359-
if (dom.ready() || isReady.call(this, created, attributes)) {
358+
function checkReady(created, attributes, booleanAttributes) {
359+
if (dom.ready() || isReady.call(this, created, attributes, booleanAttributes)) {
360360
if (this._init$) {
361361
const list = this._init$$ || [];
362362
delete this._init$$;
363363
const self = defineProperty(this, '_init$', {value: false});
364+
booleanAttributes.forEach(name => {
365+
if (self.getAttribute(name) === 'false')
366+
self.removeAttribute(name);
367+
});
364368
attributes.forEach(name => {
365369
if (self.hasOwnProperty(name)) {
366370
const curr = self[name];
@@ -374,7 +378,7 @@ function checkReady(created, attributes) {
374378
} else {
375379
if (!this.hasOwnProperty('_init$$'))
376380
defineProperty(this, '_init$$', {configurable: true, value: []});
377-
dom.list.push(checkReady.bind(this, created, attributes));
381+
dom.list.push(checkReady.bind(this, created, attributes, booleanAttributes));
378382
}
379383
}
380384

@@ -386,10 +390,10 @@ function isPrototypeOf(Class) {
386390
return this === Class.prototype;
387391
}
388392

389-
function isReady(created, attributes) {
393+
function isReady(created, attributes, booleanAttributes) {
390394
let el = this;
391395
do { if (el.nextSibling) return true; }
392396
while (el = el.parentNode);
393-
setTimeout(checkReady.bind(this, created, attributes));
397+
setTimeout(checkReady.bind(this, created, attributes, booleanAttributes));
394398
return false;
395399
}

es5.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2380,7 +2380,7 @@ var HyperHTMLElement = (function (exports) {
23802380
configurable: true,
23812381
value: function aCC(name, prev, curr) {
23822382
if (this._init$) {
2383-
checkReady.call(this, created, attributes);
2383+
checkReady.call(this, created, attributes, booleanAttributes);
23842384
if (this._init$) return this._init$$.push(aCC.bind(this, name, prev, curr));
23852385
} // ensure setting same value twice
23862386
// won't trigger twice attributeChangedCallback
@@ -2397,7 +2397,7 @@ var HyperHTMLElement = (function (exports) {
23972397
configurable: true,
23982398
value: function cC() {
23992399
if (this._init$) {
2400-
checkReady.call(this, created, attributes);
2400+
checkReady.call(this, created, attributes, booleanAttributes);
24012401
if (this._init$) return this._init$$.push(cC.bind(this));
24022402
}
24032403

@@ -2535,14 +2535,17 @@ var HyperHTMLElement = (function (exports) {
25352535
document.addEventListener(dom.type, dom, false);
25362536
}
25372537

2538-
function checkReady(created, attributes) {
2539-
if (dom.ready() || isReady.call(this, created, attributes)) {
2538+
function checkReady(created, attributes, booleanAttributes) {
2539+
if (dom.ready() || isReady.call(this, created, attributes, booleanAttributes)) {
25402540
if (this._init$) {
25412541
var list = this._init$$ || [];
25422542
delete this._init$$;
25432543
var self = defineProperty(this, '_init$', {
25442544
value: false
25452545
});
2546+
booleanAttributes.forEach(function (name) {
2547+
if (self.getAttribute(name) === 'false') self.removeAttribute(name);
2548+
});
25462549
attributes.forEach(function (name) {
25472550
if (self.hasOwnProperty(name)) {
25482551
var curr = self[name];
@@ -2560,7 +2563,7 @@ var HyperHTMLElement = (function (exports) {
25602563
configurable: true,
25612564
value: []
25622565
});
2563-
dom.list.push(checkReady.bind(this, created, attributes));
2566+
dom.list.push(checkReady.bind(this, created, attributes, booleanAttributes));
25642567
}
25652568
}
25662569

@@ -2572,14 +2575,14 @@ var HyperHTMLElement = (function (exports) {
25722575
return this === Class.prototype;
25732576
}
25742577

2575-
function isReady(created, attributes) {
2578+
function isReady(created, attributes, booleanAttributes) {
25762579
var el = this;
25772580

25782581
do {
25792582
if (el.nextSibling) return true;
25802583
} while (el = el.parentNode);
25812584

2582-
setTimeout(checkReady.bind(this, created, attributes));
2585+
setTimeout(checkReady.bind(this, created, attributes, booleanAttributes));
25832586
return false;
25842587
}
25852588

es5.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

esm/index.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class HyperHTMLElement extends HTMLElement {
126126
configurable: true,
127127
value: function aCC(name, prev, curr) {
128128
if (this._init$) {
129-
checkReady.call(this, created, attributes);
129+
checkReady.call(this, created, attributes, booleanAttributes);
130130
if (this._init$)
131131
return this._init$$.push(aCC.bind(this, name, prev, curr));
132132
}
@@ -148,7 +148,7 @@ class HyperHTMLElement extends HTMLElement {
148148
configurable: true,
149149
value: function cC() {
150150
if (this._init$) {
151-
checkReady.call(this, created, attributes);
151+
checkReady.call(this, created, attributes, booleanAttributes);
152152
if (this._init$)
153153
return this._init$$.push(cC.bind(this));
154154
}
@@ -354,12 +354,16 @@ if (!dom.ready()) {
354354
document.addEventListener(dom.type, dom, false);
355355
}
356356

357-
function checkReady(created, attributes) {
358-
if (dom.ready() || isReady.call(this, created, attributes)) {
357+
function checkReady(created, attributes, booleanAttributes) {
358+
if (dom.ready() || isReady.call(this, created, attributes, booleanAttributes)) {
359359
if (this._init$) {
360360
const list = this._init$$ || [];
361361
delete this._init$$;
362362
const self = defineProperty(this, '_init$', {value: false});
363+
booleanAttributes.forEach(name => {
364+
if (self.getAttribute(name) === 'false')
365+
self.removeAttribute(name);
366+
});
363367
attributes.forEach(name => {
364368
if (self.hasOwnProperty(name)) {
365369
const curr = self[name];
@@ -373,7 +377,7 @@ function checkReady(created, attributes) {
373377
} else {
374378
if (!this.hasOwnProperty('_init$$'))
375379
defineProperty(this, '_init$$', {configurable: true, value: []});
376-
dom.list.push(checkReady.bind(this, created, attributes));
380+
dom.list.push(checkReady.bind(this, created, attributes, booleanAttributes));
377381
}
378382
}
379383

@@ -385,10 +389,10 @@ function isPrototypeOf(Class) {
385389
return this === Class.prototype;
386390
}
387391

388-
function isReady(created, attributes) {
392+
function isReady(created, attributes, booleanAttributes) {
389393
let el = this;
390394
do { if (el.nextSibling) return true; }
391395
while (el = el.parentNode);
392-
setTimeout(checkReady.bind(this, created, attributes));
396+
setTimeout(checkReady.bind(this, created, attributes, booleanAttributes));
393397
return false;
394398
}

index.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2321,7 +2321,7 @@ var HyperHTMLElement = (function (exports) {
23212321
configurable: true,
23222322
value: function aCC(name, prev, curr) {
23232323
if (this._init$) {
2324-
checkReady.call(this, created, attributes);
2324+
checkReady.call(this, created, attributes, booleanAttributes);
23252325
if (this._init$)
23262326
return this._init$$.push(aCC.bind(this, name, prev, curr));
23272327
}
@@ -2343,7 +2343,7 @@ var HyperHTMLElement = (function (exports) {
23432343
configurable: true,
23442344
value: function cC() {
23452345
if (this._init$) {
2346-
checkReady.call(this, created, attributes);
2346+
checkReady.call(this, created, attributes, booleanAttributes);
23472347
if (this._init$)
23482348
return this._init$$.push(cC.bind(this));
23492349
}
@@ -2546,12 +2546,16 @@ var HyperHTMLElement = (function (exports) {
25462546
document.addEventListener(dom.type, dom, false);
25472547
}
25482548

2549-
function checkReady(created, attributes) {
2550-
if (dom.ready() || isReady.call(this, created, attributes)) {
2549+
function checkReady(created, attributes, booleanAttributes) {
2550+
if (dom.ready() || isReady.call(this, created, attributes, booleanAttributes)) {
25512551
if (this._init$) {
25522552
const list = this._init$$ || [];
25532553
delete this._init$$;
25542554
const self = defineProperty(this, '_init$', {value: false});
2555+
booleanAttributes.forEach(name => {
2556+
if (self.getAttribute(name) === 'false')
2557+
self.removeAttribute(name);
2558+
});
25552559
attributes.forEach(name => {
25562560
if (self.hasOwnProperty(name)) {
25572561
const curr = self[name];
@@ -2565,7 +2569,7 @@ var HyperHTMLElement = (function (exports) {
25652569
} else {
25662570
if (!this.hasOwnProperty('_init$$'))
25672571
defineProperty(this, '_init$$', {configurable: true, value: []});
2568-
dom.list.push(checkReady.bind(this, created, attributes));
2572+
dom.list.push(checkReady.bind(this, created, attributes, booleanAttributes));
25692573
}
25702574
}
25712575

@@ -2577,11 +2581,11 @@ var HyperHTMLElement = (function (exports) {
25772581
return this === Class.prototype;
25782582
}
25792583

2580-
function isReady(created, attributes) {
2584+
function isReady(created, attributes, booleanAttributes) {
25812585
let el = this;
25822586
do { if (el.nextSibling) return true; }
25832587
while (el = el.parentNode);
2584-
setTimeout(checkReady.bind(this, created, attributes));
2588+
setTimeout(checkReady.bind(this, created, attributes, booleanAttributes));
25852589
return false;
25862590
}
25872591

min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)