webcomponents / webcomponents/polyfills

[Custom Elements] Callback ordering is incorrect for `Node.prototype.replaceChild`.

Open
#107 4 comments 0 reactions 0 assignees View on GitHub
Package: custom-elements Severity: Low Type: Bug wontfix
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.