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

Unable to dynamically set className on SVG element #1097

Closed
sebastiansandqvist opened this issue Jun 7, 2016 · 1 comment
Closed

Unable to dynamically set className on SVG element #1097

sebastiansandqvist opened this issue Jun 7, 2016 · 1 comment
Milestone

Comments

@sebastiansandqvist
Copy link
Contributor

sebastiansandqvist commented Jun 7, 2016

Description:

I have an SVG Icon component which is itself just m('svg.Icon', vnode.attrs, vnode.children). When attrs contains a className (in order to add a dynamic className besides Icon) an error is thrown, but not initially. It works fine until onupdate.

Seems like it could be a simple fix:
adobe-webplatform/Snap.svg#414
If the comments there are true, it's just a matter of using setAttribute or className.baseVal when the element is an svg.

Steps to Reproduce:

const Icon = {
  view(vnode) {
    return m('svg.Icon', vnode.attrs, vnode.children);
  }
};

const FooIcon = {
  view(vnode) {
    return m(Icon, {className: 'foo'}, m('path', {d: '' }) ); // empty path for simple demo
  }
};

Expected:

SVG element should have className of Icon foo

Actual:

Uncaught TypeError: Cannot set property className of #<SVGElement> which has only a getter

https://github.com/lhorie/mithril.js/blob/rewrite/mithril.js#L532

@tivac tivac added the rewrite label Jun 7, 2016
@tivac tivac changed the title Unable to dynamically set className on SVG element #rewrite Unable to dynamically set className on SVG element Jun 7, 2016
@lhorie
Copy link
Member

lhorie commented Jun 8, 2016

Fixed in 693c87f

@lhorie lhorie closed this as completed Jun 8, 2016
@dead-claudia dead-claudia added this to the Rewrite milestone Jun 18, 2016
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