@@ -103,7 +103,23 @@ export function createPatchFunction (backend) {
103103 }
104104 }
105105
106- let inPre = 0
106+ function isUnknownElement ( vnode , inVPre ) {
107+ return (
108+ ! inVPre &&
109+ ! vnode . ns &&
110+ ! (
111+ config . ignoredElements . length &&
112+ config . ignoredElements . some ( ignore => {
113+ return isRegExp ( ignore )
114+ ? ignore . test ( vnode . tag )
115+ : ignore === vnode . tag
116+ } )
117+ ) &&
118+ config . isUnknownElement ( vnode . tag )
119+ )
120+ }
121+
122+ let creatingElmInVPre = 0
107123 function createElm ( vnode , insertedVnodeQueue , parentElm , refElm , nested ) {
108124 vnode . isRootInsert = ! nested // for transition enter check
109125 if ( createComponent ( vnode , insertedVnodeQueue , parentElm , refElm ) ) {
@@ -116,21 +132,9 @@ export function createPatchFunction (backend) {
116132 if ( isDef ( tag ) ) {
117133 if ( process . env . NODE_ENV !== 'production' ) {
118134 if ( data && data . pre ) {
119- inPre ++
135+ creatingElmInVPre ++
120136 }
121- if (
122- ! inPre &&
123- ! vnode . ns &&
124- ! (
125- config . ignoredElements . length &&
126- config . ignoredElements . some ( ignore => {
127- return isRegExp ( ignore )
128- ? ignore . test ( tag )
129- : ignore === tag
130- } )
131- ) &&
132- config . isUnknownElement ( tag )
133- ) {
137+ if ( isUnknownElement ( vnode , creatingElmInVPre ) ) {
134138 warn (
135139 'Unknown custom element: <' + tag + '> - did you ' +
136140 'register the component correctly? For recursive components, ' +
@@ -172,7 +176,7 @@ export function createPatchFunction (backend) {
172176 }
173177
174178 if ( process . env . NODE_ENV !== 'production' && data && data . pre ) {
175- inPre --
179+ creatingElmInVPre --
176180 }
177181 } else if ( isTrue ( vnode . isComment ) ) {
178182 vnode . elm = nodeOps . createComment ( vnode . text )
@@ -527,25 +531,28 @@ export function createPatchFunction (backend) {
527531 }
528532 }
529533
530- let bailed = false
534+ let hydrationBailed = false
531535 // list of modules that can skip create hook during hydration because they
532536 // are already rendered on the client or has no need for initialization
533537 const isRenderedModule = makeMap ( 'attrs,style,class,staticClass,staticStyle,key' )
534538
535539 // Note: this is a browser-only function so we can assume elms are DOM nodes.
536- function hydrate ( elm , vnode , insertedVnodeQueue ) {
540+ function hydrate ( elm , vnode , insertedVnodeQueue , inVPre ) {
541+ let i
542+ const { tag, data, children } = vnode
543+ inVPre = inVPre || ( data && data . pre )
544+ vnode . elm = elm
545+
537546 if ( isTrue ( vnode . isComment ) && isDef ( vnode . asyncFactory ) ) {
538- vnode . elm = elm
539547 vnode . isAsyncPlaceholder = true
540548 return true
541549 }
550+ // assert node match
542551 if ( process . env . NODE_ENV !== 'production' ) {
543- if ( ! assertNodeMatch ( elm , vnode ) ) {
552+ if ( ! assertNodeMatch ( elm , vnode , inVPre ) ) {
544553 return false
545554 }
546555 }
547- vnode . elm = elm
548- const { tag, data, children } = vnode
549556 if ( isDef ( data ) ) {
550557 if ( isDef ( i = data . hook ) && isDef ( i = i . init ) ) i ( vnode , true /* hydrating */ )
551558 if ( isDef ( i = vnode . componentInstance ) ) {
@@ -566,9 +573,9 @@ export function createPatchFunction (backend) {
566573 /* istanbul ignore if */
567574 if ( process . env . NODE_ENV !== 'production' &&
568575 typeof console !== 'undefined' &&
569- ! bailed
576+ ! hydrationBailed
570577 ) {
571- bailed = true
578+ hydrationBailed = true
572579 console . warn ( 'Parent: ' , elm )
573580 console . warn ( 'server innerHTML: ' , i )
574581 console . warn ( 'client innerHTML: ' , elm . innerHTML )
@@ -580,7 +587,7 @@ export function createPatchFunction (backend) {
580587 let childrenMatch = true
581588 let childNode = elm . firstChild
582589 for ( let i = 0 ; i < children . length ; i ++ ) {
583- if ( ! childNode || ! hydrate ( childNode , children [ i ] , insertedVnodeQueue ) ) {
590+ if ( ! childNode || ! hydrate ( childNode , children [ i ] , insertedVnodeQueue , inVPre ) ) {
584591 childrenMatch = false
585592 break
586593 }
@@ -592,9 +599,9 @@ export function createPatchFunction (backend) {
592599 /* istanbul ignore if */
593600 if ( process . env . NODE_ENV !== 'production' &&
594601 typeof console !== 'undefined' &&
595- ! bailed
602+ ! hydrationBailed
596603 ) {
597- bailed = true
604+ hydrationBailed = true
598605 console . warn ( 'Parent: ' , elm )
599606 console . warn ( 'Mismatching childNodes vs. VNodes: ' , elm . childNodes , children )
600607 }
@@ -617,10 +624,10 @@ export function createPatchFunction (backend) {
617624 return true
618625 }
619626
620- function assertNodeMatch ( node , vnode ) {
627+ function assertNodeMatch ( node , vnode , inVPre ) {
621628 if ( isDef ( vnode . tag ) ) {
622- return (
623- vnode . tag . indexOf ( 'vue-component' ) === 0 ||
629+ return vnode . tag . indexOf ( 'vue-component' ) === 0 || (
630+ ! isUnknownElement ( vnode , inVPre ) &&
624631 vnode . tag . toLowerCase ( ) === ( node . tagName && node . tagName . toLowerCase ( ) )
625632 )
626633 } else {
0 commit comments