Bug 147302 - Web Inspector: Start using Node.prototype.before
Summary: Web Inspector: Start using Node.prototype.before
Status: RESOLVED WONTFIX
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 21:34 PDT by Nikita Vasilyev
Modified: 2015-07-25 21:45 PDT (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nikita Vasilyev 2015-07-25 21:34:31 PDT
https://bugs.webkit.org/show_bug.cgi?id=74648 introduced Node.prototype.append, among a few other DOM methods.

Convert the following code:

    refElem.parendNode.insertBefore(newElem, refElem)

to

    refElem.before(newElem)


However, we can't safely convert all occurrences of "insertBefore" to "before".

    baseElem.insertBefore(newElem, refElem)

refElem could be a null here. refElem.before(newElem) would cause an error.
Comment 1 Radar WebKit Bug Importer 2015-07-25 21:34:51 PDT
<rdar://problem/22000400>
Comment 2 Nikita Vasilyev 2015-07-25 21:43:13 PDT
I have found only one instance that satisfier the following requirement:

elemA.parentElement.insertBefore(highlightNode, elemA);
\                                               /
 \------------------ same elements ------------/


https://github.com/WebKit/webkit/blob/981bae9952b1f312b89d362fd39768c075408669/Source/WebInspectorUI/UserInterface/Base/Main.js#L1990

Probably doesn't worth a patch.