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

Full SVG support #5

Closed
fregante opened this issue Jul 2, 2017 · 5 comments
Closed

Full SVG support #5

fregante opened this issue Jul 2, 2017 · 5 comments

Comments

@fregante
Copy link
Collaborator

fregante commented Jul 2, 2017

The list of SVG tags is incomplete, by looking at this one: https://github.com/wooorm/svg-tag-names/blob/master/index.json

In there you can also see regular HTML tag names so it's not as easy as requiring that module.

This uncovers an issue: all the tags in <svg><iframe></iframe></svg> should be created with the SVG namespace, that's what the browser does:

iframe's namespace === SVG

The only way to do that is to also look for <svg> and <foreignElement> into the parents.

@vadimdemedes
Copy link
Owner

This uncovers an issue: all the tags in <iframe></iframe> should be created with the SVG namespace

Thanks for bringing this up!

The problem is h is invoked for the most nested elements first, going from the bottom of the tree upwards. That's why we can't do what Preact does, encounter <svg> element and enable isSVG, which would use SVG namespace for all children.

Not sure right now how to work around this.

@vadimdemedes
Copy link
Owner

Until there's a solution, dom-chef could use svg-tag-names and just exclude tags that are also html tags, like iframe and a. It wouldn't count as full SVG support, but still better than nothing.

@vadimdemedes
Copy link
Owner

Added more tags using svg-tag-names module via e2f07ae.

@pygy
Copy link

pygy commented Jul 3, 2017

A solution would to have h create a vDOM tree as an IR, with a wrapper function called to materialize the DOM.

const el = domify(<svg><iframe></iframe></svg>);

where domify() propagates the NS from the root to the leafs.

@vadimdemedes vadimdemedes changed the title SVG support Full SVG support Jul 5, 2017
@fregante
Copy link
Collaborator Author

fregante commented Jul 19, 2017

I don't think this can be further resolved and probably it's fine. <iframe> works even without the SVG namespace.

Since babel-plugin-transform-react-jsx creates nested calls, h('iframe') won't know it's a child of h('svg') until the latter is created, and we can't safely correct the NS of the iframe once that happens.

The only way to support this would be by changing the babel transform to something that can be parsed at once, like JSX-IR, but really at that point it's best to just go with #7 (comment)

React either ignores this issue or is able to correct the NS before actually generating the dom because it has total control over it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants