Bug 28061

Summary: Inspector: NodeLists Don't Display Well in the Console
Product: WebKit Reporter: Joseph Pecoraro <joepeck>
Component: Web Inspector (Deprecated)Assignee: Joseph Pecoraro <joepeck>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, aroben, joepeck, kmccullough, pfeldman, sam, timothy
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
Showing Multiple Display Options for a NodeList
none
Display NodeList like an Array
none
[PATCH] Display NodeList as an Array
none
[PATCH] Display NodeList as an Array timothy: review+

Description Joseph Pecoraro 2009-08-06 21:33:43 PDT
This currently stems from another bug:
Title: typeof document.body.childNodes=="function"
Link: https://bugs.webkit.org/show_bug.cgi?id=14547

This can easily be worked around if before formatting the object we check this special case.

  if (output instanceof NodeList)
      type = "array"; // or "object"

I have a feeling its inappropriate to put this special check inside Object.type (utilities.js), but it can be done specifically inside of WebInspector.ConsoleView._format (ConsoleView).

Any preference for how it should display?
  - Object (expand triangle)
  - Array (being nodes it will be an array of inline html tree outlines)
Comment 1 Joseph Pecoraro 2009-08-06 21:35:31 PDT
Created attachment 34248 [details]
Showing Multiple Display Options for a NodeList

Here are three different ways to display the NodeList (Currently as a "function", as an "array", and as an "object").  Which do you like best?
Comment 2 Timothy Hatcher 2009-08-06 21:43:10 PDT
I think array is best.
Comment 3 Joseph Pecoraro 2009-08-06 21:52:53 PDT
Created attachment 34249 [details]
Display NodeList like an Array

Display like an array.  Although this doesn't show the indexes, I still like this approach.  Image:
http://bogojoker.com/snaps/as_array.png
Comment 4 Adam Barth 2009-08-06 22:51:54 PDT
Comment on attachment 34249 [details]
Display NodeList like an Array

Clearing review flag on attachment: 34249

Committing to http://svn.webkit.org/repository/webkit/trunk ...
	M	WebCore/ChangeLog
	M	WebCore/inspector/front-end/ConsoleView.js
Committed r46886
	M	WebCore/ChangeLog
	M	WebCore/inspector/front-end/ConsoleView.js
r46886 = 608b85eaa5602133c0facc6c3ea320c176aa4bf5 (trunk)
No changes between current HEAD and refs/remotes/trunk
Resetting to the latest refs/remotes/trunk
http://trac.webkit.org/changeset/46886
Comment 5 Adam Barth 2009-08-06 22:51:59 PDT
All reviewed patches have been landed.  Closing bug.
Comment 6 Sam Weinig 2009-08-06 22:54:11 PDT
Should we do this for other array like structures such as HTMLCollection?
Comment 7 Joseph Pecoraro 2009-10-02 23:19:49 PDT
Created attachment 40565 [details]
[PATCH] Display NodeList as an Array

Looks like this got lost in the Inspector Serialization.
Comment 8 Joseph Pecoraro 2009-10-02 23:20:25 PDT
Comment on attachment 34249 [details]
Display NodeList like an Array

Cleared Flags on old patch.
Comment 9 Joseph Pecoraro 2009-10-02 23:46:12 PDT
Created attachment 40566 [details]
[PATCH] Display NodeList as an Array

Better solution, more in line with the previous solution, thanks to guidance from pfeldman.
Comment 10 Pavel Feldman 2009-10-02 23:48:14 PDT
Comment on attachment 40565 [details]
[PATCH] Display NodeList as an Array

> +        if (isProxy && output.description === "NodeList")
> +            type = "array";

This would trigger on a string with value == "NodeList". So you should no rely upon description.
Instead, we could patch Object.type on the injected script side to pretend NodeList has an "array" type.
Comment 11 Pavel Feldman 2009-10-03 11:17:39 PDT
(In reply to comment #9)
> Created an attachment (id=40566) [details]
> [PATCH] Display NodeList as an Array
> 
> Better solution, more in line with the previous solution, thanks to guidance
> from pfeldman.

This patch looks good.
Comment 12 Joseph Pecoraro 2009-10-08 07:11:52 PDT
Landed in http://trac.webkit.org/changeset/49298
r49298 = 74c5d0dca10afaf5f4886c5fcb48e80dd5e3612d (trunk)