@vue/reactivity 3.1.1 → 3.1.5
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/reactivity.cjs.js +116 -104
- package/dist/reactivity.cjs.prod.js +116 -104
- package/dist/reactivity.d.ts +2 -2
- package/dist/reactivity.esm-browser.js +116 -104
- package/dist/reactivity.esm-browser.prod.js +1 -1
- package/dist/reactivity.esm-bundler.js +116 -104
- package/dist/reactivity.global.js +116 -104
- package/dist/reactivity.global.prod.js +1 -1
- package/package.json +2 -2
package/dist/reactivity.cjs.js
CHANGED
|
@@ -201,34 +201,36 @@ const get = /*#__PURE__*/ createGetter();
|
|
|
201
201
|
const shallowGet = /*#__PURE__*/ createGetter(false, true);
|
|
202
202
|
const readonlyGet = /*#__PURE__*/ createGetter(true);
|
|
203
203
|
const shallowReadonlyGet = /*#__PURE__*/ createGetter(true, true);
|
|
204
|
-
const arrayInstrumentations =
|
|
205
|
-
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
204
|
+
const arrayInstrumentations = /*#__PURE__*/ createArrayInstrumentations();
|
|
205
|
+
function createArrayInstrumentations() {
|
|
206
|
+
const instrumentations = {};
|
|
207
|
+
['includes', 'indexOf', 'lastIndexOf'].forEach(key => {
|
|
208
|
+
instrumentations[key] = function (...args) {
|
|
209
|
+
const arr = toRaw(this);
|
|
210
|
+
for (let i = 0, l = this.length; i < l; i++) {
|
|
211
|
+
track(arr, "get" /* GET */, i + '');
|
|
212
|
+
}
|
|
213
|
+
// we run the method using the original args first (which may be reactive)
|
|
214
|
+
const res = arr[key](...args);
|
|
215
|
+
if (res === -1 || res === false) {
|
|
216
|
+
// if that didn't work, run it again using raw values.
|
|
217
|
+
return arr[key](...args.map(toRaw));
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
return res;
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
});
|
|
224
|
+
['push', 'pop', 'shift', 'unshift', 'splice'].forEach(key => {
|
|
225
|
+
instrumentations[key] = function (...args) {
|
|
226
|
+
pauseTracking();
|
|
227
|
+
const res = toRaw(this)[key].apply(this, args);
|
|
228
|
+
resetTracking();
|
|
219
229
|
return res;
|
|
220
|
-
}
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
const method = Array.prototype[key];
|
|
225
|
-
arrayInstrumentations[key] = function (...args) {
|
|
226
|
-
pauseTracking();
|
|
227
|
-
const res = method.apply(this, args);
|
|
228
|
-
resetTracking();
|
|
229
|
-
return res;
|
|
230
|
-
};
|
|
231
|
-
});
|
|
230
|
+
};
|
|
231
|
+
});
|
|
232
|
+
return instrumentations;
|
|
233
|
+
}
|
|
232
234
|
function createGetter(isReadonly = false, shallow = false) {
|
|
233
235
|
return function get(target, key, receiver) {
|
|
234
236
|
if (key === "__v_isReactive" /* IS_REACTIVE */) {
|
|
@@ -347,14 +349,14 @@ const readonlyHandlers = {
|
|
|
347
349
|
return true;
|
|
348
350
|
}
|
|
349
351
|
};
|
|
350
|
-
const shallowReactiveHandlers = shared.extend({}, mutableHandlers, {
|
|
352
|
+
const shallowReactiveHandlers = /*#__PURE__*/ shared.extend({}, mutableHandlers, {
|
|
351
353
|
get: shallowGet,
|
|
352
354
|
set: shallowSet
|
|
353
355
|
});
|
|
354
356
|
// Props handlers are special in the sense that it should not unwrap top-level
|
|
355
357
|
// refs (in order to allow refs to be explicitly passed down), but should
|
|
356
358
|
// retain the reactivity of the normal readonly object.
|
|
357
|
-
const shallowReadonlyHandlers = shared.extend({}, readonlyHandlers, {
|
|
359
|
+
const shallowReadonlyHandlers = /*#__PURE__*/ shared.extend({}, readonlyHandlers, {
|
|
358
360
|
get: shallowReadonlyGet
|
|
359
361
|
});
|
|
360
362
|
|
|
@@ -524,73 +526,82 @@ function createReadonlyMethod(type) {
|
|
|
524
526
|
return type === "delete" /* DELETE */ ? false : this;
|
|
525
527
|
};
|
|
526
528
|
}
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
iteratorMethods
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
529
|
+
function createInstrumentations() {
|
|
530
|
+
const mutableInstrumentations = {
|
|
531
|
+
get(key) {
|
|
532
|
+
return get$1(this, key);
|
|
533
|
+
},
|
|
534
|
+
get size() {
|
|
535
|
+
return size(this);
|
|
536
|
+
},
|
|
537
|
+
has: has$1,
|
|
538
|
+
add,
|
|
539
|
+
set: set$1,
|
|
540
|
+
delete: deleteEntry,
|
|
541
|
+
clear,
|
|
542
|
+
forEach: createForEach(false, false)
|
|
543
|
+
};
|
|
544
|
+
const shallowInstrumentations = {
|
|
545
|
+
get(key) {
|
|
546
|
+
return get$1(this, key, false, true);
|
|
547
|
+
},
|
|
548
|
+
get size() {
|
|
549
|
+
return size(this);
|
|
550
|
+
},
|
|
551
|
+
has: has$1,
|
|
552
|
+
add,
|
|
553
|
+
set: set$1,
|
|
554
|
+
delete: deleteEntry,
|
|
555
|
+
clear,
|
|
556
|
+
forEach: createForEach(false, true)
|
|
557
|
+
};
|
|
558
|
+
const readonlyInstrumentations = {
|
|
559
|
+
get(key) {
|
|
560
|
+
return get$1(this, key, true);
|
|
561
|
+
},
|
|
562
|
+
get size() {
|
|
563
|
+
return size(this, true);
|
|
564
|
+
},
|
|
565
|
+
has(key) {
|
|
566
|
+
return has$1.call(this, key, true);
|
|
567
|
+
},
|
|
568
|
+
add: createReadonlyMethod("add" /* ADD */),
|
|
569
|
+
set: createReadonlyMethod("set" /* SET */),
|
|
570
|
+
delete: createReadonlyMethod("delete" /* DELETE */),
|
|
571
|
+
clear: createReadonlyMethod("clear" /* CLEAR */),
|
|
572
|
+
forEach: createForEach(true, false)
|
|
573
|
+
};
|
|
574
|
+
const shallowReadonlyInstrumentations = {
|
|
575
|
+
get(key) {
|
|
576
|
+
return get$1(this, key, true, true);
|
|
577
|
+
},
|
|
578
|
+
get size() {
|
|
579
|
+
return size(this, true);
|
|
580
|
+
},
|
|
581
|
+
has(key) {
|
|
582
|
+
return has$1.call(this, key, true);
|
|
583
|
+
},
|
|
584
|
+
add: createReadonlyMethod("add" /* ADD */),
|
|
585
|
+
set: createReadonlyMethod("set" /* SET */),
|
|
586
|
+
delete: createReadonlyMethod("delete" /* DELETE */),
|
|
587
|
+
clear: createReadonlyMethod("clear" /* CLEAR */),
|
|
588
|
+
forEach: createForEach(true, true)
|
|
589
|
+
};
|
|
590
|
+
const iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator];
|
|
591
|
+
iteratorMethods.forEach(method => {
|
|
592
|
+
mutableInstrumentations[method] = createIterableMethod(method, false, false);
|
|
593
|
+
readonlyInstrumentations[method] = createIterableMethod(method, true, false);
|
|
594
|
+
shallowInstrumentations[method] = createIterableMethod(method, false, true);
|
|
595
|
+
shallowReadonlyInstrumentations[method] = createIterableMethod(method, true, true);
|
|
596
|
+
});
|
|
597
|
+
return [
|
|
598
|
+
mutableInstrumentations,
|
|
599
|
+
readonlyInstrumentations,
|
|
600
|
+
shallowInstrumentations,
|
|
601
|
+
shallowReadonlyInstrumentations
|
|
602
|
+
];
|
|
603
|
+
}
|
|
604
|
+
const [mutableInstrumentations, readonlyInstrumentations, shallowInstrumentations, shallowReadonlyInstrumentations] = /* #__PURE__*/ createInstrumentations();
|
|
594
605
|
function createInstrumentationGetter(isReadonly, shallow) {
|
|
595
606
|
const instrumentations = shallow
|
|
596
607
|
? isReadonly
|
|
@@ -615,16 +626,16 @@ function createInstrumentationGetter(isReadonly, shallow) {
|
|
|
615
626
|
};
|
|
616
627
|
}
|
|
617
628
|
const mutableCollectionHandlers = {
|
|
618
|
-
get: createInstrumentationGetter(false, false)
|
|
629
|
+
get: /*#__PURE__*/ createInstrumentationGetter(false, false)
|
|
619
630
|
};
|
|
620
631
|
const shallowCollectionHandlers = {
|
|
621
|
-
get: createInstrumentationGetter(false, true)
|
|
632
|
+
get: /*#__PURE__*/ createInstrumentationGetter(false, true)
|
|
622
633
|
};
|
|
623
634
|
const readonlyCollectionHandlers = {
|
|
624
|
-
get: createInstrumentationGetter(true, false)
|
|
635
|
+
get: /*#__PURE__*/ createInstrumentationGetter(true, false)
|
|
625
636
|
};
|
|
626
637
|
const shallowReadonlyCollectionHandlers = {
|
|
627
|
-
get: createInstrumentationGetter(true, true)
|
|
638
|
+
get: /*#__PURE__*/ createInstrumentationGetter(true, true)
|
|
628
639
|
};
|
|
629
640
|
function checkIdentityKeys(target, has, key) {
|
|
630
641
|
const rawKey = toRaw(key);
|
|
@@ -750,18 +761,19 @@ function shallowRef(value) {
|
|
|
750
761
|
return createRef(value, true);
|
|
751
762
|
}
|
|
752
763
|
class RefImpl {
|
|
753
|
-
constructor(
|
|
754
|
-
this._rawValue = _rawValue;
|
|
764
|
+
constructor(value, _shallow = false) {
|
|
755
765
|
this._shallow = _shallow;
|
|
756
766
|
this.__v_isRef = true;
|
|
757
|
-
this.
|
|
767
|
+
this._rawValue = _shallow ? value : toRaw(value);
|
|
768
|
+
this._value = _shallow ? value : convert(value);
|
|
758
769
|
}
|
|
759
770
|
get value() {
|
|
760
771
|
track(toRaw(this), "get" /* GET */, 'value');
|
|
761
772
|
return this._value;
|
|
762
773
|
}
|
|
763
774
|
set value(newVal) {
|
|
764
|
-
|
|
775
|
+
newVal = this._shallow ? newVal : toRaw(newVal);
|
|
776
|
+
if (shared.hasChanged(newVal, this._rawValue)) {
|
|
765
777
|
this._rawValue = newVal;
|
|
766
778
|
this._value = this._shallow ? newVal : convert(newVal);
|
|
767
779
|
trigger(toRaw(this), "set" /* SET */, 'value', newVal);
|
|
@@ -182,34 +182,36 @@ const get = /*#__PURE__*/ createGetter();
|
|
|
182
182
|
const shallowGet = /*#__PURE__*/ createGetter(false, true);
|
|
183
183
|
const readonlyGet = /*#__PURE__*/ createGetter(true);
|
|
184
184
|
const shallowReadonlyGet = /*#__PURE__*/ createGetter(true, true);
|
|
185
|
-
const arrayInstrumentations =
|
|
186
|
-
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
185
|
+
const arrayInstrumentations = /*#__PURE__*/ createArrayInstrumentations();
|
|
186
|
+
function createArrayInstrumentations() {
|
|
187
|
+
const instrumentations = {};
|
|
188
|
+
['includes', 'indexOf', 'lastIndexOf'].forEach(key => {
|
|
189
|
+
instrumentations[key] = function (...args) {
|
|
190
|
+
const arr = toRaw(this);
|
|
191
|
+
for (let i = 0, l = this.length; i < l; i++) {
|
|
192
|
+
track(arr, "get" /* GET */, i + '');
|
|
193
|
+
}
|
|
194
|
+
// we run the method using the original args first (which may be reactive)
|
|
195
|
+
const res = arr[key](...args);
|
|
196
|
+
if (res === -1 || res === false) {
|
|
197
|
+
// if that didn't work, run it again using raw values.
|
|
198
|
+
return arr[key](...args.map(toRaw));
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
return res;
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
});
|
|
205
|
+
['push', 'pop', 'shift', 'unshift', 'splice'].forEach(key => {
|
|
206
|
+
instrumentations[key] = function (...args) {
|
|
207
|
+
pauseTracking();
|
|
208
|
+
const res = toRaw(this)[key].apply(this, args);
|
|
209
|
+
resetTracking();
|
|
200
210
|
return res;
|
|
201
|
-
}
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
const method = Array.prototype[key];
|
|
206
|
-
arrayInstrumentations[key] = function (...args) {
|
|
207
|
-
pauseTracking();
|
|
208
|
-
const res = method.apply(this, args);
|
|
209
|
-
resetTracking();
|
|
210
|
-
return res;
|
|
211
|
-
};
|
|
212
|
-
});
|
|
211
|
+
};
|
|
212
|
+
});
|
|
213
|
+
return instrumentations;
|
|
214
|
+
}
|
|
213
215
|
function createGetter(isReadonly = false, shallow = false) {
|
|
214
216
|
return function get(target, key, receiver) {
|
|
215
217
|
if (key === "__v_isReactive" /* IS_REACTIVE */) {
|
|
@@ -322,14 +324,14 @@ const readonlyHandlers = {
|
|
|
322
324
|
return true;
|
|
323
325
|
}
|
|
324
326
|
};
|
|
325
|
-
const shallowReactiveHandlers = shared.extend({}, mutableHandlers, {
|
|
327
|
+
const shallowReactiveHandlers = /*#__PURE__*/ shared.extend({}, mutableHandlers, {
|
|
326
328
|
get: shallowGet,
|
|
327
329
|
set: shallowSet
|
|
328
330
|
});
|
|
329
331
|
// Props handlers are special in the sense that it should not unwrap top-level
|
|
330
332
|
// refs (in order to allow refs to be explicitly passed down), but should
|
|
331
333
|
// retain the reactivity of the normal readonly object.
|
|
332
|
-
const shallowReadonlyHandlers = shared.extend({}, readonlyHandlers, {
|
|
334
|
+
const shallowReadonlyHandlers = /*#__PURE__*/ shared.extend({}, readonlyHandlers, {
|
|
333
335
|
get: shallowReadonlyGet
|
|
334
336
|
});
|
|
335
337
|
|
|
@@ -485,73 +487,82 @@ function createReadonlyMethod(type) {
|
|
|
485
487
|
return type === "delete" /* DELETE */ ? false : this;
|
|
486
488
|
};
|
|
487
489
|
}
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
iteratorMethods
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
490
|
+
function createInstrumentations() {
|
|
491
|
+
const mutableInstrumentations = {
|
|
492
|
+
get(key) {
|
|
493
|
+
return get$1(this, key);
|
|
494
|
+
},
|
|
495
|
+
get size() {
|
|
496
|
+
return size(this);
|
|
497
|
+
},
|
|
498
|
+
has: has$1,
|
|
499
|
+
add,
|
|
500
|
+
set: set$1,
|
|
501
|
+
delete: deleteEntry,
|
|
502
|
+
clear,
|
|
503
|
+
forEach: createForEach(false, false)
|
|
504
|
+
};
|
|
505
|
+
const shallowInstrumentations = {
|
|
506
|
+
get(key) {
|
|
507
|
+
return get$1(this, key, false, true);
|
|
508
|
+
},
|
|
509
|
+
get size() {
|
|
510
|
+
return size(this);
|
|
511
|
+
},
|
|
512
|
+
has: has$1,
|
|
513
|
+
add,
|
|
514
|
+
set: set$1,
|
|
515
|
+
delete: deleteEntry,
|
|
516
|
+
clear,
|
|
517
|
+
forEach: createForEach(false, true)
|
|
518
|
+
};
|
|
519
|
+
const readonlyInstrumentations = {
|
|
520
|
+
get(key) {
|
|
521
|
+
return get$1(this, key, true);
|
|
522
|
+
},
|
|
523
|
+
get size() {
|
|
524
|
+
return size(this, true);
|
|
525
|
+
},
|
|
526
|
+
has(key) {
|
|
527
|
+
return has$1.call(this, key, true);
|
|
528
|
+
},
|
|
529
|
+
add: createReadonlyMethod("add" /* ADD */),
|
|
530
|
+
set: createReadonlyMethod("set" /* SET */),
|
|
531
|
+
delete: createReadonlyMethod("delete" /* DELETE */),
|
|
532
|
+
clear: createReadonlyMethod("clear" /* CLEAR */),
|
|
533
|
+
forEach: createForEach(true, false)
|
|
534
|
+
};
|
|
535
|
+
const shallowReadonlyInstrumentations = {
|
|
536
|
+
get(key) {
|
|
537
|
+
return get$1(this, key, true, true);
|
|
538
|
+
},
|
|
539
|
+
get size() {
|
|
540
|
+
return size(this, true);
|
|
541
|
+
},
|
|
542
|
+
has(key) {
|
|
543
|
+
return has$1.call(this, key, true);
|
|
544
|
+
},
|
|
545
|
+
add: createReadonlyMethod("add" /* ADD */),
|
|
546
|
+
set: createReadonlyMethod("set" /* SET */),
|
|
547
|
+
delete: createReadonlyMethod("delete" /* DELETE */),
|
|
548
|
+
clear: createReadonlyMethod("clear" /* CLEAR */),
|
|
549
|
+
forEach: createForEach(true, true)
|
|
550
|
+
};
|
|
551
|
+
const iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator];
|
|
552
|
+
iteratorMethods.forEach(method => {
|
|
553
|
+
mutableInstrumentations[method] = createIterableMethod(method, false, false);
|
|
554
|
+
readonlyInstrumentations[method] = createIterableMethod(method, true, false);
|
|
555
|
+
shallowInstrumentations[method] = createIterableMethod(method, false, true);
|
|
556
|
+
shallowReadonlyInstrumentations[method] = createIterableMethod(method, true, true);
|
|
557
|
+
});
|
|
558
|
+
return [
|
|
559
|
+
mutableInstrumentations,
|
|
560
|
+
readonlyInstrumentations,
|
|
561
|
+
shallowInstrumentations,
|
|
562
|
+
shallowReadonlyInstrumentations
|
|
563
|
+
];
|
|
564
|
+
}
|
|
565
|
+
const [mutableInstrumentations, readonlyInstrumentations, shallowInstrumentations, shallowReadonlyInstrumentations] = /* #__PURE__*/ createInstrumentations();
|
|
555
566
|
function createInstrumentationGetter(isReadonly, shallow) {
|
|
556
567
|
const instrumentations = shallow
|
|
557
568
|
? isReadonly
|
|
@@ -576,16 +587,16 @@ function createInstrumentationGetter(isReadonly, shallow) {
|
|
|
576
587
|
};
|
|
577
588
|
}
|
|
578
589
|
const mutableCollectionHandlers = {
|
|
579
|
-
get: createInstrumentationGetter(false, false)
|
|
590
|
+
get: /*#__PURE__*/ createInstrumentationGetter(false, false)
|
|
580
591
|
};
|
|
581
592
|
const shallowCollectionHandlers = {
|
|
582
|
-
get: createInstrumentationGetter(false, true)
|
|
593
|
+
get: /*#__PURE__*/ createInstrumentationGetter(false, true)
|
|
583
594
|
};
|
|
584
595
|
const readonlyCollectionHandlers = {
|
|
585
|
-
get: createInstrumentationGetter(true, false)
|
|
596
|
+
get: /*#__PURE__*/ createInstrumentationGetter(true, false)
|
|
586
597
|
};
|
|
587
598
|
const shallowReadonlyCollectionHandlers = {
|
|
588
|
-
get: createInstrumentationGetter(true, true)
|
|
599
|
+
get: /*#__PURE__*/ createInstrumentationGetter(true, true)
|
|
589
600
|
};
|
|
590
601
|
|
|
591
602
|
const reactiveMap = new WeakMap();
|
|
@@ -697,18 +708,19 @@ function shallowRef(value) {
|
|
|
697
708
|
return createRef(value, true);
|
|
698
709
|
}
|
|
699
710
|
class RefImpl {
|
|
700
|
-
constructor(
|
|
701
|
-
this._rawValue = _rawValue;
|
|
711
|
+
constructor(value, _shallow = false) {
|
|
702
712
|
this._shallow = _shallow;
|
|
703
713
|
this.__v_isRef = true;
|
|
704
|
-
this.
|
|
714
|
+
this._rawValue = _shallow ? value : toRaw(value);
|
|
715
|
+
this._value = _shallow ? value : convert(value);
|
|
705
716
|
}
|
|
706
717
|
get value() {
|
|
707
718
|
track(toRaw(this), "get" /* GET */, 'value');
|
|
708
719
|
return this._value;
|
|
709
720
|
}
|
|
710
721
|
set value(newVal) {
|
|
711
|
-
|
|
722
|
+
newVal = this._shallow ? newVal : toRaw(newVal);
|
|
723
|
+
if (shared.hasChanged(newVal, this._rawValue)) {
|
|
712
724
|
this._rawValue = newVal;
|
|
713
725
|
this._value = this._shallow ? newVal : convert(newVal);
|
|
714
726
|
trigger(toRaw(this), "set" /* SET */, 'value', newVal);
|
package/dist/reactivity.d.ts
CHANGED
|
@@ -204,7 +204,7 @@ export declare function shallowRef<T>(value: T): Ref<T>;
|
|
|
204
204
|
export declare function shallowRef<T = any>(): Ref<T | undefined>;
|
|
205
205
|
|
|
206
206
|
export declare type ShallowUnwrapRef<T> = {
|
|
207
|
-
[K in keyof T]: T[K] extends Ref<infer V> ? V : T[K];
|
|
207
|
+
[K in keyof T]: T[K] extends Ref<infer V> ? V : T[K] extends Ref<infer V> | undefined ? unknown extends V ? undefined : V | undefined : T[K];
|
|
208
208
|
};
|
|
209
209
|
|
|
210
210
|
declare function stop_2(effect: ReactiveEffect): void;
|
|
@@ -295,7 +295,7 @@ export declare const enum TriggerOpTypes {
|
|
|
295
295
|
|
|
296
296
|
export declare function triggerRef(ref: Ref): void;
|
|
297
297
|
|
|
298
|
-
export declare function unref<T>(ref: T
|
|
298
|
+
export declare function unref<T>(ref: T | Ref<T>): T;
|
|
299
299
|
|
|
300
300
|
export declare type UnwrapNestedRefs<T> = T extends Ref ? T : UnwrapRef<T>;
|
|
301
301
|
|