Closed
Bug 1143769
Opened 10 years ago
Closed 10 years ago
[Customizer] Custom elements are registered multiple times
Categories
(Firefox OS Graveyard :: Gaia, defect, P2)
Firefox OS Graveyard
Gaia
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: drs, Assigned: drs)
References
Details
(Whiteboard: [spark])
Add-ons inherit everything from the app that they're injected into, and we're registering some web components from the Customizer. Thus, we sometimes run into situations where the app has registered a web component, and then we attempt to register it a second time from within our add-on code.
Unfortunately, the only way to detect whether or not a web component was already registered is to attempt to register it, and then either catch an exception if it was, or not if it wasn't.
Short-term strategy:
For now, let's just silently ignore duplicate `document.registerElement()` calls. This can be done by commenting out this line:
https://dxr.mozilla.org/mozilla-central/source/dom/base/nsDocument.cpp#6180
I will land a patch for this on cypress after bug 1133943 lands on m-c.
Long-term strategy:
I don't have a very good solution here, but I have some suggestions, sorted in descending order of my preference, without too much thought put into this:
* Augment the web components API to allow us to check whether or not a web component exists. With this, we could just avoid registering it if it's already registered.
* Write some kind of wrapper for all of our web components, perhaps part of our gulp build, that adds some code that catches this particular exception and ignores it.
* Add code to each and every web component to catch exceptions on registration and discard them.
Comment 1•10 years ago
|
||
Thinking a try-catch within gaia-component.js might be the best way to deal with this. There are some alternatives [1] but I fear they may pose a greater performance penalty.
[1] http://stackoverflow.com/questions/27334365/how-to-get-list-of-registered-custom-elements
Assignee | ||
Comment 2•10 years ago
|
||
I went ahead and landed this change in each component that we're using.
https://github.com/gaia-components/gaia-header/commit/b61a86c71980c93fcaad4b2c53306938be353215
https://github.com/gaia-components/gaia-dialog/commit/38bd55b56093c907cba5b9e54de058f47bfb6ed6
https://github.com/gaia-components/gaia-component/commit/b42cdf4f1866e39db1174aacf50c6119e9133ab9
These changes were really trivial so I didn't ask for review, but I'd be happy to make any followup changes if you'd like, Wilson.
With these changes and a few Gecko patches, the Customizer actually injects into apps and runs. So unless there's any followup work here to be done, I think we can close this bug.
Flags: needinfo?(wilsonpage)
Assignee | ||
Updated•10 years ago
|
Assignee: nobody → drs
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Updated•10 years ago
|
Whiteboard: [lightsaber] → [ignite]
Updated•10 years ago
|
Whiteboard: [ignite] → [spark]
You need to log in
before you can comment on or make changes to this bug.
Description
•