You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the polyfill is active, creating and adding an Attr node to an element, changing an existing Attr node, or removing an Attr node from an element does not trigger the attributeChangedCallback.
When the polyfill is not active, these modifications do trigger the attributeChangedCallback.
This does not just influence custom elements using the scoped registry, but all custom elements on the page. Therefore, loading the polyfill could break unrelated code.
Example
<!DOCTYPE html><htmllang="en"><head><metacharset="UTF-8"><scriptsrc="https://unpkg.com/@webcomponents/[email protected]/src/scoped-custom-element-registry.js"></script></head><body><script>customElements.define('my-element',classMyElementextendsHTMLElement{staticgetobservedAttributes(){return['param'];}attributeChangedCallback(name,oldValue,newValue){console.log('attributeChangedCallback',{ name, oldValue, newValue });}});constelement=document.createElement('my-element');constattr=document.createAttribute('param');attr.value='Initial value';// This should log adding the attributeelement.setAttributeNode(attr);// This should log changing the attributeattr.value='New value';// This should log changing the attributeelement.getAttributeNode('param').value='Another value';for(constnodeofelement.attributes){if(node.nodeName==='param'){// This should log changing the attributenode.value='Value from for-loop';}}// This should log removing the attributeelement.removeAttributeNode(attr);</script></body></html>
I have also created a number of tests demonstrating this behavior in this patch file: attributeNode-tests.txt.
Expected behavior
Modifications to an Element's observed Attr nodes should trigger the attributeChangedCallback.
Actual behavior
Modifications to an Element's observed Attr nodes do not trigger the attributeChangedCallback.
Version
0.0.9
Browsers affected
Chrome
Firefox
Edge
Safari
IE 11
(only browsers I could test)
The text was updated successfully, but these errors were encountered:
Description
When the polyfill is active, creating and adding an
Attr
node to an element, changing an existingAttr
node, or removing anAttr
node from an element does not trigger theattributeChangedCallback
.When the polyfill is not active, these modifications do trigger the
attributeChangedCallback
.This does not just influence custom elements using the scoped registry, but all custom elements on the page. Therefore, loading the polyfill could break unrelated code.
Example
I have also created a number of tests demonstrating this behavior in this patch file: attributeNode-tests.txt.
Expected behavior
Modifications to an Element's observed Attr nodes should trigger the attributeChangedCallback.
Actual behavior
Modifications to an Element's observed Attr nodes do not trigger the attributeChangedCallback.
Version
0.0.9
Browsers affected
(only browsers I could test)
The text was updated successfully, but these errors were encountered: