Skip to content

Commit

Permalink
fix(Component): Changed boundAttrubutes setter to work with named att…
Browse files Browse the repository at this point in the history
…ributes with no values eg: 'disabled' or 'required' for Component inputs
  • Loading branch information
calebdwilliams committed Jul 19, 2018
1 parent af449a5 commit de8af6f
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 14 deletions.
5 changes: 3 additions & 2 deletions dist/templiteral.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ class Component extends HTMLElement {
return this.getAttribute(attr);
},
set(_attr) {
if (_attr) {
if (_attr || attr === '') {
this.setAttribute(attr, _attr);
} else {
this.removeAttribute(attr);
Expand All @@ -472,7 +472,6 @@ class Component extends HTMLElement {
this[this.constructor.renderer]();
}
attrs.add(attr);

}
});
});
Expand Down Expand Up @@ -508,6 +507,8 @@ class Component extends HTMLElement {
attributeChangedCallback(name, oldValue, newValue) {
if (oldValue !== newValue) {
this[name] = newValue;
} else if (newValue === '' && this.hasAttribute(name)) {
this[name] = true;
}
}

Expand Down
2 changes: 1 addition & 1 deletion dist/templiteral.cjs.min.js

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions dist/templiteral.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ class Component extends HTMLElement {
return this.getAttribute(attr);
},
set(_attr) {
if (_attr) {
if (_attr || attr === '') {
this.setAttribute(attr, _attr);
} else {
this.removeAttribute(attr);
Expand All @@ -468,7 +468,6 @@ class Component extends HTMLElement {
this[this.constructor.renderer]();
}
attrs.add(attr);

}
});
});
Expand Down Expand Up @@ -504,6 +503,8 @@ class Component extends HTMLElement {
attributeChangedCallback(name, oldValue, newValue) {
if (oldValue !== newValue) {
this[name] = newValue;
} else if (newValue === '' && this.hasAttribute(name)) {
this[name] = true;
}
}

Expand Down
2 changes: 1 addition & 1 deletion dist/templiteral.es.min.js

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions dist/templiteral.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ class Component extends HTMLElement {
return this.getAttribute(attr);
},
set(_attr) {
if (_attr) {
if (_attr || attr === '') {
this.setAttribute(attr, _attr);
} else {
this.removeAttribute(attr);
Expand All @@ -471,7 +471,6 @@ class Component extends HTMLElement {
this[this.constructor.renderer]();
}
attrs.add(attr);

}
});
});
Expand Down Expand Up @@ -507,6 +506,8 @@ class Component extends HTMLElement {
attributeChangedCallback(name, oldValue, newValue) {
if (oldValue !== newValue) {
this[name] = newValue;
} else if (newValue === '' && this.hasAttribute(name)) {
this[name] = true;
}
}

Expand Down
2 changes: 1 addition & 1 deletion dist/templiteral.min.js

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions dist/templiteral.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ class Component extends HTMLElement {
return this.getAttribute(attr);
},
set(_attr) {
if (_attr) {
if (_attr || attr === '') {
this.setAttribute(attr, _attr);
} else {
this.removeAttribute(attr);
Expand All @@ -474,7 +474,6 @@ class Component extends HTMLElement {
this[this.constructor.renderer]();
}
attrs.add(attr);

}
});
});
Expand Down Expand Up @@ -510,6 +509,8 @@ class Component extends HTMLElement {
attributeChangedCallback(name, oldValue, newValue) {
if (oldValue !== newValue) {
this[name] = newValue;
} else if (newValue === '' && this.hasAttribute(name)) {
this[name] = true;
}
}

Expand Down
2 changes: 1 addition & 1 deletion dist/templiteral.umd.min.js

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions src/templiteral.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class Component extends HTMLElement {
return this.getAttribute(attr);
},
set(_attr) {
if (_attr) {
if (_attr || attr === '') {
this.setAttribute(attr, _attr);
} else {
this.removeAttribute(attr);
Expand All @@ -73,7 +73,6 @@ export class Component extends HTMLElement {
this[this.constructor.renderer]();
}
attrs.add(attr);

}
});
});
Expand Down Expand Up @@ -109,6 +108,8 @@ export class Component extends HTMLElement {
attributeChangedCallback(name, oldValue, newValue) {
if (oldValue !== newValue) {
this[name] = newValue;
} else if (newValue === '' && this.hasAttribute(name)) {
this[name] = true;
}
}

Expand Down

0 comments on commit de8af6f

Please sign in to comment.