Bug 173747 - Web Inspector: Use Element.closest for internal code
Summary: Web Inspector: Use Element.closest for internal code
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Devin Rousso
URL:
Keywords: GoodFirstBug, InRadar
Depends on:
Blocks:
 
Reported: 2017-06-22 16:56 PDT by Nikita Vasilyev
Modified: 2020-02-06 02:39 PST (History)
6 users (show)

See Also:


Attachments
Patch (30.30 KB, patch)
2019-02-27 13:48 PST, Devin Rousso
no flags Details | Formatted Diff | Diff
Patch (30.30 KB, patch)
2019-02-27 15:15 PST, Devin Rousso
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 2017-06-22 16:56:55 PDT
There're a few methods defined in Utilities.js that could be replaced by Element.prototype.closest[1]:

    Node.prototype.enclosingNodeOrSelfWithClass
    Node.prototype.enclosingNodeOrSelfWithNodeName
    Node.prototype.enclosingNodeOrSelfWithNodeNameInArray

[1]: https://developer.mozilla.org/en-US/docs/Web/API/Element/closest
Comment 1 Devin Rousso 2019-02-27 13:48:33 PST
Created attachment 363127 [details]
Patch

I haven't tested every single case, but the ones I did worked fine :)
Comment 2 Joseph Pecoraro 2019-02-27 15:12:23 PST
Comment on attachment 363127 [details]
Patch

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

r=me

> Source/WebInspectorUI/UserInterface/Base/Main.js:2340
> +        let contentBrowserElement = this.currentFocusElement.closest("content-browser");

This should be ".content-browser"
Comment 3 Devin Rousso 2019-02-27 15:15:00 PST
Created attachment 363137 [details]
Patch
Comment 4 WebKit Commit Bot 2019-02-27 15:54:48 PST
Comment on attachment 363137 [details]
Patch

Clearing flags on attachment: 363137

Committed r242174: <https://trac.webkit.org/changeset/242174>
Comment 5 WebKit Commit Bot 2019-02-27 15:54:49 PST
All reviewed patches have been landed.  Closing bug.
Comment 6 Radar WebKit Bug Importer 2019-02-27 15:55:40 PST
<rdar://problem/48454502>
Comment 7 Fujii Hironori 2020-02-06 02:39:43 PST
Comment on attachment 363137 [details]
Patch

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

> Source/WebInspectorUI/UserInterface/Views/LogContentView.js:536
> +                wrapper = selection.focusNode.closest("." + WI.LogContentView.ItemWrapperStyleClassName);

selection.focusNode isn't necessarily an Element. 
Filed: Bug 207248 – [Web Inspector][WinCairo] Selecting an error message in Console causes "TypeError:​ selection.focusNode.closest is not a function."