polyfills icon indicating copy to clipboard operation
polyfills copied to clipboard

[ShadyDOM] Node.prototype.replaceChild removes node when same ref_node is used

Open tmsns opened this issue 5 years ago • 3 comments

Description

When using Node.prototype.replaceChild with the same node as ref_node, the node gets cleaned. (eg. removed from its parent)

Example

https://jsbin.com/qajapuxupa/1/edit?html,console,output

Steps to reproduce

  1. Create a div and a span within
  2. Get a reference to both elements.
  3. Execute replaceChild on div, but use span for both the node as the ref_node
  4. The span element is not connected anymore.

Expected behavior

The span element is untouched. (check other browsers)

Actual behavior

The span element has been cleaned

Version

@webcomponents/[email protected]

Browsers affected

  • [ ] Chrome
  • [ ] Firefox
  • [x] Edge (non Chromium versions)
  • [ ] Safari
  • [x] IE 11

tmsns avatar Jun 08 '20 14:06 tmsns

The issue resides here: https://github.com/webcomponents/polyfills/blob/master/packages/shadydom/src/patches/Node.js#L463 The two functions should only be executed if node and ref_node are different.

If you guys like, I can send in a MR? 😃

tmsns avatar Jun 08 '20 14:06 tmsns

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.

stale[bot] avatar Jun 16 '21 00:06 stale[bot]

This issue has been automatically closed after being marked stale. If you're still facing this problem with the above solution, please comment and we'll reopen!

stale[bot] avatar Sep 17 '23 16:09 stale[bot]