Set up the XBadge class and write its script; every line really runs in the teacher’s register: which callbacks the browser calls and in what order, a badge…
This is the foundation of Web Components and many design systems (Shoelace, Lit, GitHub’s and Salesforce’s components). Their bugs are nearly always about timing: code in the wrong callback, an attribute not registered, or a constructor that does too much.
You do not call the callbacks, the browser does
attributeChangedCallback never fires That attribute is not listed in static observedAttributes. Only names on that list are reported by the browser; add it (in lowercase).constructor because the DOM is not ready When the constructor runs, the element was just born: not in the document, and through createElement it has no attributes yet. Adding attributes or children there makes createElement fail with NotSupportedError and hands you a broken element. Move it to connectedCallback; the constructor is only for state and attachShadow().customElements.define is called twice and throws A name can only be registered once, and a registration cannot be undone. Guard it with if (!customElements.get('x-badge')) customElements.define(...), which matters with HMR or a bundle loaded twice.mejaB.append(el) One line, two callbacks: disconnected then connected. The browser takes the badge off Rara’s desk first.label to observedAttributes The badge follows to "Baru" at once: now the browser tells your class every time the label changes.customElements.define line to the very bottom Before it, <x-badge> is a plain HTMLElement (:defined false). On the define line, the constructor, attributeChanged and connected run at once: an upgrade.set atribut createElement reports a NotSupportedError (a constructor may not add attributes) and returns a failed element that never gets a callback. Try the From HTML preset too: through the parser, the element is made first and upgraded later, so that rule does not apply.