From 963aa6eba3d9a12070fe3ce9d9b5416ff55cb1dc Mon Sep 17 00:00:00 2001 From: tofulm Date: Tue, 17 Aug 2021 21:55:10 +0200 Subject: [PATCH] maj vue en 3.2.4 --- js/vue.js | 9193 +++++++++++++++++++++++++++++++------------------ js/vue.min.js | 2 +- paquet.xml | 2 +- 3 files changed, 5834 insertions(+), 3363 deletions(-) diff --git a/js/vue.js b/js/vue.js index 9cab498..b9dd2f3 100644 --- a/js/vue.js +++ b/js/vue.js @@ -17,12 +17,9 @@ var Vue = (function (exports) { return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val]; } - // Patch flags are optimization hints generated by the compiler. - // when a block with dynamicChildren is encountered during diff, the algorithm - // enters "optimized mode". In this mode, we know that the vdom is produced by - // a render function generated by the compiler, so the algorithm only needs to - // handle updates explicitly marked by these patch flags. - // dev only flag -> name mapping + /** + * dev only flag -> name mapping + */ const PatchFlagNames = { [1 /* TEXT */]: `TEXT`, [2 /* CLASS */]: `CLASS`, @@ -33,24 +30,43 @@ var Vue = (function (exports) { [64 /* STABLE_FRAGMENT */]: `STABLE_FRAGMENT`, [128 /* KEYED_FRAGMENT */]: `KEYED_FRAGMENT`, [256 /* UNKEYED_FRAGMENT */]: `UNKEYED_FRAGMENT`, - [1024 /* DYNAMIC_SLOTS */]: `DYNAMIC_SLOTS`, [512 /* NEED_PATCH */]: `NEED_PATCH`, + [1024 /* DYNAMIC_SLOTS */]: `DYNAMIC_SLOTS`, + [2048 /* DEV_ROOT_FRAGMENT */]: `DEV_ROOT_FRAGMENT`, [-1 /* HOISTED */]: `HOISTED`, [-2 /* BAIL */]: `BAIL` }; + /** + * Dev only + */ + const slotFlagsText = { + [1 /* STABLE */]: 'STABLE', + [2 /* DYNAMIC */]: 'DYNAMIC', + [3 /* FORWARDED */]: 'FORWARDED' + }; + const GLOBALS_WHITE_LISTED = 'Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,' + 'decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,' + - 'Object,Boolean,String,RegExp,Map,Set,JSON,Intl'; + 'Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt'; const isGloballyWhitelisted = /*#__PURE__*/ makeMap(GLOBALS_WHITE_LISTED); const range = 2; function generateCodeFrame(source, start = 0, end = source.length) { - const lines = source.split(/\r?\n/); + // Split the content into individual lines but capture the newline sequence + // that separated each line. This is important because the actual sequence is + // needed to properly take into account the full line length for offset + // comparison + let lines = source.split(/(\r?\n)/); + // Separate the lines and newline sequences into separate arrays for easier referencing + const newlineSequences = lines.filter((_, idx) => idx % 2 === 1); + lines = lines.filter((_, idx) => idx % 2 === 0); let count = 0; const res = []; for (let i = 0; i < lines.length; i++) { - count += lines[i].length + 1; + count += + lines[i].length + + ((newlineSequences[i] && newlineSequences[i].length) || 0); if (count >= start) { for (let j = i - range; j <= i + range || end > count; j++) { if (j < 0 || j >= lines.length) @@ -58,9 +74,10 @@ var Vue = (function (exports) { const line = j + 1; res.push(`${line}${' '.repeat(Math.max(3 - String(line).length, 0))}| ${lines[j]}`); const lineLength = lines[j].length; + const newLineSeqLength = (newlineSequences[j] && newlineSequences[j].length) || 0; if (j === i) { // push underline - const pad = start - (count - lineLength) + 1; + const pad = start - (count - (lineLength + newLineSeqLength)); const length = Math.max(1, end > count ? lineLength - pad : end - start); res.push(` | ` + ' '.repeat(pad) + '^'.repeat(length)); } @@ -69,7 +86,7 @@ var Vue = (function (exports) { const length = Math.max(Math.min(end - count, lineLength), 1); res.push(` | ` + '^'.repeat(length)); } - count += lineLength + 1; + count += lineLength + newLineSeqLength; } } break; @@ -90,14 +107,23 @@ var Vue = (function (exports) { * - readonly -> readOnly */ const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`; - const isSpecialBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs); + const isSpecialBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs); + /** + * Boolean attributes should be included if the value is truthy or ''. + * e.g. + const forcePatchValue = (type === 'input' && dirs) || type === 'option'; // skip props & children if this is hoisted static nodes - if (patchFlag !== -1 /* HOISTED */) { + if (forcePatchValue || patchFlag !== -1 /* HOISTED */) { if (dirs) { invokeDirectiveHook(vnode, null, parentComponent, 'created'); } // props if (props) { - if (!optimized || - (patchFlag & 16 /* FULL_PROPS */ || - patchFlag & 32 /* HYDRATE_EVENTS */)) { + if (forcePatchValue || + !optimized || + patchFlag & (16 /* FULL_PROPS */ | 32 /* HYDRATE_EVENTS */)) { for (const key in props) { - if (!isReservedProp(key) && isOn(key)) { + if ((forcePatchValue && key.endsWith('value')) || + (isOn(key) && !isReservedProp(key))) { patchProp(el, key, null, props[key]); } } @@ -4396,12 +5206,12 @@ var Vue = (function (exports) { if (shapeFlag & 16 /* ARRAY_CHILDREN */ && // skip if element has innerHTML / textContent !(props && (props.innerHTML || props.textContent))) { - let next = hydrateChildren(el.firstChild, vnode, el, parentComponent, parentSuspense, optimized); + let next = hydrateChildren(el.firstChild, vnode, el, parentComponent, parentSuspense, slotScopeIds, optimized); let hasWarned = false; while (next) { hasMismatch = true; - if ( !hasWarned) { - warn(`Hydration children mismatch in <${vnode.type}>: ` + + if (!hasWarned) { + warn$1(`Hydration children mismatch in <${vnode.type}>: ` + `server rendered element contains more child nodes than client vdom.`); hasWarned = true; } @@ -4414,8 +5224,7 @@ var Vue = (function (exports) { else if (shapeFlag & 8 /* TEXT_CHILDREN */) { if (el.textContent !== vnode.children) { hasMismatch = true; - - warn(`Hydration text content mismatch in <${vnode.type}>:\n` + + warn$1(`Hydration text content mismatch in <${vnode.type}>:\n` + `- Client: ${el.textContent}\n` + `- Server: ${vnode.children}`); el.textContent = vnode.children; @@ -4424,7 +5233,7 @@ var Vue = (function (exports) { } return el.nextSibling; }; - const hydrateChildren = (node, parentVNode, container, parentComponent, parentSuspense, optimized) => { + const hydrateChildren = (node, parentVNode, container, parentComponent, parentSuspense, slotScopeIds, optimized) => { optimized = optimized || !!parentVNode.dynamicChildren; const children = parentVNode.children; const l = children.length; @@ -4434,24 +5243,33 @@ var Vue = (function (exports) { ? children[i] : (children[i] = normalizeVNode(children[i])); if (node) { - node = hydrateNode(node, vnode, parentComponent, parentSuspense, optimized); + node = hydrateNode(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized); + } + else if (vnode.type === Text && !vnode.children) { + continue; } else { hasMismatch = true; - if ( !hasWarned) { - warn(`Hydration children mismatch in <${container.tagName.toLowerCase()}>: ` + + if (!hasWarned) { + warn$1(`Hydration children mismatch in <${container.tagName.toLowerCase()}>: ` + `server rendered element contains fewer child nodes than client vdom.`); hasWarned = true; } // the SSRed DOM didn't contain enough nodes. Mount the missing ones. - patch(null, vnode, container, null, parentComponent, parentSuspense, isSVGContainer(container)); + patch(null, vnode, container, null, parentComponent, parentSuspense, isSVGContainer(container), slotScopeIds); } } return node; }; - const hydrateFragment = (node, vnode, parentComponent, parentSuspense, optimized) => { + const hydrateFragment = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => { + const { slotScopeIds: fragmentSlotScopeIds } = vnode; + if (fragmentSlotScopeIds) { + slotScopeIds = slotScopeIds + ? slotScopeIds.concat(fragmentSlotScopeIds) + : fragmentSlotScopeIds; + } const container = parentNode(node); - const next = hydrateChildren(nextSibling(node), vnode, container, parentComponent, parentSuspense, optimized); + const next = hydrateChildren(nextSibling(node), vnode, container, parentComponent, parentSuspense, slotScopeIds, optimized); if (next && isComment(next) && next.data === ']') { return nextSibling((vnode.anchor = next)); } @@ -4464,10 +5282,9 @@ var Vue = (function (exports) { return next; } }; - const handleMismatch = (node, vnode, parentComponent, parentSuspense, isFragment) => { + const handleMismatch = (node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragment) => { hasMismatch = true; - - warn(`Hydration node mismatch:\n- Client vnode:`, vnode.type, `\n- Server rendered DOM:`, node, node.nodeType === 3 /* TEXT */ + warn$1(`Hydration node mismatch:\n- Client vnode:`, vnode.type, `\n- Server rendered DOM:`, node, node.nodeType === 3 /* TEXT */ ? `(text)` : isComment(node) && node.data === '[' ? `(start of fragment)` @@ -4489,7 +5306,7 @@ var Vue = (function (exports) { const next = nextSibling(node); const container = parentNode(node); remove(node); - patch(null, vnode, container, next, parentComponent, parentSuspense, isSVGContainer(container)); + patch(null, vnode, container, next, parentComponent, parentSuspense, isSVGContainer(container), slotScopeIds); return next; }; const locateClosingAsyncAnchor = (node) => { @@ -4520,6 +5337,9 @@ var Vue = (function (exports) { if (instance.appContext.config.performance && isSupported()) { perf.mark(`vue-${type}-${instance.uid}`); } + { + devtoolsPerfStart(instance, type, supported ? perf.now() : Date.now()); + } } function endMeasure(instance, type) { if (instance.appContext.config.performance && isSupported()) { @@ -4530,6 +5350,9 @@ var Vue = (function (exports) { perf.clearMarks(startTag); perf.clearMarks(endTag); } + { + devtoolsPerfEnd(instance, type, supported ? perf.now() : Date.now()); + } } function isSupported() { if (supported !== undefined) { @@ -4547,94 +5370,8 @@ var Vue = (function (exports) { return supported; } - function createDevEffectOptions(instance) { - return { - scheduler: queueJob, - allowRecurse: true, - onTrack: instance.rtc ? e => invokeArrayFns(instance.rtc, e) : void 0, - onTrigger: instance.rtg ? e => invokeArrayFns(instance.rtg, e) : void 0 - }; - } - const queuePostRenderEffect = queueEffectWithSuspense + const queuePostRenderEffect = queueEffectWithSuspense ; - const setRef = (rawRef, oldRawRef, parentComponent, parentSuspense, vnode) => { - if (isArray(rawRef)) { - rawRef.forEach((r, i) => setRef(r, oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef), parentComponent, parentSuspense, vnode)); - return; - } - let value; - if (!vnode) { - value = null; - } - else { - if (vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */) { - value = vnode.component.proxy; - } - else { - value = vnode.el; - } - } - const { i: owner, r: ref } = rawRef; - if ( !owner) { - warn(`Missing ref owner context. ref cannot be used on hoisted vnodes. ` + - `A vnode with ref must be created inside the render function.`); - return; - } - const oldRef = oldRawRef && oldRawRef.r; - const refs = owner.refs === EMPTY_OBJ ? (owner.refs = {}) : owner.refs; - const setupState = owner.setupState; - // unset old ref - if (oldRef != null && oldRef !== ref) { - if (isString(oldRef)) { - refs[oldRef] = null; - if (hasOwn(setupState, oldRef)) { - setupState[oldRef] = null; - } - } - else if (isRef(oldRef)) { - oldRef.value = null; - } - } - if (isString(ref)) { - const doSet = () => { - refs[ref] = value; - if (hasOwn(setupState, ref)) { - setupState[ref] = value; - } - }; - // #1789: for non-null values, set them after render - // null values means this is unmount and it should not overwrite another - // ref with the same key - if (value) { - doSet.id = -1; - queuePostRenderEffect(doSet, parentSuspense); - } - else { - doSet(); - } - } - else if (isRef(ref)) { - const doSet = () => { - ref.value = value; - }; - if (value) { - doSet.id = -1; - queuePostRenderEffect(doSet, parentSuspense); - } - else { - doSet(); - } - } - else if (isFunction(ref)) { - callWithErrorHandling(ref, parentComponent, 12 /* FUNCTION_REF */, [ - value, - refs - ]); - } - else { - warn('Invalid template ref type:', value, `(${typeof value})`); - } - }; /** * The createRenderer function accepts two generic arguments: * HostNode and HostElement, corresponding to Node and Element types in the @@ -4661,10 +5398,18 @@ var Vue = (function (exports) { } // implementation function baseCreateRenderer(options, createHydrationFns) { - const { insert: hostInsert, remove: hostRemove, patchProp: hostPatchProp, forcePatchProp: hostForcePatchProp, createElement: hostCreateElement, createText: hostCreateText, createComment: hostCreateComment, setText: hostSetText, setElementText: hostSetElementText, parentNode: hostParentNode, nextSibling: hostNextSibling, setScopeId: hostSetScopeId = NOOP, cloneNode: hostCloneNode, insertStaticContent: hostInsertStaticContent } = options; + { + const target = getGlobalThis(); + target.__VUE__ = true; + setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__); + } + const { insert: hostInsert, remove: hostRemove, patchProp: hostPatchProp, createElement: hostCreateElement, createText: hostCreateText, createComment: hostCreateComment, setText: hostSetText, setElementText: hostSetElementText, parentNode: hostParentNode, nextSibling: hostNextSibling, setScopeId: hostSetScopeId = NOOP, cloneNode: hostCloneNode, insertStaticContent: hostInsertStaticContent } = options; // Note: functions inside this closure should use `const xxx = () => {}` // style in order to prevent being inlined by minifiers. - const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, isSVG = false, optimized = false) => { + const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, isSVG = false, slotScopeIds = null, optimized = isHmrUpdating ? false : !!n2.dynamicChildren) => { + if (n1 === n2) { + return; + } // patching & not same type, unmount old tree if (n1 && !isSameVNodeType(n1, n2)) { anchor = getNextHostNode(n1); @@ -4680,7 +5425,7 @@ var Vue = (function (exports) { case Text: processText(n1, n2, container, anchor); break; - case Comment: + case Comment$1: processCommentNode(n1, n2, container, anchor); break; case Static: @@ -4692,28 +5437,28 @@ var Vue = (function (exports) { } break; case Fragment: - processFragment(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized); + processFragment(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); break; default: if (shapeFlag & 1 /* ELEMENT */) { - processElement(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized); + processElement(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); } else if (shapeFlag & 6 /* COMPONENT */) { - processComponent(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized); + processComponent(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); } else if (shapeFlag & 64 /* TELEPORT */) { - type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized, internals); + type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals); } - else if ( shapeFlag & 128 /* SUSPENSE */) { - type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized, internals); + else if (shapeFlag & 128 /* SUSPENSE */) { + type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals); } else { - warn('Invalid VNode type:', type, `(${typeof type})`); + warn$1('Invalid VNode type:', type, `(${typeof type})`); } } // set ref if (ref != null && parentComponent) { - setRef(ref, n1 && n1.ref, parentComponent, parentSuspense, n2); + setRef(ref, n1 && n1.ref, parentSuspense, n2 || n1, !n2); } }; const processText = (n1, n2, container, anchor) => { @@ -4755,53 +5500,46 @@ var Vue = (function (exports) { n2.anchor = n1.anchor; } }; - /** - * Dev / HMR only - */ - const moveStaticNode = (vnode, container, anchor) => { - let cur = vnode.el; - const end = vnode.anchor; - while (cur && cur !== end) { - const next = hostNextSibling(cur); - hostInsert(cur, container, anchor); - cur = next; + const moveStaticNode = ({ el, anchor }, container, nextSibling) => { + let next; + while (el && el !== anchor) { + next = hostNextSibling(el); + hostInsert(el, container, nextSibling); + el = next; } - hostInsert(end, container, anchor); + hostInsert(anchor, container, nextSibling); }; - /** - * Dev / HMR only - */ - const removeStaticNode = (vnode) => { - let cur = vnode.el; - while (cur && cur !== vnode.anchor) { - const next = hostNextSibling(cur); - hostRemove(cur); - cur = next; + const removeStaticNode = ({ el, anchor }) => { + let next; + while (el && el !== anchor) { + next = hostNextSibling(el); + hostRemove(el); + el = next; } - hostRemove(vnode.anchor); + hostRemove(anchor); }; - const processElement = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized) => { + const processElement = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => { isSVG = isSVG || n2.type === 'svg'; if (n1 == null) { - mountElement(n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized); + mountElement(n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); } else { - patchElement(n1, n2, parentComponent, parentSuspense, isSVG, optimized); + patchElement(n1, n2, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); } }; - const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, isSVG, optimized) => { + const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => { let el; let vnodeHook; - const { type, props, shapeFlag, transition, scopeId, patchFlag, dirs } = vnode; + const { type, props, shapeFlag, transition, patchFlag, dirs } = vnode; { - el = vnode.el = hostCreateElement(vnode.type, isSVG, props && props.is); + el = vnode.el = hostCreateElement(vnode.type, isSVG, props && props.is, props); // mount children first, since some props may rely on child content // being already rendered, e.g. `