Re: [whatwg/dom] Side effects due to tree insertion or removal (script, iframe) (#808)

> - Inserting an inline <script> (one without src) runs the script text in it immediately, before the insert call returns.
> - Inserting an iframe with no src attribute set (and maybe with one set to about:blank?) fires a load event synchronously, before the call returns, in Chrome.
> - Removing an iframe synchronously fires beforeunload and unload events on the document inside, last I checked.

Thanks for listing these examples!
I tried reproducing all of them here: https://dom-side-effects.glitch.me
After running it in each browser, these are my observations:
- When inserting an inline `<script>`, the script will be executed before `appendChild` returns, just like you said.
- When inserting an iframe which doesn't have a `src` attribute, chrome/safari will fire the `load` event before `appendChild` returns, whereas firefox will fire the load event after `appendChild` returns, just like you said.
- When removing an iframe, the `unload` event is fired before `remove()` returns, just like you said.

Are there any other side effects of interest, or is that it?

For the script and unload cases, is the goal really to make script get executed after insertion and make unload fire after remove? I don't really see the benefit and I feel like we would just be breaking websites, especially since the behavior is already the same in chrome firefox and safari.

For the sync load event case, I suppose it is worth looking into changing in chrome, although I think this could be very challenging to implement and I'm afraid of breaking websites. Does anyone know if there is already a crbug open for this?

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

Received on Monday, 14 September 2020 18:59:45 UTC