Kaynağa Gözat

compile: warn directives on fragment instance placeholders

Evan You 10 yıl önce
ebeveyn
işleme
f7dab277e5
1 değiştirilmiş dosya ile 12 ekleme ve 0 silme
  1. 12 0
      src/compiler/compile.js

+ 12 - 0
src/compiler/compile.js

@@ -205,6 +205,18 @@ exports.compileRoot = function (el, options) {
       // non-component, just compile as a normal element.
       replacerLinkFn = compileDirectives(el.attributes, options)
     }
+  } else if (process.env.NODE_ENV !== 'production' && containerAttrs) {
+    // warn container directives for fragment instances
+    containerAttrs.forEach(function (attr) {
+      if (attr.name.indexOf('v-') === 0 || attr.name === 'transition') {
+        _.warn(
+          attr.name + ' is ignored on component ' +
+          '<' + options.el.tagName.toLowerCase() + '> because ' +
+          'the component is a fragment instance: ' +
+          'http://vuejs.org/guide/components.html#Fragment_Instance'
+        )
+      }
+    })
   }
 
   return function rootLinkFn (vm, el, scope) {