vue 3.2.24 → 3.2.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/vue.esm-browser.js +176 -116
- package/dist/vue.esm-browser.prod.js +1 -1
- package/dist/vue.global.js +176 -116
- package/dist/vue.global.prod.js +1 -1
- package/dist/vue.runtime.esm-browser.js +128 -95
- package/dist/vue.runtime.esm-browser.prod.js +1 -1
- package/dist/vue.runtime.global.js +128 -95
- package/dist/vue.runtime.global.prod.js +1 -1
- package/package.json +9 -7
- package/ref-macros.d.ts +2 -98
package/dist/vue.esm-browser.js
CHANGED
|
@@ -107,7 +107,7 @@ const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomo
|
|
|
107
107
|
const isSpecialBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs);
|
|
108
108
|
/**
|
|
109
109
|
* Boolean attributes should be included if the value is truthy or ''.
|
|
110
|
-
* e.g.
|
|
110
|
+
* e.g. `<select multiple>` compiles to `{ multiple: '' }`
|
|
111
111
|
*/
|
|
112
112
|
function includeBooleanAttr(value) {
|
|
113
113
|
return !!value || value === '';
|
|
@@ -341,7 +341,7 @@ const isIntegerKey = (key) => isString(key) &&
|
|
|
341
341
|
'' + parseInt(key, 10) === key;
|
|
342
342
|
const isReservedProp = /*#__PURE__*/ makeMap(
|
|
343
343
|
// the leading comma is intentional so empty string "" is also included
|
|
344
|
-
',key,ref,' +
|
|
344
|
+
',key,ref,ref_for,ref_key,' +
|
|
345
345
|
'onVnodeBeforeMount,onVnodeMounted,' +
|
|
346
346
|
'onVnodeBeforeUpdate,onVnodeUpdated,' +
|
|
347
347
|
'onVnodeBeforeUnmount,onVnodeUnmounted');
|
|
@@ -1436,21 +1436,25 @@ function toRefs(object) {
|
|
|
1436
1436
|
return ret;
|
|
1437
1437
|
}
|
|
1438
1438
|
class ObjectRefImpl {
|
|
1439
|
-
constructor(_object, _key) {
|
|
1439
|
+
constructor(_object, _key, _defaultValue) {
|
|
1440
1440
|
this._object = _object;
|
|
1441
1441
|
this._key = _key;
|
|
1442
|
+
this._defaultValue = _defaultValue;
|
|
1442
1443
|
this.__v_isRef = true;
|
|
1443
1444
|
}
|
|
1444
1445
|
get value() {
|
|
1445
|
-
|
|
1446
|
+
const val = this._object[this._key];
|
|
1447
|
+
return val === undefined ? this._defaultValue : val;
|
|
1446
1448
|
}
|
|
1447
1449
|
set value(newVal) {
|
|
1448
1450
|
this._object[this._key] = newVal;
|
|
1449
1451
|
}
|
|
1450
1452
|
}
|
|
1451
|
-
function toRef(object, key) {
|
|
1453
|
+
function toRef(object, key, defaultValue) {
|
|
1452
1454
|
const val = object[key];
|
|
1453
|
-
return isRef(val)
|
|
1455
|
+
return isRef(val)
|
|
1456
|
+
? val
|
|
1457
|
+
: new ObjectRefImpl(object, key, defaultValue);
|
|
1454
1458
|
}
|
|
1455
1459
|
|
|
1456
1460
|
class ComputedRefImpl {
|
|
@@ -4710,6 +4714,102 @@ function createAppAPI(render, hydrate) {
|
|
|
4710
4714
|
};
|
|
4711
4715
|
}
|
|
4712
4716
|
|
|
4717
|
+
/**
|
|
4718
|
+
* Function for handling a template ref
|
|
4719
|
+
*/
|
|
4720
|
+
function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
|
|
4721
|
+
if (isArray(rawRef)) {
|
|
4722
|
+
rawRef.forEach((r, i) => setRef(r, oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef), parentSuspense, vnode, isUnmount));
|
|
4723
|
+
return;
|
|
4724
|
+
}
|
|
4725
|
+
if (isAsyncWrapper(vnode) && !isUnmount) {
|
|
4726
|
+
// when mounting async components, nothing needs to be done,
|
|
4727
|
+
// because the template ref is forwarded to inner component
|
|
4728
|
+
return;
|
|
4729
|
+
}
|
|
4730
|
+
const refValue = vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */
|
|
4731
|
+
? getExposeProxy(vnode.component) || vnode.component.proxy
|
|
4732
|
+
: vnode.el;
|
|
4733
|
+
const value = isUnmount ? null : refValue;
|
|
4734
|
+
const { i: owner, r: ref } = rawRef;
|
|
4735
|
+
if (!owner) {
|
|
4736
|
+
warn$1(`Missing ref owner context. ref cannot be used on hoisted vnodes. ` +
|
|
4737
|
+
`A vnode with ref must be created inside the render function.`);
|
|
4738
|
+
return;
|
|
4739
|
+
}
|
|
4740
|
+
const oldRef = oldRawRef && oldRawRef.r;
|
|
4741
|
+
const refs = owner.refs === EMPTY_OBJ ? (owner.refs = {}) : owner.refs;
|
|
4742
|
+
const setupState = owner.setupState;
|
|
4743
|
+
// dynamic ref changed. unset old ref
|
|
4744
|
+
if (oldRef != null && oldRef !== ref) {
|
|
4745
|
+
if (isString(oldRef)) {
|
|
4746
|
+
refs[oldRef] = null;
|
|
4747
|
+
if (hasOwn(setupState, oldRef)) {
|
|
4748
|
+
setupState[oldRef] = null;
|
|
4749
|
+
}
|
|
4750
|
+
}
|
|
4751
|
+
else if (isRef(oldRef)) {
|
|
4752
|
+
oldRef.value = null;
|
|
4753
|
+
}
|
|
4754
|
+
}
|
|
4755
|
+
if (isFunction(ref)) {
|
|
4756
|
+
callWithErrorHandling(ref, owner, 12 /* FUNCTION_REF */, [value, refs]);
|
|
4757
|
+
}
|
|
4758
|
+
else {
|
|
4759
|
+
const _isString = isString(ref);
|
|
4760
|
+
const _isRef = isRef(ref);
|
|
4761
|
+
if (_isString || _isRef) {
|
|
4762
|
+
const doSet = () => {
|
|
4763
|
+
if (rawRef.f) {
|
|
4764
|
+
const existing = _isString ? refs[ref] : ref.value;
|
|
4765
|
+
if (isUnmount) {
|
|
4766
|
+
isArray(existing) && remove(existing, refValue);
|
|
4767
|
+
}
|
|
4768
|
+
else {
|
|
4769
|
+
if (!isArray(existing)) {
|
|
4770
|
+
if (_isString) {
|
|
4771
|
+
refs[ref] = [refValue];
|
|
4772
|
+
}
|
|
4773
|
+
else {
|
|
4774
|
+
ref.value = [refValue];
|
|
4775
|
+
if (rawRef.k)
|
|
4776
|
+
refs[rawRef.k] = ref.value;
|
|
4777
|
+
}
|
|
4778
|
+
}
|
|
4779
|
+
else if (!existing.includes(refValue)) {
|
|
4780
|
+
existing.push(refValue);
|
|
4781
|
+
}
|
|
4782
|
+
}
|
|
4783
|
+
}
|
|
4784
|
+
else if (_isString) {
|
|
4785
|
+
refs[ref] = value;
|
|
4786
|
+
if (hasOwn(setupState, ref)) {
|
|
4787
|
+
setupState[ref] = value;
|
|
4788
|
+
}
|
|
4789
|
+
}
|
|
4790
|
+
else if (isRef(ref)) {
|
|
4791
|
+
ref.value = value;
|
|
4792
|
+
if (rawRef.k)
|
|
4793
|
+
refs[rawRef.k] = value;
|
|
4794
|
+
}
|
|
4795
|
+
else {
|
|
4796
|
+
warn$1('Invalid template ref type:', ref, `(${typeof ref})`);
|
|
4797
|
+
}
|
|
4798
|
+
};
|
|
4799
|
+
if (value) {
|
|
4800
|
+
doSet.id = -1;
|
|
4801
|
+
queuePostRenderEffect(doSet, parentSuspense);
|
|
4802
|
+
}
|
|
4803
|
+
else {
|
|
4804
|
+
doSet();
|
|
4805
|
+
}
|
|
4806
|
+
}
|
|
4807
|
+
else {
|
|
4808
|
+
warn$1('Invalid template ref type:', ref, `(${typeof ref})`);
|
|
4809
|
+
}
|
|
4810
|
+
}
|
|
4811
|
+
}
|
|
4812
|
+
|
|
4713
4813
|
let hasMismatch = false;
|
|
4714
4814
|
const isSVGContainer = (container) => /svg/.test(container.namespaceURI) && container.tagName !== 'foreignObject';
|
|
4715
4815
|
const isComment = (node) => node.nodeType === 8 /* COMMENT */;
|
|
@@ -5342,12 +5442,15 @@ function baseCreateRenderer(options, createHydrationFns) {
|
|
|
5342
5442
|
const oldProps = n1.props || EMPTY_OBJ;
|
|
5343
5443
|
const newProps = n2.props || EMPTY_OBJ;
|
|
5344
5444
|
let vnodeHook;
|
|
5445
|
+
// disable recurse in beforeUpdate hooks
|
|
5446
|
+
parentComponent && toggleRecurse(parentComponent, false);
|
|
5345
5447
|
if ((vnodeHook = newProps.onVnodeBeforeUpdate)) {
|
|
5346
5448
|
invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
|
|
5347
5449
|
}
|
|
5348
5450
|
if (dirs) {
|
|
5349
5451
|
invokeDirectiveHook(n2, n1, parentComponent, 'beforeUpdate');
|
|
5350
5452
|
}
|
|
5453
|
+
parentComponent && toggleRecurse(parentComponent, true);
|
|
5351
5454
|
if (isHmrUpdating) {
|
|
5352
5455
|
// HMR updated, force full diff
|
|
5353
5456
|
patchFlag = 0;
|
|
@@ -5627,7 +5730,7 @@ function baseCreateRenderer(options, createHydrationFns) {
|
|
|
5627
5730
|
const { el, props } = initialVNode;
|
|
5628
5731
|
const { bm, m, parent } = instance;
|
|
5629
5732
|
const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
|
|
5630
|
-
|
|
5733
|
+
toggleRecurse(instance, false);
|
|
5631
5734
|
// beforeMount hook
|
|
5632
5735
|
if (bm) {
|
|
5633
5736
|
invokeArrayFns(bm);
|
|
@@ -5637,7 +5740,7 @@ function baseCreateRenderer(options, createHydrationFns) {
|
|
|
5637
5740
|
(vnodeHook = props && props.onVnodeBeforeMount)) {
|
|
5638
5741
|
invokeVNodeHook(vnodeHook, parent, initialVNode);
|
|
5639
5742
|
}
|
|
5640
|
-
|
|
5743
|
+
toggleRecurse(instance, true);
|
|
5641
5744
|
if (el && hydrateNode) {
|
|
5642
5745
|
// vnode has adopted host node - perform hydration instead of mount.
|
|
5643
5746
|
const hydrateSubTree = () => {
|
|
@@ -5719,7 +5822,7 @@ function baseCreateRenderer(options, createHydrationFns) {
|
|
|
5719
5822
|
pushWarningContext(next || instance.vnode);
|
|
5720
5823
|
}
|
|
5721
5824
|
// Disallow component effect recursion during pre-lifecycle hooks.
|
|
5722
|
-
|
|
5825
|
+
toggleRecurse(instance, false);
|
|
5723
5826
|
if (next) {
|
|
5724
5827
|
next.el = vnode.el;
|
|
5725
5828
|
updateComponentPreRender(instance, next, optimized);
|
|
@@ -5735,7 +5838,7 @@ function baseCreateRenderer(options, createHydrationFns) {
|
|
|
5735
5838
|
if ((vnodeHook = next.props && next.props.onVnodeBeforeUpdate)) {
|
|
5736
5839
|
invokeVNodeHook(vnodeHook, parent, next, vnode);
|
|
5737
5840
|
}
|
|
5738
|
-
|
|
5841
|
+
toggleRecurse(instance, true);
|
|
5739
5842
|
// render
|
|
5740
5843
|
{
|
|
5741
5844
|
startMeasure(instance, `render`);
|
|
@@ -5781,13 +5884,13 @@ function baseCreateRenderer(options, createHydrationFns) {
|
|
|
5781
5884
|
}
|
|
5782
5885
|
};
|
|
5783
5886
|
// create reactive effect for rendering
|
|
5784
|
-
const effect = new ReactiveEffect(componentUpdateFn, () => queueJob(instance.update), instance.scope // track it in component's effect scope
|
|
5785
|
-
);
|
|
5887
|
+
const effect = (instance.effect = new ReactiveEffect(componentUpdateFn, () => queueJob(instance.update), instance.scope // track it in component's effect scope
|
|
5888
|
+
));
|
|
5786
5889
|
const update = (instance.update = effect.run.bind(effect));
|
|
5787
5890
|
update.id = instance.uid;
|
|
5788
5891
|
// allowRecurse
|
|
5789
5892
|
// #1801, #2043 component render effects should allow recursive updates
|
|
5790
|
-
|
|
5893
|
+
toggleRecurse(instance, true);
|
|
5791
5894
|
{
|
|
5792
5895
|
effect.onTrack = instance.rtc
|
|
5793
5896
|
? e => invokeArrayFns(instance.rtc, e)
|
|
@@ -6311,85 +6414,8 @@ function baseCreateRenderer(options, createHydrationFns) {
|
|
|
6311
6414
|
createApp: createAppAPI(render, hydrate)
|
|
6312
6415
|
};
|
|
6313
6416
|
}
|
|
6314
|
-
function
|
|
6315
|
-
|
|
6316
|
-
rawRef.forEach((r, i) => setRef(r, oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef), parentSuspense, vnode, isUnmount));
|
|
6317
|
-
return;
|
|
6318
|
-
}
|
|
6319
|
-
if (isAsyncWrapper(vnode) && !isUnmount) {
|
|
6320
|
-
// when mounting async components, nothing needs to be done,
|
|
6321
|
-
// because the template ref is forwarded to inner component
|
|
6322
|
-
return;
|
|
6323
|
-
}
|
|
6324
|
-
const refValue = vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */
|
|
6325
|
-
? getExposeProxy(vnode.component) || vnode.component.proxy
|
|
6326
|
-
: vnode.el;
|
|
6327
|
-
const value = isUnmount ? null : refValue;
|
|
6328
|
-
const { i: owner, r: ref } = rawRef;
|
|
6329
|
-
if (!owner) {
|
|
6330
|
-
warn$1(`Missing ref owner context. ref cannot be used on hoisted vnodes. ` +
|
|
6331
|
-
`A vnode with ref must be created inside the render function.`);
|
|
6332
|
-
return;
|
|
6333
|
-
}
|
|
6334
|
-
const oldRef = oldRawRef && oldRawRef.r;
|
|
6335
|
-
const refs = owner.refs === EMPTY_OBJ ? (owner.refs = {}) : owner.refs;
|
|
6336
|
-
const setupState = owner.setupState;
|
|
6337
|
-
// dynamic ref changed. unset old ref
|
|
6338
|
-
if (oldRef != null && oldRef !== ref) {
|
|
6339
|
-
if (isString(oldRef)) {
|
|
6340
|
-
refs[oldRef] = null;
|
|
6341
|
-
if (hasOwn(setupState, oldRef)) {
|
|
6342
|
-
setupState[oldRef] = null;
|
|
6343
|
-
}
|
|
6344
|
-
}
|
|
6345
|
-
else if (isRef(oldRef)) {
|
|
6346
|
-
oldRef.value = null;
|
|
6347
|
-
}
|
|
6348
|
-
}
|
|
6349
|
-
if (isString(ref)) {
|
|
6350
|
-
const doSet = () => {
|
|
6351
|
-
{
|
|
6352
|
-
refs[ref] = value;
|
|
6353
|
-
}
|
|
6354
|
-
if (hasOwn(setupState, ref)) {
|
|
6355
|
-
setupState[ref] = value;
|
|
6356
|
-
}
|
|
6357
|
-
};
|
|
6358
|
-
// #1789: for non-null values, set them after render
|
|
6359
|
-
// null values means this is unmount and it should not overwrite another
|
|
6360
|
-
// ref with the same key
|
|
6361
|
-
if (value) {
|
|
6362
|
-
doSet.id = -1;
|
|
6363
|
-
queuePostRenderEffect(doSet, parentSuspense);
|
|
6364
|
-
}
|
|
6365
|
-
else {
|
|
6366
|
-
doSet();
|
|
6367
|
-
}
|
|
6368
|
-
}
|
|
6369
|
-
else if (isRef(ref)) {
|
|
6370
|
-
const doSet = () => {
|
|
6371
|
-
ref.value = value;
|
|
6372
|
-
};
|
|
6373
|
-
if (value) {
|
|
6374
|
-
doSet.id = -1;
|
|
6375
|
-
queuePostRenderEffect(doSet, parentSuspense);
|
|
6376
|
-
}
|
|
6377
|
-
else {
|
|
6378
|
-
doSet();
|
|
6379
|
-
}
|
|
6380
|
-
}
|
|
6381
|
-
else if (isFunction(ref)) {
|
|
6382
|
-
callWithErrorHandling(ref, owner, 12 /* FUNCTION_REF */, [value, refs]);
|
|
6383
|
-
}
|
|
6384
|
-
else {
|
|
6385
|
-
warn$1('Invalid template ref type:', value, `(${typeof value})`);
|
|
6386
|
-
}
|
|
6387
|
-
}
|
|
6388
|
-
function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
|
|
6389
|
-
callWithAsyncErrorHandling(hook, instance, 7 /* VNODE_HOOK */, [
|
|
6390
|
-
vnode,
|
|
6391
|
-
prevVNode
|
|
6392
|
-
]);
|
|
6417
|
+
function toggleRecurse({ effect, update }, allowed) {
|
|
6418
|
+
effect.allowRecurse = update.allowRecurse = allowed;
|
|
6393
6419
|
}
|
|
6394
6420
|
/**
|
|
6395
6421
|
* #1156
|
|
@@ -6848,10 +6874,10 @@ const createVNodeWithArgsTransform = (...args) => {
|
|
|
6848
6874
|
};
|
|
6849
6875
|
const InternalObjectKey = `__vInternal`;
|
|
6850
6876
|
const normalizeKey = ({ key }) => key != null ? key : null;
|
|
6851
|
-
const normalizeRef = ({ ref }) => {
|
|
6877
|
+
const normalizeRef = ({ ref, ref_key, ref_for }) => {
|
|
6852
6878
|
return (ref != null
|
|
6853
6879
|
? isString(ref) || isRef(ref) || isFunction(ref)
|
|
6854
|
-
? { i: currentRenderingInstance, r: ref }
|
|
6880
|
+
? { i: currentRenderingInstance, r: ref, k: ref_key, f: !!ref_for }
|
|
6855
6881
|
: ref
|
|
6856
6882
|
: null);
|
|
6857
6883
|
};
|
|
@@ -7193,6 +7219,12 @@ function mergeProps(...args) {
|
|
|
7193
7219
|
}
|
|
7194
7220
|
}
|
|
7195
7221
|
return ret;
|
|
7222
|
+
}
|
|
7223
|
+
function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
|
|
7224
|
+
callWithAsyncErrorHandling(hook, instance, 7 /* VNODE_HOOK */, [
|
|
7225
|
+
vnode,
|
|
7226
|
+
prevVNode
|
|
7227
|
+
]);
|
|
7196
7228
|
}
|
|
7197
7229
|
|
|
7198
7230
|
/**
|
|
@@ -7604,6 +7636,7 @@ function createComponentInstance(vnode, parent, suspense) {
|
|
|
7604
7636
|
root: null,
|
|
7605
7637
|
next: null,
|
|
7606
7638
|
subTree: null,
|
|
7639
|
+
effect: null,
|
|
7607
7640
|
update: null,
|
|
7608
7641
|
scope: new EffectScope(true /* detached */),
|
|
7609
7642
|
render: null,
|
|
@@ -9045,7 +9078,7 @@ function isMemoSame(cached, memo) {
|
|
|
9045
9078
|
}
|
|
9046
9079
|
|
|
9047
9080
|
// Core API ------------------------------------------------------------------
|
|
9048
|
-
const version = "3.2.
|
|
9081
|
+
const version = "3.2.25";
|
|
9049
9082
|
/**
|
|
9050
9083
|
* SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
|
|
9051
9084
|
* @internal
|
|
@@ -11300,12 +11333,12 @@ function findProp(node, name, dynamicOnly = false, allowEmpty = false) {
|
|
|
11300
11333
|
}
|
|
11301
11334
|
else if (p.name === 'bind' &&
|
|
11302
11335
|
(p.exp || allowEmpty) &&
|
|
11303
|
-
|
|
11336
|
+
isStaticArgOf(p.arg, name)) {
|
|
11304
11337
|
return p;
|
|
11305
11338
|
}
|
|
11306
11339
|
}
|
|
11307
11340
|
}
|
|
11308
|
-
function
|
|
11341
|
+
function isStaticArgOf(arg, name) {
|
|
11309
11342
|
return !!(arg && isStaticExp(arg) && arg.content === name);
|
|
11310
11343
|
}
|
|
11311
11344
|
function hasDynamicKeyVBind(node) {
|
|
@@ -11495,11 +11528,6 @@ const deprecationData = {
|
|
|
11495
11528
|
`data source.`,
|
|
11496
11529
|
link: `https://v3.vuejs.org/guide/migration/v-if-v-for.html`
|
|
11497
11530
|
},
|
|
11498
|
-
["COMPILER_V_FOR_REF" /* COMPILER_V_FOR_REF */]: {
|
|
11499
|
-
message: `Ref usage on v-for no longer creates array ref values in Vue 3. ` +
|
|
11500
|
-
`Consider using function refs or refactor to avoid ref usage altogether.`,
|
|
11501
|
-
link: `https://v3.vuejs.org/guide/migration/array-refs.html`
|
|
11502
|
-
},
|
|
11503
11531
|
["COMPILER_NATIVE_TEMPLATE" /* COMPILER_NATIVE_TEMPLATE */]: {
|
|
11504
11532
|
message: `<template> with no special directives will render as a native template ` +
|
|
11505
11533
|
`element instead of its inner content in Vue 3.`
|
|
@@ -11972,7 +12000,7 @@ function isComponent(tag, props, context) {
|
|
|
11972
12000
|
else if (
|
|
11973
12001
|
// :is on plain element - only treat as component in compat mode
|
|
11974
12002
|
p.name === 'bind' &&
|
|
11975
|
-
|
|
12003
|
+
isStaticArgOf(p.arg, 'is') &&
|
|
11976
12004
|
false &&
|
|
11977
12005
|
checkCompatEnabled("COMPILER_IS_ON_ELEMENT" /* COMPILER_IS_ON_ELEMENT */, context, p.loc)) {
|
|
11978
12006
|
return true;
|
|
@@ -12419,6 +12447,11 @@ function getConstantType(node, context) {
|
|
|
12419
12447
|
if (codegenNode.type !== 13 /* VNODE_CALL */) {
|
|
12420
12448
|
return 0 /* NOT_CONSTANT */;
|
|
12421
12449
|
}
|
|
12450
|
+
if (codegenNode.isBlock &&
|
|
12451
|
+
node.tag !== 'svg' &&
|
|
12452
|
+
node.tag !== 'foreignObject') {
|
|
12453
|
+
return 0 /* NOT_CONSTANT */;
|
|
12454
|
+
}
|
|
12422
12455
|
const flag = getPatchFlag(codegenNode);
|
|
12423
12456
|
if (!flag) {
|
|
12424
12457
|
let returnType = 3 /* CAN_STRINGIFY */;
|
|
@@ -12555,7 +12588,7 @@ function getGeneratedPropsConstantType(node, context) {
|
|
|
12555
12588
|
else if (value.type === 14 /* JS_CALL_EXPRESSION */) {
|
|
12556
12589
|
// some helper calls can be hoisted,
|
|
12557
12590
|
// such as the `normalizeProps` generated by the compiler for pre-normalize class,
|
|
12558
|
-
// in this case we need to respect the ConstantType of the helper's
|
|
12591
|
+
// in this case we need to respect the ConstantType of the helper's arguments
|
|
12559
12592
|
valueType = getConstantTypeOfHelperCall(value, context);
|
|
12560
12593
|
}
|
|
12561
12594
|
else {
|
|
@@ -14203,10 +14236,7 @@ const transformElement = (node, context) => {
|
|
|
14203
14236
|
// updates inside get proper isSVG flag at runtime. (#639, #643)
|
|
14204
14237
|
// This is technically web-specific, but splitting the logic out of core
|
|
14205
14238
|
// leads to too much unnecessary complexity.
|
|
14206
|
-
(tag === 'svg' ||
|
|
14207
|
-
tag === 'foreignObject' ||
|
|
14208
|
-
// #938: elements with dynamic keys should be forced into blocks
|
|
14209
|
-
findProp(node, 'key', true)));
|
|
14239
|
+
(tag === 'svg' || tag === 'foreignObject'));
|
|
14210
14240
|
// props
|
|
14211
14241
|
if (props.length > 0) {
|
|
14212
14242
|
const propsBuildResult = buildProps(node, context);
|
|
@@ -14218,6 +14248,9 @@ const transformElement = (node, context) => {
|
|
|
14218
14248
|
directives && directives.length
|
|
14219
14249
|
? createArrayExpression(directives.map(dir => buildDirectiveArgs(dir, context)))
|
|
14220
14250
|
: undefined;
|
|
14251
|
+
if (propsBuildResult.shouldUseBlock) {
|
|
14252
|
+
shouldUseBlock = true;
|
|
14253
|
+
}
|
|
14221
14254
|
}
|
|
14222
14255
|
// children
|
|
14223
14256
|
if (node.children.length > 0) {
|
|
@@ -14346,11 +14379,13 @@ function resolveComponentType(node, context, ssr = false) {
|
|
|
14346
14379
|
return toValidAssetId(tag, `component`);
|
|
14347
14380
|
}
|
|
14348
14381
|
function buildProps(node, context, props = node.props, ssr = false) {
|
|
14349
|
-
const { tag, loc: elementLoc } = node;
|
|
14382
|
+
const { tag, loc: elementLoc, children } = node;
|
|
14350
14383
|
const isComponent = node.tagType === 1 /* COMPONENT */;
|
|
14351
14384
|
let properties = [];
|
|
14352
14385
|
const mergeArgs = [];
|
|
14353
14386
|
const runtimeDirectives = [];
|
|
14387
|
+
const hasChildren = children.length > 0;
|
|
14388
|
+
let shouldUseBlock = false;
|
|
14354
14389
|
// patchFlag analysis
|
|
14355
14390
|
let patchFlag = 0;
|
|
14356
14391
|
let hasRef = false;
|
|
@@ -14413,9 +14448,12 @@ function buildProps(node, context, props = node.props, ssr = false) {
|
|
|
14413
14448
|
const prop = props[i];
|
|
14414
14449
|
if (prop.type === 6 /* ATTRIBUTE */) {
|
|
14415
14450
|
const { loc, name, value } = prop;
|
|
14416
|
-
let
|
|
14451
|
+
let isStatic = true;
|
|
14417
14452
|
if (name === 'ref') {
|
|
14418
14453
|
hasRef = true;
|
|
14454
|
+
if (context.scopes.vFor > 0) {
|
|
14455
|
+
properties.push(createObjectProperty(createSimpleExpression('ref_for', true), createSimpleExpression('true')));
|
|
14456
|
+
}
|
|
14419
14457
|
}
|
|
14420
14458
|
// skip is on <component>, or is="vue:xxx"
|
|
14421
14459
|
if (name === 'is' &&
|
|
@@ -14424,7 +14462,7 @@ function buildProps(node, context, props = node.props, ssr = false) {
|
|
|
14424
14462
|
(false ))) {
|
|
14425
14463
|
continue;
|
|
14426
14464
|
}
|
|
14427
|
-
properties.push(createObjectProperty(createSimpleExpression(name, true, getInnerRange(loc, 0, name.length)),
|
|
14465
|
+
properties.push(createObjectProperty(createSimpleExpression(name, true, getInnerRange(loc, 0, name.length)), createSimpleExpression(value ? value.content : '', isStatic, value ? value.loc : loc)));
|
|
14428
14466
|
}
|
|
14429
14467
|
else {
|
|
14430
14468
|
// directives
|
|
@@ -14445,7 +14483,7 @@ function buildProps(node, context, props = node.props, ssr = false) {
|
|
|
14445
14483
|
// skip v-is and :is on <component>
|
|
14446
14484
|
if (name === 'is' ||
|
|
14447
14485
|
(isVBind &&
|
|
14448
|
-
|
|
14486
|
+
isStaticArgOf(arg, 'is') &&
|
|
14449
14487
|
(isComponentTag(tag) ||
|
|
14450
14488
|
(false )))) {
|
|
14451
14489
|
continue;
|
|
@@ -14454,6 +14492,17 @@ function buildProps(node, context, props = node.props, ssr = false) {
|
|
|
14454
14492
|
if (isVOn && ssr) {
|
|
14455
14493
|
continue;
|
|
14456
14494
|
}
|
|
14495
|
+
if (
|
|
14496
|
+
// #938: elements with dynamic keys should be forced into blocks
|
|
14497
|
+
(isVBind && isStaticArgOf(arg, 'key')) ||
|
|
14498
|
+
// inline before-update hooks need to force block so that it is invoked
|
|
14499
|
+
// before children
|
|
14500
|
+
(isVOn && hasChildren && isStaticArgOf(arg, 'vue:before-update'))) {
|
|
14501
|
+
shouldUseBlock = true;
|
|
14502
|
+
}
|
|
14503
|
+
if (isVBind && isStaticArgOf(arg, 'ref') && context.scopes.vFor > 0) {
|
|
14504
|
+
properties.push(createObjectProperty(createSimpleExpression('ref_for', true), createSimpleExpression('true')));
|
|
14505
|
+
}
|
|
14457
14506
|
// special case for v-bind and v-on with no argument
|
|
14458
14507
|
if (!arg && (isVBind || isVOn)) {
|
|
14459
14508
|
hasDynamicKeys = true;
|
|
@@ -14498,6 +14547,11 @@ function buildProps(node, context, props = node.props, ssr = false) {
|
|
|
14498
14547
|
else {
|
|
14499
14548
|
// no built-in transform, this is a user custom directive.
|
|
14500
14549
|
runtimeDirectives.push(prop);
|
|
14550
|
+
// custom dirs may use beforeUpdate so they need to force blocks
|
|
14551
|
+
// to ensure before-update gets called before children update
|
|
14552
|
+
if (hasChildren) {
|
|
14553
|
+
shouldUseBlock = true;
|
|
14554
|
+
}
|
|
14501
14555
|
}
|
|
14502
14556
|
}
|
|
14503
14557
|
}
|
|
@@ -14536,7 +14590,8 @@ function buildProps(node, context, props = node.props, ssr = false) {
|
|
|
14536
14590
|
patchFlag |= 32 /* HYDRATE_EVENTS */;
|
|
14537
14591
|
}
|
|
14538
14592
|
}
|
|
14539
|
-
if (
|
|
14593
|
+
if (!shouldUseBlock &&
|
|
14594
|
+
(patchFlag === 0 || patchFlag === 32 /* HYDRATE_EVENTS */) &&
|
|
14540
14595
|
(hasRef || hasVnodeHook || runtimeDirectives.length > 0)) {
|
|
14541
14596
|
patchFlag |= 512 /* NEED_PATCH */;
|
|
14542
14597
|
}
|
|
@@ -14603,7 +14658,8 @@ function buildProps(node, context, props = node.props, ssr = false) {
|
|
|
14603
14658
|
props: propsExpression,
|
|
14604
14659
|
directives: runtimeDirectives,
|
|
14605
14660
|
patchFlag,
|
|
14606
|
-
dynamicPropNames
|
|
14661
|
+
dynamicPropNames,
|
|
14662
|
+
shouldUseBlock
|
|
14607
14663
|
};
|
|
14608
14664
|
}
|
|
14609
14665
|
// Dedupe props in an object literal.
|
|
@@ -14739,7 +14795,7 @@ function processSlotOutlet(node, context) {
|
|
|
14739
14795
|
}
|
|
14740
14796
|
}
|
|
14741
14797
|
else {
|
|
14742
|
-
if (p.name === 'bind' &&
|
|
14798
|
+
if (p.name === 'bind' && isStaticArgOf(p.arg, 'name')) {
|
|
14743
14799
|
if (p.exp)
|
|
14744
14800
|
slotName = p.exp;
|
|
14745
14801
|
}
|
|
@@ -14773,7 +14829,11 @@ const transformOn = (dir, node, context, augmentor) => {
|
|
|
14773
14829
|
let eventName;
|
|
14774
14830
|
if (arg.type === 4 /* SIMPLE_EXPRESSION */) {
|
|
14775
14831
|
if (arg.isStatic) {
|
|
14776
|
-
|
|
14832
|
+
let rawName = arg.content;
|
|
14833
|
+
// TODO deprecate @vnodeXXX usage
|
|
14834
|
+
if (rawName.startsWith('vue:')) {
|
|
14835
|
+
rawName = `vnode-${rawName.slice(4)}`;
|
|
14836
|
+
}
|
|
14777
14837
|
// for all event listeners, auto convert it to camelCase. See issue #2249
|
|
14778
14838
|
eventName = createSimpleExpression(toHandlerKey(camelize(rawName)), true, arg.loc);
|
|
14779
14839
|
}
|