@vue/compiler-sfc 2.7.1 → 2.7.4
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 +56 -55
- package/package.json +1 -1
package/dist/compiler-sfc.js
CHANGED
|
@@ -740,7 +740,11 @@ function parseComponent(source, options = {}) {
|
|
|
740
740
|
if (depth === 1 && currentBlock) {
|
|
741
741
|
currentBlock.end = start;
|
|
742
742
|
let text = source.slice(currentBlock.start, currentBlock.end);
|
|
743
|
-
if (options.deindent
|
|
743
|
+
if (options.deindent === true ||
|
|
744
|
+
// by default, deindent unless it's script with default lang or ts
|
|
745
|
+
(options.deindent !== false &&
|
|
746
|
+
!(currentBlock.type === 'script' &&
|
|
747
|
+
(!currentBlock.lang || currentBlock.lang === 'ts')))) {
|
|
744
748
|
text = deIndent(text);
|
|
745
749
|
}
|
|
746
750
|
// pad content so that linters and pre-processors can output correct
|
|
@@ -3347,7 +3351,9 @@ const LIFECYCLE_HOOKS = [
|
|
|
3347
3351
|
'activated',
|
|
3348
3352
|
'deactivated',
|
|
3349
3353
|
'errorCaptured',
|
|
3350
|
-
'serverPrefetch'
|
|
3354
|
+
'serverPrefetch',
|
|
3355
|
+
'renderTracked',
|
|
3356
|
+
'renderTriggered'
|
|
3351
3357
|
];
|
|
3352
3358
|
|
|
3353
3359
|
var config = {
|
|
@@ -4357,7 +4363,7 @@ function renderStatic(index, isInFor) {
|
|
|
4357
4363
|
return tree;
|
|
4358
4364
|
}
|
|
4359
4365
|
// otherwise, render a fresh tree.
|
|
4360
|
-
tree = cached[index] = this.$options.staticRenderFns[index].call(this._renderProxy,
|
|
4366
|
+
tree = cached[index] = this.$options.staticRenderFns[index].call(this._renderProxy, this._c, this // for render fns generated for functional component templates
|
|
4361
4367
|
);
|
|
4362
4368
|
markStatic$1(tree, `__static__${index}`, false);
|
|
4363
4369
|
return tree;
|
|
@@ -5186,6 +5192,13 @@ let shouldObserve = true;
|
|
|
5186
5192
|
function toggleObserving(value) {
|
|
5187
5193
|
shouldObserve = value;
|
|
5188
5194
|
}
|
|
5195
|
+
// ssr mock dep
|
|
5196
|
+
const mockDep = {
|
|
5197
|
+
notify: noop,
|
|
5198
|
+
depend: noop,
|
|
5199
|
+
addSub: noop,
|
|
5200
|
+
removeSub: noop
|
|
5201
|
+
};
|
|
5189
5202
|
/**
|
|
5190
5203
|
* Observer class that is attached to each observed
|
|
5191
5204
|
* object. Once attached, the observer converts the target
|
|
@@ -5193,76 +5206,60 @@ function toggleObserving(value) {
|
|
|
5193
5206
|
* collect dependencies and dispatch updates.
|
|
5194
5207
|
*/
|
|
5195
5208
|
class Observer {
|
|
5196
|
-
constructor(value, shallow = false) {
|
|
5209
|
+
constructor(value, shallow = false, mock = false) {
|
|
5197
5210
|
this.value = value;
|
|
5198
5211
|
this.shallow = shallow;
|
|
5212
|
+
this.mock = mock;
|
|
5199
5213
|
// this.value = value
|
|
5200
|
-
this.dep = new Dep();
|
|
5214
|
+
this.dep = mock ? mockDep : new Dep();
|
|
5201
5215
|
this.vmCount = 0;
|
|
5202
5216
|
def(value, '__ob__', this);
|
|
5203
5217
|
if (isArray(value)) {
|
|
5204
|
-
if (
|
|
5205
|
-
|
|
5206
|
-
|
|
5207
|
-
|
|
5208
|
-
|
|
5218
|
+
if (!mock) {
|
|
5219
|
+
if (hasProto) {
|
|
5220
|
+
value.__proto__ = arrayMethods;
|
|
5221
|
+
/* eslint-enable no-proto */
|
|
5222
|
+
}
|
|
5223
|
+
else {
|
|
5224
|
+
for (let i = 0, l = arrayKeys.length; i < l; i++) {
|
|
5225
|
+
const key = arrayKeys[i];
|
|
5226
|
+
def(value, key, arrayMethods[key]);
|
|
5227
|
+
}
|
|
5228
|
+
}
|
|
5209
5229
|
}
|
|
5210
5230
|
if (!shallow) {
|
|
5211
5231
|
this.observeArray(value);
|
|
5212
5232
|
}
|
|
5213
5233
|
}
|
|
5214
5234
|
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);
|
|
5235
|
+
/**
|
|
5236
|
+
* Walk through all properties and convert them into
|
|
5237
|
+
* getter/setters. This method should only be called when
|
|
5238
|
+
* value type is Object.
|
|
5239
|
+
*/
|
|
5240
|
+
const keys = Object.keys(value);
|
|
5241
|
+
for (let i = 0; i < keys.length; i++) {
|
|
5242
|
+
const key = keys[i];
|
|
5243
|
+
defineReactive(value, key, NO_INIITIAL_VALUE, undefined, shallow, mock);
|
|
5244
|
+
}
|
|
5228
5245
|
}
|
|
5229
5246
|
}
|
|
5230
5247
|
/**
|
|
5231
5248
|
* Observe a list of Array items.
|
|
5232
5249
|
*/
|
|
5233
|
-
observeArray(
|
|
5234
|
-
for (let i = 0, l =
|
|
5235
|
-
observe(
|
|
5250
|
+
observeArray(value) {
|
|
5251
|
+
for (let i = 0, l = value.length; i < l; i++) {
|
|
5252
|
+
observe(value[i], false, this.mock);
|
|
5236
5253
|
}
|
|
5237
5254
|
}
|
|
5238
5255
|
}
|
|
5239
5256
|
// 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
5257
|
/**
|
|
5261
5258
|
* Attempt to create an observer instance for a value,
|
|
5262
5259
|
* returns the new observer if successfully observed,
|
|
5263
5260
|
* or the existing observer if the value already has one.
|
|
5264
5261
|
*/
|
|
5265
|
-
function observe(value, shallow) {
|
|
5262
|
+
function observe(value, shallow, ssrMockReactivity) {
|
|
5266
5263
|
if (!isObject$1(value) || isRef(value) || value instanceof VNode) {
|
|
5267
5264
|
return;
|
|
5268
5265
|
}
|
|
@@ -5271,18 +5268,18 @@ function observe(value, shallow) {
|
|
|
5271
5268
|
ob = value.__ob__;
|
|
5272
5269
|
}
|
|
5273
5270
|
else if (shouldObserve &&
|
|
5274
|
-
!isServerRendering() &&
|
|
5271
|
+
(ssrMockReactivity || !isServerRendering()) &&
|
|
5275
5272
|
(isArray(value) || isPlainObject(value)) &&
|
|
5276
5273
|
Object.isExtensible(value) &&
|
|
5277
|
-
!value.__v_skip) {
|
|
5278
|
-
ob = new Observer(value, shallow);
|
|
5274
|
+
!value.__v_skip /* ReactiveFlags.SKIP */) {
|
|
5275
|
+
ob = new Observer(value, shallow, ssrMockReactivity);
|
|
5279
5276
|
}
|
|
5280
5277
|
return ob;
|
|
5281
5278
|
}
|
|
5282
5279
|
/**
|
|
5283
5280
|
* Define a reactive property on an Object.
|
|
5284
5281
|
*/
|
|
5285
|
-
function defineReactive(obj, key, val, customSetter, shallow) {
|
|
5282
|
+
function defineReactive(obj, key, val, customSetter, shallow, mock) {
|
|
5286
5283
|
const dep = new Dep();
|
|
5287
5284
|
const property = Object.getOwnPropertyDescriptor(obj, key);
|
|
5288
5285
|
if (property && property.configurable === false) {
|
|
@@ -5295,7 +5292,7 @@ function defineReactive(obj, key, val, customSetter, shallow) {
|
|
|
5295
5292
|
(val === NO_INIITIAL_VALUE || arguments.length === 2)) {
|
|
5296
5293
|
val = obj[key];
|
|
5297
5294
|
}
|
|
5298
|
-
let childOb = !shallow && observe(val);
|
|
5295
|
+
let childOb = !shallow && observe(val, false, mock);
|
|
5299
5296
|
Object.defineProperty(obj, key, {
|
|
5300
5297
|
enumerable: true,
|
|
5301
5298
|
configurable: true,
|
|
@@ -5343,7 +5340,7 @@ function defineReactive(obj, key, val, customSetter, shallow) {
|
|
|
5343
5340
|
else {
|
|
5344
5341
|
val = newVal;
|
|
5345
5342
|
}
|
|
5346
|
-
childOb = !shallow && observe(newVal);
|
|
5343
|
+
childOb = !shallow && observe(newVal, false, mock);
|
|
5347
5344
|
if (process.env.NODE_ENV !== 'production') {
|
|
5348
5345
|
dep.notify({
|
|
5349
5346
|
type: "set" /* TriggerOpTypes.SET */,
|
|
@@ -5368,16 +5365,20 @@ function set(target, key, val) {
|
|
|
5368
5365
|
process.env.NODE_ENV !== 'production' && warn$3(`Set operation on key "${key}" failed: target is readonly.`);
|
|
5369
5366
|
return;
|
|
5370
5367
|
}
|
|
5368
|
+
const ob = target.__ob__;
|
|
5371
5369
|
if (isArray(target) && isValidArrayIndex(key)) {
|
|
5372
5370
|
target.length = Math.max(target.length, key);
|
|
5373
5371
|
target.splice(key, 1, val);
|
|
5372
|
+
// when mocking for SSR, array methods are not hijacked
|
|
5373
|
+
if (ob && !ob.shallow && ob.mock) {
|
|
5374
|
+
observe(val, false, true);
|
|
5375
|
+
}
|
|
5374
5376
|
return val;
|
|
5375
5377
|
}
|
|
5376
5378
|
if (key in target && !(key in Object.prototype)) {
|
|
5377
5379
|
target[key] = val;
|
|
5378
5380
|
return val;
|
|
5379
5381
|
}
|
|
5380
|
-
const ob = target.__ob__;
|
|
5381
5382
|
if (target._isVue || (ob && ob.vmCount)) {
|
|
5382
5383
|
process.env.NODE_ENV !== 'production' &&
|
|
5383
5384
|
warn$3('Avoid adding reactive properties to a Vue instance or its root $data ' +
|
|
@@ -5388,7 +5389,7 @@ function set(target, key, val) {
|
|
|
5388
5389
|
target[key] = val;
|
|
5389
5390
|
return val;
|
|
5390
5391
|
}
|
|
5391
|
-
defineReactive(ob.value, key, val);
|
|
5392
|
+
defineReactive(ob.value, key, val, undefined, ob.shallow, ob.mock);
|
|
5392
5393
|
if (process.env.NODE_ENV !== 'production') {
|
|
5393
5394
|
ob.dep.notify({
|
|
5394
5395
|
type: "add" /* TriggerOpTypes.ADD */,
|