vue 2.7.0-beta.2 → 2.7.0-beta.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/vue.common.dev.js +65 -19
- package/dist/vue.common.prod.js +3 -3
- package/dist/vue.esm.browser.js +58 -20
- package/dist/vue.esm.browser.min.js +3 -3
- package/dist/vue.esm.js +65 -20
- package/dist/vue.js +57 -19
- package/dist/vue.min.js +3 -3
- package/dist/vue.runtime.common.dev.js +65 -19
- package/dist/vue.runtime.common.prod.js +3 -3
- package/dist/vue.runtime.esm.js +65 -20
- package/dist/vue.runtime.js +57 -19
- package/dist/vue.runtime.min.js +3 -3
- package/dist/vue.runtime.mjs +65 -20
- package/package.json +2 -2
- package/packages/compiler-sfc/dist/compiler-sfc.d.ts +22 -11
- package/packages/compiler-sfc/dist/compiler-sfc.js +306 -168
- package/packages/compiler-sfc/package.json +1 -1
- package/packages/compiler-sfc/src/compileScript.ts +31 -3
- package/packages/compiler-sfc/src/compileStyle.ts +4 -0
- package/packages/compiler-sfc/src/compileTemplate.ts +2 -4
- package/packages/compiler-sfc/src/cssVars.ts +179 -0
- package/packages/compiler-sfc/src/index.ts +1 -0
- package/packages/compiler-sfc/src/parse.ts +13 -3
- package/packages/compiler-sfc/src/parseComponent.ts +4 -1
- package/packages/compiler-sfc/src/prefixIdentifiers.ts +17 -23
- package/packages/compiler-sfc/src/stylePlugins/scoped.ts +18 -21
- package/packages/compiler-sfc/test/__snapshots__/cssVars.spec.ts.snap +189 -0
- package/packages/compiler-sfc/test/compileScript.spec.ts +1 -29
- package/packages/compiler-sfc/test/cssVars.spec.ts +247 -0
- package/packages/compiler-sfc/test/prefixIdentifiers.spec.ts +7 -4
- package/packages/compiler-sfc/test/util.ts +35 -0
- package/src/core/instance/lifecycle.ts +8 -6
- package/src/core/instance/state.ts +2 -2
- package/src/core/vdom/modules/template-ref.ts +2 -4
- package/src/global.d.ts +1 -0
- package/src/v3/apiSetup.ts +13 -5
- package/src/v3/index.ts +3 -0
- package/src/v3/sfc-helpers/useCssModule.ts +24 -0
- package/src/v3/sfc-helpers/useCssVars.ts +34 -0
- package/types/v3-generated.d.ts +8 -0
- package/types/vue.d.ts +6 -1
package/dist/vue.common.dev.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Vue.js v2.7.0-beta.
|
|
2
|
+
* Vue.js v2.7.0-beta.5
|
|
3
3
|
* (c) 2014-2022 Evan You
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -1430,7 +1430,9 @@ function initSetup(vm) {
|
|
|
1430
1430
|
if (setup) {
|
|
1431
1431
|
const ctx = (vm._setupContext = createSetupContext(vm));
|
|
1432
1432
|
setCurrentInstance(vm);
|
|
1433
|
-
|
|
1433
|
+
pushTarget();
|
|
1434
|
+
const setupResult = invokeWithErrorHandling(setup, null, [vm._props || shallowReactive({}), ctx], vm, `setup`);
|
|
1435
|
+
popTarget();
|
|
1434
1436
|
setCurrentInstance();
|
|
1435
1437
|
if (isFunction(setupResult)) {
|
|
1436
1438
|
// render function
|
|
@@ -1469,12 +1471,17 @@ function initSetup(vm) {
|
|
|
1469
1471
|
}
|
|
1470
1472
|
}
|
|
1471
1473
|
function proxyWithRefUnwrap(target, source, key) {
|
|
1472
|
-
let raw = source[key];
|
|
1473
1474
|
Object.defineProperty(target, key, {
|
|
1474
1475
|
enumerable: true,
|
|
1475
1476
|
configurable: true,
|
|
1476
|
-
get: () =>
|
|
1477
|
-
|
|
1477
|
+
get: () => {
|
|
1478
|
+
const raw = source[key];
|
|
1479
|
+
return isRef(raw) ? raw.value : raw;
|
|
1480
|
+
},
|
|
1481
|
+
set: newVal => {
|
|
1482
|
+
const raw = source[key];
|
|
1483
|
+
isRef(raw) ? (raw.value = newVal) : (source[key] = newVal);
|
|
1484
|
+
}
|
|
1478
1485
|
});
|
|
1479
1486
|
}
|
|
1480
1487
|
function createSetupContext(vm) {
|
|
@@ -1638,7 +1645,7 @@ function initState(vm) {
|
|
|
1638
1645
|
}
|
|
1639
1646
|
function initProps$1(vm, propsOptions) {
|
|
1640
1647
|
const propsData = vm.$options.propsData || {};
|
|
1641
|
-
const props = (vm._props = {});
|
|
1648
|
+
const props = (vm._props = shallowReactive({}));
|
|
1642
1649
|
// cache prop keys so that future props updates can iterate using Array
|
|
1643
1650
|
// instead of dynamic object key enumeration.
|
|
1644
1651
|
const keys = (vm.$options._propKeys = []);
|
|
@@ -3550,15 +3557,16 @@ function mountComponent(vm, el, hydrating) {
|
|
|
3550
3557
|
// component's mounted hook), which relies on vm._watcher being already defined
|
|
3551
3558
|
new Watcher(vm, updateComponent, noop, watcherOptions, true /* isRenderWatcher */);
|
|
3552
3559
|
hydrating = false;
|
|
3560
|
+
// flush buffer for flush: "pre" watchers queued in setup()
|
|
3561
|
+
const preWatchers = vm._preWatchers;
|
|
3562
|
+
if (preWatchers) {
|
|
3563
|
+
for (let i = 0; i < preWatchers.length; i++) {
|
|
3564
|
+
preWatchers[i].run();
|
|
3565
|
+
}
|
|
3566
|
+
}
|
|
3553
3567
|
// manually mounted instance, call mounted on self
|
|
3554
3568
|
// mounted is called for render-created child components in its inserted hook
|
|
3555
3569
|
if (vm.$vnode == null) {
|
|
3556
|
-
const preWatchers = vm._preWatchers;
|
|
3557
|
-
if (preWatchers) {
|
|
3558
|
-
for (let i = 0; i < preWatchers.length; i++) {
|
|
3559
|
-
preWatchers[i].run();
|
|
3560
|
-
}
|
|
3561
|
-
}
|
|
3562
3570
|
vm._isMounted = true;
|
|
3563
3571
|
callHook$1(vm, 'mounted');
|
|
3564
3572
|
}
|
|
@@ -4502,6 +4510,46 @@ function nextTick(cb, ctx) {
|
|
|
4502
4510
|
}
|
|
4503
4511
|
}
|
|
4504
4512
|
|
|
4513
|
+
function useCssModule(name = '$style') {
|
|
4514
|
+
/* istanbul ignore else */
|
|
4515
|
+
{
|
|
4516
|
+
if (!currentInstance) {
|
|
4517
|
+
warn$2(`useCssModule must be called inside setup()`);
|
|
4518
|
+
return emptyObject;
|
|
4519
|
+
}
|
|
4520
|
+
const mod = currentInstance[name];
|
|
4521
|
+
if (!mod) {
|
|
4522
|
+
warn$2(`Current instance does not have CSS module named "${name}".`);
|
|
4523
|
+
return emptyObject;
|
|
4524
|
+
}
|
|
4525
|
+
return mod;
|
|
4526
|
+
}
|
|
4527
|
+
}
|
|
4528
|
+
|
|
4529
|
+
/**
|
|
4530
|
+
* Runtime helper for SFC's CSS variable injection feature.
|
|
4531
|
+
* @private
|
|
4532
|
+
*/
|
|
4533
|
+
function useCssVars(getter) {
|
|
4534
|
+
if (!inBrowser && !false)
|
|
4535
|
+
return;
|
|
4536
|
+
const instance = currentInstance;
|
|
4537
|
+
if (!instance) {
|
|
4538
|
+
warn$2(`useCssVars is called without current active component instance.`);
|
|
4539
|
+
return;
|
|
4540
|
+
}
|
|
4541
|
+
watchPostEffect(() => {
|
|
4542
|
+
const el = instance.$el;
|
|
4543
|
+
const vars = getter(instance, instance._setupProxy);
|
|
4544
|
+
if (el && el.nodeType === 1) {
|
|
4545
|
+
const style = el.style;
|
|
4546
|
+
for (const key in vars) {
|
|
4547
|
+
style.setProperty(`--${key}`, vars[key]);
|
|
4548
|
+
}
|
|
4549
|
+
}
|
|
4550
|
+
});
|
|
4551
|
+
}
|
|
4552
|
+
|
|
4505
4553
|
function createLifeCycle(hookName) {
|
|
4506
4554
|
return (fn, target = currentInstance) => {
|
|
4507
4555
|
if (!target) {
|
|
@@ -4539,7 +4587,7 @@ const onServerPrefetch = createLifeCycle('serverPrefetch');
|
|
|
4539
4587
|
const onRenderTracked = createLifeCycle('renderTracked');
|
|
4540
4588
|
const onRenderTriggered = createLifeCycle('renderTriggered');
|
|
4541
4589
|
|
|
4542
|
-
const version = '2.7.0-beta.
|
|
4590
|
+
const version = '2.7.0-beta.5';
|
|
4543
4591
|
/**
|
|
4544
4592
|
* @internal type is manually declared in <root>/types/v3-define-component.d.ts
|
|
4545
4593
|
*/
|
|
@@ -4588,6 +4636,8 @@ var vca = /*#__PURE__*/Object.freeze({
|
|
|
4588
4636
|
nextTick: nextTick,
|
|
4589
4637
|
set: set,
|
|
4590
4638
|
del: del,
|
|
4639
|
+
useCssModule: useCssModule,
|
|
4640
|
+
useCssVars: useCssVars,
|
|
4591
4641
|
onBeforeMount: onBeforeMount,
|
|
4592
4642
|
onMounted: onMounted,
|
|
4593
4643
|
onBeforeUpdate: onBeforeUpdate,
|
|
@@ -6051,11 +6101,11 @@ function registerRef(vnode, isRemoval) {
|
|
|
6051
6101
|
const vm = vnode.context;
|
|
6052
6102
|
const refValue = vnode.componentInstance || vnode.elm;
|
|
6053
6103
|
const value = isRemoval ? null : refValue;
|
|
6104
|
+
const $refsValue = isRemoval ? undefined : refValue;
|
|
6054
6105
|
if (isFunction(ref)) {
|
|
6055
6106
|
invokeWithErrorHandling(ref, vm, [value], vm, `template ref function`);
|
|
6056
6107
|
return;
|
|
6057
6108
|
}
|
|
6058
|
-
const setupRefKey = vnode.data.ref_key;
|
|
6059
6109
|
const isFor = vnode.data.refInFor;
|
|
6060
6110
|
const _isString = typeof ref === 'string' || typeof ref === 'number';
|
|
6061
6111
|
const _isRef = isRef(ref);
|
|
@@ -6074,8 +6124,6 @@ function registerRef(vnode, isRemoval) {
|
|
|
6074
6124
|
}
|
|
6075
6125
|
else {
|
|
6076
6126
|
ref.value = [refValue];
|
|
6077
|
-
if (setupRefKey)
|
|
6078
|
-
refs[setupRefKey] = ref.value;
|
|
6079
6127
|
}
|
|
6080
6128
|
}
|
|
6081
6129
|
else if (!existing.includes(refValue)) {
|
|
@@ -6087,7 +6135,7 @@ function registerRef(vnode, isRemoval) {
|
|
|
6087
6135
|
if (isRemoval && refs[ref] !== refValue) {
|
|
6088
6136
|
return;
|
|
6089
6137
|
}
|
|
6090
|
-
refs[ref] =
|
|
6138
|
+
refs[ref] = $refsValue;
|
|
6091
6139
|
setSetupRef(vm, ref, value);
|
|
6092
6140
|
}
|
|
6093
6141
|
else if (_isRef) {
|
|
@@ -6095,8 +6143,6 @@ function registerRef(vnode, isRemoval) {
|
|
|
6095
6143
|
return;
|
|
6096
6144
|
}
|
|
6097
6145
|
ref.value = value;
|
|
6098
|
-
if (setupRefKey)
|
|
6099
|
-
refs[setupRefKey] = value;
|
|
6100
6146
|
}
|
|
6101
6147
|
else {
|
|
6102
6148
|
warn$2(`Invalid template ref type: ${typeof ref}`);
|