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

Function hydrate

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

Source from the content-addressed store, hash-verified

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

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