Closed
Bug 1207122
Opened 9 years ago
Closed 6 years ago
Make private View methods private
Categories
(Firefox OS Graveyard :: Gaia::L10n, defect)
Tracking
(Not tracked)
RESOLVED
WONTFIX
People
(Reporter: stas, Assigned: stas)
References
Details
Attachments
(2 files)
3.92 KB,
patch
|
Details | Diff | Splinter Review | |
39 bytes,
text/x-github-pull-request
|
Details | Review |
View methods like observe, disconnect and _resolveEntity should only be accessible by priviledged code, in this case, the DOM bindings. We can achieve this using Symbols. I have a PoC ready which I can finish and rebase after bug 1204086, bug 1207120 and bug 1207121 land.
Assignee | ||
Comment 1•9 years ago
|
||
https://github.com/stasm/l20n.js/tree/1207122-private-view-methods
Assignee | ||
Comment 2•9 years ago
|
||
We can use the same approach to hide view.doc and others. It all boils down to defining "interfaces" or "protocols". The DOM bindings might define a PDom protocol, while the View can define its own PView protocol with symbols which will be used to access private methods and properties. (In the PR I used the name IView instead of PDom.)
Comment 3•9 years ago
|
||
Uuuh, I have to say that it feels to me like obfuscating the code. I'll look more into this, but I'm wondering if if we can just define them as local functions instead of using Symbols?
Assignee | ||
Comment 4•9 years ago
|
||
Hmm, I haven't found a way to do this in the setup we have right now. If 'resolveEntity' is a local function in view.js, you need to import it in dom.js and use it like this: resolveEntity.call(view, …). I'd like to be able to do this this way, but as far as I understand it, it makes it impossible to reuse the dom.js code in other bindings, e.g. gaiabuild. Gaiabuild's View needs to have its own resolveEntity, while with the local function apporach, dom.js hardcodes import { resolveEntity } from 'src/bindings/html/view'; I found that local functions make it generally harder to extend the code. Symbols, OTOH, can be imported by the code which wants to do the extending. Do you have other ideas on how to achieve this? It bugs me that half of View's public methods are in fact private.
Assignee | ||
Comment 5•9 years ago
|
||
I updated and clean up the code a bit. Attaching the link to the pull request so it doesn't get lost.
Comment 6•8 years ago
|
||
Comment on attachment 8664184 [details] [diff] [review] PoC not a target at the moment.
Attachment #8664184 -
Flags: feedback?(gandalf)
Comment 7•6 years ago
|
||
Firefox OS is not being worked on
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → WONTFIX
You need to log in
before you can comment on or make changes to this bug.
Description
•