Skip to main content
","learningResourceType":"Practice problem","educationalLevel":"hard","about":"HTML","teaches":"custom-element lifecycle","url":"https://journeyuncommon.com/quiz/question/e0278046-ccc4-4662-b867-c874c0ec8c5c","inLanguage":"en","isAccessibleForFree":true,"provider":{"@id":"https://journeyuncommon.com/#organization"},"isPartOf":{"@type":"WebSite","@id":"https://journeyuncommon.com/#website","name":"Journey Uncommon","url":"https://journeyuncommon.com"}}
Journey Uncommon Logo
JourneyUncommon
hardHTMLcustom-element lifecycleSingle-choice MCQ

Regarding custom-element lifecycle ordering: an autonomous custom element is defined AFTER the parser has already created the element in the DOM (upgrade scenario). In what order do reactions fire during upgrade, and what is the state of attributes/children?

<my-el data-x="1">text</my-el> <script> customElements.define('my-el', class extends HTMLElement { static observedAttributes = ['data-x']; constructor(){ super(); } connectedCallback(){ /* A */ } attributeChangedCallback(){ /* B */ } }); </script>