JSON Viewer: empty arrays should hide the zero count

RESOLVED FIXED in Firefox 50

Status

DevTools
JSON Viewer
RESOLVED FIXED
3 years ago
a month ago

People

(Reporter: clarkbw, Assigned: dalimil)

Tracking

unspecified
Firefox 50

Firefox Tracking Flags

(firefox50 fixed)

Details

Attachments

(1 attachment, 1 obsolete attachment)

Helen, what do you think about hiding the size count when the size is zero?  

via bug 1223143 comment 7

> ## JSON tab - misleading representation of empty arrays
> 
> Empty arrays are represented as:
> 
> key_name [0]
> 
> (or "key_name: [0]" in object summaries)
> 
> This, and the syntax coloring used (the zero is green, like a number literal
> in the Console) suggests that the value for key_name is an array with one
> value, the number 0. Yet the value is an *empty* array.
> 
> It should probably be represented as "key_name: []".
> 
> For the record, empty objects are: "key_name { }".

I wouldn't characterize the 0 as misleading, however it does seem superfluous given the colouring and that an empty array would give just as much meaning without confusing the eye.
(Reporter)

Updated

3 years ago
Summary: JSON VIewer: empty arrays should hide the zero count → JSON Viewer: empty arrays should hide the zero count
(Reporter)

Updated

3 years ago
Blocks: 1243951
(Assignee)

Comment 1

2 years ago
Created attachment 8770156 [details] [diff] [review]
rev1

I made a patch that removes the array length from the brackets when it's equal to 0.
Assignee: nobody → dalimilhajek
Status: NEW → ASSIGNED
Attachment #8770156 - Flags: review?(clarkbw)
(Reporter)

Comment 2

2 years ago
Comment on attachment 8770156 [details] [diff] [review]
rev1

Awesome work!
I'm going to re-assign this to Honza who can do the review.
Attachment #8770156 - Flags: review?(clarkbw) → review?(odvarko)
Lin, I like this and it's also inline with how the Console works now. Just one little thing.

The console displays two spaces between the brackets:

Logging: `[]` produces: `Array [  ]`

I think there shouldn't be space at all (Chrome works that way too, ah and no `Array` title):

Logging: `[]` produces: `[]`

What do you think?
Honza
Flags: needinfo?(lclark)
This sounds good to me.
Flags: needinfo?(lclark)
Comment on attachment 8770156 [details] [diff] [review]
rev1

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

Thanks for the patch!

Please see my inline comments.

Honza

::: devtools/client/shared/components/reps/array.js
@@ +127,5 @@
>        let items;
>  
>        if (mode == "tiny") {
> +        let isEmpty = object.length === 0;
> +        items = DOM.span({className: "length"}, isEmpty ? "" : object.length);

The same thing needs to be done also for GripArray rep (grip-array.js)

We have two since, there are two kinds of reps:
1) For JS objects that are directly accessible
2) For remote JS objects that are accessible through RDP/grips


And I guess, tests also need to be adopted. There are two tests:

devtools/client/shared/components/test/mochitest/test_reps_array.html
devtools/client/shared/components/test/mochitest/test_reps_grip-array.html

Honza
Attachment #8770156 - Flags: review?(odvarko)
(Assignee)

Comment 6

2 years ago
Created attachment 8771437 [details] [diff] [review]
rev2

I changed the grip-array.js and the tests. Although I am still not quite sure where I can see the grip-array being used in the browser...
Attachment #8770156 - Attachment is obsolete: true
Attachment #8771437 - Flags: review?(odvarko)
Comment on attachment 8771437 [details] [diff] [review]
rev2

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

Nice!

> Although I am still not quite
> sure where I can see the grip-array being used in the browser...

E.g. in the DOM panel (can be enabled in the Options panel)

Honza
Attachment #8771437 - Flags: review?(odvarko) → review+
(Assignee)

Updated

2 years ago
Keywords: checkin-needed

Comment 9

2 years ago
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/fx-team/rev/f4c0b8d3e348
JSON Viewer: empty arrays should hide the zero count. r=odvarko
Keywords: checkin-needed

Comment 10

2 years ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/f4c0b8d3e348
Status: ASSIGNED → RESOLVED
Last Resolved: 2 years ago
status-firefox50: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → Firefox 50

Updated

a month ago
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.