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

In WebKit, insertion and removal are different.

Newly inserted nodes are notified in two stages: [`insertedIntoAncestor`](https://trac.webkit.org/browser/webkit/trunk/Source/WebCore/dom/Node.h?rev=259575#L419) and [`didFinishInsertingNodes`](https://trac.webkit.org/browser/webkit/trunk/Source/WebCore/dom/Node.h?rev=259575#L420). The former is responsible for updating internal node's states and not allowed to execute any scripts. The latter is called on a subset of nodes which may execute scripts after node insertion. A subset of elements such as `HTMLScriptElement` [overrides it](https://trac.webkit.org/browser/webkit/trunk/Source/WebCore/dom/ScriptElement.cpp?rev=259575#L84) to [execute scripts](https://trac.webkit.org/browser/webkit/trunk/Source/WebCore/dom/ScriptElement.cpp?rev=259575#L84). Both of these things happen synchronously as we remove nodes.

During [removal](https://trac.webkit.org/browser/webkit/trunk/Source/WebCore/dom/ContainerNode.cpp?rev=257192#L81), we disconnect all subframes first (during which introduction of nested browsing contexts are prohibited) and then remove nodes but we don't allow any scripts to execute as a result of removing nodes once we start removing nodes. All of this happens synchronously.

-- 
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-610099830

Received on Tuesday, 7 April 2020 00:07:22 UTC