- From: Dominic Farolino <notifications@github.com>
- Date: Thu, 22 Feb 2024 07:04:55 -0800
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/dom/issues/808/1959641118@github.com>
> However generalizing it seems harder, since for at least iframes, ever browser aligns on synchronously firing the load event during the HTML element insertion steps. Changing that to be consistent with the model (2) above is almost certainly a compat issue. Thoughts? > > Thank you for [the load event example](https://software.hixie.ch/utilities/js/live-dom-viewer/?.%3Cscript%3E%0Ai1%20%3D%20document.createElement(%22iframe%22)%3B%0Ai1.onload%20%3D%20()%20%3D%3E%20%7B%20w(i2.parentNode)%3B%20w(document.body.childElementCount)%20%7D%3B%0Ai2%20%3D%20document.createElement(%22iframe%22)%3B%0Ai2.onload%20%3Dw%3B%0Adocument.body.append(i1%2Ci2)%3B%0A%3C%2Fscript%3E). However, my results are different from yours. At least from what I'm seeing Chromium and Gecko don't execute the event listener until after both nodes are inserted. Could you share your test? Yep you are correct, the `load` event in Blink & Gecko indeed are consistently fired after all DOM mutations are done Thanks for confirming, that makes me feel better about this :) @noamr has kindly helped shape up https://github.com/web-platform-tests/wpt/pull/15264 into the new https://github.com/web-platform-tests/wpt/pull/44658 for tentative tests around the model proposed here. We're planning on landing that alongside https://github.com/web-platform-tests/wpt/pull/44308, and we'll be simultaneously reviving https://github.com/whatwg/dom/pull/732 (which you also pointed me to) to try and finish this off. ---- Note that regarding **removal**, I don't think we an have the same kind of "atomicity" that we're shooting for with **insertion**. In the insertion case, we can defer some actions until after DOM mutations because the element is supposed to be connected at that point. Removals work differently because the removal steps run *before* each node actually gets removed from the DOM / disconnected. Moving the steps _after_ all DOM mutations (for removals) would mean executing steps on disconnected nodes, which sounds like a bad idea (and the cause for many security bugs it sounds). So I think that preserving the asymmetry between insertion and removal is OK. Let me know if you think otherwise. -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/dom/issues/808#issuecomment-1959641118 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/dom/issues/808/1959641118@github.com>
Received on Thursday, 22 February 2024 15:04:59 UTC