samedi 6 février 2016

In Ember, how do I bind an attribute whose name has a colon?

I want to create a component whose root element is

<svg width='150px'
     height='150px'
     viewBox='0 0 150 150'
     version='1.1'
     xmlns='http://ift.tt/nvqhV5'
     xmlns:xlink='http://ift.tt/PGV9lw'>

I can set most of those up with simple attribute bindings:

Ember.Component.extend({
  attributeBindings: [ 'height', 'version', 'viewBox', 'width', 'xmlns' ],
  tagName: 'svg',
  height: '150px',
  version: '1.1',
  viewBox: '0 0 150 150',
  width: '150px',
  xmlns: 'http://ift.tt/nvqhV5'
});

The one that won't work is xmlns:xlink. If I try to add that as an attribute binding, Ember interprets the colon to mean bind the xlink attribute to the value of the xmlns property so I get

<svg width='150px'
     height='150px'
     viewBox='0 0 150 150'
     version='1.1'
     xmlns='http://ift.tt/nvqhV5'
     xlink='http://ift.tt/nvqhV5'>

How can I set up an attribute binding for this property?




Aucun commentaire:

Enregistrer un commentaire