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

support svg #7

Open
dominictarr opened this issue May 22, 2013 · 13 comments
Open

support svg #7

dominictarr opened this issue May 22, 2013 · 13 comments

Comments

@dominictarr
Copy link
Collaborator

Would be cool if this supported svg.
you can't create svg with html elements...
and you can't detect an element is an svg element purely on the name of that tag,
be cause <a> means different thing in svg land, also, svg seems to use attributes, not properties...

So, probably write a new module hypersvg...

Refactor hyperscript, so that most of the code can be the same...

@Raynos
Copy link
Collaborator

Raynos commented May 22, 2013

svg elements should live in a <svg> node.

@dominictarr
Copy link
Collaborator Author

I considered that, but I may want to have a function that say, returns a svg circle, so I can't use magic to make it know that function is being called as an argument to a h('svg') function.

Another possibility would be for h('svg', h('circle')) to realize it's an svg, and convert the circle element into an SVG element, but this too is magic.

simplest:

var h = require('hyperscript')
var s = require('hypersvg')
h('svg', s('circle'))

@Raynos
Copy link
Collaborator

Raynos commented Apr 8, 2014

We landed svg support in virtual-dom today ( Matt-Esch/virtual-dom@be1d792 )

Maybe take inspiration from that implementation.

@staltz
Copy link

staltz commented Aug 4, 2014

It would be really helpful if hyperscript and virtual-hyperscript would have the same API. Would be very useful to be able to swap between them whenever. I just ran into that issue while doing svg elements.

@dominictarr
Copy link
Collaborator Author

+1

@tomek-he-him
Copy link
Contributor

It would be really helpful if hyperscript and virtual-hyperscript would have the same API. Would be very useful to be able to swap between them whenever. I just ran into that issue while doing svg elements.

Seems like virtual-hyperscript takes a namespace option. Can that be a good first step perhaps?

@tomek-he-him
Copy link
Contributor

@staltz I think I’ve never used virtual-dom for SVG yet. Can you show us a minimal example what it looks like? Does h('svg', h('circle')) work there?

@staltz
Copy link

staltz commented Sep 23, 2015

@tomek-he-him
Copy link
Contributor

Is Cycle.svg a separate module like @dominictarr suggested?

@staltz
Copy link

staltz commented Sep 23, 2015

It's just a shortcut to virtual-dom's svg helper. Cycle.js is a framework on top of virtual-dom.

@tomek-he-him
Copy link
Contributor

Thanks! So it looks like @dominictarr’s idea var s = require('hypersvg') is the way to go.

@tomek-he-him
Copy link
Contributor

(BTW @staltz I have stumbled across Cycle.js before, but never used it for anything. Looks very interesting! I like the way you solved a couple of problems. But having been bitten by Angular and later Mithril I now prefer to compose libraries instead of sticking to a framework.)

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

No branches or pull requests

4 participants