Browse Source

fix #253 attribute names with colons

Evan You 12 years ago
parent
commit
3180eab53a
2 changed files with 16 additions and 1 deletions
  1. 2 1
      src/compiler.js
  2. 14 0
      test/unit/specs/misc.js

+ 2 - 1
src/compiler.js

@@ -552,7 +552,8 @@ CompilerProto.compileElement = function (node, root) {
                 // non directive attribute, check interpolation tags
                 exp = TextParser.parseAttr(attr.value)
                 if (exp) {
-                    directive = this.parseDirective('attr', attr.name + ':' + exp, node)
+                    directive = this.parseDirective('attr', exp, node)
+                    directive.arg = attr.name
                     if (params && params.indexOf(attr.name) > -1) {
                         // a param attribute... we should use the parent binding
                         // to avoid circular updates like size={{size}}

+ 14 - 0
test/unit/specs/misc.js

@@ -285,4 +285,18 @@ describe('Misc Features', function () {
 
     })
 
+    describe('attribute names with colons', function () {
+        
+        it('should be parsed properly', function () {
+            var t = new Vue({
+                template: '<use xlink:href="{{icon}}"></use>',
+                data: {
+                    icon: 'test'
+                }
+            })
+            assert.equal(t.$el.firstChild.getAttribute('xlink:href'), 'test')
+        })
+
+    })
+
 })