vue 2.7.0-beta.1 → 2.7.0-beta.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/vue.common.dev.js +59 -9
- package/dist/vue.common.prod.js +3 -3
- package/dist/vue.esm.browser.js +52 -10
- package/dist/vue.esm.browser.min.js +3 -3
- package/dist/vue.esm.js +59 -10
- package/dist/vue.js +51 -9
- package/dist/vue.min.js +3 -3
- package/dist/vue.runtime.common.dev.js +59 -9
- package/dist/vue.runtime.common.prod.js +3 -3
- package/dist/vue.runtime.esm.js +59 -10
- package/dist/vue.runtime.js +51 -9
- package/dist/vue.runtime.min.js +3 -3
- package/dist/vue.runtime.mjs +59 -10
- package/package.json +2 -2
- package/packages/compiler-sfc/dist/compiler-sfc.d.ts +22 -11
- package/packages/compiler-sfc/dist/compiler-sfc.js +317 -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/src/templateCompilerModules/utils.ts +14 -1
- 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/compileStyle.spec.ts +4 -4
- package/packages/compiler-sfc/test/compileTemplate.spec.ts +28 -3
- 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/state.ts +2 -2
- package/src/core/vdom/modules/template-ref.ts +3 -2
- 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/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.4
|
|
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 = []);
|
|
@@ -4502,6 +4509,46 @@ function nextTick(cb, ctx) {
|
|
|
4502
4509
|
}
|
|
4503
4510
|
}
|
|
4504
4511
|
|
|
4512
|
+
function useCssModule(name = '$style') {
|
|
4513
|
+
/* istanbul ignore else */
|
|
4514
|
+
{
|
|
4515
|
+
if (!currentInstance) {
|
|
4516
|
+
warn$2(`useCssModule must be called inside setup()`);
|
|
4517
|
+
return emptyObject;
|
|
4518
|
+
}
|
|
4519
|
+
const mod = currentInstance[name];
|
|
4520
|
+
if (!mod) {
|
|
4521
|
+
warn$2(`Current instance does not have CSS module named "${name}".`);
|
|
4522
|
+
return emptyObject;
|
|
4523
|
+
}
|
|
4524
|
+
return mod;
|
|
4525
|
+
}
|
|
4526
|
+
}
|
|
4527
|
+
|
|
4528
|
+
/**
|
|
4529
|
+
* Runtime helper for SFC's CSS variable injection feature.
|
|
4530
|
+
* @private
|
|
4531
|
+
*/
|
|
4532
|
+
function useCssVars(getter) {
|
|
4533
|
+
if (!inBrowser && !false)
|
|
4534
|
+
return;
|
|
4535
|
+
const instance = currentInstance;
|
|
4536
|
+
if (!instance) {
|
|
4537
|
+
warn$2(`useCssVars is called without current active component instance.`);
|
|
4538
|
+
return;
|
|
4539
|
+
}
|
|
4540
|
+
watchPostEffect(() => {
|
|
4541
|
+
const el = instance.$el;
|
|
4542
|
+
const vars = getter(instance, instance._setupProxy);
|
|
4543
|
+
if (el && el.nodeType === 1) {
|
|
4544
|
+
const style = el.style;
|
|
4545
|
+
for (const key in vars) {
|
|
4546
|
+
style.setProperty(`--${key}`, vars[key]);
|
|
4547
|
+
}
|
|
4548
|
+
}
|
|
4549
|
+
});
|
|
4550
|
+
}
|
|
4551
|
+
|
|
4505
4552
|
function createLifeCycle(hookName) {
|
|
4506
4553
|
return (fn, target = currentInstance) => {
|
|
4507
4554
|
if (!target) {
|
|
@@ -4539,7 +4586,7 @@ const onServerPrefetch = createLifeCycle('serverPrefetch');
|
|
|
4539
4586
|
const onRenderTracked = createLifeCycle('renderTracked');
|
|
4540
4587
|
const onRenderTriggered = createLifeCycle('renderTriggered');
|
|
4541
4588
|
|
|
4542
|
-
const version = '2.7.0-beta.
|
|
4589
|
+
const version = '2.7.0-beta.4';
|
|
4543
4590
|
/**
|
|
4544
4591
|
* @internal type is manually declared in <root>/types/v3-define-component.d.ts
|
|
4545
4592
|
*/
|
|
@@ -4588,6 +4635,8 @@ var vca = /*#__PURE__*/Object.freeze({
|
|
|
4588
4635
|
nextTick: nextTick,
|
|
4589
4636
|
set: set,
|
|
4590
4637
|
del: del,
|
|
4638
|
+
useCssModule: useCssModule,
|
|
4639
|
+
useCssVars: useCssVars,
|
|
4591
4640
|
onBeforeMount: onBeforeMount,
|
|
4592
4641
|
onMounted: onMounted,
|
|
4593
4642
|
onBeforeUpdate: onBeforeUpdate,
|
|
@@ -6051,6 +6100,7 @@ function registerRef(vnode, isRemoval) {
|
|
|
6051
6100
|
const vm = vnode.context;
|
|
6052
6101
|
const refValue = vnode.componentInstance || vnode.elm;
|
|
6053
6102
|
const value = isRemoval ? null : refValue;
|
|
6103
|
+
const $refsValue = isRemoval ? undefined : refValue;
|
|
6054
6104
|
if (isFunction(ref)) {
|
|
6055
6105
|
invokeWithErrorHandling(ref, vm, [value], vm, `template ref function`);
|
|
6056
6106
|
return;
|
|
@@ -6087,7 +6137,7 @@ function registerRef(vnode, isRemoval) {
|
|
|
6087
6137
|
if (isRemoval && refs[ref] !== refValue) {
|
|
6088
6138
|
return;
|
|
6089
6139
|
}
|
|
6090
|
-
refs[ref] =
|
|
6140
|
+
refs[ref] = $refsValue;
|
|
6091
6141
|
setSetupRef(vm, ref, value);
|
|
6092
6142
|
}
|
|
6093
6143
|
else if (_isRef) {
|
|
@@ -6096,7 +6146,7 @@ function registerRef(vnode, isRemoval) {
|
|
|
6096
6146
|
}
|
|
6097
6147
|
ref.value = value;
|
|
6098
6148
|
if (setupRefKey)
|
|
6099
|
-
refs[setupRefKey] =
|
|
6149
|
+
refs[setupRefKey] = $refsValue;
|
|
6100
6150
|
}
|
|
6101
6151
|
else {
|
|
6102
6152
|
warn$2(`Invalid template ref type: ${typeof ref}`);
|