Closed Bug 1080029 Opened 10 years ago Closed 6 years ago

html template tag does not work on a XUL page

Categories

(Core :: XUL, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla68
Tracking Status
firefox68 --- fixed

People

(Reporter: evold, Assigned: bdahl)

References

Details

Attachments

(2 files)

I was working on bug 1079434 and ran into this. You can use the diff I created there, I expected it to just work, but it is failing on the `let inputs = template.content.querySelectorAll("input");` bit, returning a length of 0 and I expect a length of 2.
Product: Firefox → Core
The magic support for putting things in the .content instead of the actual DOM is part of the HTML parsing algorithm. This document is not being parsed with the HTML parser, but with the XUL parser, so you don't get the magic. It looks like we hacked nsXMLContentSink to make this work (per the "willful violation of the XML specification" note in HTML), but not the XUL content sink.
Component: General → XUL
Summary: html template tag does not work on a xul page → html template tag does not work on a XUL page
See Also: → 1011831
Unfortunately, the XUL content sink uses nsXULPrototypeNode as its "current parent" abstraction, which makes things here ... complicated. In particular, presumably supporting this needs changes to prototype instantiation, not just the parser.
Yeah, I don't think making this work is worth it.
This issue has surfaced in multiple forms lately as we are trying to reduce our dependency on XUL/XBL. Two cases are: 1) The move from DTD/.properties to Fluent involved use of DOM Overlays which use <template> tag to merge and sanitize DOM Fragments for localization. That works great for HTML, but unfortunately lack of <template> tag in XUL makes it not able to handle XUL. We currently inject HTML elements into XUL for that (<a> and <img> etc.) but that's suboptimal. It would be make the Fluent transition easier and less likely to regress if we could use <template> tag in XUL 2) The XUL Overlay removal also would benefit from ability to use <teplate> tag in XUL ( NI on :bdhal for more detail). Is there any chance this became less complex to do over the last three years bz?
Flags: needinfo?(bzbarsky)
Flags: needinfo?(bdahl)
Nothing about the parsing end of this has changed.
Flags: needinfo?(bzbarsky)
(In reply to Zibi Braniecki [:gandalf][:zibi] from comment #5) > 2) The XUL Overlay removal also would benefit from ability to use <teplate> > tag in XUL ( NI on :bdhal for more detail). I was considering using a template so I could create the downloads panel lazily (see bug 1434077). However, using a hidden="true" for panel appears to be enough to not cause performance issues.
Flags: needinfo?(bdahl)

I would need this too for bug 1520350 and I ended up hack my way out with CDATA ... I guess this will be supported automagically when we convert the XUL files to XHTML?

(In reply to Tim Guan-tin Chien [:timdream] (please needinfo; no longer work for MoCo) from comment #8)

I would need this too for bug 1520350 and I ended up hack my way out with CDATA ... I guess this will be supported automagically when we convert the XUL files to XHTML?

I don't think it will, at least not for XHTML docs created via the prototype cache (as added in Bug 1527977).

Perhaps PrototypeDocumentContentSink would give us a better starting point for adding support (dealing with stuff like Comment 3). I'm not sure, but it's quite likely we'll want something like this for lazifying markup for the remaining XBL bindings (see discussion in https://phabricator.services.mozilla.com/D24914#729312). Going to needinfo Brendan for when he gets back to see if we have any new options here.

Flags: needinfo?(bdahl)

With XHTML the first parse and creation of the prototype document still is done with an XML parser and XUL content sink, so nothing has really changed here.

Flags: needinfo?(bdahl)
Assignee: nobody → bdahl

Check if the current parent element is an HTML template element and if it
is, append to the document fragment instead of it.

Pushed by bdahl@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/8235d59e1d86 Support HTML template in XUL documents. r=smaug
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla68
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: