vue 2.7.0 → 2.7.3
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.common.dev.js +88 -75
- package/dist/vue.common.prod.js +3 -3
- package/dist/vue.esm.browser.js +88 -76
- package/dist/vue.esm.browser.min.js +3 -3
- package/dist/vue.esm.js +89 -76
- package/dist/vue.js +89 -75
- package/dist/vue.min.js +3 -3
- package/dist/vue.runtime.common.dev.js +88 -75
- package/dist/vue.runtime.common.prod.js +3 -3
- package/dist/vue.runtime.esm.js +89 -76
- package/dist/vue.runtime.js +89 -75
- package/dist/vue.runtime.min.js +3 -3
- package/dist/vue.runtime.mjs +89 -76
- package/package.json +2 -2
- package/packages/compiler-sfc/dist/compiler-sfc.js +70 -67
- package/packages/compiler-sfc/package.json +1 -1
- package/packages/compiler-sfc/src/compileScript.ts +12 -15
- package/packages/compiler-sfc/src/parseComponent.ts +6 -1
- package/packages/compiler-sfc/src/templateCompilerModules/srcset.ts +1 -1
- package/packages/compiler-sfc/test/compileScript.spec.ts +12 -0
- package/src/core/observer/index.ts +55 -56
- package/src/core/util/next-tick.ts +2 -1
- package/src/core/vdom/modules/directives.ts +2 -2
- package/src/shared/constants.ts +3 -1
- package/src/shared/util.ts +1 -1
- package/src/v3/apiSetup.ts +4 -21
- package/src/v3/apiWatch.ts +2 -2
- package/src/v3/index.ts +1 -0
- package/src/v3/reactivity/reactive.ts +13 -2
- package/src/v3/reactivity/ref.ts +40 -2
- package/types/common.d.ts +6 -0
- package/types/index.d.ts +7 -4
- package/types/jsx.d.ts +16 -2
- package/types/options.d.ts +7 -1
- package/types/v3-component-options.d.ts +162 -33
- package/types/v3-component-props.d.ts +19 -20
- package/types/v3-component-public-instance.d.ts +230 -0
- package/types/v3-define-component.d.ts +70 -12
- package/types/v3-generated.d.ts +5 -1
- package/types/v3-setup-context.d.ts +0 -6
- package/types/vnode.d.ts +15 -0
- package/types/v3-component-proxy.d.ts +0 -189
package/dist/vue.runtime.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Vue.js v2.7.
|
|
2
|
+
* Vue.js v2.7.3
|
|
3
3
|
* (c) 2014-2022 Evan You
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -306,7 +306,7 @@ function hasChanged(x, y) {
|
|
|
306
306
|
return x === 0 && 1 / x !== 1 / y;
|
|
307
307
|
}
|
|
308
308
|
else {
|
|
309
|
-
return x === x
|
|
309
|
+
return x === x || y === y;
|
|
310
310
|
}
|
|
311
311
|
}
|
|
312
312
|
|
|
@@ -324,7 +324,9 @@ var LIFECYCLE_HOOKS = [
|
|
|
324
324
|
'activated',
|
|
325
325
|
'deactivated',
|
|
326
326
|
'errorCaptured',
|
|
327
|
-
'serverPrefetch'
|
|
327
|
+
'serverPrefetch',
|
|
328
|
+
'renderTracked',
|
|
329
|
+
'renderTriggered'
|
|
328
330
|
];
|
|
329
331
|
|
|
330
332
|
var config = {
|
|
@@ -879,7 +881,7 @@ function makeReactive(target, shallow) {
|
|
|
879
881
|
warn("Target is already a ".concat(existingOb.shallow ? "" : "non-", "shallow reactive object, and cannot be converted to ").concat(shallow ? "" : "non-", "shallow."));
|
|
880
882
|
}
|
|
881
883
|
}
|
|
882
|
-
var ob = observe(target, shallow);
|
|
884
|
+
var ob = observe(target, shallow, isServerRendering() /* ssr mock reactivity */);
|
|
883
885
|
if (process.env.NODE_ENV !== 'production' && !ob) {
|
|
884
886
|
if (target == null || isPrimitive(target)) {
|
|
885
887
|
warn("value cannot be made reactive: ".concat(String(target)));
|
|
@@ -941,7 +943,7 @@ function createRef(rawValue, shallow) {
|
|
|
941
943
|
var ref = {};
|
|
942
944
|
def(ref, RefFlag, true);
|
|
943
945
|
def(ref, "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */, true);
|
|
944
|
-
ref
|
|
946
|
+
def(ref, 'dep', defineReactive(ref, 'value', rawValue, null, shallow, isServerRendering()));
|
|
945
947
|
return ref;
|
|
946
948
|
}
|
|
947
949
|
function triggerRef(ref) {
|
|
@@ -963,6 +965,33 @@ function triggerRef(ref) {
|
|
|
963
965
|
function unref(ref) {
|
|
964
966
|
return isRef(ref) ? ref.value : ref;
|
|
965
967
|
}
|
|
968
|
+
function proxyRefs(objectWithRefs) {
|
|
969
|
+
if (isReactive(objectWithRefs)) {
|
|
970
|
+
return objectWithRefs;
|
|
971
|
+
}
|
|
972
|
+
var proxy = {};
|
|
973
|
+
var keys = Object.keys(objectWithRefs);
|
|
974
|
+
for (var i = 0; i < keys.length; i++) {
|
|
975
|
+
proxyWithRefUnwrap(proxy, objectWithRefs, keys[i]);
|
|
976
|
+
}
|
|
977
|
+
return proxy;
|
|
978
|
+
}
|
|
979
|
+
function proxyWithRefUnwrap(target, source, key) {
|
|
980
|
+
Object.defineProperty(target, key, {
|
|
981
|
+
enumerable: true,
|
|
982
|
+
configurable: true,
|
|
983
|
+
get: function () { return unref(source[key]); },
|
|
984
|
+
set: function (value) {
|
|
985
|
+
var oldValue = source[key];
|
|
986
|
+
if (isRef(oldValue) && !isRef(value)) {
|
|
987
|
+
oldValue.value = value;
|
|
988
|
+
}
|
|
989
|
+
else {
|
|
990
|
+
source[key] = value;
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
});
|
|
994
|
+
}
|
|
966
995
|
function customRef(factory) {
|
|
967
996
|
var dep = new Dep();
|
|
968
997
|
var _a = factory(function () {
|
|
@@ -2380,7 +2409,9 @@ function initSetup(vm) {
|
|
|
2380
2409
|
// exposed for compiled render fn
|
|
2381
2410
|
var proxy = (vm._setupProxy = {});
|
|
2382
2411
|
for (var key in setupResult) {
|
|
2383
|
-
|
|
2412
|
+
if (key !== '__sfc') {
|
|
2413
|
+
proxyWithRefUnwrap(proxy, setupResult, key);
|
|
2414
|
+
}
|
|
2384
2415
|
}
|
|
2385
2416
|
}
|
|
2386
2417
|
}
|
|
@@ -2389,20 +2420,6 @@ function initSetup(vm) {
|
|
|
2389
2420
|
}
|
|
2390
2421
|
}
|
|
2391
2422
|
}
|
|
2392
|
-
function proxyWithRefUnwrap(target, source, key) {
|
|
2393
|
-
Object.defineProperty(target, key, {
|
|
2394
|
-
enumerable: true,
|
|
2395
|
-
configurable: true,
|
|
2396
|
-
get: function () {
|
|
2397
|
-
var raw = source[key];
|
|
2398
|
-
return isRef(raw) ? raw.value : raw;
|
|
2399
|
-
},
|
|
2400
|
-
set: function (newVal) {
|
|
2401
|
-
var raw = source[key];
|
|
2402
|
-
isRef(raw) ? (raw.value = newVal) : (source[key] = newVal);
|
|
2403
|
-
}
|
|
2404
|
-
});
|
|
2405
|
-
}
|
|
2406
2423
|
function createSetupContext(vm) {
|
|
2407
2424
|
var exposeCalled = false;
|
|
2408
2425
|
return {
|
|
@@ -4198,7 +4215,7 @@ var onServerPrefetch = createLifeCycle('serverPrefetch');
|
|
|
4198
4215
|
var onRenderTracked = createLifeCycle('renderTracked');
|
|
4199
4216
|
var onRenderTriggered = createLifeCycle('renderTriggered');
|
|
4200
4217
|
|
|
4201
|
-
var version = '2.7.
|
|
4218
|
+
var version = '2.7.3';
|
|
4202
4219
|
/**
|
|
4203
4220
|
* @internal type is manually declared in <root>/types/v3-define-component.d.ts
|
|
4204
4221
|
*/
|
|
@@ -4216,6 +4233,13 @@ var shouldObserve = true;
|
|
|
4216
4233
|
function toggleObserving(value) {
|
|
4217
4234
|
shouldObserve = value;
|
|
4218
4235
|
}
|
|
4236
|
+
// ssr mock dep
|
|
4237
|
+
var mockDep = {
|
|
4238
|
+
notify: noop,
|
|
4239
|
+
depend: noop,
|
|
4240
|
+
addSub: noop,
|
|
4241
|
+
removeSub: noop
|
|
4242
|
+
};
|
|
4219
4243
|
/**
|
|
4220
4244
|
* Observer class that is attached to each observed
|
|
4221
4245
|
* object. Once attached, the observer converts the target
|
|
@@ -4223,78 +4247,63 @@ function toggleObserving(value) {
|
|
|
4223
4247
|
* collect dependencies and dispatch updates.
|
|
4224
4248
|
*/
|
|
4225
4249
|
var Observer = /** @class */ (function () {
|
|
4226
|
-
function Observer(value, shallow) {
|
|
4250
|
+
function Observer(value, shallow, mock) {
|
|
4227
4251
|
if (shallow === void 0) { shallow = false; }
|
|
4252
|
+
if (mock === void 0) { mock = false; }
|
|
4228
4253
|
this.value = value;
|
|
4229
4254
|
this.shallow = shallow;
|
|
4255
|
+
this.mock = mock;
|
|
4230
4256
|
// this.value = value
|
|
4231
|
-
this.dep = new Dep();
|
|
4257
|
+
this.dep = mock ? mockDep : new Dep();
|
|
4232
4258
|
this.vmCount = 0;
|
|
4233
4259
|
def(value, '__ob__', this);
|
|
4234
4260
|
if (isArray(value)) {
|
|
4235
|
-
if (
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
4261
|
+
if (!mock) {
|
|
4262
|
+
if (hasProto) {
|
|
4263
|
+
value.__proto__ = arrayMethods;
|
|
4264
|
+
/* eslint-enable no-proto */
|
|
4265
|
+
}
|
|
4266
|
+
else {
|
|
4267
|
+
for (var i = 0, l = arrayKeys.length; i < l; i++) {
|
|
4268
|
+
var key = arrayKeys[i];
|
|
4269
|
+
def(value, key, arrayMethods[key]);
|
|
4270
|
+
}
|
|
4271
|
+
}
|
|
4240
4272
|
}
|
|
4241
4273
|
if (!shallow) {
|
|
4242
4274
|
this.observeArray(value);
|
|
4243
4275
|
}
|
|
4244
4276
|
}
|
|
4245
4277
|
else {
|
|
4246
|
-
|
|
4278
|
+
/**
|
|
4279
|
+
* Walk through all properties and convert them into
|
|
4280
|
+
* getter/setters. This method should only be called when
|
|
4281
|
+
* value type is Object.
|
|
4282
|
+
*/
|
|
4283
|
+
var keys = Object.keys(value);
|
|
4284
|
+
for (var i = 0; i < keys.length; i++) {
|
|
4285
|
+
var key = keys[i];
|
|
4286
|
+
defineReactive(value, key, NO_INIITIAL_VALUE, undefined, shallow, mock);
|
|
4287
|
+
}
|
|
4247
4288
|
}
|
|
4248
4289
|
}
|
|
4249
|
-
/**
|
|
4250
|
-
* Walk through all properties and convert them into
|
|
4251
|
-
* getter/setters. This method should only be called when
|
|
4252
|
-
* value type is Object.
|
|
4253
|
-
*/
|
|
4254
|
-
Observer.prototype.walk = function (obj, shallow) {
|
|
4255
|
-
var keys = Object.keys(obj);
|
|
4256
|
-
for (var i = 0; i < keys.length; i++) {
|
|
4257
|
-
var key = keys[i];
|
|
4258
|
-
defineReactive(obj, key, NO_INIITIAL_VALUE, undefined, shallow);
|
|
4259
|
-
}
|
|
4260
|
-
};
|
|
4261
4290
|
/**
|
|
4262
4291
|
* Observe a list of Array items.
|
|
4263
4292
|
*/
|
|
4264
|
-
Observer.prototype.observeArray = function (
|
|
4265
|
-
for (var i = 0, l =
|
|
4266
|
-
observe(
|
|
4293
|
+
Observer.prototype.observeArray = function (value) {
|
|
4294
|
+
for (var i = 0, l = value.length; i < l; i++) {
|
|
4295
|
+
observe(value[i], false, this.mock);
|
|
4267
4296
|
}
|
|
4268
4297
|
};
|
|
4269
4298
|
return Observer;
|
|
4270
4299
|
}());
|
|
4271
4300
|
// helpers
|
|
4272
|
-
/**
|
|
4273
|
-
* Augment a target Object or Array by intercepting
|
|
4274
|
-
* the prototype chain using __proto__
|
|
4275
|
-
*/
|
|
4276
|
-
function protoAugment(target, src) {
|
|
4277
|
-
/* eslint-disable no-proto */
|
|
4278
|
-
target.__proto__ = src;
|
|
4279
|
-
/* eslint-enable no-proto */
|
|
4280
|
-
}
|
|
4281
|
-
/**
|
|
4282
|
-
* Augment a target Object or Array by defining
|
|
4283
|
-
* hidden properties.
|
|
4284
|
-
*/
|
|
4285
|
-
/* istanbul ignore next */
|
|
4286
|
-
function copyAugment(target, src, keys) {
|
|
4287
|
-
for (var i = 0, l = keys.length; i < l; i++) {
|
|
4288
|
-
var key = keys[i];
|
|
4289
|
-
def(target, key, src[key]);
|
|
4290
|
-
}
|
|
4291
|
-
}
|
|
4292
4301
|
/**
|
|
4293
4302
|
* Attempt to create an observer instance for a value,
|
|
4294
4303
|
* returns the new observer if successfully observed,
|
|
4295
4304
|
* or the existing observer if the value already has one.
|
|
4296
4305
|
*/
|
|
4297
|
-
function observe(value, shallow) {
|
|
4306
|
+
function observe(value, shallow, ssrMockReactivity) {
|
|
4298
4307
|
if (!isObject(value) || isRef(value) || value instanceof VNode) {
|
|
4299
4308
|
return;
|
|
4300
4309
|
}
|
|
@@ -4303,18 +4312,18 @@ function observe(value, shallow) {
|
|
|
4303
4312
|
ob = value.__ob__;
|
|
4304
4313
|
}
|
|
4305
4314
|
else if (shouldObserve &&
|
|
4306
|
-
!isServerRendering() &&
|
|
4315
|
+
(ssrMockReactivity || !isServerRendering()) &&
|
|
4307
4316
|
(isArray(value) || isPlainObject(value)) &&
|
|
4308
4317
|
Object.isExtensible(value) &&
|
|
4309
|
-
!value.__v_skip) {
|
|
4310
|
-
ob = new Observer(value, shallow);
|
|
4318
|
+
!value.__v_skip /* ReactiveFlags.SKIP */) {
|
|
4319
|
+
ob = new Observer(value, shallow, ssrMockReactivity);
|
|
4311
4320
|
}
|
|
4312
4321
|
return ob;
|
|
4313
4322
|
}
|
|
4314
4323
|
/**
|
|
4315
4324
|
* Define a reactive property on an Object.
|
|
4316
4325
|
*/
|
|
4317
|
-
function defineReactive(obj, key, val, customSetter, shallow) {
|
|
4326
|
+
function defineReactive(obj, key, val, customSetter, shallow, mock) {
|
|
4318
4327
|
var dep = new Dep();
|
|
4319
4328
|
var property = Object.getOwnPropertyDescriptor(obj, key);
|
|
4320
4329
|
if (property && property.configurable === false) {
|
|
@@ -4327,7 +4336,7 @@ function defineReactive(obj, key, val, customSetter, shallow) {
|
|
|
4327
4336
|
(val === NO_INIITIAL_VALUE || arguments.length === 2)) {
|
|
4328
4337
|
val = obj[key];
|
|
4329
4338
|
}
|
|
4330
|
-
var childOb = !shallow && observe(val);
|
|
4339
|
+
var childOb = !shallow && observe(val, false, mock);
|
|
4331
4340
|
Object.defineProperty(obj, key, {
|
|
4332
4341
|
enumerable: true,
|
|
4333
4342
|
configurable: true,
|
|
@@ -4351,7 +4360,7 @@ function defineReactive(obj, key, val, customSetter, shallow) {
|
|
|
4351
4360
|
}
|
|
4352
4361
|
}
|
|
4353
4362
|
}
|
|
4354
|
-
return isRef(value) ? value.value : value;
|
|
4363
|
+
return isRef(value) && !shallow ? value.value : value;
|
|
4355
4364
|
},
|
|
4356
4365
|
set: function reactiveSetter(newVal) {
|
|
4357
4366
|
var value = getter ? getter.call(obj) : val;
|
|
@@ -4375,7 +4384,7 @@ function defineReactive(obj, key, val, customSetter, shallow) {
|
|
|
4375
4384
|
else {
|
|
4376
4385
|
val = newVal;
|
|
4377
4386
|
}
|
|
4378
|
-
childOb = !shallow && observe(newVal);
|
|
4387
|
+
childOb = !shallow && observe(newVal, false, mock);
|
|
4379
4388
|
if (process.env.NODE_ENV !== 'production') {
|
|
4380
4389
|
dep.notify({
|
|
4381
4390
|
type: "set" /* TriggerOpTypes.SET */,
|
|
@@ -4400,16 +4409,20 @@ function set(target, key, val) {
|
|
|
4400
4409
|
process.env.NODE_ENV !== 'production' && warn("Set operation on key \"".concat(key, "\" failed: target is readonly."));
|
|
4401
4410
|
return;
|
|
4402
4411
|
}
|
|
4412
|
+
var ob = target.__ob__;
|
|
4403
4413
|
if (isArray(target) && isValidArrayIndex(key)) {
|
|
4404
4414
|
target.length = Math.max(target.length, key);
|
|
4405
4415
|
target.splice(key, 1, val);
|
|
4416
|
+
// when mocking for SSR, array methods are not hijacked
|
|
4417
|
+
if (!ob.shallow && ob.mock) {
|
|
4418
|
+
observe(val, false, true);
|
|
4419
|
+
}
|
|
4406
4420
|
return val;
|
|
4407
4421
|
}
|
|
4408
4422
|
if (key in target && !(key in Object.prototype)) {
|
|
4409
4423
|
target[key] = val;
|
|
4410
4424
|
return val;
|
|
4411
4425
|
}
|
|
4412
|
-
var ob = target.__ob__;
|
|
4413
4426
|
if (target._isVue || (ob && ob.vmCount)) {
|
|
4414
4427
|
process.env.NODE_ENV !== 'production' &&
|
|
4415
4428
|
warn('Avoid adding reactive properties to a Vue instance or its root $data ' +
|
|
@@ -4420,7 +4433,7 @@ function set(target, key, val) {
|
|
|
4420
4433
|
target[key] = val;
|
|
4421
4434
|
return val;
|
|
4422
4435
|
}
|
|
4423
|
-
defineReactive(ob.value, key, val);
|
|
4436
|
+
defineReactive(ob.value, key, val, undefined, ob.shallow, ob.mock);
|
|
4424
4437
|
if (process.env.NODE_ENV !== 'production') {
|
|
4425
4438
|
ob.dep.notify({
|
|
4426
4439
|
type: "add" /* TriggerOpTypes.ADD */,
|
|
@@ -7042,7 +7055,7 @@ function normalizeDirectives(dirs, vm) {
|
|
|
7042
7055
|
}
|
|
7043
7056
|
res[getRawDirName(dir)] = dir;
|
|
7044
7057
|
if (vm._setupState && vm._setupState.__sfc) {
|
|
7045
|
-
dir.def = resolveAsset(vm, '_setupState', 'v-' + dir.name);
|
|
7058
|
+
dir.def = dir.def || resolveAsset(vm, '_setupState', 'v-' + dir.name);
|
|
7046
7059
|
}
|
|
7047
7060
|
dir.def = dir.def || resolveAsset(vm.$options, 'directives', dir.name, true);
|
|
7048
7061
|
}
|
|
@@ -8589,4 +8602,4 @@ if (inBrowser) {
|
|
|
8589
8602
|
}, 0);
|
|
8590
8603
|
}
|
|
8591
8604
|
|
|
8592
|
-
export { EffectScope, computed, customRef, Vue as default, defineComponent, del, effectScope, getCurrentInstance, getCurrentScope, h, inject, isProxy, isReactive, isReadonly, isRef, isShallow, markRaw, mergeDefaults, nextTick, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, provide, reactive, readonly, ref$1 as ref, set, shallowReactive, shallowReadonly, shallowRef, toRaw, toRef, toRefs, triggerRef, unref, useAttrs, useCssModule, useCssVars, useSlots, version, watch, watchEffect, watchPostEffect, watchSyncEffect };
|
|
8605
|
+
export { EffectScope, computed, customRef, Vue as default, defineComponent, del, effectScope, getCurrentInstance, getCurrentScope, h, inject, isProxy, isReactive, isReadonly, isRef, isShallow, markRaw, mergeDefaults, nextTick, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, provide, proxyRefs, reactive, readonly, ref$1 as ref, set, shallowReactive, shallowReadonly, shallowRef, toRaw, toRef, toRefs, triggerRef, unref, useAttrs, useCssModule, useCssVars, useSlots, version, watch, watchEffect, watchPostEffect, watchSyncEffect };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.3",
|
|
4
4
|
"packageManager": "pnpm@7.1.0",
|
|
5
5
|
"description": "Reactive, component-oriented view layer for modern web interfaces.",
|
|
6
6
|
"main": "dist/vue.runtime.common.js",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
},
|
|
61
61
|
"homepage": "https://github.com/vuejs/vue#readme",
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@vue/compiler-sfc": "2.7.
|
|
63
|
+
"@vue/compiler-sfc": "2.7.3",
|
|
64
64
|
"csstype": "^3.1.0"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
@@ -329,7 +329,7 @@ function hasChanged(x, y) {
|
|
|
329
329
|
return x === 0 && 1 / x !== 1 / y;
|
|
330
330
|
}
|
|
331
331
|
else {
|
|
332
|
-
return x === x
|
|
332
|
+
return x === x || y === y;
|
|
333
333
|
}
|
|
334
334
|
}
|
|
335
335
|
|
|
@@ -646,6 +646,7 @@ const DEFAULT_FILENAME = 'anonymous.vue';
|
|
|
646
646
|
const splitRE$1 = /\r?\n/g;
|
|
647
647
|
const replaceRE = /./g;
|
|
648
648
|
const isSpecialTag = makeMap('script,style,template', true);
|
|
649
|
+
const isNeedIndentLang = makeMap('pug,jade');
|
|
649
650
|
/**
|
|
650
651
|
* Parse a single-file component (*.vue) file into an SFC Descriptor Object.
|
|
651
652
|
*/
|
|
@@ -740,7 +741,9 @@ function parseComponent(source, options = {}) {
|
|
|
740
741
|
if (depth === 1 && currentBlock) {
|
|
741
742
|
currentBlock.end = start;
|
|
742
743
|
let text = source.slice(currentBlock.start, currentBlock.end);
|
|
743
|
-
if (options.deindent
|
|
744
|
+
if (options.deindent ||
|
|
745
|
+
// certain langs like pug are indent sensitive, preserve old behavior
|
|
746
|
+
(currentBlock.lang && isNeedIndentLang(currentBlock.lang))) {
|
|
744
747
|
text = deIndent(text);
|
|
745
748
|
}
|
|
746
749
|
// pad content so that linters and pre-processors can output correct
|
|
@@ -3347,7 +3350,9 @@ const LIFECYCLE_HOOKS = [
|
|
|
3347
3350
|
'activated',
|
|
3348
3351
|
'deactivated',
|
|
3349
3352
|
'errorCaptured',
|
|
3350
|
-
'serverPrefetch'
|
|
3353
|
+
'serverPrefetch',
|
|
3354
|
+
'renderTracked',
|
|
3355
|
+
'renderTriggered'
|
|
3351
3356
|
];
|
|
3352
3357
|
|
|
3353
3358
|
var config = {
|
|
@@ -5186,6 +5191,13 @@ let shouldObserve = true;
|
|
|
5186
5191
|
function toggleObserving(value) {
|
|
5187
5192
|
shouldObserve = value;
|
|
5188
5193
|
}
|
|
5194
|
+
// ssr mock dep
|
|
5195
|
+
const mockDep = {
|
|
5196
|
+
notify: noop,
|
|
5197
|
+
depend: noop,
|
|
5198
|
+
addSub: noop,
|
|
5199
|
+
removeSub: noop
|
|
5200
|
+
};
|
|
5189
5201
|
/**
|
|
5190
5202
|
* Observer class that is attached to each observed
|
|
5191
5203
|
* object. Once attached, the observer converts the target
|
|
@@ -5193,76 +5205,60 @@ function toggleObserving(value) {
|
|
|
5193
5205
|
* collect dependencies and dispatch updates.
|
|
5194
5206
|
*/
|
|
5195
5207
|
class Observer {
|
|
5196
|
-
constructor(value, shallow = false) {
|
|
5208
|
+
constructor(value, shallow = false, mock = false) {
|
|
5197
5209
|
this.value = value;
|
|
5198
5210
|
this.shallow = shallow;
|
|
5211
|
+
this.mock = mock;
|
|
5199
5212
|
// this.value = value
|
|
5200
|
-
this.dep = new Dep();
|
|
5213
|
+
this.dep = mock ? mockDep : new Dep();
|
|
5201
5214
|
this.vmCount = 0;
|
|
5202
5215
|
def(value, '__ob__', this);
|
|
5203
5216
|
if (isArray(value)) {
|
|
5204
|
-
if (
|
|
5205
|
-
|
|
5206
|
-
|
|
5207
|
-
|
|
5208
|
-
|
|
5217
|
+
if (!mock) {
|
|
5218
|
+
if (hasProto) {
|
|
5219
|
+
value.__proto__ = arrayMethods;
|
|
5220
|
+
/* eslint-enable no-proto */
|
|
5221
|
+
}
|
|
5222
|
+
else {
|
|
5223
|
+
for (let i = 0, l = arrayKeys.length; i < l; i++) {
|
|
5224
|
+
const key = arrayKeys[i];
|
|
5225
|
+
def(value, key, arrayMethods[key]);
|
|
5226
|
+
}
|
|
5227
|
+
}
|
|
5209
5228
|
}
|
|
5210
5229
|
if (!shallow) {
|
|
5211
5230
|
this.observeArray(value);
|
|
5212
5231
|
}
|
|
5213
5232
|
}
|
|
5214
5233
|
else {
|
|
5215
|
-
|
|
5216
|
-
|
|
5217
|
-
|
|
5218
|
-
|
|
5219
|
-
|
|
5220
|
-
|
|
5221
|
-
|
|
5222
|
-
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
-
for (let i = 0; i < keys.length; i++) {
|
|
5226
|
-
const key = keys[i];
|
|
5227
|
-
defineReactive(obj, key, NO_INIITIAL_VALUE, undefined, shallow);
|
|
5234
|
+
/**
|
|
5235
|
+
* Walk through all properties and convert them into
|
|
5236
|
+
* getter/setters. This method should only be called when
|
|
5237
|
+
* value type is Object.
|
|
5238
|
+
*/
|
|
5239
|
+
const keys = Object.keys(value);
|
|
5240
|
+
for (let i = 0; i < keys.length; i++) {
|
|
5241
|
+
const key = keys[i];
|
|
5242
|
+
defineReactive(value, key, NO_INIITIAL_VALUE, undefined, shallow, mock);
|
|
5243
|
+
}
|
|
5228
5244
|
}
|
|
5229
5245
|
}
|
|
5230
5246
|
/**
|
|
5231
5247
|
* Observe a list of Array items.
|
|
5232
5248
|
*/
|
|
5233
|
-
observeArray(
|
|
5234
|
-
for (let i = 0, l =
|
|
5235
|
-
observe(
|
|
5249
|
+
observeArray(value) {
|
|
5250
|
+
for (let i = 0, l = value.length; i < l; i++) {
|
|
5251
|
+
observe(value[i], false, this.mock);
|
|
5236
5252
|
}
|
|
5237
5253
|
}
|
|
5238
5254
|
}
|
|
5239
5255
|
// helpers
|
|
5240
|
-
/**
|
|
5241
|
-
* Augment a target Object or Array by intercepting
|
|
5242
|
-
* the prototype chain using __proto__
|
|
5243
|
-
*/
|
|
5244
|
-
function protoAugment(target, src) {
|
|
5245
|
-
/* eslint-disable no-proto */
|
|
5246
|
-
target.__proto__ = src;
|
|
5247
|
-
/* eslint-enable no-proto */
|
|
5248
|
-
}
|
|
5249
|
-
/**
|
|
5250
|
-
* Augment a target Object or Array by defining
|
|
5251
|
-
* hidden properties.
|
|
5252
|
-
*/
|
|
5253
|
-
/* istanbul ignore next */
|
|
5254
|
-
function copyAugment(target, src, keys) {
|
|
5255
|
-
for (let i = 0, l = keys.length; i < l; i++) {
|
|
5256
|
-
const key = keys[i];
|
|
5257
|
-
def(target, key, src[key]);
|
|
5258
|
-
}
|
|
5259
|
-
}
|
|
5260
5256
|
/**
|
|
5261
5257
|
* Attempt to create an observer instance for a value,
|
|
5262
5258
|
* returns the new observer if successfully observed,
|
|
5263
5259
|
* or the existing observer if the value already has one.
|
|
5264
5260
|
*/
|
|
5265
|
-
function observe(value, shallow) {
|
|
5261
|
+
function observe(value, shallow, ssrMockReactivity) {
|
|
5266
5262
|
if (!isObject$1(value) || isRef(value) || value instanceof VNode) {
|
|
5267
5263
|
return;
|
|
5268
5264
|
}
|
|
@@ -5271,18 +5267,18 @@ function observe(value, shallow) {
|
|
|
5271
5267
|
ob = value.__ob__;
|
|
5272
5268
|
}
|
|
5273
5269
|
else if (shouldObserve &&
|
|
5274
|
-
!isServerRendering() &&
|
|
5270
|
+
(ssrMockReactivity || !isServerRendering()) &&
|
|
5275
5271
|
(isArray(value) || isPlainObject(value)) &&
|
|
5276
5272
|
Object.isExtensible(value) &&
|
|
5277
|
-
!value.__v_skip) {
|
|
5278
|
-
ob = new Observer(value, shallow);
|
|
5273
|
+
!value.__v_skip /* ReactiveFlags.SKIP */) {
|
|
5274
|
+
ob = new Observer(value, shallow, ssrMockReactivity);
|
|
5279
5275
|
}
|
|
5280
5276
|
return ob;
|
|
5281
5277
|
}
|
|
5282
5278
|
/**
|
|
5283
5279
|
* Define a reactive property on an Object.
|
|
5284
5280
|
*/
|
|
5285
|
-
function defineReactive(obj, key, val, customSetter, shallow) {
|
|
5281
|
+
function defineReactive(obj, key, val, customSetter, shallow, mock) {
|
|
5286
5282
|
const dep = new Dep();
|
|
5287
5283
|
const property = Object.getOwnPropertyDescriptor(obj, key);
|
|
5288
5284
|
if (property && property.configurable === false) {
|
|
@@ -5295,7 +5291,7 @@ function defineReactive(obj, key, val, customSetter, shallow) {
|
|
|
5295
5291
|
(val === NO_INIITIAL_VALUE || arguments.length === 2)) {
|
|
5296
5292
|
val = obj[key];
|
|
5297
5293
|
}
|
|
5298
|
-
let childOb = !shallow && observe(val);
|
|
5294
|
+
let childOb = !shallow && observe(val, false, mock);
|
|
5299
5295
|
Object.defineProperty(obj, key, {
|
|
5300
5296
|
enumerable: true,
|
|
5301
5297
|
configurable: true,
|
|
@@ -5319,7 +5315,7 @@ function defineReactive(obj, key, val, customSetter, shallow) {
|
|
|
5319
5315
|
}
|
|
5320
5316
|
}
|
|
5321
5317
|
}
|
|
5322
|
-
return isRef(value) ? value.value : value;
|
|
5318
|
+
return isRef(value) && !shallow ? value.value : value;
|
|
5323
5319
|
},
|
|
5324
5320
|
set: function reactiveSetter(newVal) {
|
|
5325
5321
|
const value = getter ? getter.call(obj) : val;
|
|
@@ -5343,7 +5339,7 @@ function defineReactive(obj, key, val, customSetter, shallow) {
|
|
|
5343
5339
|
else {
|
|
5344
5340
|
val = newVal;
|
|
5345
5341
|
}
|
|
5346
|
-
childOb = !shallow && observe(newVal);
|
|
5342
|
+
childOb = !shallow && observe(newVal, false, mock);
|
|
5347
5343
|
if (process.env.NODE_ENV !== 'production') {
|
|
5348
5344
|
dep.notify({
|
|
5349
5345
|
type: "set" /* TriggerOpTypes.SET */,
|
|
@@ -5368,16 +5364,20 @@ function set(target, key, val) {
|
|
|
5368
5364
|
process.env.NODE_ENV !== 'production' && warn$3(`Set operation on key "${key}" failed: target is readonly.`);
|
|
5369
5365
|
return;
|
|
5370
5366
|
}
|
|
5367
|
+
const ob = target.__ob__;
|
|
5371
5368
|
if (isArray(target) && isValidArrayIndex(key)) {
|
|
5372
5369
|
target.length = Math.max(target.length, key);
|
|
5373
5370
|
target.splice(key, 1, val);
|
|
5371
|
+
// when mocking for SSR, array methods are not hijacked
|
|
5372
|
+
if (!ob.shallow && ob.mock) {
|
|
5373
|
+
observe(val, false, true);
|
|
5374
|
+
}
|
|
5374
5375
|
return val;
|
|
5375
5376
|
}
|
|
5376
5377
|
if (key in target && !(key in Object.prototype)) {
|
|
5377
5378
|
target[key] = val;
|
|
5378
5379
|
return val;
|
|
5379
5380
|
}
|
|
5380
|
-
const ob = target.__ob__;
|
|
5381
5381
|
if (target._isVue || (ob && ob.vmCount)) {
|
|
5382
5382
|
process.env.NODE_ENV !== 'production' &&
|
|
5383
5383
|
warn$3('Avoid adding reactive properties to a Vue instance or its root $data ' +
|
|
@@ -5388,7 +5388,7 @@ function set(target, key, val) {
|
|
|
5388
5388
|
target[key] = val;
|
|
5389
5389
|
return val;
|
|
5390
5390
|
}
|
|
5391
|
-
defineReactive(ob.value, key, val);
|
|
5391
|
+
defineReactive(ob.value, key, val, undefined, ob.shallow, ob.mock);
|
|
5392
5392
|
if (process.env.NODE_ENV !== 'production') {
|
|
5393
5393
|
ob.dep.notify({
|
|
5394
5394
|
type: "add" /* TriggerOpTypes.ADD */,
|
|
@@ -8360,18 +8360,14 @@ function compileScript(sfc, options = { id: '' }) {
|
|
|
8360
8360
|
function error(msg, node, end = node.end + startOffset) {
|
|
8361
8361
|
throw new Error(`[@vue/compiler-sfc] ${msg}\n\n${filename}\n${generateCodeFrame(source, node.start + startOffset, end)}`);
|
|
8362
8362
|
}
|
|
8363
|
-
function registerUserImport(source, local, imported, isType, isFromSetup
|
|
8363
|
+
function registerUserImport(source, local, imported, isType, isFromSetup) {
|
|
8364
8364
|
if (source === 'vue' && imported) {
|
|
8365
8365
|
userImportAlias[imported] = local;
|
|
8366
8366
|
}
|
|
8367
8367
|
// template usage check is only needed in non-inline mode, so we can skip
|
|
8368
8368
|
// the work if inlineTemplate is true.
|
|
8369
|
-
let isUsedInTemplate =
|
|
8370
|
-
if (
|
|
8371
|
-
isTS &&
|
|
8372
|
-
sfc.template &&
|
|
8373
|
-
!sfc.template.src &&
|
|
8374
|
-
!sfc.template.lang) {
|
|
8369
|
+
let isUsedInTemplate = true;
|
|
8370
|
+
if (isTS && sfc.template && !sfc.template.src && !sfc.template.lang) {
|
|
8375
8371
|
isUsedInTemplate = isImportUsed(local, sfc);
|
|
8376
8372
|
}
|
|
8377
8373
|
userImports[local] = {
|
|
@@ -8622,7 +8618,7 @@ function compileScript(sfc, options = { id: '' }) {
|
|
|
8622
8618
|
specifier.imported.name;
|
|
8623
8619
|
registerUserImport(node.source.value, specifier.local.name, imported, node.importKind === 'type' ||
|
|
8624
8620
|
(specifier.type === 'ImportSpecifier' &&
|
|
8625
|
-
specifier.importKind === 'type'), false
|
|
8621
|
+
specifier.importKind === 'type'), false);
|
|
8626
8622
|
}
|
|
8627
8623
|
}
|
|
8628
8624
|
else if (node.type === 'ExportDefaultDeclaration') {
|
|
@@ -8791,7 +8787,7 @@ function compileScript(sfc, options = { id: '' }) {
|
|
|
8791
8787
|
else {
|
|
8792
8788
|
registerUserImport(source, local, imported, node.importKind === 'type' ||
|
|
8793
8789
|
(specifier.type === 'ImportSpecifier' &&
|
|
8794
|
-
specifier.importKind === 'type'), true
|
|
8790
|
+
specifier.importKind === 'type'), true);
|
|
8795
8791
|
}
|
|
8796
8792
|
}
|
|
8797
8793
|
if (node.specifiers.length && removed === node.specifiers.length) {
|
|
@@ -9526,7 +9522,11 @@ function resolveTemplateUsageCheckString(sfc) {
|
|
|
9526
9522
|
for (let i = 0; i < attrs.length; i++) {
|
|
9527
9523
|
const { name, value } = attrs[i];
|
|
9528
9524
|
if (dirRE.test(name)) {
|
|
9529
|
-
const baseName =
|
|
9525
|
+
const baseName = onRE.test(name)
|
|
9526
|
+
? 'on'
|
|
9527
|
+
: bindRE.test(name)
|
|
9528
|
+
? 'bind'
|
|
9529
|
+
: name.replace(dirRE, '');
|
|
9530
9530
|
if (!isBuiltInDir$1(baseName)) {
|
|
9531
9531
|
code += `,v${capitalize(camelize(baseName))}`;
|
|
9532
9532
|
}
|
|
@@ -9552,6 +9552,9 @@ function processExp(exp, dir) {
|
|
|
9552
9552
|
if (dir === 'slot') {
|
|
9553
9553
|
exp = `(${exp})=>{}`;
|
|
9554
9554
|
}
|
|
9555
|
+
else if (dir === 'on') {
|
|
9556
|
+
exp = `()=>{${exp}}`;
|
|
9557
|
+
}
|
|
9555
9558
|
else if (dir === 'for') {
|
|
9556
9559
|
const inMatch = exp.match(forAliasRE);
|
|
9557
9560
|
if (inMatch) {
|
|
@@ -9807,7 +9810,7 @@ function transform(node, transformAssetUrlsOptions) {
|
|
|
9807
9810
|
return;
|
|
9808
9811
|
}
|
|
9809
9812
|
const imageCandidates = value
|
|
9810
|
-
.
|
|
9813
|
+
.slice(1, -1)
|
|
9811
9814
|
.split(',')
|
|
9812
9815
|
.map(s => {
|
|
9813
9816
|
// The attribute value arrives here with all whitespace, except
|