- From: Dominic Farolino <notifications@github.com>
- Date: Fri, 31 May 2024 04:27:31 -0700
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/dom/issues/1291@github.com>
### What is the issue with the DOM Standard? See https://github.com/whatwg/dom/pull/1261#discussion_r1594562487 for context. In short, after https://github.com/whatwg/dom/pull/1261, it is possible to run the post-connected steps multiple times/reentrantly for a single element during an insertion. Should that be allowed? Copied from the aforementioned comment: Imagine a case where you insert two scripts at the same time, i.e., `document.body.append(script1, script2)`. `script2` has an invalid type and therefore is not executable upon insertion as-is. `script1` does two things: 1. Moves `script2` around in the DOM (thus reentrantly invoking the DOM insertion algorithm, and running `script2`'s post-connected steps for the first time) 2. Removes `script2`'s invalid `type` attribute, making it valid/executable (but not immediately executing it, because `type` attribute mutations do not trigger the script processing model). At least in Chromium, when `script2`'s post-connected steps run for the second time (as a result of the outermost `document.body.append(script1, script2)` call finally invoking `script2`'s post-connected steps), `script2` will finally execute. Here's the code snippet: ```js const script1 = document.createElement('script'); script1.innerText = ` const div = document.querySelector('div'); div.append(script2); script2.removeAttribute('type'); `; const script2 = document.createElement('script'); script2.id = 'script2'; // Makes the script invalid so that it does not run upon insertion. script2.type = 'foo'; script2.innerText = 'console.log("grazie");'; document.body.append(script1, script2); ``` Despite being generally structured like Blink here, WebKit does not run `script2` in this scenario, which I think indicates that the post-connected steps do not run the second time for script2. I would love to know why / how WebKit does this, @rniwa do you know? And WDYT @smaug----? -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/dom/issues/1291 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/dom/issues/1291@github.com>
Received on Friday, 31 May 2024 11:27:35 UTC