Ver código fonte

Merge pull request #2366 from rhyzx/fix-terminal-directives-with-global-mixin

Fix custom terminal directive with global mixin
Evan You 10 anos atrás
pai
commit
fdf1b8d9bd
2 arquivos alterados com 15 adições e 1 exclusões
  1. 2 1
      src/compiler/compile.js
  2. 13 0
      test/unit/specs/compiler/compile_spec.js

+ 2 - 1
src/compiler/compile.js

@@ -627,7 +627,8 @@ function makeTerminalNodeLinkFn (el, dirName, value, options, def) {
     filters: parsed.filters,
     raw: value,
     // either an element directive, or if/for
-    def: def || publicDirectives[dirName]
+    // #2366 or custom terminal directive
+    def: def || resolveAsset(options, 'directives', dirName)
   }
   // check ref for v-for and router-view
   if (dirName === 'for' || dirName === 'router-view') {

+ 13 - 0
test/unit/specs/compiler/compile_spec.js

@@ -634,4 +634,17 @@ describe('Compile', function () {
     expect(el.textContent).toBe('worked!')
     expect(getWarnCount()).toBe(0)
   })
+
+  it('allow custom terminal directive', function () {
+    Vue.mixin({}) // #2366 conflict with custom terminal directive
+    Vue.compiler.terminalDirectives.push('foo')
+    Vue.directive('foo', {})
+
+    new Vue({
+      el: el,
+      template: '<div v-foo></div>'
+    })
+
+    expect(getWarnCount()).toBe(0)
+  })
 })