Closed
Bug 968378
Opened 11 years ago
Closed 11 years ago
Hide private members in Home.jsm using closures
Categories
(Firefox for Android Graveyard :: Awesomescreen, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
Firefox 30
People
(Reporter: mcomella, Assigned: lpy)
References
Details
(Whiteboard: [mentor=mcomella][lang=js])
Attachments
(2 files, 4 obsolete files)
(deleted),
text/plain
|
Details | |
(deleted),
patch
|
lpy
:
review+
|
Details | Diff | Splinter Review |
The private members are currently declared using leading underscores.
Alternatively, we can declare the functionality as non-exported top-level objects, however, margaret agreed on IRC that the encapsulation with closures is probably preferable.
Reporter | ||
Comment 1•11 years ago
|
||
Example private member in the code: https://mxr.mozilla.org/mozilla-central/source/mobile/android/modules/Home.jsm?rev=46c932e276ea#167
Reporter | ||
Updated•11 years ago
|
Attachment #8370962 -
Attachment description: Private member example → Ideal private member example
Assignee | ||
Comment 2•11 years ago
|
||
I take this one, and I will wait until bug 965023 landed.
Assignee: nobody → pylaurent1314
Reporter | ||
Updated•11 years ago
|
Status: NEW → ASSIGNED
Assignee | ||
Comment 3•11 years ago
|
||
Attachment #8373196 -
Flags: review?(michael.l.comella)
Reporter | ||
Comment 4•11 years ago
|
||
Comment on attachment 8373196 [details] [diff] [review]
bug968378.patch
Review of attachment 8373196 [details] [diff] [review]:
-----------------------------------------------------------------
::: mobile/android/modules/Home.jsm
@@ +67,5 @@
> break;
> + }
> + },
> +
> + _handleGet: function() {
Sorry if I was unclear but these private functions should also not be in the returned object as calling them could change internal state.
@@ +157,2 @@
> // Valid layouts for a panel.
> + let Layout = {
This needs to be a part of the returned object as it's part of the API. Assume any reference that does not start with an underscore should be public and anything with the underscore should be private.
[1]: https://wiki.mozilla.org/Mobile/Projects/Third-party_service_integration_MVP#JS_APIs
@@ +161,3 @@
>
> // Valid types of views for a dataset.
> + let View = {
Same: public.
Attachment #8373196 -
Flags: review?(michael.l.comella) → review-
Assignee | ||
Comment 5•11 years ago
|
||
Thank you :) I wasn't aware of that before.
Attachment #8373196 -
Attachment is obsolete: true
Attachment #8374013 -
Flags: review?(michael.l.comella)
Reporter | ||
Comment 6•11 years ago
|
||
Comment on attachment 8374013 [details] [diff] [review]
bug968378-V2.patch
Review of attachment 8374013 [details] [diff] [review]:
-----------------------------------------------------------------
::: mobile/android/modules/Home.jsm
@@ +215,5 @@
> + throw "Home.panels: Can't create a home panel without an id and title!";
> + }
> +
> + // Bail if the panel already exists
> + if (panel.id in this._panels) {
`this` refers to the object on which this method was called (unless altered by `bind()` and similar methods, but let's not worry about this). In this case, `this` refers to the return object which has not `_panels` attribute, meaning `this._panels` is null, and this fails.
(I believe) removing `this` should fix the issue. Can you update this here and where ever else it is an issue? Sorry I didn't mention this before - I didn't realize it would be an issue until running the code! :P
In testing, check the logcat output to ensure there are no errors in Home.jsm, and no errors in the addon. If "Replace doc w/ feed contents" appears in the overflow menu (hamburger button), the addon has generally loaded successfully.
@@ +255,5 @@
> + sendMessageToJava({
> + type: "HomePanels:Remove",
> + panel: this._panelToJSON(panel)
> + });
> + }
nit: Excess end of line whitespace.
Attachment #8374013 -
Flags: review?(michael.l.comella) → review-
Assignee | ||
Comment 7•11 years ago
|
||
Should work this time. Thanks
Attachment #8374013 -
Attachment is obsolete: true
Attachment #8374757 -
Flags: review?(michael.l.comella)
Reporter | ||
Comment 8•11 years ago
|
||
Comment on attachment 8374757 [details] [diff] [review]
bug968378-V3.patch
Review of attachment 8374757 [details] [diff] [review]:
-----------------------------------------------------------------
Nice!
Attachment #8374757 -
Flags: review?(michael.l.comella) → review+
Assignee | ||
Comment 11•11 years ago
|
||
sorry, my bad.
Attachment #8374757 -
Attachment is obsolete: true
Attachment #8375599 -
Flags: review+
Assignee | ||
Updated•11 years ago
|
Keywords: checkin-needed
Assignee | ||
Comment 13•11 years ago
|
||
thank you
Attachment #8375599 -
Attachment is obsolete: true
Attachment #8376047 -
Flags: review+
Assignee | ||
Updated•11 years ago
|
Keywords: checkin-needed
Comment 14•11 years ago
|
||
Keywords: checkin-needed
Whiteboard: [mentor=mcomella][lang=js] → [mentor=mcomella][lang=js][fixed-in-fx-team]
Comment 15•11 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Whiteboard: [mentor=mcomella][lang=js][fixed-in-fx-team] → [mentor=mcomella][lang=js]
Target Milestone: --- → Firefox 30
Updated•4 years ago
|
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•