Bug 149073 - ChildNode.replaceWith() without argument should replace the node with an empty DocumentFragment
Summary: ChildNode.replaceWith() without argument should replace the node with an empt...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar, WebExposed
Depends on:
Blocks:
 
Reported: 2015-09-11 14:22 PDT by Chris Dumez
Modified: 2015-09-16 10:32 PDT (History)
6 users (show)

See Also:


Attachments
Patch (7.76 KB, patch)
2015-09-11 14:30 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2015-09-11 14:22:11 PDT
ChildNode.replaceWith() without argument should replace the node with an empty DocumentFragment, as per the specification:
https://dom.spec.whatwg.org/#dom-childnode-replacewith
https://dom.spec.whatwg.org/#converting-nodes-into-a-node

Currently, WebKit does not do anything in this case (no-op).
Comment 1 Chris Dumez 2015-09-11 14:22:25 PDT
rdar://problem/22547801
Comment 2 Chris Dumez 2015-09-11 14:30:25 PDT
Created attachment 261016 [details]
Patch
Comment 3 Ryosuke Niwa 2015-09-11 14:52:25 PDT
Comment on attachment 261016 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=261016&action=review

> Source/WebCore/ChangeLog:17
> +        No new tests, already covered by existing test.

Does this match behaviors of other browsers?
Comment 4 Chris Dumez 2015-09-11 14:58:56 PDT
(In reply to comment #3)
> Comment on attachment 261016 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=261016&action=review
> 
> > Source/WebCore/ChangeLog:17
> > +        No new tests, already covered by existing test.
> 
> Does this match behaviors of other browsers?

Other browsers don't seem to implement replaceChild() yet. This is fairly recent I believe.
Comment 5 Chris Dumez 2015-09-11 14:59:36 PDT
(In reply to comment #4)
> (In reply to comment #3)
> > Comment on attachment 261016 [details]
> > Patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=261016&action=review
> > 
> > > Source/WebCore/ChangeLog:17
> > > +        No new tests, already covered by existing test.
> > 
> > Does this match behaviors of other browsers?
> 
> Other browsers don't seem to implement replaceChild() yet. This is fairly
> recent I believe.

replaceWith
Comment 6 WebKit Commit Bot 2015-09-12 10:34:05 PDT
Comment on attachment 261016 [details]
Patch

Clearing flags on attachment: 261016

Committed r189653: <http://trac.webkit.org/changeset/189653>
Comment 7 WebKit Commit Bot 2015-09-12 10:34:10 PDT
All reviewed patches have been landed.  Closing bug.
Comment 8 Darin Adler 2015-09-16 10:32:20 PDT
Comment on attachment 261016 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=261016&action=review

> Source/WebCore/dom/Node.cpp:564
> +    if (ec)
>          return;

Not new, but this code is wrong. It’s not the caller’s responsibility to set ec to zero. The caller might not set it at all if it doesn’t plan to look at it.

That means that ec might be non-zero when this function is called, and convertNodesOrStringsIntoNode might not touch it, so checking it is not right. Someone has to set ec to 0 if they are going to be checking it after the fact. So either Node::replaceWith or convertNodesOrStringsIntoNode needs to set ec to zero. This error seems to be repeated in multiple functions in this file.