RESOLVED FIXED Bug 198578
Implement ParentNode.prototype.replaceChildren
https://bugs.webkit.org/show_bug.cgi?id=198578
Summary Implement ParentNode.prototype.replaceChildren
Attachments
Patch (23.96 KB, patch)
2020-05-30 22:32 PDT, Tetsuharu Ohzeki [UTC+9]
no flags
Patch (22.99 KB, patch)
2020-06-01 08:48 PDT, Tetsuharu Ohzeki [UTC+9]
no flags
Anne van Kesteren
Comment 1 2020-03-29 23:46:42 PDT
Latest PR at https://github.com/whatwg/dom/pull/851. I'm going to assume y'all are still interested.
Chris Dumez
Comment 2 2020-03-30 08:18:45 PDT
(In reply to Anne van Kesteren from comment #1) > Latest PR at https://github.com/whatwg/dom/pull/851. I'm going to assume > y'all are still interested. Sure.
Tetsuharu Ohzeki [UTC+9]
Comment 3 2020-05-29 06:05:53 PDT
May I take this?
Ryosuke Niwa
Comment 4 2020-05-29 14:10:59 PDT
(In reply to Tetsuharu Ohzeki from comment #3) > May I take this? You may!
Tetsuharu Ohzeki [UTC+9]
Comment 5 2020-05-30 22:32:04 PDT
Darin Adler
Comment 6 2020-06-01 07:35:22 PDT
Comment on attachment 400694 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=400694&action=review > Source/WebCore/dom/ContainerNode.cpp:674 > +// https://dom.spec.whatwg.org/#concept-node-replace-all > +void ContainerNode::replaceAllChildrenNaively(Ref<Node>&& node) > +{ > + Ref<ContainerNode> protectedThis(*this); > + ChildListMutationScope mutation(*this); > + removeAllChildrenWithScriptAssertion(ChildChangeSource::API, DeferChildrenChanged::Yes); > + > + // we assume that we check preinsertion validity on the caller side. > + auto result = appendChildWithoutPreInsertionValidityCheck(node); > + ASSERT_UNUSED(result, !result.hasException()); > + > + rebuildSVGExtensionsElementsIfNecessary(); > + dispatchSubtreeModifiedEvent(); > +} I don’t see the value in factoring this out as a named function. The pre-condition that you must already have checked pre-insertion validity makes it hard to use this correctly. I suggest just including this code in ContainerNode::replaceChildren for now, and factoring it out only if we find we have a good way to share code with other call sites. I don’t understand why it is OK that this does not use executeNodeInsertionWithScriptAssertion.
Tetsuharu Ohzeki [UTC+9]
Comment 7 2020-06-01 08:24:02 PDT
(In reply to Darin Adler from comment #6) > I don’t see the value in factoring this out as a named function. The > pre-condition that you must already have checked pre-insertion validity > makes it hard to use this correctly. I suggest just including this code in > ContainerNode::replaceChildren for now, and factoring it out only if we find > we have a good way to share code with other call sites. Thank you review! Okay. I'll change like that. > I don’t understand why it is OK that this does not use > executeNodeInsertionWithScriptAssertion. As my understanding, ContainerNode::appendChildWithoutPreInsertionValidityCheck calls executeNodeInsertionWithScriptAssertion internally and appendChildWithoutPreInsertionValidityCheck has additional operations related to there is a parent.
Darin Adler
Comment 8 2020-06-01 08:26:07 PDT
(In reply to Tetsuharu Ohzeki from comment #7) > (In reply to Darin Adler from comment #6) > > I don’t understand why it is OK that this does not use > > executeNodeInsertionWithScriptAssertion. > > ContainerNode::appendChildWithoutPreInsertionValidityCheck calls > executeNodeInsertionWithScriptAssertion internally I see that now.
Tetsuharu Ohzeki [UTC+9]
Comment 9 2020-06-01 08:48:23 PDT
Created attachment 400735 [details] Patch I addressed the review comment.
EWS
Comment 10 2020-06-01 09:58:03 PDT
Committed r262381: <https://trac.webkit.org/changeset/262381> All reviewed patches have been landed. Closing bug and clearing flags on attachment 400735 [details].
Radar WebKit Bug Importer
Comment 11 2020-06-01 09:59:24 PDT
Note You need to log in before you can comment on or make changes to this bug.