Bug 99336 - Web Inspector: [Elements] Double-click to live edit style tags changes text to 'undefined' in some situations
Summary: Web Inspector: [Elements] Double-click to live edit style tags changes text t...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (Deprecated) (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Alexander Pavlov (apavlov)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-10-15 09:04 PDT by Alexander Pavlov (apavlov)
Modified: 2012-10-16 07:53 PDT (History)
9 users (show)

See Also:


Attachments
Patch (2.09 KB, patch)
2012-10-15 09:11 PDT, Alexander Pavlov (apavlov)
no flags Details | Formatted Diff | Diff
Patch (2.12 KB, patch)
2012-10-16 02:48 PDT, Alexander Pavlov (apavlov)
no flags Details | Formatted Diff | Diff
Patch (22.31 KB, patch)
2012-10-16 06:52 PDT, Alexander Pavlov (apavlov)
vsevik: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Pavlov (apavlov) 2012-10-15 09:04:08 PDT
1. load a page with an inline style tag inside of a div (http://jsfiddle.net/show)
2. open the inspector
3. expand the div, double click on the body styles inside of the style tag

Upstreaming http://code.google.com/p/chromium/issues/detail?id=152973
Comment 1 Alexander Pavlov (apavlov) 2012-10-15 09:11:36 PDT
Created attachment 168728 [details]
Patch
Comment 2 Eric Seidel (no email) 2012-10-15 12:44:54 PDT
Comment on attachment 168728 [details]
Patch

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

> Source/WebCore/inspector/front-end/ElementsTreeOutline.js:1327
> +            container.innerText = textNode._originalContent || container.innerText;

textContent is the new hotness.  Why innerText (which is an IE extension) instead?
Comment 3 Alexander Pavlov (apavlov) 2012-10-15 13:06:01 PDT
(In reply to comment #2)
> (From update of attachment 168728 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=168728&action=review
> 
> > Source/WebCore/inspector/front-end/ElementsTreeOutline.js:1327
> > +            container.innerText = textNode._originalContent || container.innerText;
> 
> textContent is the new hotness.  Why innerText (which is an IE extension) instead?

Thanks for the hint; it's legacy code. Is textContent far better than innerText (from the client's PoV) and is it worth migrating to the former? AFAIK, the only tangible difference is whitespace handling, unless I'm missing something...
Comment 4 Alexander Pavlov (apavlov) 2012-10-16 02:33:52 PDT
(In reply to comment #2)
> (From update of attachment 168728 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=168728&action=review
> 
> > Source/WebCore/inspector/front-end/ElementsTreeOutline.js:1327
> > +            container.innerText = textNode._originalContent || container.innerText;
> 
> textContent is the new hotness.  Why innerText (which is an IE extension) instead?

After double-checking, I made sure innerText is there not without reason. Setting textContent collapses all whitespace and, what's most important, newlines, so that multiline text nodes all occur on a single line. We had a bug for that a while ago, and most likely it was fixed by using innerText rather than textContent in this snippet.
Comment 5 Alexander Pavlov (apavlov) 2012-10-16 02:48:14 PDT
Created attachment 168903 [details]
Patch
Comment 6 Pavel Feldman 2012-10-16 02:59:14 PDT
Comment on attachment 168903 [details]
Patch

We should never use innerText. Also, this change needs a test.
Comment 7 Alexander Pavlov (apavlov) 2012-10-16 06:52:53 PDT
Created attachment 168939 [details]
Patch
Comment 8 Vsevolod Vlasov 2012-10-16 07:24:06 PDT
Comment on attachment 168939 [details]
Patch

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

> Source/WebCore/inspector/front-end/ElementsTreeOutline.js:1326
> +            var node = this.representedObject;

I would rename textNode to textNodeElement  and node to textNode.

> Source/WebCore/inspector/front-end/ElementsTreeOutline.js:1331
>          var config = new WebInspector.EditingConfig(this._textNodeEditingCommitted.bind(this), this._editingCancelled.bind(this));

You should bind textNode parameter for _textNodeEditingCommitted to avoid duplicating the code in _textNodeEditingCommitted.
Comment 9 Alexander Pavlov (apavlov) 2012-10-16 07:53:03 PDT
Committed r131455: <http://trac.webkit.org/changeset/131455>