Vue: Binding viewBox attribute on svg

Created on 28 Jan 2016  ·  5Comments  ·  Source: vuejs/vue

Binding viewBox attribute on svg does not seen to work.

Repro: https://jsfiddle.net/ct1zagyz/2/

improvement

Most helpful comment

Hmm, this is annoying because HTML parsing only preserves the camelCase for valid camelCase attributes, so v-bind:viewBox is converted to v-bind:viewbox before the directive can handle it.

Two things I'm considering:

  1. Add a .camel modifier so that you can do <svg :view-box.camel="xxx">. A bit indirect but is trivial to implement.
  2. Include a built-in whitelist of valid SVG camelCase attributes. The annoying part is the list will either be super long (thus shipping a lot of extra code that is likely unused in a lot of scenarios), or be incomplete. I personally do not work with SVG a lot, but would like to get feedback on how common such camelCase attributes are encountered.

All 5 comments

Hmm, this is annoying because HTML parsing only preserves the camelCase for valid camelCase attributes, so v-bind:viewBox is converted to v-bind:viewbox before the directive can handle it.

Two things I'm considering:

  1. Add a .camel modifier so that you can do <svg :view-box.camel="xxx">. A bit indirect but is trivial to implement.
  2. Include a built-in whitelist of valid SVG camelCase attributes. The annoying part is the list will either be super long (thus shipping a lot of extra code that is likely unused in a lot of scenarios), or be incomplete. I personally do not work with SVG a lot, but would like to get feedback on how common such camelCase attributes are encountered.

Could svg attributes as a whole be ignored, would that be simpler?

I'll take the .camel over the whitelist.

@simplesmiler ok, it's already in the dev branch :)

thank you for post

Was this page helpful?
0 / 5 - 0 ratings