Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<template> element capability/semantics in SVG parsing context #3563

Open
kevinpschaaf opened this issue Mar 13, 2018 · 4 comments
Open

<template> element capability/semantics in SVG parsing context #3563

kevinpschaaf opened this issue Mar 13, 2018 · 4 comments
Labels
addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest topic: parser

Comments

@kevinpschaaf
Copy link

This is a feature request to provide similar capability/semantics of the HTMLTemplateElement/<template> tag for elements parsed in the SVG namespace.

From a user's point of view, the use cases and reasons that made <template> useful -- ability to parse a prototypical chunk of elements from a document, holding the parsed nodes in an inert fragment, and ability to efficiently clone one or more instances of the template without incurring re-parsing costs or needing to recursively walk a tree to create them -- all apply to elements in the SVG context. However, the <template> tag is only defined in the HTML namespace, and there is no built-in equivalent for SVG.

This seems like an obvious hole in the platform; what are the current blockers to considering such an addition?

@kevinpschaaf
Copy link
Author

The original discussions of the <template> proposal that @annevk helpfully pointed to indicate a concern for adding this capability to SVG:

The proposal here doesn't support SVG (or MathML, but SVG seems more important for <template>). Short of hard-coding a list of SVG elements, which seems really bad for forwards compatibility, I don't have a good proposal for dealing with this. I suppose we could go back to having an attribute on <template>, this time setting the context at a more coarse level of just HTML vs SVG vs MathML; that's more likely to be understood by authors than what I was suggesting before ("in table body", etc).

It wasn't immediately clear to this lay person what would necessitate a hard-coded list of SVG elements; it seems like if the parser is parsing in the SVG namespace and there was a <template> element defined in that namespace, it could be a straightforward addition.

@annevk annevk added addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest topic: parser labels Mar 14, 2018
@annevk
Copy link
Member

annevk commented Mar 14, 2018

What you are suggesting is effectively introducing a new element with equivalent semantics to the template element. That comes at a high cost and is unlikely to gain support given that it duplicates an element and requires changes to the HTML parser (which have a high bar).

If instead the suggestion is changed to make it create an HTML template element, but whose insertion mode sticks with SVG somehow, that would already be far more reasonable, but given #919 (comment) is also unlikely to succeed.

I do think it would be good to figure out something here as SVG is very much part of the platform and it's rather crappy for templates to not support it properly, but it's probably better at this point to take a couple steps back and focus on high-level use cases and requirements first (and perhaps a survey of what frameworks have on offer).

@tabatkins
Copy link
Contributor

And my very next comment #919 (comment) complains about Henri's comment as being discussion-stopping, and provides a solution to fix things. ^_^ (Add a new HTML <vector> element, which acts identically to <svg>, but which parses with the normal HTML parser, and just assigns things to the SVG or HTML namespace as appropriate based on localName.)

@annevk
Copy link
Member

annevk commented Mar 15, 2018

I think that has the same issues he's worried about. Namely that introducing new ways to create elements has security implications and even if all browsers updated it's unclear if servers would.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest topic: parser
Development

No branches or pull requests

3 participants