Skip to content

Commit

Permalink
transclude class merging should skip interpolated class (fix vuejs#2085)
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Dec 25, 2015
1 parent da9e036 commit cdf233f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/compiler/transclude.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { parseTemplate } from '../parsers/template'
import { parseText } from '../parsers/text'
import {
warn,
isTemplate,
Expand Down Expand Up @@ -149,7 +150,7 @@ function mergeAttrs (from, to) {
value = attrs[i].value
if (!to.hasAttribute(name) && !specialCharRE.test(name)) {
to.setAttribute(name, value)
} else if (name === 'class') {
} else if (name === 'class' && !parseText(value)) {
value.split(/\s+/).forEach(function (cls) {
addClass(to, cls)
})
Expand Down
17 changes: 17 additions & 0 deletions test/unit/specs/misc_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,4 +428,21 @@ describe('Misc', function () {
})
expect(vm.$el.firstChild.className).toBe('hi test-transition')
})

it('transclude class merging should skip interpolated class', function () {
var vm = new Vue({
el: document.createElement('div'),
template: '<test class="outer-{{test}}"></test>',
data: {
test: 'hi'
},
components: {
test: {
template: '<div class="inner"></div>',
replace: true
}
}
})
expect(vm.$el.firstChild.className).toBe('outer-hi')
})
})

0 comments on commit cdf233f

Please sign in to comment.