Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardHTMLobservedAttributesSingle-choice MCQ

A custom element's class declares `observedAttributes` as a `static` class field initialized from a helper that reads from a config object. The element is defined, then the config object is mutated and a NEW subclass is defined that inherits (does not redeclare) `observedAttributes`. How does the engine resolve `observedAttributes` for the subclass, and what does this reveal about where the list lives?

const cfg = { attrs: ['a'] }; class Base extends HTMLElement { static get observedAttributes(){ return cfg.attrs; } attributeChangedCallback(n){ console.log('base', n); } } customElements.define('x-base', Base); cfg.attrs = ['a', 'b']; class Sub extends Base {} // no own observedAttributes customElements.define('x-sub', Sub);