Przeglądaj źródła

fix class merging for svg elements (fix #1093)

Evan You 10 lat temu
rodzic
commit
067e1746cb

+ 2 - 1
src/compiler/transclude.js

@@ -143,7 +143,8 @@ function mergeAttrs (from, to) {
     if (!to.hasAttribute(name)) {
       to.setAttribute(name, value)
     } else if (name === 'class') {
-      to.className = to.className + ' ' + value
+      value = to.getAttribute(name) + ' ' + value
+      to.setAttribute(name, value)
     }
   }
 }

+ 10 - 0
test/unit/specs/compiler/transclude_spec.js

@@ -117,5 +117,15 @@ if (_.inBrowser) {
       expect(res.getAttribute('title')).toBe('child')
     })
 
+    it('class merge for svg elements', function () {
+      el.setAttribute('class', 'test')
+      options.template = '<circle class="other"></circle>'
+      options.replace = true
+      options._asComponent = true
+      var res = transclude(el, options)
+      expect(res.namespaceURI).toBe('http://www.w3.org/2000/svg')
+      expect(res.getAttribute('class')).toBe('other test')
+    })
+
   })
 }