Closed
Bug 563447
Opened 15 years ago
Closed 15 years ago
Update context-menu module to use new api-utils module
Categories
(Add-on SDK Graveyard :: General, defect)
Add-on SDK Graveyard
General
Tracking
(Not tracked)
RESOLVED
FIXED
0.4
People
(Reporter: adw, Assigned: adw)
References
Details
Attachments
(1 file, 1 obsolete file)
|
9.30 KB,
patch
|
myk
:
review+
|
Details | Diff | Splinter Review |
Bug 559859 moved publicConstructor() and validateOptions() to a new api-utils module. We should remove those implementations from context-menu and replace their uses with api-utils.
| Assignee | ||
Comment 1•15 years ago
|
||
Replaces proto-api-utils implementations with api-utils use. Noticed an anon function that needs a name, took the opportunity to name it.
Attachment #444228 -
Flags: review?(myk)
Comment 2•15 years ago
|
||
Comment on attachment 444228 [details] [diff] [review]
patch
>diff --git a/packages/jetpack-core/lib/context-menu.js
>- this.__defineGetter__("onClick", function () options.onClick);
>- this.__defineGetter__("data", function () options.data);
>+ this.__defineGetter__("onClick", function () options.onClick || undefined);
Perhaps I'm not seeing something, but if onClick has been validated to be either a function or undefined, then isn't it redundant to return onClick || undefined, as returning just onClick will return undefined if the property hasn't been set to a function?
>+ this.__defineGetter__("data", function () options.data || undefined);
I might be missing something here too, but if data has been set to the empty string, which evaluates to false in a conditional, then it seems like this will return undefined when it should be returning the empty string.
r- per the issue with data, will switch to r+ once you point out what I'm missing. ;-)
Attachment #444228 -
Flags: review?(myk) → review-
| Assignee | ||
Comment 3•15 years ago
|
||
(In reply to comment #2)
> Perhaps I'm not seeing something, but if onClick has been validated to be
> either a function or undefined, then isn't it redundant to return onClick ||
> undefined, as returning just onClick will return undefined if the property
> hasn't been set to a function?
The problem is, if an option "foo" is optional (undefined is a valid value) and !("foo" in options), then !("foo" in validateOptions(options, requirements)). So the || undefined is only there to avoid strict warnings.
Originally it was the case that if ("foo" in requirements), then ("foo" in validateOptions()). But Felipe had a case where the value of "foo" was a number, zero being a valid value, so he couldn't use the idiom |if (validateOptions().foo)|, and he also couldn't use ("foo" in validatedOptions()) since it was always true, so he had to resort to some awkward or redundant checks. If you have any thoughts about this, I'd love to hear them.
> I might be missing something here too, but if data has been set to the empty
> string, which evaluates to false in a conditional, then it seems like this will
> return undefined when it should be returning the empty string.
D'oh, totally right.
I also noticed I was doing an unnecessary options.items || [] in Menu. options.items is validated to be an array, so it can't be undefined.
Attachment #444228 -
Attachment is obsolete: true
Attachment #444409 -
Flags: review?(myk)
Comment 4•15 years ago
|
||
Comment on attachment 444409 [details] [diff] [review]
patch v2
(In reply to comment #3)
> If you have any thoughts about this, I'd love to hear them.
Hmm, that makes perfect sense; I don't have any better ideas.
Looks great, r=myk!
Attachment #444409 -
Flags: review?(myk) → review+
| Assignee | ||
Comment 5•15 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Comment 6•15 years ago
|
||
The Add-on SDK is no longer a Mozilla Labs experiment and has become a big enough project to warrant its own Bugzilla product, so the "Add-on SDK" product has been created for it, and I am moving its bugs to that product.
To filter bugmail related to this change, filter on the word "looptid".
Component: Jetpack SDK → General
Product: Mozilla Labs → Add-on SDK
QA Contact: jetpack-sdk → general
Version: Trunk → unspecified
You need to log in
before you can comment on or make changes to this bug.
Description
•