Skip to content

Commit 067e174

Browse files
committed
fix class merging for svg elements (fix #1093)
1 parent 974c5c3 commit 067e174

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/compiler/transclude.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ function mergeAttrs (from, to) {
143143
if (!to.hasAttribute(name)) {
144144
to.setAttribute(name, value)
145145
} else if (name === 'class') {
146-
to.className = to.className + ' ' + value
146+
value = to.getAttribute(name) + ' ' + value
147+
to.setAttribute(name, value)
147148
}
148149
}
149150
}

test/unit/specs/compiler/transclude_spec.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,5 +117,15 @@ if (_.inBrowser) {
117117
expect(res.getAttribute('title')).toBe('child')
118118
})
119119

120+
it('class merge for svg elements', function () {
121+
el.setAttribute('class', 'test')
122+
options.template = '<circle class="other"></circle>'
123+
options.replace = true
124+
options._asComponent = true
125+
var res = transclude(el, options)
126+
expect(res.namespaceURI).toBe('http://www.w3.org/2000/svg')
127+
expect(res.getAttribute('class')).toBe('other test')
128+
})
129+
120130
})
121131
}

0 commit comments

Comments
 (0)