diff --git a/packages/scoped-custom-element-registry/src/scoped-custom-element-registry.ts b/packages/scoped-custom-element-registry/src/scoped-custom-element-registry.ts index d46f9228..5cc04187 100644 --- a/packages/scoped-custom-element-registry/src/scoped-custom-element-registry.ts +++ b/packages/scoped-custom-element-registry/src/scoped-custom-element-registry.ts @@ -520,7 +520,8 @@ const patchAttributes = ( if (observedAttributes.has(name)) { const old = this.getAttribute(name); setAttribute.call(this, name, value); - attributeChangedCallback.call(this, name, old, value); + const newValue = this.getAttribute(name); + attributeChangedCallback.call(this, name, old, newValue); } else { setAttribute.call(this, name, value); } diff --git a/packages/scoped-custom-element-registry/test/Element.test.html.js b/packages/scoped-custom-element-registry/test/Element.test.html.js index 4d3df101..a4b51cda 100644 --- a/packages/scoped-custom-element-registry/test/Element.test.html.js +++ b/packages/scoped-custom-element-registry/test/Element.test.html.js @@ -114,13 +114,21 @@ describe('Element', () => { it('should call setAttribute', () => { const {tagName, CustomElementClass} = getObservedAttributesTestElement([ 'foo', + 'boo', + 'int', ]); customElements.define(tagName, CustomElementClass); const $el = document.createElement(tagName); $el.setAttribute('foo', 'bar'); + $el.setAttribute('boo', true); + $el.setAttribute('boo', false); + $el.setAttribute('int', 42); expect($el.attributeChanges).to.be.deep.equal([ {name: 'foo', old: null, value: 'bar'}, + {name: 'boo', old: null, value: 'true'}, + {name: 'boo', old: 'true', value: 'false'}, + {name: 'int', old: null, value: '42'}, ]); expect($el.getAttribute('foo')).to.equal('bar'); });