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

Function hydrate

static/vuejs/vue.esm.js:4969–5028  ·  view source on GitHub ↗
(elm, vnode, insertedVnodeQueue)

Source from the content-addressed store, hash-verified

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

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