diff --git a/src/CustomElements.js b/src/CustomElements.js index f75c581..23ba63c 100644 --- a/src/CustomElements.js +++ b/src/CustomElements.js @@ -276,17 +276,20 @@ if (useNative) { changeAttribute.call(this, name, value, setAttribute); } var removeAttribute = prototype.removeAttribute; - prototype.removeAttribute = function(name, value) { - changeAttribute.call(this, name, value, removeAttribute); + prototype.removeAttribute = function(name) { + changeAttribute.call(this, name, null, removeAttribute); } } + // https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/custom/ + // index.html#dfn-attribute-changed-callback function changeAttribute(name, value, operation) { var oldValue = this.getAttribute(name); operation.apply(this, arguments); - if (this.attributeChangedCallback - && (this.getAttribute(name) !== oldValue)) { - this.attributeChangedCallback(name, oldValue); + var newValue = this.getAttribute(name); + if (this.attributeChangedCallback + && (newValue !== oldValue)) { + this.attributeChangedCallback(name, oldValue, newValue); } } diff --git a/test/html/attributes.html b/test/html/attributes.html index 00c9938..d0a7a16 100644 --- a/test/html/attributes.html +++ b/test/html/attributes.html @@ -20,8 +20,9 @@ this.setAttributeOk = true; HTMLElement.prototype.setAttribute.call(this, name, value); }; - prototype.attributeChangedCallback = function(name) { - this.attributeChangedOk = (name == 'squid'); + prototype.attributeChangedCallback = function(name, oldValue, newValue) { + this.attributeChangedOk = (name === 'squid') && (oldValue === null) + && (newValue === 'tentacles'); }; document.register('x-foo', {prototype: prototype});