-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Description
The custom element upgrade spec, section 4.13.5, step 1, says "If element is custom, then return". And there is a large example there showing a custom element constructor that attempts to call itself recursively. What should that example do?
A simplified example is:
customElements.define("x-foo", class extends HTMLElement {
constructor() {
super();
customElements.upgrade(this);
}
});See this Chromium bug for a more detailed discussion of this situation. There is a debate about whether the constructor and/or CE reactions should happen in step 2 or step 4 of the CEReactions spec. If the constructor happens at step 2, and the (recursively triggered) upgrade reactions happen at step 4, then the current spec is correct, the Chromium implementation is wrong, and there should be no infinite recursion here. If, on the other hand, both the constructor and the (recursively triggered) upgrades happen within a single step (2 or 4) then the spec is wrong, Chromium is correct, and the example above will generate a JS stack overflow.