What is the issue with the DOM Standard?
See #1261 (comment) for context. In short, after #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:
- Moves
script2 around in the DOM (thus reentrantly invoking the DOM insertion algorithm, and running script2's post-connected steps for the first time)
- 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:
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----?
What is the issue with the DOM Standard?
See #1261 (comment) for context. In short, after #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).script2has an invalid type and therefore is not executable upon insertion as-is.script1does two things:script2around in the DOM (thus reentrantly invoking the DOM insertion algorithm, and runningscript2's post-connected steps for the first time)script2's invalidtypeattribute, making it valid/executable (but not immediately executing it, becausetypeattribute 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 outermostdocument.body.append(script1, script2)call finally invokingscript2's post-connected steps),script2will finally execute. Here's the code snippet:Despite being generally structured like Blink here, WebKit does not run
script2in 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----?