webcomponents / webcomponents/polyfills
[Custom Elements] Callback ordering is incorrect for `Node.prototype.replaceChild`.
- Dominant language
- HTML
- Stars
- 1.2k
- Forks
- 168
- PR merge metrics
- No merged PRs in 30d
Description
https://github.com/webcomponents/custom-elements/blob/6ad9993949a4f25c05b50b27a031a2ebfc49df89/src/Patch/Node.js#L151-L161
The ordering of reactions triggered by this snippet is incorrect, both in terms of when the spec text triggers enqueues the reactions and what order they would be called when the queue is being flushed.
The spec text ordering - described [here, in 'replace'](https://dom.spec.whatwg.org/#concept-node-replace) - would be:
1. disconnect `nodeToInsert`.
1. disconnect `nodeToRemove`.
1. connect `nodeToInsert`.
Which, when flushed, would be:
1. `nodeToInsert`'s `disconnectedCallback`.
1. `nodeToInsert`'s `connectedCallback`.
1. `nodeToRemove`'s `disconnectedCallback`.
Contributor guide
Assessment
This issue has not been assessed yet.