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

Function hydrate

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

Source from the content-addressed store, hash-verified

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

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