Closed
Bug 308068
Opened 20 years ago
Closed 20 years ago
JavaScript strict warning in richlistbox.xml
Categories
(Toolkit :: UI Widgets, defect)
Tracking
()
VERIFIED
FIXED
mozilla1.8.1
People
(Reporter: zeniko, Assigned: zeniko)
References
Details
(Keywords: fixed1.8.1)
Attachments
(2 files, 1 obsolete file)
2.22 KB,
patch
|
doronr
:
first-review+
mconnor
:
second-review+
|
Details | Diff | Splinter Review |
2.16 KB,
patch
|
mconnor
:
second-review+
asa
:
approval1.8b5-
mconnor
:
approval-branch-1.8.1+
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8b4) Gecko/20050910 Firefox/1.4
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8b4) Gecko/20050910 Firefox/1.4
A strict warning is thrown, whenever the selectedItem field of a richlistbox is
set to null (e.g. in clearSelection). A patch is following.
Reproducible: Always
Steps to Reproduce:
1. Make sure javascript.options.strict and javascript.options.showInConsole are
set to true (in about:config)
2. Open the JavaScript Console and the Extensions Manager
3. Hit [Home] or [End] in the Extensions Manager
Actual Results:
The following two strict warnings are thrown:
Warning: reference to undefined property children[run]
Source File: chrome://global/content/bindings/richlistbox.xml
Line: 331
Warning: reference to undefined property children[run]
Source File: chrome://global/content/bindings/richlistbox.xml
Line: 335
Expected Results:
No console cluttering.
Updated•20 years ago
|
Assignee: nobody → doronr
Assignee | ||
Comment 1•20 years ago
|
||
The problem can be fixed by reversing the equality and the bounds check in
getIndexOf. By testing for null at the beginning, the problem also goes away.
Since getIndexOf and the selectedIndex getter share much common code, I decided
to unify them and to combine both possible fixes for stability and speed. Hope
the code remains clear enough.
Attachment #195681 -
Flags: first-review?(bugs.mano)
Updated•20 years ago
|
Attachment #195681 -
Flags: first-review?(bugs.mano) → first-review?(doronr)
Updated•20 years ago
|
Status: UNCONFIRMED → NEW
Ever confirmed: true
Version: unspecified → Trunk
Assignee | ||
Updated•20 years ago
|
Blocks: 296661
Summary: Strict warning in richlistbox (undefinded property children[run]) → JavaScript strict warning in richlistbox.xml
Comment 2•20 years ago
|
||
Comment on attachment 195681 [details] [diff] [review]
Code simplification, fixes strict warning
code gets somewhat unreadable, but doesn't take too much work to figure it out.
Attachment #195681 -
Flags: first-review?(doronr) → first-review+
Assignee | ||
Comment 3•20 years ago
|
||
Comment on attachment 195681 [details] [diff] [review]
Code simplification, fixes strict warning
Any suggestions on how to make the code better readable?
Attachment #195681 -
Flags: second-review?(mconnor)
Comment 4•20 years ago
|
||
What's wrong with using a for loop? Makes it much more readable IMO...
Assignee | ||
Comment 5•20 years ago
|
||
Assignee | ||
Comment 6•20 years ago
|
||
Thinking it over, the solution seems to be a one-liner when using the new
Array.indexOf. The null-test remains for performance reasons (the replaced
selectedIndex getter did the same test).
Attachment #195745 -
Attachment is obsolete: true
Comment 7•20 years ago
|
||
Comment on attachment 195681 [details] [diff] [review]
Code simplification, fixes strict warning
>- while (children[run] != aElement && run < children.length) {
>- run++;
>+ while (index < children.length && children[index] != aElement) {
>+ index++;
> }
>
>- if (children[run] == aElement)
>- index = run;
>-
>- return index;
>+ return (index < children.length) ? index : -1;
I generally find the following style clearer in the return on match case
while (index < children.length) {
if (children[index] == aElement)
return index;
index++
}
return -1;
r=me with that changed
Attachment #195681 -
Flags: second-review?(mconnor) → second-review+
Assignee | ||
Comment 8•20 years ago
|
||
Comment on attachment 195851 [details] [diff] [review]
using Array.indexOf for trivial solution
I'd rather include this patch, anyway. Alternatively you might prefer
attachment 195745 [details] [diff] [review]. Please review one of them before I rewrite the original
patch.
Attachment #195851 -
Flags: second-review?(mconnor)
Updated•20 years ago
|
Attachment #195851 -
Flags: second-review?(mconnor) → second-review+
Assignee | ||
Updated•20 years ago
|
Attachment #195851 -
Flags: approval1.8b5?
Updated•20 years ago
|
Whiteboard: [checkin needed]
Comment 9•20 years ago
|
||
Comment on attachment 195851 [details] [diff] [review]
using Array.indexOf for trivial solution
not the time or the place to take this kind of fix. please do not request
approval for this kind of change when we're in lockdown mode. thanks.
Attachment #195851 -
Flags: approval1.8b5? → approval1.8b5-
Updated•20 years ago
|
Assignee: doronr → zeniko
Comment 10•20 years ago
|
||
Trunk:
mozilla/toolkit/content/widgets/richlistbox.xml; new revision: 1.22;
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Whiteboard: [checkin needed]
Target Milestone: --- → mozilla1.9alpha1
Updated•20 years ago
|
Status: RESOLVED → VERIFIED
Updated•19 years ago
|
Attachment #195851 -
Flags: approval-branch-1.8.1?(mconnor)
Updated•19 years ago
|
Attachment #195851 -
Flags: approval-branch-1.8.1?(mconnor) → approval-branch-1.8.1+
Comment 11•19 years ago
|
||
mozilla/toolkit/content/widgets/richlistbox.xml 1.13.2.11
Updated•19 years ago
|
Flags: in-testsuite-
You need to log in
before you can comment on or make changes to this bug.
Description
•