Re: [whatwg/dom] Clarify create an element assertion (Issue #1338)

This is very subtle. I wrote several wrong answers to this question before arriving at the conclusion that, yes, I think this is true.

The case I was concerned about was.

```js
customElements.define("x-y", class extends HTMLElement {
  constructor() {
    // super() intentionally omitted
  }
});

document.createElement("x-y");
```

In that case the Web IDL "construct" call does nothing to set the custom element state or custom element definition (since no `[HTMLConstructor]` spec code ran). So I thought the assert would fail. However, what actually happens is that https://webidl.spec.whatwg.org/#construct-a-callback-function step 12 throws, because _result_ is not a platform object and so cannot be converted to `HTMLElement`.

Inserting a note to this effect would be helpful to future readers, I think.

---

So yes, if we make it past the construct step, we must have run the `[HTMLConstructor]` steps to completion. Which I believe means your suggestions hold.

It still might be worth building WebKit with such an assertion and then running the custom-elements/ WPT suite, just to check.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/1338#issuecomment-2552726901
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/dom/issues/1338/2552726901@github.com>

Received on Thursday, 19 December 2024 04:03:23 UTC