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

Function hydrate

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

Source from the content-addressed store, hash-verified

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

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