Преглед изворни кода

transclude class merging should skip interpolated class (fix #2085)

Evan You пре 10 година
родитељ
комит
cdf233f59f
2 измењених фајлова са 19 додато и 1 уклоњено
  1. 2 1
      src/compiler/transclude.js
  2. 17 0
      test/unit/specs/misc_spec.js

+ 2 - 1
src/compiler/transclude.js

@@ -1,4 +1,5 @@
 import { parseTemplate } from '../parsers/template'
+import { parseText } from '../parsers/text'
 import {
   warn,
   isTemplate,
@@ -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)
       })

+ 17 - 0
test/unit/specs/misc_spec.js

@@ -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')
+  })
 })