MCPcopy Create free account
hub / github.com/TruthHun/BookStack / hydrate

Function hydrate

static/vuejs/vue.runtime.common.js:4967–5026  ·  view source on GitHub ↗
(elm, vnode, insertedVnodeQueue)

Source from the content-addressed store, hash-verified

4965
4966 // Note: this is a browser-only function so we can assume elms are DOM nodes.
4967 function hydrate (elm, vnode, insertedVnodeQueue) {
4968 if (process.env.NODE_ENV !== 'production') {
4969 if (!assertNodeMatch(elm, vnode)) {
4970 return false
4971 }
4972 }
4973 vnode.elm = elm;
4974 var tag = vnode.tag;
4975 var data = vnode.data;
4976 var children = vnode.children;
4977 if (isDef(data)) {
4978 if (isDef(i = data.hook) && isDef(i = i.init)) { i(vnode, true /* hydrating */); }
4979 if (isDef(i = vnode.componentInstance)) {
4980 // child component. it should have hydrated its own tree.
4981 initComponent(vnode, insertedVnodeQueue);
4982 return true
4983 }
4984 }
4985 if (isDef(tag)) {
4986 if (isDef(children)) {
4987 // empty element, allow client to pick up and populate children
4988 if (!elm.hasChildNodes()) {
4989 createChildren(vnode, children, insertedVnodeQueue);
4990 } else {
4991 var childrenMatch = true;
4992 var childNode = elm.firstChild;
4993 for (var i$1 = 0; i$1 < children.length; i$1++) {
4994 if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue)) {
4995 childrenMatch = false;
4996 break
4997 }
4998 childNode = childNode.nextSibling;
4999 }
5000 // if childNode is not null, it means the actual childNodes list is
5001 // longer than the virtual children list.
5002 if (!childrenMatch || childNode) {
5003 if (process.env.NODE_ENV !== 'production' &&
5004 typeof console !== 'undefined' &&
5005 !bailed) {
5006 bailed = true;
5007 console.warn('Parent: ', elm);
5008 console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
5009 }
5010 return false
5011 }
5012 }
5013 }
5014 if (isDef(data)) {
5015 for (var key in data) {
5016 if (!isRenderedModule(key)) {
5017 invokeCreateHooks(vnode, insertedVnodeQueue);
5018 break
5019 }
5020 }
5021 }
5022 } else if (elm.data !== vnode.text) {
5023 elm.data = vnode.text;
5024 }

Callers 1

createPatchFunctionFunction · 0.70

Calls 6

assertNodeMatchFunction · 0.70
isDefFunction · 0.70
iFunction · 0.70
initComponentFunction · 0.70
createChildrenFunction · 0.70
invokeCreateHooksFunction · 0.70

Tested by

no test coverage detected