RESOLVED FIXED 217537
replaceChildren() (with no arguments) silently does nothing rather than removing the children
https://bugs.webkit.org/show_bug.cgi?id=217537
Summary replaceChildren() (with no arguments) silently does nothing rather than remov...
Ashley Gullen
Reported 2020-10-09 15:26:39 PDT
Safari TP114 appears to ship a broken implementation of elem.replaceChildren() which is enabled by default. Demo: https://downloads.scirra.com/labs/replacechildren.html Click the button. It calls replaceChildren() with empty arguments to remove the three paragraphs. It works in Chrome and Firefox and the elements disappear. In Safari it does nothing - no elements are removed.
Attachments
Patch (6.47 KB, patch)
2020-10-10 11:37 PDT, Darin Adler
ews-feeder: commit-queue-
Patch (6.47 KB, patch)
2020-10-10 12:02 PDT, Darin Adler
sam: review+
Alexey Proskuryakov
Comment 1 2020-10-09 18:18:57 PDT
Same behavior in Safari 14.0.1 beta.
Radar WebKit Bug Importer
Comment 2 2020-10-09 18:19:12 PDT
Tetsuharu Ohzeki [UTC+9]
Comment 3 2020-10-09 21:44:45 PDT
(In reply to Alexey Proskuryakov from comment #1) > Same behavior in Safari 14.0.1 beta. I seem Safari v14 does not enable `ParentNode.replaceChildren()` in the first place. Oddly Safari TP 114 and the trunk which enables that API also does not work this.
Darin Adler
Comment 4 2020-10-10 01:34:07 PDT
This was added in r262381 and passed all the Web Platform Tests then and since. Haven’t looked at this test here yet.
Darin Adler
Comment 5 2020-10-10 11:19:28 PDT
I took a look at the DOM specification. It has an incorrect step: https://dom.spec.whatwg.org/#dom-parentnode-replacechildren Note that step 2 says "Ensure pre-insertion validity of node into this before null." But that should only be done if node is non-null. We should probably report that issue. If we took it literally then the function would need to throw a HierarchyRequestError exception, but clearly that’s needed. I took a look at the Web Platform Tests. https://github.com/web-platform-tests/wpt/blob/master/dom/nodes/ParentNode-replaceChildren.html For some reason it does not include a test case for replaceChildren without any argument, on a parent having a child. So we pass that test even though our algorithm is incorrect. Fixing the bug is really easy, and it’s also easy for me to add a test to WPT, but I don’t know how to correctly upstream a change like this. Could use some help with that.
Darin Adler
Comment 6 2020-10-10 11:31:28 PDT
(In reply to Darin Adler from comment #5) > I took a look at the DOM specification. It has an incorrect step: > > https://dom.spec.whatwg.org/#dom-parentnode-replacechildren Filed https://github.com/whatwg/dom/issues/901
Darin Adler
Comment 7 2020-10-10 11:37:55 PDT Comment hidden (obsolete)
EWS Watchlist
Comment 8 2020-10-10 11:38:39 PDT
This patch modifies the imported WPT tests. Please ensure that any changes on the tests (not coming from a WPT import) are exported to WPT. Please see https://trac.webkit.org/wiki/WPTExportProcess
Darin Adler
Comment 9 2020-10-10 12:02:15 PDT
Darin Adler
Comment 10 2020-10-10 12:02:56 PDT Comment hidden (obsolete)
Darin Adler
Comment 12 2020-10-10 13:39:30 PDT
Ryosuke Niwa
Comment 13 2020-10-13 00:18:47 PDT
FWIW, this is definitely enabled by default on Safari 14.0.1.
Darin Adler
Comment 14 2020-10-13 09:00:25 PDT
You mean that the broken version is included in Safari 14.0.1 or that the fixed version is included in 14.0.1?
Tetsuharu Ohzeki [UTC+9]
Comment 15 2020-10-13 22:07:24 PDT
(In reply to Ryosuke Niwa from comment #13) > FWIW, this is definitely enabled by default on Safari 14.0.1. Oh, I'm sorry to add the incomplete implementation in bug 198578...
Ryosuke Niwa
Comment 16 2020-10-13 22:25:32 PDT
(In reply to Darin Adler from comment #14) > You mean that the broken version is included in Safari 14.0.1 or that the > fixed version is included in 14.0.1? The broken version is in Safari 14.0.1.
Note You need to log in before you can comment on or make changes to this bug.