提交 b9379508 编写于 作者: Q qiang

chore: build

上级 13a6220c
...@@ -957,10 +957,10 @@ export default function vueFactory(exports) { ...@@ -957,10 +957,10 @@ export default function vueFactory(exports) {
if (type === "clear" if (type === "clear"
/* CLEAR */ /* CLEAR */
) { ) {
// collection being cleared // collection being cleared
// trigger all effects for target // trigger all effects for target
depsMap.forEach(add); depsMap.forEach(add);
} else if (key === 'length' && isArray(target)) { } else if (key === 'length' && isArray(target)) {
depsMap.forEach((dep, key) => { depsMap.forEach((dep, key) => {
if (key === 'length' || key >= newValue) { if (key === 'length' || key >= newValue) {
add(dep); add(dep);
...@@ -1088,12 +1088,12 @@ export default function vueFactory(exports) { ...@@ -1088,12 +1088,12 @@ export default function vueFactory(exports) {
if (key === "__v_isReactive" if (key === "__v_isReactive"
/* IS_REACTIVE */ /* IS_REACTIVE */
) { ) {
return !isReadonly; return !isReadonly;
} else if (key === "__v_isReadonly" } else if (key === "__v_isReadonly"
/* IS_READONLY */ /* IS_READONLY */
) { ) {
return isReadonly; return isReadonly;
} else if (key === "__v_raw" } else if (key === "__v_raw"
/* RAW */ /* RAW */
&& receiver === (isReadonly ? shallow ? shallowReadonlyMap : readonlyMap : shallow ? shallowReactiveMap : reactiveMap).get(target)) { && receiver === (isReadonly ? shallow ? shallowReadonlyMap : readonlyMap : shallow ? shallowReactiveMap : reactiveMap).get(target)) {
return target; return target;
...@@ -1587,16 +1587,16 @@ export default function vueFactory(exports) { ...@@ -1587,16 +1587,16 @@ export default function vueFactory(exports) {
if (key === "__v_isReactive" if (key === "__v_isReactive"
/* IS_REACTIVE */ /* IS_REACTIVE */
) { ) {
return !isReadonly; return !isReadonly;
} else if (key === "__v_isReadonly" } else if (key === "__v_isReadonly"
/* IS_READONLY */ /* IS_READONLY */
) { ) {
return isReadonly; return isReadonly;
} else if (key === "__v_raw" } else if (key === "__v_raw"
/* RAW */ /* RAW */
) { ) {
return target; return target;
} }
return Reflect.get(hasOwn(instrumentations, key) && key in target ? instrumentations : target, key, receiver); return Reflect.get(hasOwn(instrumentations, key) && key in target ? instrumentations : target, key, receiver);
}; };
...@@ -1733,8 +1733,8 @@ export default function vueFactory(exports) { ...@@ -1733,8 +1733,8 @@ export default function vueFactory(exports) {
if (targetType === 0 if (targetType === 0
/* INVALID */ /* INVALID */
) { ) {
return target; return target;
} }
var proxy = new Proxy(target, targetType === 2 var proxy = new Proxy(target, targetType === 2
/* COLLECTION */ /* COLLECTION */
...@@ -3033,12 +3033,12 @@ export default function vueFactory(exports) { ...@@ -3033,12 +3033,12 @@ export default function vueFactory(exports) {
if (vnode.shapeFlag & 4 if (vnode.shapeFlag & 4
/* STATEFUL_COMPONENT */ /* STATEFUL_COMPONENT */
) { ) {
// withProxy is a proxy with a different `has` trap only for // withProxy is a proxy with a different `has` trap only for
// runtime-compiled render functions using `with` block. // runtime-compiled render functions using `with` block.
var proxyToUse = withProxy || proxy; var proxyToUse = withProxy || proxy;
result = normalizeVNode(render.call(proxyToUse, proxyToUse, renderCache, props, setupState, data, ctx)); result = normalizeVNode(render.call(proxyToUse, proxyToUse, renderCache, props, setupState, data, ctx));
fallthroughAttrs = attrs; fallthroughAttrs = attrs;
} else { } else {
// functional // functional
var _render = Component; // in dev, mark attrs accessed if optional props (attrs === props) var _render = Component; // in dev, mark attrs accessed if optional props (attrs === props)
...@@ -3073,9 +3073,9 @@ export default function vueFactory(exports) { ...@@ -3073,9 +3073,9 @@ export default function vueFactory(exports) {
if (process.env.NODE_ENV !== 'production' && result.patchFlag > 0 && result.patchFlag & 2048 if (process.env.NODE_ENV !== 'production' && result.patchFlag > 0 && result.patchFlag & 2048
/* DEV_ROOT_FRAGMENT */ /* DEV_ROOT_FRAGMENT */
) { ) {
; ;
[root, setRoot] = getChildRoot(result); [root, setRoot] = getChildRoot(result);
} }
if (fallthroughAttrs && inheritAttrs !== false) { if (fallthroughAttrs && inheritAttrs !== false) {
var keys = Object.keys(fallthroughAttrs); var keys = Object.keys(fallthroughAttrs);
...@@ -3089,16 +3089,16 @@ export default function vueFactory(exports) { ...@@ -3089,16 +3089,16 @@ export default function vueFactory(exports) {
|| shapeFlag & 6 || shapeFlag & 6
/* COMPONENT */ /* COMPONENT */
) { ) {
if (propsOptions && keys.some(isModelListener)) { if (propsOptions && keys.some(isModelListener)) {
// If a v-model listener (onUpdate:xxx) has a corresponding declared // If a v-model listener (onUpdate:xxx) has a corresponding declared
// prop, it indicates this component expects to handle v-model and // prop, it indicates this component expects to handle v-model and
// it should not fallthrough. // it should not fallthrough.
// related: #1543, #1643, #1989 // related: #1543, #1643, #1989
fallthroughAttrs = filterModelListeners(fallthroughAttrs, propsOptions); fallthroughAttrs = filterModelListeners(fallthroughAttrs, propsOptions);
} }
root = cloneVNode(root, fallthroughAttrs); root = cloneVNode(root, fallthroughAttrs);
} else if (process.env.NODE_ENV !== 'production' && !accessedAttrs && root.type !== Comment$1) { } else if (process.env.NODE_ENV !== 'production' && !accessedAttrs && root.type !== Comment$1) {
var allAttrs = Object.keys(attrs); var allAttrs = Object.keys(attrs);
var eventAttrs = []; var eventAttrs = [];
var extraAttrs = []; var extraAttrs = [];
...@@ -3292,33 +3292,33 @@ export default function vueFactory(exports) { ...@@ -3292,33 +3292,33 @@ export default function vueFactory(exports) {
if (patchFlag & 1024 if (patchFlag & 1024
/* DYNAMIC_SLOTS */ /* DYNAMIC_SLOTS */
) { ) {
// slot content that references values that might have changed, // slot content that references values that might have changed,
// e.g. in a v-for // e.g. in a v-for
return true; return true;
} }
if (patchFlag & 16 if (patchFlag & 16
/* FULL_PROPS */ /* FULL_PROPS */
) { ) {
if (!prevProps) { if (!prevProps) {
return !!nextProps; return !!nextProps;
} // presence of this flag indicates props are always non-null } // presence of this flag indicates props are always non-null
return hasPropsChanged(prevProps, nextProps, emits); return hasPropsChanged(prevProps, nextProps, emits);
} else if (patchFlag & 8 } else if (patchFlag & 8
/* PROPS */ /* PROPS */
) { ) {
var dynamicProps = nextVNode.dynamicProps; var dynamicProps = nextVNode.dynamicProps;
for (var i = 0; i < dynamicProps.length; i++) { for (var i = 0; i < dynamicProps.length; i++) {
var key = dynamicProps[i]; var key = dynamicProps[i];
if (nextProps[key] !== prevProps[key] && !isEmitListener(emits, key)) { if (nextProps[key] !== prevProps[key] && !isEmitListener(emits, key)) {
return true; return true;
}
} }
} }
}
} else { } else {
// this path is only taken by manually written render functions // this path is only taken by manually written render functions
// so presence of any children leads to a forced update // so presence of any children leads to a forced update
...@@ -4552,9 +4552,9 @@ export default function vueFactory(exports) { ...@@ -4552,9 +4552,9 @@ export default function vueFactory(exports) {
} else if (vnode.shapeFlag & 128 } else if (vnode.shapeFlag & 128
/* SUSPENSE */ /* SUSPENSE */
) { ) {
vnode.ssContent.transition = hooks.clone(vnode.ssContent); vnode.ssContent.transition = hooks.clone(vnode.ssContent);
vnode.ssFallback.transition = hooks.clone(vnode.ssFallback); vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);
} else { } else {
vnode.transition = hooks; vnode.transition = hooks;
} }
} }
...@@ -4573,8 +4573,8 @@ export default function vueFactory(exports) { ...@@ -4573,8 +4573,8 @@ export default function vueFactory(exports) {
ret = ret.concat(getTransitionRawChildren(child.children, keepComment)); ret = ret.concat(getTransitionRawChildren(child.children, keepComment));
} // comment placeholders should be skipped, e.g. v-if } // comment placeholders should be skipped, e.g. v-if
else if (keepComment || child.type !== Comment$1) { else if (keepComment || child.type !== Comment$1) {
ret.push(child); ret.push(child);
} }
} // #1126 if a transition children list contains multiple sub fragments, these } // #1126 if a transition children list contains multiple sub fragments, these
// fragments will be merged into a flat children array. Since each v-for // fragments will be merged into a flat children array. Since each v-for
// fragment may contain different static bindings inside, we need to de-op // fragment may contain different static bindings inside, we need to de-op
...@@ -4992,8 +4992,8 @@ export default function vueFactory(exports) { ...@@ -4992,8 +4992,8 @@ export default function vueFactory(exports) {
if (rawVNode.shapeFlag & 128 if (rawVNode.shapeFlag & 128
/* SUSPENSE */ /* SUSPENSE */
) { ) {
rawVNode.ssContent = vnode; rawVNode.ssContent = vnode;
} }
} // #1513 it's possible for the returned vnode to be cloned due to attr } // #1513 it's possible for the returned vnode to be cloned due to attr
// fallthrough or scopeId, so the vnode here may not be the final vnode // fallthrough or scopeId, so the vnode here may not be the final vnode
// that is mounted. Instead of caching it directly, we store the pending // that is mounted. Instead of caching it directly, we store the pending
...@@ -5123,18 +5123,18 @@ export default function vueFactory(exports) { ...@@ -5123,18 +5123,18 @@ export default function vueFactory(exports) {
if (shapeFlag & 256 if (shapeFlag & 256
/* COMPONENT_SHOULD_KEEP_ALIVE */ /* COMPONENT_SHOULD_KEEP_ALIVE */
) { ) {
shapeFlag -= 256 shapeFlag -= 256
/* COMPONENT_SHOULD_KEEP_ALIVE */ /* COMPONENT_SHOULD_KEEP_ALIVE */
; ;
} }
if (shapeFlag & 512 if (shapeFlag & 512
/* COMPONENT_KEPT_ALIVE */ /* COMPONENT_KEPT_ALIVE */
) { ) {
shapeFlag -= 512 shapeFlag -= 512
/* COMPONENT_KEPT_ALIVE */ /* COMPONENT_KEPT_ALIVE */
; ;
} }
vnode.shapeFlag = shapeFlag; vnode.shapeFlag = shapeFlag;
} }
...@@ -5757,37 +5757,37 @@ export default function vueFactory(exports) { ...@@ -5757,37 +5757,37 @@ export default function vueFactory(exports) {
if (patchFlag & 8 if (patchFlag & 8
/* PROPS */ /* PROPS */
) { ) {
// Compiler-generated props & no keys change, just set the updated // Compiler-generated props & no keys change, just set the updated
// the props. // the props.
var propsToUpdate = instance.vnode.dynamicProps; var propsToUpdate = instance.vnode.dynamicProps;
for (var i = 0; i < propsToUpdate.length; i++) { for (var i = 0; i < propsToUpdate.length; i++) {
var key = propsToUpdate[i]; // PROPS flag guarantees rawProps to be non-null var key = propsToUpdate[i]; // PROPS flag guarantees rawProps to be non-null
var value = rawProps[key]; var value = rawProps[key];
if (options) { if (options) {
// attr / props separation was done on init and will be consistent // attr / props separation was done on init and will be consistent
// in this code path, so just check if attrs have it. // in this code path, so just check if attrs have it.
if (hasOwn(attrs, key)) { if (hasOwn(attrs, key)) {
if (value !== attrs[key]) {
attrs[key] = value;
hasAttrsChanged = true;
}
} else {
var camelizedKey = camelize(key);
props[camelizedKey] = resolvePropValue(options, rawCurrentProps, camelizedKey, value, instance, false
/* isAbsent */
);
}
} else {
if (value !== attrs[key]) { if (value !== attrs[key]) {
attrs[key] = value; attrs[key] = value;
hasAttrsChanged = true; hasAttrsChanged = true;
} }
} else {
var camelizedKey = camelize(key);
props[camelizedKey] = resolvePropValue(options, rawCurrentProps, camelizedKey, value, instance, false
/* isAbsent */
);
}
} else {
if (value !== attrs[key]) {
attrs[key] = value;
hasAttrsChanged = true;
} }
} }
} }
}
} else { } else {
// full props update. // full props update.
if (setFullProps(instance, rawProps, props, attrs)) { if (setFullProps(instance, rawProps, props, attrs)) {
...@@ -5799,9 +5799,13 @@ export default function vueFactory(exports) { ...@@ -5799,9 +5799,13 @@ export default function vueFactory(exports) {
var kebabKey; var kebabKey;
for (var _key6 in rawCurrentProps) { for (var _key6 in rawCurrentProps) {
if (!rawProps || !hasOwn(rawProps, _key6) && ((kebabKey = hyphenate(_key6)) === _key6 || !hasOwn(rawProps, kebabKey))) { if (!rawProps || // for camelCase
!hasOwn(rawProps, _key6) && ( // it's possible the original props was passed in as kebab-case
// and converted to camelCase (#955)
(kebabKey = hyphenate(_key6)) === _key6 || !hasOwn(rawProps, kebabKey))) {
if (options) { if (options) {
if (rawPrevProps && (rawPrevProps[_key6] !== undefined || // for kebab-case if (rawPrevProps && ( // for camelCase
rawPrevProps[_key6] !== undefined || // for kebab-case
rawPrevProps[kebabKey] !== undefined)) { rawPrevProps[kebabKey] !== undefined)) {
props[_key6] = resolvePropValue(options, rawCurrentProps, _key6, undefined, instance, true props[_key6] = resolvePropValue(options, rawCurrentProps, _key6, undefined, instance, true
/* isAbsent */ /* isAbsent */
...@@ -6246,18 +6250,18 @@ export default function vueFactory(exports) { ...@@ -6246,18 +6250,18 @@ export default function vueFactory(exports) {
if (instance.vnode.shapeFlag & 32 if (instance.vnode.shapeFlag & 32
/* SLOTS_CHILDREN */ /* SLOTS_CHILDREN */
) { ) {
var type = children._; var type = children._;
if (type) { if (type) {
// users can get the shallow readonly version of the slots object through `this.$slots`, // users can get the shallow readonly version of the slots object through `this.$slots`,
// we should avoid the proxy object polluting the slots of the internal instance // we should avoid the proxy object polluting the slots of the internal instance
instance.slots = toRaw(children); // make compiler marker non-enumerable instance.slots = toRaw(children); // make compiler marker non-enumerable
def(children, '_', type); def(children, '_', type);
} else {
normalizeObjectSlots(children, instance.slots = {});
}
} else { } else {
normalizeObjectSlots(children, instance.slots = {});
}
} else {
instance.slots = {}; instance.slots = {};
if (children) { if (children) {
...@@ -6279,41 +6283,41 @@ export default function vueFactory(exports) { ...@@ -6279,41 +6283,41 @@ export default function vueFactory(exports) {
if (vnode.shapeFlag & 32 if (vnode.shapeFlag & 32
/* SLOTS_CHILDREN */ /* SLOTS_CHILDREN */
) { ) {
var type = children._; var type = children._;
if (type) { if (type) {
// compiled slots. // compiled slots.
if (process.env.NODE_ENV !== 'production' && isHmrUpdating) { if (process.env.NODE_ENV !== 'production' && isHmrUpdating) {
// Parent was HMR updated so slot content may have changed. // Parent was HMR updated so slot content may have changed.
// force update slots and mark instance for hmr as well // force update slots and mark instance for hmr as well
extend(slots, children); extend(slots, children);
} else if (optimized && type === 1 } else if (optimized && type === 1
/* STABLE */
) {
// compiled AND stable.
// no need to update, and skip stale slots removal.
needDeletionCheck = false;
} else {
// compiled but dynamic (v-if/v-for on slots) - update slots, but skip
// normalization.
extend(slots, children); // #2893
// when rendering the optimized slots by manually written render function,
// we need to delete the `slots._` flag if necessary to make subsequent updates reliable,
// i.e. let the `renderSlot` create the bailed Fragment
if (!optimized && type === 1
/* STABLE */ /* STABLE */
) { ) {
delete slots._; // compiled AND stable.
// no need to update, and skip stale slots removal.
needDeletionCheck = false;
} else {
// compiled but dynamic (v-if/v-for on slots) - update slots, but skip
// normalization.
extend(slots, children); // #2893
// when rendering the optimized slots by manually written render function,
// we need to delete the `slots._` flag if necessary to make subsequent updates reliable,
// i.e. let the `renderSlot` create the bailed Fragment
if (!optimized && type === 1
/* STABLE */
) {
delete slots._;
}
} }
} else {
needDeletionCheck = !children.$stable;
normalizeObjectSlots(children, slots);
} }
} else {
needDeletionCheck = !children.$stable;
normalizeObjectSlots(children, slots);
}
deletionComparisonTarget = children; deletionComparisonTarget = children;
} else if (children) { } else if (children) {
// non slot object children (direct value) passed to a component // non slot object children (direct value) passed to a component
normalizeVNodeSlots(instance, children); normalizeVNodeSlots(instance, children);
deletionComparisonTarget = { deletionComparisonTarget = {
...@@ -6658,8 +6662,8 @@ export default function vueFactory(exports) { ...@@ -6658,8 +6662,8 @@ export default function vueFactory(exports) {
if (domType !== 3 if (domType !== 3
/* TEXT */ /* TEXT */
) { ) {
nextNode = onMismatch(); nextNode = onMismatch();
} else { } else {
if (node.data !== vnode.children) { if (node.data !== vnode.children) {
hasMismatch = true; hasMismatch = true;
process.env.NODE_ENV !== 'production' && warn("Hydration text mismatch:" + "\n- Client: ".concat(JSON.stringify(node.data)) + "\n- Server: ".concat(JSON.stringify(vnode.children))); process.env.NODE_ENV !== 'production' && warn("Hydration text mismatch:" + "\n- Client: ".concat(JSON.stringify(node.data)) + "\n- Server: ".concat(JSON.stringify(vnode.children)));
...@@ -6686,8 +6690,8 @@ export default function vueFactory(exports) { ...@@ -6686,8 +6690,8 @@ export default function vueFactory(exports) {
if (domType !== 1 if (domType !== 1
/* ELEMENT */ /* ELEMENT */
) { ) {
nextNode = onMismatch(); nextNode = onMismatch();
} else { } else {
// determine anchor, adopt content // determine anchor, adopt content
nextNode = node; // if the static vnode has its content stripped during build, nextNode = node; // if the static vnode has its content stripped during build,
// adopt it from the server-rendered HTML. // adopt it from the server-rendered HTML.
...@@ -6722,58 +6726,58 @@ export default function vueFactory(exports) { ...@@ -6722,58 +6726,58 @@ export default function vueFactory(exports) {
if (shapeFlag & 1 if (shapeFlag & 1
/* ELEMENT */ /* ELEMENT */
) { ) {
if (domType !== 1 if (domType !== 1
/* ELEMENT */ /* ELEMENT */
|| vnode.type.toLowerCase() !== node.tagName.toLowerCase()) { || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) {
nextNode = onMismatch(); nextNode = onMismatch();
} else {
nextNode = hydrateElement(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
}
} else if (shapeFlag & 6
/* COMPONENT */
) {
// when setting up the render effect, if the initial vnode already
// has .el set, the component will perform hydration instead of mount
// on its sub-tree.
vnode.slotScopeIds = slotScopeIds;
var container = parentNode(node);
mountComponent(vnode, container, null, parentComponent, parentSuspense, isSVGContainer(container), optimized); // component may be async, so in the case of fragments we cannot rely
// on component's rendered output to determine the end of the fragment
// instead, we do a lookahead to find the end anchor node.
nextNode = isFragmentStart ? locateClosingAsyncAnchor(node) : nextSibling(node); // #3787
// if component is async, it may get moved / unmounted before its
// inner component is loaded, so we need to give it a placeholder
// vnode that matches its adopted DOM.
if (isAsyncWrapper(vnode)) {
var subTree;
if (isFragmentStart) {
subTree = createVNode(Fragment);
subTree.anchor = nextNode ? nextNode.previousSibling : container.lastChild;
} else { } else {
subTree = node.nodeType === 3 ? createTextVNode('') : createVNode('div'); nextNode = hydrateElement(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
} }
} else if (shapeFlag & 6
/* COMPONENT */
) {
// when setting up the render effect, if the initial vnode already
// has .el set, the component will perform hydration instead of mount
// on its sub-tree.
vnode.slotScopeIds = slotScopeIds;
var container = parentNode(node);
mountComponent(vnode, container, null, parentComponent, parentSuspense, isSVGContainer(container), optimized); // component may be async, so in the case of fragments we cannot rely
// on component's rendered output to determine the end of the fragment
// instead, we do a lookahead to find the end anchor node.
nextNode = isFragmentStart ? locateClosingAsyncAnchor(node) : nextSibling(node); // #3787
// if component is async, it may get moved / unmounted before its
// inner component is loaded, so we need to give it a placeholder
// vnode that matches its adopted DOM.
if (isAsyncWrapper(vnode)) {
var subTree;
if (isFragmentStart) {
subTree = createVNode(Fragment);
subTree.anchor = nextNode ? nextNode.previousSibling : container.lastChild;
} else {
subTree = node.nodeType === 3 ? createTextVNode('') : createVNode('div');
}
subTree.el = node; subTree.el = node;
vnode.component.subTree = subTree; vnode.component.subTree = subTree;
} }
} else if (shapeFlag & 64 } else if (shapeFlag & 64
/* TELEPORT */ /* TELEPORT */
) { ) {
if (domType !== 8 if (domType !== 8
/* COMMENT */ /* COMMENT */
) { ) {
nextNode = onMismatch(); nextNode = onMismatch();
} else { } else {
nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, rendererInternals, hydrateChildren); nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, rendererInternals, hydrateChildren);
} }
} else if (shapeFlag & 128 } else if (shapeFlag & 128
/* SUSPENSE */ /* SUSPENSE */
) { ) {
nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, isSVGContainer(parentNode(node)), slotScopeIds, optimized, rendererInternals, hydrateNode); nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, isSVGContainer(parentNode(node)), slotScopeIds, optimized, rendererInternals, hydrateNode);
} else if (process.env.NODE_ENV !== 'production') { } else if (process.env.NODE_ENV !== 'production') {
warn('Invalid HostVNode type:', type, "(".concat(typeof type, ")")); warn('Invalid HostVNode type:', type, "(".concat(typeof type, ")"));
} }
...@@ -6802,78 +6806,78 @@ export default function vueFactory(exports) { ...@@ -6802,78 +6806,78 @@ export default function vueFactory(exports) {
if (forcePatchValue || patchFlag !== -1 if (forcePatchValue || patchFlag !== -1
/* HOISTED */ /* HOISTED */
) { ) {
if (dirs) { if (dirs) {
invokeDirectiveHook(vnode, null, parentComponent, 'created'); invokeDirectiveHook(vnode, null, parentComponent, 'created');
} // props } // props
if (props) { if (props) {
if (forcePatchValue || !optimized || patchFlag & 16 if (forcePatchValue || !optimized || patchFlag & 16
/* FULL_PROPS */ /* FULL_PROPS */
|| patchFlag & 32 || patchFlag & 32
/* HYDRATE_EVENTS */ /* HYDRATE_EVENTS */
) { ) {
for (var key in props) { for (var key in props) {
if (forcePatchValue && key.endsWith('value') || isOn(key) && !isReservedProp(key)) { if (forcePatchValue && key.endsWith('value') || isOn(key) && !isReservedProp(key)) {
patchProp(el, key, null, props[key]); patchProp(el, key, null, props[key]);
}
} }
} else if (props.onClick) {
// Fast path for click listeners (which is most often) to avoid
// iterating through props.
patchProp(el, 'onClick', null, props.onClick);
} }
} else if (props.onClick) { } // vnode / directive hooks
// Fast path for click listeners (which is most often) to avoid
// iterating through props.
patchProp(el, 'onClick', null, props.onClick);
}
} // vnode / directive hooks
var vnodeHooks; var vnodeHooks;
if (vnodeHooks = props && props.onVnodeBeforeMount) { if (vnodeHooks = props && props.onVnodeBeforeMount) {
invokeVNodeHook(vnodeHooks, parentComponent, vnode); invokeVNodeHook(vnodeHooks, parentComponent, vnode);
} }
if (dirs) { if (dirs) {
invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount'); invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount');
} }
if ((vnodeHooks = props && props.onVnodeMounted) || dirs) { if ((vnodeHooks = props && props.onVnodeMounted) || dirs) {
queueEffectWithSuspense(() => { queueEffectWithSuspense(() => {
vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode); vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
dirs && invokeDirectiveHook(vnode, null, parentComponent, 'mounted'); dirs && invokeDirectiveHook(vnode, null, parentComponent, 'mounted');
}, parentSuspense); }, parentSuspense);
} // children } // children
if (shapeFlag & 16 if (shapeFlag & 16
/* ARRAY_CHILDREN */ /* ARRAY_CHILDREN */
&& // skip if element has innerHTML / textContent && // skip if element has innerHTML / textContent
!(props && (props.innerHTML || props.textContent))) { !(props && (props.innerHTML || props.textContent))) {
var next = hydrateChildren(el.firstChild, vnode, el, parentComponent, parentSuspense, slotScopeIds, optimized); var next = hydrateChildren(el.firstChild, vnode, el, parentComponent, parentSuspense, slotScopeIds, optimized);
var _hasWarned = false; var _hasWarned = false;
while (next) { while (next) {
hasMismatch = true; hasMismatch = true;
if (process.env.NODE_ENV !== 'production' && !_hasWarned) { if (process.env.NODE_ENV !== 'production' && !_hasWarned) {
warn("Hydration children mismatch in <".concat(vnode.type, ">: ") + "server rendered element contains more child nodes than client vdom."); warn("Hydration children mismatch in <".concat(vnode.type, ">: ") + "server rendered element contains more child nodes than client vdom.");
_hasWarned = true; _hasWarned = true;
} // The SSRed DOM contains more nodes than it should. Remove them. } // The SSRed DOM contains more nodes than it should. Remove them.
var cur = next; var cur = next;
next = next.nextSibling; next = next.nextSibling;
remove(cur); remove(cur);
} }
} else if (shapeFlag & 8 } else if (shapeFlag & 8
/* TEXT_CHILDREN */ /* TEXT_CHILDREN */
) { ) {
if (el.textContent !== vnode.children) { if (el.textContent !== vnode.children) {
hasMismatch = true; hasMismatch = true;
process.env.NODE_ENV !== 'production' && warn("Hydration text content mismatch in <".concat(vnode.type, ">:\n") + "- Client: ".concat(el.textContent, "\n") + "- Server: ".concat(vnode.children)); process.env.NODE_ENV !== 'production' && warn("Hydration text content mismatch in <".concat(vnode.type, ">:\n") + "- Client: ".concat(el.textContent, "\n") + "- Server: ".concat(vnode.children));
el.textContent = vnode.children; el.textContent = vnode.children;
} }
}
} }
}
return el.nextSibling; return el.nextSibling;
}; };
...@@ -7217,9 +7221,9 @@ export default function vueFactory(exports) { ...@@ -7217,9 +7221,9 @@ export default function vueFactory(exports) {
if (n2.patchFlag === -2 if (n2.patchFlag === -2
/* BAIL */ /* BAIL */
) { ) {
optimized = false; optimized = false;
n2.dynamicChildren = null; n2.dynamicChildren = null;
} }
var { var {
type, type,
...@@ -7253,20 +7257,20 @@ export default function vueFactory(exports) { ...@@ -7253,20 +7257,20 @@ export default function vueFactory(exports) {
if (shapeFlag & 1 if (shapeFlag & 1
/* ELEMENT */ /* ELEMENT */
) { ) {
processElement(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); processElement(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
} else if (shapeFlag & 6 } else if (shapeFlag & 6
/* COMPONENT */ /* COMPONENT */
) { ) {
processComponent(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); processComponent(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
} else if (shapeFlag & 64 } else if (shapeFlag & 64
/* TELEPORT */ /* TELEPORT */
) { ) {
type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals); type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals);
} else if (shapeFlag & 128 } else if (shapeFlag & 128
/* SUSPENSE */ /* SUSPENSE */
) { ) {
type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals); type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals);
} else if (process.env.NODE_ENV !== 'production') { } else if (process.env.NODE_ENV !== 'production') {
warn('Invalid VNode type:', type, "(".concat(typeof type, ")")); warn('Invalid VNode type:', type, "(".concat(typeof type, ")"));
} }
...@@ -7389,12 +7393,12 @@ export default function vueFactory(exports) { ...@@ -7389,12 +7393,12 @@ export default function vueFactory(exports) {
if (!(process.env.NODE_ENV !== 'production') && vnode.el && hostCloneNode !== undefined && patchFlag === -1 if (!(process.env.NODE_ENV !== 'production') && vnode.el && hostCloneNode !== undefined && patchFlag === -1
/* HOISTED */ /* HOISTED */
) { ) {
// If a vnode has non-null el, it means it's being reused. // If a vnode has non-null el, it means it's being reused.
// Only static vnodes can be reused, so its mounted DOM nodes should be // Only static vnodes can be reused, so its mounted DOM nodes should be
// exactly the same, and we can simply do a clone here. // exactly the same, and we can simply do a clone here.
// only do this in production since cloned trees cannot be HMR updated. // only do this in production since cloned trees cannot be HMR updated.
el = vnode.el = hostCloneNode(vnode.el); el = vnode.el = hostCloneNode(vnode.el);
} else { } else {
el = vnode.el = hostCreateElement( // fixed by xxxxxx el = vnode.el = hostCreateElement( // fixed by xxxxxx
vnode.type, container); // mount children first, since some props may rely on child content vnode.type, container); // mount children first, since some props may rely on child content
// being already rendered, e.g. `<select value>` // being already rendered, e.g. `<select value>`
...@@ -7402,12 +7406,12 @@ export default function vueFactory(exports) { ...@@ -7402,12 +7406,12 @@ export default function vueFactory(exports) {
if (shapeFlag & 8 if (shapeFlag & 8
/* TEXT_CHILDREN */ /* TEXT_CHILDREN */
) { ) {
hostSetElementText(el, vnode.children); hostSetElementText(el, vnode.children);
} else if (shapeFlag & 16 } else if (shapeFlag & 16
/* ARRAY_CHILDREN */ /* ARRAY_CHILDREN */
) { ) {
mountChildren(vnode.children, el, null, parentComponent, parentSuspense, isSVG && type !== 'foreignObject', slotScopeIds, optimized || !!vnode.dynamicChildren); mountChildren(vnode.children, el, null, parentComponent, parentSuspense, isSVG && type !== 'foreignObject', slotScopeIds, optimized || !!vnode.dynamicChildren);
} }
if (dirs) { if (dirs) {
invokeDirectiveHook(vnode, null, parentComponent, 'created'); invokeDirectiveHook(vnode, null, parentComponent, 'created');
...@@ -7481,8 +7485,8 @@ export default function vueFactory(exports) { ...@@ -7481,8 +7485,8 @@ export default function vueFactory(exports) {
if (process.env.NODE_ENV !== 'production' && subTree.patchFlag > 0 && subTree.patchFlag & 2048 if (process.env.NODE_ENV !== 'production' && subTree.patchFlag > 0 && subTree.patchFlag & 2048
/* DEV_ROOT_FRAGMENT */ /* DEV_ROOT_FRAGMENT */
) { ) {
subTree = filterSingleRoot(subTree.children) || subTree; subTree = filterSingleRoot(subTree.children) || subTree;
} }
if (vnode === subTree) { if (vnode === subTree) {
var parentVNode = parentComponent.vnode; var parentVNode = parentComponent.vnode;
...@@ -7537,26 +7541,26 @@ export default function vueFactory(exports) { ...@@ -7537,26 +7541,26 @@ export default function vueFactory(exports) {
if (patchFlag & 16 if (patchFlag & 16
/* FULL_PROPS */ /* FULL_PROPS */
) { ) {
// element props contain dynamic keys, full diff needed // element props contain dynamic keys, full diff needed
patchProps(el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG); patchProps(el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG);
} else { } else {
// class // class
// this flag is matched when the element has dynamic class bindings. // this flag is matched when the element has dynamic class bindings.
if (patchFlag & 2 if (patchFlag & 2
/* CLASS */ /* CLASS */
) { ) {
if (oldProps.class !== newProps.class) { if (oldProps.class !== newProps.class) {
hostPatchProp(el, 'class', null, newProps.class, isSVG); hostPatchProp(el, 'class', null, newProps.class, isSVG);
} }
} // style } // style
// this flag is matched when the element has dynamic style bindings // this flag is matched when the element has dynamic style bindings
if (patchFlag & 4 if (patchFlag & 4
/* STYLE */ /* STYLE */
) { ) {
hostPatchProp(el, 'style', oldProps.style, newProps.style, isSVG); hostPatchProp(el, 'style', oldProps.style, newProps.style, isSVG);
} // props } // props
// This flag is matched when the element has dynamic prop/attr bindings // This flag is matched when the element has dynamic prop/attr bindings
// other than class and style. The keys of dynamic prop/attrs are saved for // other than class and style. The keys of dynamic prop/attrs are saved for
// faster iteration. // faster iteration.
...@@ -7567,19 +7571,19 @@ export default function vueFactory(exports) { ...@@ -7567,19 +7571,19 @@ export default function vueFactory(exports) {
if (patchFlag & 8 if (patchFlag & 8
/* PROPS */ /* PROPS */
) { ) {
// if the flag is present then dynamicProps must be non-null // if the flag is present then dynamicProps must be non-null
var propsToUpdate = n2.dynamicProps; var propsToUpdate = n2.dynamicProps;
for (var i = 0; i < propsToUpdate.length; i++) { for (var i = 0; i < propsToUpdate.length; i++) {
var key = propsToUpdate[i]; var key = propsToUpdate[i];
var prev = oldProps[key]; var prev = oldProps[key];
var next = newProps[key]; var next = newProps[key];
if (next !== prev || hostForcePatchProp && hostForcePatchProp(el, key)) { if (next !== prev || hostForcePatchProp && hostForcePatchProp(el, key)) {
hostPatchProp(el, key, prev, next, isSVG, n1.children, parentComponent, parentSuspense, unmountChildren); hostPatchProp(el, key, prev, next, isSVG, n1.children, parentComponent, parentSuspense, unmountChildren);
}
} }
} }
}
} // text } // text
// This flag is matched when the element has only dynamic text children. // This flag is matched when the element has only dynamic text children.
...@@ -7587,10 +7591,10 @@ export default function vueFactory(exports) { ...@@ -7587,10 +7591,10 @@ export default function vueFactory(exports) {
if (patchFlag & 1 if (patchFlag & 1
/* TEXT */ /* TEXT */
) { ) {
if (n1.children !== n2.children) { if (n1.children !== n2.children) {
hostSetElementText(el, n2.children); hostSetElementText(el, n2.children);
}
} }
}
} else if (!optimized && dynamicChildren == null) { } else if (!optimized && dynamicChildren == null) {
// unoptimized, full diff // unoptimized, full diff
patchProps(el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG); patchProps(el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG);
...@@ -7625,7 +7629,9 @@ export default function vueFactory(exports) { ...@@ -7625,7 +7629,9 @@ export default function vueFactory(exports) {
var container = // oldVNode may be an errored async setup() component inside Suspense var container = // oldVNode may be an errored async setup() component inside Suspense
// which will not have a mounted element // which will not have a mounted element
oldVNode.el && (oldVNode.type === Fragment || // - In the case of different nodes, there is going to be a replacement oldVNode.el && ( // - In the case of a Fragment, we need to provide the actual parent
// of the Fragment itself so it can move its children.
oldVNode.type === Fragment || // - In the case of different nodes, there is going to be a replacement
// which also requires the correct parent container // which also requires the correct parent container
!isSameVNodeType(oldVNode, newVNode) || // - In the case of a component, it could contain anything. !isSameVNodeType(oldVNode, newVNode) || // - In the case of a component, it could contain anything.
oldVNode.shapeFlag & 6 oldVNode.shapeFlag & 6
...@@ -7734,8 +7740,8 @@ export default function vueFactory(exports) { ...@@ -7734,8 +7740,8 @@ export default function vueFactory(exports) {
if (n2.shapeFlag & 512 if (n2.shapeFlag & 512
/* COMPONENT_KEPT_ALIVE */ /* COMPONENT_KEPT_ALIVE */
) { ) {
parentComponent.ctx.activate(n2, container, anchor, isSVG, optimized); parentComponent.ctx.activate(n2, container, anchor, isSVG, optimized);
} else { } else {
mountComponent(n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized); mountComponent(n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized);
} }
} else { } else {
...@@ -7927,8 +7933,8 @@ export default function vueFactory(exports) { ...@@ -7927,8 +7933,8 @@ export default function vueFactory(exports) {
if (initialVNode.shapeFlag & 256 if (initialVNode.shapeFlag & 256
/* COMPONENT_SHOULD_KEEP_ALIVE */ /* COMPONENT_SHOULD_KEEP_ALIVE */
) { ) {
instance.a && queuePostRenderEffect(instance.a, parentSuspense); instance.a && queuePostRenderEffect(instance.a, parentSuspense);
} }
instance.isMounted = true; instance.isMounted = true;
...@@ -8062,62 +8068,62 @@ export default function vueFactory(exports) { ...@@ -8062,62 +8068,62 @@ export default function vueFactory(exports) {
if (patchFlag & 128 if (patchFlag & 128
/* KEYED_FRAGMENT */ /* KEYED_FRAGMENT */
) { ) {
// this could be either fully-keyed or mixed (some keyed some not) // this could be either fully-keyed or mixed (some keyed some not)
// presence of patchFlag means children are guaranteed to be arrays // presence of patchFlag means children are guaranteed to be arrays
patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
return; return;
} else if (patchFlag & 256 } else if (patchFlag & 256
/* UNKEYED_FRAGMENT */ /* UNKEYED_FRAGMENT */
) { ) {
// unkeyed // unkeyed
patchUnkeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); patchUnkeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
return; return;
} }
} // children has 3 possibilities: text, array or no children. } // children has 3 possibilities: text, array or no children.
if (shapeFlag & 8 if (shapeFlag & 8
/* TEXT_CHILDREN */ /* TEXT_CHILDREN */
) { ) {
// text children fast path // text children fast path
if (prevShapeFlag & 16 if (prevShapeFlag & 16
/* ARRAY_CHILDREN */ /* ARRAY_CHILDREN */
) { ) {
unmountChildren(c1, parentComponent, parentSuspense); unmountChildren(c1, parentComponent, parentSuspense);
} }
if (c2 !== c1) { if (c2 !== c1) {
hostSetElementText(container, c2); hostSetElementText(container, c2);
} }
} else { } else {
if (prevShapeFlag & 16 if (prevShapeFlag & 16
/* ARRAY_CHILDREN */ /* ARRAY_CHILDREN */
) { ) {
// prev children was array // prev children was array
if (shapeFlag & 16 if (shapeFlag & 16
/* ARRAY_CHILDREN */ /* ARRAY_CHILDREN */
) { ) {
// two arrays, cannot assume anything, do full diff // two arrays, cannot assume anything, do full diff
patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
} else {
// no new children, just unmount old
unmountChildren(c1, parentComponent, parentSuspense, true);
}
} else { } else {
// no new children, just unmount old
unmountChildren(c1, parentComponent, parentSuspense, true);
}
} else {
// prev children was text OR null // prev children was text OR null
// new children is array OR null // new children is array OR null
if (prevShapeFlag & 8 if (prevShapeFlag & 8
/* TEXT_CHILDREN */ /* TEXT_CHILDREN */
) { ) {
hostSetElementText(container, ''); hostSetElementText(container, '');
} // mount new if array } // mount new if array
if (shapeFlag & 16 if (shapeFlag & 16
/* ARRAY_CHILDREN */ /* ARRAY_CHILDREN */
) { ) {
mountChildren(c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); mountChildren(c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
} }
} }
} }
}; };
...@@ -8211,120 +8217,120 @@ export default function vueFactory(exports) { ...@@ -8211,120 +8217,120 @@ export default function vueFactory(exports) {
// (b c) // (b c)
// i = 0, e1 = 0, e2 = -1 // i = 0, e1 = 0, e2 = -1
else if (i > e2) { else if (i > e2) {
while (i <= e1) { while (i <= e1) {
unmount(c1[i], parentComponent, parentSuspense, true); unmount(c1[i], parentComponent, parentSuspense, true);
i++; i++;
}
} // 5. unknown sequence
// [i ... e1 + 1]: a b [c d e] f g
// [i ... e2 + 1]: a b [e d c h] f g
// i = 2, e1 = 4, e2 = 5
else {
var s1 = i; // prev starting index
var s2 = i; // next starting index
// 5.1 build key:index map for newChildren
var keyToNewIndexMap = new Map();
for (i = s2; i <= e2; i++) {
var nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
if (nextChild.key != null) {
if (process.env.NODE_ENV !== 'production' && keyToNewIndexMap.has(nextChild.key)) {
warn("Duplicate keys found during update:", JSON.stringify(nextChild.key), "Make sure keys are unique.");
}
keyToNewIndexMap.set(nextChild.key, i);
} }
} // 5.2 loop through old children left to be patched and try to patch } // 5. unknown sequence
// matching nodes & remove nodes that are no longer present // [i ... e1 + 1]: a b [c d e] f g
// [i ... e2 + 1]: a b [e d c h] f g
// i = 2, e1 = 4, e2 = 5
else {
var s1 = i; // prev starting index
var j; var s2 = i; // next starting index
var patched = 0; // 5.1 build key:index map for newChildren
var toBePatched = e2 - s2 + 1;
var moved = false; // used to track whether any node has moved
var maxNewIndexSoFar = 0; // works as Map<newIndex, oldIndex> var keyToNewIndexMap = new Map();
// Note that oldIndex is offset by +1
// and oldIndex = 0 is a special value indicating the new node has
// no corresponding old node.
// used for determining longest stable subsequence
var newIndexToOldIndexMap = new Array(toBePatched); for (i = s2; i <= e2; i++) {
var nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
for (i = 0; i < toBePatched; i++) { if (nextChild.key != null) {
newIndexToOldIndexMap[i] = 0; if (process.env.NODE_ENV !== 'production' && keyToNewIndexMap.has(nextChild.key)) {
} warn("Duplicate keys found during update:", JSON.stringify(nextChild.key), "Make sure keys are unique.");
}
for (i = s1; i <= e1; i++) { keyToNewIndexMap.set(nextChild.key, i);
var prevChild = c1[i]; }
} // 5.2 loop through old children left to be patched and try to patch
// matching nodes & remove nodes that are no longer present
if (patched >= toBePatched) {
// all new children have been patched so this can only be a removal
unmount(prevChild, parentComponent, parentSuspense, true);
continue;
}
var newIndex = void 0; var j;
var patched = 0;
var toBePatched = e2 - s2 + 1;
var moved = false; // used to track whether any node has moved
if (prevChild.key != null) { var maxNewIndexSoFar = 0; // works as Map<newIndex, oldIndex>
newIndex = keyToNewIndexMap.get(prevChild.key); // Note that oldIndex is offset by +1
} else { // and oldIndex = 0 is a special value indicating the new node has
// key-less node, try to locate a key-less node of the same type // no corresponding old node.
for (j = s2; j <= e2; j++) { // used for determining longest stable subsequence
if (newIndexToOldIndexMap[j - s2] === 0 && isSameVNodeType(prevChild, c2[j])) {
newIndex = j;
break;
}
}
}
if (newIndex === undefined) { var newIndexToOldIndexMap = new Array(toBePatched);
unmount(prevChild, parentComponent, parentSuspense, true);
} else {
newIndexToOldIndexMap[newIndex - s2] = i + 1;
if (newIndex >= maxNewIndexSoFar) { for (i = 0; i < toBePatched; i++) {
maxNewIndexSoFar = newIndex; newIndexToOldIndexMap[i] = 0;
} else {
moved = true;
} }
patch(prevChild, c2[newIndex], container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); for (i = s1; i <= e1; i++) {
patched++; var prevChild = c1[i];
}
} // 5.3 move and mount
// generate longest stable subsequence only when nodes have moved
if (patched >= toBePatched) {
// all new children have been patched so this can only be a removal
unmount(prevChild, parentComponent, parentSuspense, true);
continue;
}
var increasingNewIndexSequence = moved ? getSequence(newIndexToOldIndexMap) : EMPTY_ARR; var newIndex = void 0;
j = increasingNewIndexSequence.length - 1; // looping backwards so that we can use last patched node as anchor
for (i = toBePatched - 1; i >= 0; i--) { if (prevChild.key != null) {
var nextIndex = s2 + i; newIndex = keyToNewIndexMap.get(prevChild.key);
var _nextChild = c2[nextIndex]; } else {
// key-less node, try to locate a key-less node of the same type
for (j = s2; j <= e2; j++) {
if (newIndexToOldIndexMap[j - s2] === 0 && isSameVNodeType(prevChild, c2[j])) {
newIndex = j;
break;
}
}
}
var _anchor2 = nextIndex + 1 < l2 ? c2[nextIndex + 1].el : parentAnchor; if (newIndex === undefined) {
unmount(prevChild, parentComponent, parentSuspense, true);
} else {
newIndexToOldIndexMap[newIndex - s2] = i + 1;
if (newIndexToOldIndexMap[i] === 0) { if (newIndex >= maxNewIndexSoFar) {
// mount new maxNewIndexSoFar = newIndex;
patch(null, _nextChild, container, _anchor2, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); } else {
} else if (moved) { moved = true;
// move if: }
// There is no stable subsequence (e.g. a reverse)
// OR current node is not among the stable sequence patch(prevChild, c2[newIndex], container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
if (j < 0 || i !== increasingNewIndexSequence[j]) { patched++;
move(_nextChild, container, _anchor2, 2 }
/* REORDER */ } // 5.3 move and mount
); // generate longest stable subsequence only when nodes have moved
} else {
j--;
var increasingNewIndexSequence = moved ? getSequence(newIndexToOldIndexMap) : EMPTY_ARR;
j = increasingNewIndexSequence.length - 1; // looping backwards so that we can use last patched node as anchor
for (i = toBePatched - 1; i >= 0; i--) {
var nextIndex = s2 + i;
var _nextChild = c2[nextIndex];
var _anchor2 = nextIndex + 1 < l2 ? c2[nextIndex + 1].el : parentAnchor;
if (newIndexToOldIndexMap[i] === 0) {
// mount new
patch(null, _nextChild, container, _anchor2, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
} else if (moved) {
// move if:
// There is no stable subsequence (e.g. a reverse)
// OR current node is not among the stable sequence
if (j < 0 || i !== increasingNewIndexSequence[j]) {
move(_nextChild, container, _anchor2, 2
/* REORDER */
);
} else {
j--;
}
}
} }
} }
}
}
}; };
var move = (vnode, container, anchor, moveType, parentSuspense = null) => { var move = (vnode, container, anchor, moveType, parentSuspense = null) => {
...@@ -8339,23 +8345,23 @@ export default function vueFactory(exports) { ...@@ -8339,23 +8345,23 @@ export default function vueFactory(exports) {
if (shapeFlag & 6 if (shapeFlag & 6
/* COMPONENT */ /* COMPONENT */
) { ) {
move(vnode.component.subTree, container, anchor, moveType); move(vnode.component.subTree, container, anchor, moveType);
return; return;
} }
if (shapeFlag & 128 if (shapeFlag & 128
/* SUSPENSE */ /* SUSPENSE */
) { ) {
vnode.suspense.move(container, anchor, moveType); vnode.suspense.move(container, anchor, moveType);
return; return;
} }
if (shapeFlag & 64 if (shapeFlag & 64
/* TELEPORT */ /* TELEPORT */
) { ) {
type.move(vnode, container, anchor, internals); type.move(vnode, container, anchor, internals);
return; return;
} }
if (type === Fragment) { if (type === Fragment) {
hostInsert(el, container, anchor); hostInsert(el, container, anchor);
...@@ -8384,10 +8390,10 @@ export default function vueFactory(exports) { ...@@ -8384,10 +8390,10 @@ export default function vueFactory(exports) {
if (moveType === 0 if (moveType === 0
/* ENTER */ /* ENTER */
) { ) {
transition.beforeEnter(el); transition.beforeEnter(el);
hostInsert(el, container, anchor); hostInsert(el, container, anchor);
queuePostRenderEffect(() => transition.enter(el), parentSuspense); queuePostRenderEffect(() => transition.enter(el), parentSuspense);
} else { } else {
var { var {
leave, leave,
delayLeave, delayLeave,
...@@ -8434,9 +8440,9 @@ export default function vueFactory(exports) { ...@@ -8434,9 +8440,9 @@ export default function vueFactory(exports) {
if (shapeFlag & 256 if (shapeFlag & 256
/* COMPONENT_SHOULD_KEEP_ALIVE */ /* COMPONENT_SHOULD_KEEP_ALIVE */
) { ) {
parentComponent.ctx.deactivate(vnode); parentComponent.ctx.deactivate(vnode);
return; return;
} }
var shouldInvokeDirs = shapeFlag & 1 var shouldInvokeDirs = shapeFlag & 1
/* ELEMENT */ /* ELEMENT */
...@@ -8450,14 +8456,14 @@ export default function vueFactory(exports) { ...@@ -8450,14 +8456,14 @@ export default function vueFactory(exports) {
if (shapeFlag & 6 if (shapeFlag & 6
/* COMPONENT */ /* COMPONENT */
) { ) {
unmountComponent(vnode.component, parentSuspense, doRemove); unmountComponent(vnode.component, parentSuspense, doRemove);
} else { } else {
if (shapeFlag & 128 if (shapeFlag & 128
/* SUSPENSE */ /* SUSPENSE */
) { ) {
vnode.suspense.unmount(parentSuspense, doRemove); vnode.suspense.unmount(parentSuspense, doRemove);
return; return;
} }
if (shouldInvokeDirs) { if (shouldInvokeDirs) {
invokeDirectiveHook(vnode, null, parentComponent, 'beforeUnmount'); invokeDirectiveHook(vnode, null, parentComponent, 'beforeUnmount');
...@@ -8466,8 +8472,9 @@ export default function vueFactory(exports) { ...@@ -8466,8 +8472,9 @@ export default function vueFactory(exports) {
if (shapeFlag & 64 if (shapeFlag & 64
/* TELEPORT */ /* TELEPORT */
) { ) {
vnode.type.remove(vnode, parentComponent, parentSuspense, optimized, internals, doRemove); vnode.type.remove(vnode, parentComponent, parentSuspense, optimized, internals, doRemove);
} else if (dynamicChildren && (type !== Fragment || patchFlag > 0 && patchFlag & 64 } else if (dynamicChildren && ( // #1153: fast path should not be taken for non-stable (v-for) fragments
type !== Fragment || patchFlag > 0 && patchFlag & 64
/* STABLE_FRAGMENT */ /* STABLE_FRAGMENT */
)) { )) {
// fast path for block nodes: only need to unmount dynamic children. // fast path for block nodes: only need to unmount dynamic children.
...@@ -8619,14 +8626,14 @@ export default function vueFactory(exports) { ...@@ -8619,14 +8626,14 @@ export default function vueFactory(exports) {
if (vnode.shapeFlag & 6 if (vnode.shapeFlag & 6
/* COMPONENT */ /* COMPONENT */
) { ) {
return getNextHostNode(vnode.component.subTree); return getNextHostNode(vnode.component.subTree);
} }
if (vnode.shapeFlag & 128 if (vnode.shapeFlag & 128
/* SUSPENSE */ /* SUSPENSE */
) { ) {
return vnode.suspense.next(); return vnode.suspense.next();
} }
return hostNextSibling(vnode.anchor || vnode.el); return hostNextSibling(vnode.anchor || vnode.el);
}; };
...@@ -8705,9 +8712,9 @@ export default function vueFactory(exports) { ...@@ -8705,9 +8712,9 @@ export default function vueFactory(exports) {
if (c2.patchFlag <= 0 || c2.patchFlag === 32 if (c2.patchFlag <= 0 || c2.patchFlag === 32
/* HYDRATE_EVENTS */ /* HYDRATE_EVENTS */
) { ) {
c2 = ch2[i] = cloneIfMounted(ch2[i]); c2 = ch2[i] = cloneIfMounted(ch2[i]);
c2.el = c1.el; c2.el = c1.el;
} }
if (!shallow) traverseStaticChildren(c1, c2); if (!shallow) traverseStaticChildren(c1, c2);
} // also inherit for comment nodes, but not placeholders (e.g. v-if which } // also inherit for comment nodes, but not placeholders (e.g. v-if which
...@@ -8860,8 +8867,8 @@ export default function vueFactory(exports) { ...@@ -8860,8 +8867,8 @@ export default function vueFactory(exports) {
if (shapeFlag & 16 if (shapeFlag & 16
/* ARRAY_CHILDREN */ /* ARRAY_CHILDREN */
) { ) {
mountChildren(children, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); mountChildren(children, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
} }
}; };
if (disabled) { if (disabled) {
...@@ -8952,11 +8959,11 @@ export default function vueFactory(exports) { ...@@ -8952,11 +8959,11 @@ export default function vueFactory(exports) {
if (shapeFlag & 16 if (shapeFlag & 16
/* ARRAY_CHILDREN */ /* ARRAY_CHILDREN */
) { ) {
for (var i = 0; i < children.length; i++) { for (var i = 0; i < children.length; i++) {
var child = children[i]; var child = children[i];
unmount(child, parentComponent, parentSuspense, true, !!child.dynamicChildren); unmount(child, parentComponent, parentSuspense, true, !!child.dynamicChildren);
}
} }
}
} }
}, },
...@@ -8976,8 +8983,8 @@ export default function vueFactory(exports) { ...@@ -8976,8 +8983,8 @@ export default function vueFactory(exports) {
if (moveType === 0 if (moveType === 0
/* TARGET_CHANGE */ /* TARGET_CHANGE */
) { ) {
insert(vnode.targetAnchor, container, parentAnchor); insert(vnode.targetAnchor, container, parentAnchor);
} }
var { var {
el, el,
...@@ -9002,12 +9009,12 @@ export default function vueFactory(exports) { ...@@ -9002,12 +9009,12 @@ export default function vueFactory(exports) {
if (shapeFlag & 16 if (shapeFlag & 16
/* ARRAY_CHILDREN */ /* ARRAY_CHILDREN */
) { ) {
for (var i = 0; i < children.length; i++) { for (var i = 0; i < children.length; i++) {
move(children[i], container, parentAnchor, 2 move(children[i], container, parentAnchor, 2
/* REORDER */ /* REORDER */
); );
}
} }
}
} // move main view anchor if this is a re-order. } // move main view anchor if this is a re-order.
...@@ -9033,16 +9040,16 @@ export default function vueFactory(exports) { ...@@ -9033,16 +9040,16 @@ export default function vueFactory(exports) {
if (vnode.shapeFlag & 16 if (vnode.shapeFlag & 16
/* ARRAY_CHILDREN */ /* ARRAY_CHILDREN */
) { ) {
if (isTeleportDisabled(vnode.props)) { if (isTeleportDisabled(vnode.props)) {
vnode.anchor = hydrateChildren(nextSibling(node), vnode, parentNode(node), parentComponent, parentSuspense, slotScopeIds, optimized); vnode.anchor = hydrateChildren(nextSibling(node), vnode, parentNode(node), parentComponent, parentSuspense, slotScopeIds, optimized);
vnode.targetAnchor = targetNode; vnode.targetAnchor = targetNode;
} else { } else {
vnode.anchor = nextSibling(node); vnode.anchor = nextSibling(node);
vnode.targetAnchor = hydrateChildren(targetNode, vnode, target, parentComponent, parentSuspense, slotScopeIds, optimized); vnode.targetAnchor = hydrateChildren(targetNode, vnode, target, parentComponent, parentSuspense, slotScopeIds, optimized);
} }
target._lpa = vnode.targetAnchor && nextSibling(vnode.targetAnchor); target._lpa = vnode.targetAnchor && nextSibling(vnode.targetAnchor);
} }
} }
return vnode.anchor && nextSibling(vnode.anchor); return vnode.anchor && nextSibling(vnode.anchor);
...@@ -9369,20 +9376,24 @@ export default function vueFactory(exports) { ...@@ -9369,20 +9376,24 @@ export default function vueFactory(exports) {
if (shapeFlag & 128 if (shapeFlag & 128
/* SUSPENSE */ /* SUSPENSE */
) { ) {
type.normalize(vnode); type.normalize(vnode);
} }
if (isBlockTreeEnabled > 0 && // avoid a block node from tracking itself if (isBlockTreeEnabled > 0 && // avoid a block node from tracking itself
!isBlockNode && // has current parent block !isBlockNode && // has current parent block
currentBlock && (patchFlag > 0 || shapeFlag & 6 currentBlock && ( // presence of a patch flag indicates this node needs patching on updates.
// component nodes also should always be patched, because even if the
// component doesn't need to update, it needs to persist the instance on to
// the next vnode so that it can be properly unmounted later.
patchFlag > 0 || shapeFlag & 6
/* COMPONENT */ /* COMPONENT */
) && // the EVENTS flag is only for hydration and if it is the only flag, the ) && // the EVENTS flag is only for hydration and if it is the only flag, the
// vnode should not be considered dynamic due to handler caching. // vnode should not be considered dynamic due to handler caching.
patchFlag !== 32 patchFlag !== 32
/* HYDRATE_EVENTS */ /* HYDRATE_EVENTS */
) { ) {
currentBlock.push(vnode); currentBlock.push(vnode);
} }
return vnode; return vnode;
} }
...@@ -9532,18 +9543,18 @@ export default function vueFactory(exports) { ...@@ -9532,18 +9543,18 @@ export default function vueFactory(exports) {
|| shapeFlag & 64 || shapeFlag & 64
/* TELEPORT */ /* TELEPORT */
) { ) {
// Normalize slot to plain children for plain element and Teleport // Normalize slot to plain children for plain element and Teleport
var slot = children.default; var slot = children.default;
if (slot) { if (slot) {
// _c marker is added by withCtx() indicating this is a compiled slot // _c marker is added by withCtx() indicating this is a compiled slot
slot._c && (slot._d = false); slot._c && (slot._d = false);
normalizeChildren(vnode, slot()); normalizeChildren(vnode, slot());
slot._c && (slot._d = true); slot._c && (slot._d = true);
} }
return; return;
} else { } else {
type = 32 type = 32
/* SLOTS_CHILDREN */ /* SLOTS_CHILDREN */
; ;
...@@ -9559,10 +9570,10 @@ export default function vueFactory(exports) { ...@@ -9559,10 +9570,10 @@ export default function vueFactory(exports) {
if (currentRenderingInstance.slots._ === 1 if (currentRenderingInstance.slots._ === 1
/* STABLE */ /* STABLE */
) { ) {
children._ = 1 children._ = 1
/* STABLE */ /* STABLE */
; ;
} else { } else {
children._ = 2 children._ = 2
/* DYNAMIC */ /* DYNAMIC */
; ;
...@@ -9586,11 +9597,11 @@ export default function vueFactory(exports) { ...@@ -9586,11 +9597,11 @@ export default function vueFactory(exports) {
if (shapeFlag & 64 if (shapeFlag & 64
/* TELEPORT */ /* TELEPORT */
) { ) {
type = 16 type = 16
/* ARRAY_CHILDREN */ /* ARRAY_CHILDREN */
; ;
children = [createTextVNode(children)]; children = [createTextVNode(children)];
} else { } else {
type = 8 type = 8
/* TEXT_CHILDREN */ /* TEXT_CHILDREN */
; ;
...@@ -9909,7 +9920,8 @@ export default function vueFactory(exports) { ...@@ -9909,7 +9920,8 @@ export default function vueFactory(exports) {
/* CONTEXT */ /* CONTEXT */
; ;
return ctx[key]; return ctx[key];
} else if (globalProperties = appContext.config.globalProperties, hasOwn(globalProperties, key)) { } else if ( // window properties
globalProperties = appContext.config.globalProperties, hasOwn(globalProperties, key)) {
{ {
return globalProperties[key]; return globalProperties[key];
} }
...@@ -11195,15 +11207,15 @@ export default function vueFactory(exports) { ...@@ -11195,15 +11207,15 @@ export default function vueFactory(exports) {
if (vnode.shapeFlag & 128 if (vnode.shapeFlag & 128
/* SUSPENSE */ /* SUSPENSE */
) { ) {
var suspense = vnode.suspense; var suspense = vnode.suspense;
vnode = suspense.activeBranch; vnode = suspense.activeBranch;
if (suspense.pendingBranch && !suspense.isHydrating) { if (suspense.pendingBranch && !suspense.isHydrating) {
suspense.effects.push(() => { suspense.effects.push(() => {
setVarsOnVNode(suspense.activeBranch, vars); setVarsOnVNode(suspense.activeBranch, vars);
}); });
} }
} // drill down HOCs until it's a non-component vnode } // drill down HOCs until it's a non-component vnode
while (vnode.component) { while (vnode.component) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册