Closed Bug 989629 Opened 10 years ago Closed 10 years ago

Object Inspector should display class names for DOM elements

Categories

(DevTools :: Object Inspector, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Firefox 32

People

(Reporter: danemacmillan, Assigned: sjakthol)

Details

Attachments

(2 files, 2 obsolete files)

Since bug 682033 comment 13, the output of nodes in the Console have included their class names. This is great. I think the side panel (when clicking to see the rest of the truncated results) that also displays NodeLists should include that information, too, otherwise it's not as useful, as discussed in the bug comment referenced.

I think this is especially pertinent if the output of results in the Console do not have the cap on truncated collections (arrays, objects, NodeLists) increased or removed, via bug 989624.
Summary: Console's side panel does not order NodeList keys (numbers) naturally. → Console's side panel should also display class names for NodeLists.
Component: Developer Tools: Console → Developer Tools: Object Inspector
Summary: Console's side panel should also display class names for NodeLists. → Object Inspector should display class names for DOM elements
Here's a patch that adds class names to DOMNodes in variables view with the standard DOM selector convention. A DOM node might look like <div#id.class-one.class-two>. The patch also contains a test case to ensure the nodes are rendered correctly.
Attachment #8430547 - Flags: review?(past)
The previous patch contained a little error. Here's a patch that calls the correct cleanup function in the attached test case.
Attachment #8430547 - Attachment is obsolete: true
Attachment #8430547 - Flags: review?(past)
Attachment #8430567 - Flags: review?(past)
Comment on attachment 8430567 [details] [diff] [review]
variablesview-show-element-classes.patch

Review of attachment 8430567 [details] [diff] [review]:
-----------------------------------------------------------------

::: browser/devtools/shared/widgets/VariablesView.jsm
@@ +3698,5 @@
>            result += "#" + attrs.id;
>          }
> +
> +        if (attrs.class) {
> +          result += "." + attrs.class.replace(" ", ".");

This would properly match class="foo bar", but not class="foo    bar". Better use class.replace(/\s+/, "."). Add another check in the test for this case, too.

Looks good otherwise.
Attachment #8430567 - Flags: review?(past)
That's a good point I didn't thought of. Thanks for the review. Here's a revised version of the patch with fix for the issue you pointed out.
Attachment #8430567 - Attachment is obsolete: true
Attachment #8430948 - Flags: review?(past)
Comment on attachment 8430948 [details] [diff] [review]
variablesview-show-element-classes.patch

Review of attachment 8430948 [details] [diff] [review]:
-----------------------------------------------------------------

Thanks for the updated patch. Pushed to try:
https://tbpl.mozilla.org/?tree=Try&rev=65925b7716f1
Attachment #8430948 - Flags: review?(past) → review+
Assignee: nobody → sjakthol
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
https://hg.mozilla.org/mozilla-central/rev/767e7eb767d8
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Whiteboard: [fixed-in-fx-team]
Target Milestone: --- → Firefox 32
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: