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

SVG not supported #204

Open
buckle2000 opened this issue Feb 15, 2018 · 5 comments
Open

SVG not supported #204

buckle2000 opened this issue Feb 15, 2018 · 5 comments
Labels

Comments

@buckle2000
Copy link

buckle2000 commented Feb 15, 2018

new Moon({
	template: `<svg width="200" height="200" viewport="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
    <rect x="0" y="70" width="10" height="30"></rect>
  </svg>`,
  el: '#target'
})

This code yields nothing.
Seems like the svg namespace is not supported.

@kbrsh
Copy link
Owner

kbrsh commented Feb 15, 2018

Hey! @buckle2000

SVG is partially supported in Moon v0.11.0, but had some issues. I've implemented full SVG support for v1.

@buckle2000
Copy link
Author

buckle2000 commented Mar 2, 2018

Here is an example script for SVG manipulation:

var ns = 'http://www.w3.org/2000/svg'
var div = document.getElementById('drawing') 
var svg = document.createElementNS(ns, 'svg')
svg.setAttributeNS(null, 'width', '100%')
svg.setAttributeNS(null, 'height', '100%')
div.appendChild(svg)
var rect = document.createElementNS(ns, 'rect')
rect.setAttributeNS(null, 'width', 100)
rect.setAttributeNS(null, 'height', 100)
rect.setAttributeNS(null, 'fill', '#f06')
svg.appendChild(rect)

moon should use setAttributeNS. Updating SVG node attribute in DOM does nothing.

node.width = 100; // no
node.setAttributeNS(null, 'width', 100); // yes

@kbrsh
Copy link
Owner

kbrsh commented Mar 2, 2018

Yup! Moon v1 has full support for SVG at the moment (check out this line), but I need to make updating attributes a bit more efficient.

@buckle2000
Copy link
Author

I cannot find any setAttributeNS in code.

@kbrsh
Copy link
Owner

kbrsh commented Mar 3, 2018

I'm still in the process of making updating attributes more efficient. If you look at other discussions in other issues, I'm also just taking a break from rewriting things for Moon v1 and am rethinking Moon's goals and making a new API from scratch.

@kbrsh kbrsh added the feature label Jun 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants