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
The callback attributeChangedCallback is being called on ANY attribute change, not only on the observed ones as expected.
here is a jest test to help you reproduce
import{Window}from"happy-dom";classMyElemextendsHTMLElement{attributeChangedCallback(attribute,oldValue,newValue){}staticgetobservedAttributes(){return['my-attr'];}}constwindow=newWindow();constdocument=window.document;letmyElem;window.customElements.define("my-elem",MyElem);beforeEach(()=>{document.body.innerHTML="<my-elem id='my-elem'></my-elem>";myElem=document.querySelector("#my-elem");});describe("Make sure component is created",()=>{//SUCCESStest("’Make sure <my-elem> is defined",()=>{expect(myElem).not.toBeNull();});//SUCCESStest("’Make sure changing an observed attribute will triiger change callback",()=>{constspy=jest.spyOn(myElem,'attributeChangedCallback');myElem.setAttribute("my-attr","css-class");expect(spy).toHaveBeenCalled();});//FAILStest("’Make sure changing non observed attribute will not triiger change callback",()=>{constspy=jest.spyOn(myElem,'attributeChangedCallback');myElem.setAttribute("class","css-class");expect(spy).not.toHaveBeenCalled();});//FAILStest("’Make sure changing non observed attribute will not triiger change callback",()=>{constspy=jest.spyOn(myElem,'attributeChangedCallback');myElem.setAttribute("style","display: block;");expect(spy).not.toHaveBeenCalled();});//FAILStest("’Make sure changing non observed attribute will not triiger change callback",()=>{constspy=jest.spyOn(myElem,'attributeChangedCallback');myElem.setAttribute("id","other-id");expect(spy).not.toHaveBeenCalled();});});
The text was updated successfully, but these errors were encountered:
The callback
attributeChangedCallback
is being called on ANY attribute change, not only on the observed ones as expected.here is a jest test to help you reproduce
The text was updated successfully, but these errors were encountered: