Bug 227774

Summary: Web Inspector: Elements Tab DOM Tree does not update when a top-level item in the DOM tree is added/removed
Product: WebKit Reporter: Patrick Angle <pangle>
Component: Web InspectorAssignee: Patrick Angle <pangle>
Status: RESOLVED FIXED    
Severity: Normal CC: ews-watchlist, hi, inspector-bugzilla-changes, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
Attachments:
Description Flags
Patch v1.0 hi: review+

Description Patrick Angle 2021-07-07 14:57:33 PDT
<rdar://31137058>
Comment 1 Patrick Angle 2021-07-07 15:31:27 PDT
Created attachment 433085 [details]
Patch v1.0
Comment 2 Devin Rousso 2022-08-30 10:17:45 PDT
Comment on attachment 433085 [details]
Patch v1.0

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

r=me

> Source/WebInspectorUI/UserInterface/Views/DOMTreeUpdater.js:134
> +            if (parentNode.attached && !parentNode.parentNode) {

I think the only way for this to be true is if `parentNode` is the document, so it might be better to directly check for that instead (especially since we probably will eventually move to a future where nodes can be sent to the frontend without including parent info, so `attached` might be `true` even if the `parentNode` is `null`).  That way you could also rename it to `documentNeedsUpdate`, which IMO is more understandable/reasonable as a reason to update the entire `WI.DOMTreeOutline`.

> Source/WebInspectorUI/UserInterface/Views/DOMTreeUpdater.js:151
> +            this._recentlyModifiedNodes.clear();
> +            this._recentlyModifiedAttributes.clear();

NIT: Instead of duplicating these `clear()` here, you could take the entire `for` below and put it inside an `else` for this.  I personally try to avoid early returns like this cause it means there's more state one has to keep track of when creating branches in the future, whereas if there's no `return` then everything always flows down the same path to the same end.

> Source/WebInspectorUI/UserInterface/Views/DOMTreeUpdater.js:167
> -                return;
> +                continue;

LOL oops wonder how many other problems this caused 😅
Comment 3 Patrick Angle 2022-08-30 14:16:56 PDT
Comment on attachment 433085 [details]
Patch v1.0

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

>> Source/WebInspectorUI/UserInterface/Views/DOMTreeUpdater.js:167
>> +                continue;
> 
> LOL oops wonder how many other problems this caused 😅

Such a good bug, I later fixed it anyways apparently https://bugs.webkit.org/show_bug.cgi?id=230289
Comment 4 Patrick Angle 2022-09-01 09:32:01 PDT
Pull request: https://github.com/WebKit/WebKit/pull/3914
Comment 5 EWS 2022-09-01 13:04:05 PDT
Committed 254062@main (f6c535899310): <https://commits.webkit.org/254062@main>

Reviewed commits have been landed. Closing PR #3914 and removing active labels.