Просмотр исходного кода

avoid warning unknown custom elements in v-pre

Evan You 9 лет назад
Родитель
Сommit
7b389bc34e
3 измененных файлов с 13 добавлено и 0 удалено
  1. 1 0
      flow/vnode.js
  2. 4 0
      src/compiler/codegen/index.js
  3. 8 0
      src/core/vdom/patch.js

+ 1 - 0
flow/vnode.js

@@ -34,6 +34,7 @@ declare interface VNodeData {
   key?: string | number;
   slot?: string;
   ref?: string;
+  pre?: boolean;
   tag?: string;
   staticClass?: string;
   class?: any;

+ 4 - 0
src/compiler/codegen/index.js

@@ -164,6 +164,10 @@ function genData (el: ASTElement): string {
   if (el.refInFor) {
     data += `refInFor:true,`
   }
+  // pre
+  if (el.pre) {
+    data += `pre:true,`
+  }
   // record original tag name for components using "is" attribute
   if (el.component) {
     data += `tag:"${el.tag}",`

+ 8 - 0
src/core/vdom/patch.js

@@ -84,6 +84,7 @@ export function createPatchFunction (backend) {
     }
   }
 
+  let inPre = 0
   function createElm (vnode, insertedVnodeQueue, nested) {
     let i
     const data = vnode.data
@@ -103,7 +104,11 @@ export function createPatchFunction (backend) {
     const tag = vnode.tag
     if (isDef(tag)) {
       if (process.env.NODE_ENV !== 'production') {
+        if (data && data.pre) {
+          inPre++
+        }
         if (
+          !inPre &&
           !vnode.ns &&
           !(config.ignoredElements && config.ignoredElements.indexOf(tag) > -1) &&
           config.isUnknownElement(tag)
@@ -124,6 +129,9 @@ export function createPatchFunction (backend) {
       if (isDef(data)) {
         invokeCreateHooks(vnode, insertedVnodeQueue)
       }
+      if (process.env.NODE_ENV !== 'production' && data && data.pre) {
+        inPre--
+      }
     } else if (vnode.isComment) {
       vnode.elm = nodeOps.createComment(vnode.text)
     } else {