Bug 147304 - Web Inspector: Start using Node.prototype.remove
Summary: Web Inspector: Start using Node.prototype.remove
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nikita Vasilyev
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2015-07-25 22:10 PDT by Nikita Vasilyev
Modified: 2015-07-27 15:46 PDT (History)
8 users (show)

See Also:


Attachments
Patch (5.29 KB, patch)
2015-07-25 22:18 PDT, Nikita Vasilyev
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nikita Vasilyev 2015-07-25 22:10:49 PDT
Convert the following code:

    refElem.parendNode.removeChild(refElem)

to

    refElem.remove()


Note that when refElem.parendNode is null, refElem.remove() is no-op, it doesn't throw any errors.
Comment 1 Radar WebKit Bug Importer 2015-07-25 22:10:59 PDT
<rdar://problem/22000479>
Comment 2 Nikita Vasilyev 2015-07-25 22:18:15 PDT
Created attachment 257529 [details]
Patch
Comment 3 WebKit Commit Bot 2015-07-25 23:32:01 PDT
Comment on attachment 257529 [details]
Patch

Clearing flags on attachment: 257529

Committed r187405: <http://trac.webkit.org/changeset/187405>
Comment 4 WebKit Commit Bot 2015-07-25 23:32:05 PDT
All reviewed patches have been landed.  Closing bug.
Comment 5 Joseph Pecoraro 2015-07-27 15:11:54 PDT
Comment on attachment 257529 [details]
Patch

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

> Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js:1269
> -            parentElement.removeChild(self);
> +            self.remove();

Is this valid? Isn't "self" here a WebInspector.TreeElement, not a DOM Element?
Comment 6 Joseph Pecoraro 2015-07-27 15:46:06 PDT
(In reply to comment #5)
> Comment on attachment 257529 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=257529&action=review
> 
> > Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js:1269
> > -            parentElement.removeChild(self);
> > +            self.remove();
> 
> Is this valid? Isn't "self" here a WebInspector.TreeElement, not a DOM
> Element?

Yes, although this still works, it works in lucky / poor way.

This is inside of remove(), so it calls remove() again asynchronously, and only stops this loop because eventually the actual RemoveChild DOM event would remove this tree element from the parent. Lets fix this.