webcomponents / polyfills

Web Components Polyfills
BSD 3-Clause "New" or "Revised" License
1.13k stars 166 forks source link

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

Open bicknellr opened 6 years ago

bicknellr commented 6 years ago

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' - would be:

  1. disconnect nodeToInsert.
  2. disconnect nodeToRemove.
  3. connect nodeToInsert.

Which, when flushed, would be:

  1. nodeToInsert's disconnectedCallback.
  2. nodeToInsert's connectedCallback.
  3. nodeToRemove's disconnectedCallback.
bicknellr commented 6 years ago

I'm inclined to say that it should be changed to the spec-text order, rather than attempting to emulate the reactions stack at a local level since it won't really work out until everything is using an actual implementation of the reactions stack.

dfreedm commented 5 years ago

@bicknellr Is this still relevant?

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.