@vue/compiler-sfc 2.7.13 → 2.7.15
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/compiler-sfc.js +43 -28
- package/package.json +1 -1
package/dist/compiler-sfc.js
CHANGED
|
@@ -248,9 +248,7 @@ const identity = (_) => _;
|
|
|
248
248
|
*/
|
|
249
249
|
function genStaticKeys$1(modules) {
|
|
250
250
|
return modules
|
|
251
|
-
.reduce((keys, m) =>
|
|
252
|
-
return keys.concat(m.staticKeys || []);
|
|
253
|
-
}, [])
|
|
251
|
+
.reduce((keys, m) => keys.concat(m.staticKeys || []), [])
|
|
254
252
|
.join(',');
|
|
255
253
|
}
|
|
256
254
|
/**
|
|
@@ -413,7 +411,7 @@ function parseHTML(html, options) {
|
|
|
413
411
|
continue;
|
|
414
412
|
}
|
|
415
413
|
}
|
|
416
|
-
//
|
|
414
|
+
// https://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
|
|
417
415
|
if (conditionalComment.test(html)) {
|
|
418
416
|
const conditionalEnd = html.indexOf(']>');
|
|
419
417
|
if (conditionalEnd >= 0) {
|
|
@@ -3643,13 +3641,8 @@ methodsToPatch.forEach(function (method) {
|
|
|
3643
3641
|
});
|
|
3644
3642
|
});
|
|
3645
3643
|
|
|
3646
|
-
const rawMap = new WeakMap();
|
|
3647
|
-
function isReadonly(value) {
|
|
3648
|
-
return !!(value && value.__v_isReadonly);
|
|
3649
|
-
}
|
|
3650
|
-
|
|
3651
3644
|
const arrayKeys = Object.getOwnPropertyNames(arrayMethods);
|
|
3652
|
-
const
|
|
3645
|
+
const NO_INITIAL_VALUE = {};
|
|
3653
3646
|
/**
|
|
3654
3647
|
* In some cases we may want to disable observation inside a component's
|
|
3655
3648
|
* update computation.
|
|
@@ -3706,7 +3699,7 @@ class Observer {
|
|
|
3706
3699
|
const keys = Object.keys(value);
|
|
3707
3700
|
for (let i = 0; i < keys.length; i++) {
|
|
3708
3701
|
const key = keys[i];
|
|
3709
|
-
defineReactive(value, key,
|
|
3702
|
+
defineReactive(value, key, NO_INITIAL_VALUE, undefined, shallow, mock);
|
|
3710
3703
|
}
|
|
3711
3704
|
}
|
|
3712
3705
|
}
|
|
@@ -3734,7 +3727,6 @@ function observe(value, shallow, ssrMockReactivity) {
|
|
|
3734
3727
|
(isArray(value) || isPlainObject(value)) &&
|
|
3735
3728
|
Object.isExtensible(value) &&
|
|
3736
3729
|
!value.__v_skip /* ReactiveFlags.SKIP */ &&
|
|
3737
|
-
!rawMap.has(value) &&
|
|
3738
3730
|
!isRef(value) &&
|
|
3739
3731
|
!(value instanceof VNode)) {
|
|
3740
3732
|
return new Observer(value, shallow, ssrMockReactivity);
|
|
@@ -3753,7 +3745,7 @@ function defineReactive(obj, key, val, customSetter, shallow, mock) {
|
|
|
3753
3745
|
const getter = property && property.get;
|
|
3754
3746
|
const setter = property && property.set;
|
|
3755
3747
|
if ((!getter || setter) &&
|
|
3756
|
-
(val ===
|
|
3748
|
+
(val === NO_INITIAL_VALUE || arguments.length === 2)) {
|
|
3757
3749
|
val = obj[key];
|
|
3758
3750
|
}
|
|
3759
3751
|
let childOb = !shallow && observe(val, false, mock);
|
|
@@ -3884,6 +3876,10 @@ function dependArray(value) {
|
|
|
3884
3876
|
}
|
|
3885
3877
|
}
|
|
3886
3878
|
|
|
3879
|
+
function isReadonly(value) {
|
|
3880
|
+
return !!(value && value.__v_isReadonly);
|
|
3881
|
+
}
|
|
3882
|
+
|
|
3887
3883
|
function isRef(r) {
|
|
3888
3884
|
return !!(r && r.__v_isRef === true);
|
|
3889
3885
|
}
|
|
@@ -4788,7 +4784,7 @@ function deactivateChildComponent(vm, direct) {
|
|
|
4788
4784
|
function callHook(vm, hook, args, setContext = true) {
|
|
4789
4785
|
// #7573 disable dep collection when invoking lifecycle hooks
|
|
4790
4786
|
pushTarget();
|
|
4791
|
-
const
|
|
4787
|
+
const prevInst = currentInstance;
|
|
4792
4788
|
setContext && setCurrentInstance(vm);
|
|
4793
4789
|
const handlers = vm.$options[hook];
|
|
4794
4790
|
const info = `${hook} hook`;
|
|
@@ -4800,7 +4796,9 @@ function callHook(vm, hook, args, setContext = true) {
|
|
|
4800
4796
|
if (vm._hasHookEvent) {
|
|
4801
4797
|
vm.$emit('hook:' + hook);
|
|
4802
4798
|
}
|
|
4803
|
-
|
|
4799
|
+
if (setContext) {
|
|
4800
|
+
setCurrentInstance(prevInst);
|
|
4801
|
+
}
|
|
4804
4802
|
popTarget();
|
|
4805
4803
|
}
|
|
4806
4804
|
|
|
@@ -5447,7 +5445,7 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
5447
5445
|
/**
|
|
5448
5446
|
* Helper that recursively merges two data objects together.
|
|
5449
5447
|
*/
|
|
5450
|
-
function mergeData(to, from) {
|
|
5448
|
+
function mergeData(to, from, recursive = true) {
|
|
5451
5449
|
if (!from)
|
|
5452
5450
|
return to;
|
|
5453
5451
|
let key, toVal, fromVal;
|
|
@@ -5461,7 +5459,7 @@ function mergeData(to, from) {
|
|
|
5461
5459
|
continue;
|
|
5462
5460
|
toVal = to[key];
|
|
5463
5461
|
fromVal = from[key];
|
|
5464
|
-
if (!hasOwn(to, key)) {
|
|
5462
|
+
if (!recursive || !hasOwn(to, key)) {
|
|
5465
5463
|
set(to, key, fromVal);
|
|
5466
5464
|
}
|
|
5467
5465
|
else if (toVal !== fromVal &&
|
|
@@ -5622,7 +5620,19 @@ strats.props =
|
|
|
5622
5620
|
extend(ret, childVal);
|
|
5623
5621
|
return ret;
|
|
5624
5622
|
};
|
|
5625
|
-
strats.provide =
|
|
5623
|
+
strats.provide = function (parentVal, childVal) {
|
|
5624
|
+
if (!parentVal)
|
|
5625
|
+
return childVal;
|
|
5626
|
+
return function () {
|
|
5627
|
+
const ret = Object.create(null);
|
|
5628
|
+
mergeData(ret, isFunction(parentVal) ? parentVal.call(this) : parentVal);
|
|
5629
|
+
if (childVal) {
|
|
5630
|
+
mergeData(ret, isFunction(childVal) ? childVal.call(this) : childVal, false // non-recursive
|
|
5631
|
+
);
|
|
5632
|
+
}
|
|
5633
|
+
return ret;
|
|
5634
|
+
};
|
|
5635
|
+
};
|
|
5626
5636
|
/**
|
|
5627
5637
|
* Default strategy.
|
|
5628
5638
|
*/
|
|
@@ -8458,7 +8468,10 @@ function compileScript(sfc, options = { id: '' }) {
|
|
|
8458
8468
|
}
|
|
8459
8469
|
}
|
|
8460
8470
|
if (declId) {
|
|
8461
|
-
emitIdentifier =
|
|
8471
|
+
emitIdentifier =
|
|
8472
|
+
declId.type === 'Identifier'
|
|
8473
|
+
? declId.name
|
|
8474
|
+
: scriptSetup.content.slice(declId.start, declId.end);
|
|
8462
8475
|
}
|
|
8463
8476
|
return true;
|
|
8464
8477
|
}
|
|
@@ -8835,12 +8848,12 @@ function compileScript(sfc, options = { id: '' }) {
|
|
|
8835
8848
|
else {
|
|
8836
8849
|
let start = decl.start + startOffset;
|
|
8837
8850
|
let end = decl.end + startOffset;
|
|
8838
|
-
if (i
|
|
8839
|
-
//
|
|
8851
|
+
if (i === 0) {
|
|
8852
|
+
// first one, locate the start of the next
|
|
8840
8853
|
end = node.declarations[i + 1].start + startOffset;
|
|
8841
8854
|
}
|
|
8842
8855
|
else {
|
|
8843
|
-
//
|
|
8856
|
+
// not first one, locate the end of the prev
|
|
8844
8857
|
start = node.declarations[i - 1].end + startOffset;
|
|
8845
8858
|
}
|
|
8846
8859
|
s.remove(start, end);
|
|
@@ -9014,7 +9027,7 @@ function compileScript(sfc, options = { id: '' }) {
|
|
|
9014
9027
|
// we use a default __props so that template expressions referencing props
|
|
9015
9028
|
// can use it directly
|
|
9016
9029
|
if (propsIdentifier) {
|
|
9017
|
-
s.prependLeft(startOffset, `\nconst ${propsIdentifier} = __props${propsTypeDecl ? ` as ${genSetupPropsType(propsTypeDecl)}` : ``}
|
|
9030
|
+
s.prependLeft(startOffset, `\nconst ${propsIdentifier} = __props${propsTypeDecl ? ` as ${genSetupPropsType(propsTypeDecl)}` : ``};\n`);
|
|
9018
9031
|
}
|
|
9019
9032
|
const destructureElements = hasDefineExposeCall ? [`expose`] : [];
|
|
9020
9033
|
if (emitIdentifier) {
|
|
@@ -9537,9 +9550,11 @@ function resolveTemplateUsageCheckString(sfc, isTS) {
|
|
|
9537
9550
|
if (dirRE.test(name)) {
|
|
9538
9551
|
const baseName = onRE.test(name)
|
|
9539
9552
|
? 'on'
|
|
9540
|
-
:
|
|
9541
|
-
? '
|
|
9542
|
-
:
|
|
9553
|
+
: slotRE.test(name)
|
|
9554
|
+
? 'slot'
|
|
9555
|
+
: bindRE.test(name)
|
|
9556
|
+
? 'bind'
|
|
9557
|
+
: name.replace(dirRE, '');
|
|
9543
9558
|
if (!isBuiltInDir$1(baseName)) {
|
|
9544
9559
|
code += `,v${capitalize(camelize(baseName))}`;
|
|
9545
9560
|
}
|
|
@@ -9566,7 +9581,7 @@ function processExp(exp, isTS, dir) {
|
|
|
9566
9581
|
exp = `(${exp})=>{}`;
|
|
9567
9582
|
}
|
|
9568
9583
|
else if (dir === 'on') {
|
|
9569
|
-
exp = `()=>{${exp}}`;
|
|
9584
|
+
exp = `()=>{return ${exp}}`;
|
|
9570
9585
|
}
|
|
9571
9586
|
else if (dir === 'for') {
|
|
9572
9587
|
const inMatch = exp.match(forAliasRE);
|
|
@@ -12136,7 +12151,7 @@ function genFor(el, state, altGen, altHelper) {
|
|
|
12136
12151
|
!el.key) {
|
|
12137
12152
|
state.warn(`<${el.tag} v-for="${alias} in ${exp}">: component lists rendered with ` +
|
|
12138
12153
|
`v-for should have explicit keys. ` +
|
|
12139
|
-
`See https://vuejs.org/guide/list.html#key for more info.`, el.rawAttrsMap['v-for'], true /* tip */);
|
|
12154
|
+
`See https://v2.vuejs.org/v2/guide/list.html#key for more info.`, el.rawAttrsMap['v-for'], true /* tip */);
|
|
12140
12155
|
}
|
|
12141
12156
|
el.forProcessed = true; // avoid recursion
|
|
12142
12157
|
return (`${altHelper || '_l'}((${exp}),` +
|