Closed Bug 1462798 Opened 6 years ago Closed 6 years ago

Create a base custom element class that shares the parseXULToFragment helper

Categories

(Toolkit :: UI Widgets, task)

task
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla62
Tracking Status
firefox62 --- fixed

People

(Reporter: bgrins, Assigned: bgrins)

References

Details

Attachments

(1 file)

We'll want to share the parseXULToFragment function (and other helpers) across multiple elements. For more discussion, see https://bugzilla.mozilla.org/show_bug.cgi?id=1459556#c36 and https://bugzilla.mozilla.org/show_bug.cgi?id=1459556#c37.

One way to achieve this would be to make a new customElements.js file, move the stuff happening during "document-element-inserted" in MainProcessSingleton in there, and load just that file from MainProcessSingleton. Then we could attach a class like MozXULElement to the window, with a static parseXULToFragment function. CE classes would then extend MozXULElement.
Blocks: war-on-xbl
Blocks: 1411707
Paolo, what do you think about landing this change ahead of Bug 1459556 instead of vice versa? Would limit the amount of churn if that changeset could use the shared helper right away.
Assignee: nobody → bgrinstead
Status: NEW → ASSIGNED
Comment on attachment 8977114 [details]
Bug 1462798 - Create a base custom element class that shares the parseXULToFragment helper;

Super!

When we introduce classes that extend something different from XULElement, we may want to add the mixin part, but for now this looks great!
Attachment #8977114 - Flags: review?(paolo.mozmail) → review+
For some reason the r+ didn't get carried over into mozreview so I can't push this to autoland.
Flags: needinfo?(paolo.mozmail)
Switching to block bug 1459556 as suggested in Comment 5
Blocks: 1459556
No longer depends on: 1459556
Comment on attachment 8977114 [details]
Bug 1462798 - Create a base custom element class that shares the parseXULToFragment helper;

https://reviewboard.mozilla.org/r/245192/#review251310
Comment on attachment 8977114 [details]
Bug 1462798 - Create a base custom element class that shares the parseXULToFragment helper;

https://reviewboard.mozilla.org/r/245192/#review251314

::: toolkit/content/customElements.js:53
(Diff revision 5)
> +    // stripped out, so we simply remove all text nodes after using the parser.
> +    let nodeIterator = doc.createNodeIterator(doc, NodeFilter.SHOW_TEXT);
> +    let currentNode = nodeIterator.nextNode();
> +    while (currentNode) {
> +      currentNode.remove();
> +      currentNode = nodeIterator.nextNode();

nit: you can use the double parenthesis here to reduce repetition and pass the linter, like while((a = b())).
Pushed by bgrinstead@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/7c4c86f3913f
Create a base custom element class that shares the parseXULToFragment helper;r=Paolo
https://hg.mozilla.org/mozilla-central/rev/7c4c86f3913f
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla62
Flags: needinfo?(paolo.mozmail)
Type: enhancement → task
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: