Custom Elements & Lifecycle Callbacks

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…

Why it matters

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.

The key idea

You do not call the callbacks, the browser does

Common mistakes

Try it in this playground