Skip to main content
","learningResourceType":"Practice problem","educationalLevel":"hard","about":"HTML","teaches":"custom-element lifecycle","url":"https://journeyuncommon.com/quiz/question/2a05c7ec-91ce-4927-ab6c-9e8c57daacff","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

An element of type x-widget exists in the parsed DOM before customElements.define('x-widget', ...) runs. When the definition runs, in what order do the upgrade steps fire relative to the constructor and connectedCallback?

<x-widget></x-widget> <script> // element already in DOM and connected here customElements.define('x-widget', class extends HTMLElement { constructor() { super(); /* A */ } connectedCallback() { /* B */ } }); </script>