vue 2.7.7 → 2.7.8

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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Vue.js v2.7.7
2
+ * Vue.js v2.7.8
3
3
  * (c) 2014-2022 Evan You
4
4
  * Released under the MIT License.
5
5
  */
@@ -959,7 +959,7 @@ function defineReactive(obj, key, val, customSetter, shallow, mock) {
959
959
  // #7981: for accessor properties without setter
960
960
  return;
961
961
  }
962
- else if (isRef(value) && !isRef(newVal)) {
962
+ else if (!shallow && isRef(value) && !isRef(newVal)) {
963
963
  value.value = newVal;
964
964
  return;
965
965
  }
@@ -2232,7 +2232,19 @@ function createSetupContext(vm) {
2232
2232
  let exposeCalled = false;
2233
2233
  return {
2234
2234
  get attrs() {
2235
- return initAttrsProxy(vm);
2235
+ if (!vm._attrsProxy) {
2236
+ const proxy = (vm._attrsProxy = {});
2237
+ def(proxy, '_v_attr_proxy', true);
2238
+ syncSetupProxy(proxy, vm.$attrs, emptyObject, vm, '$attrs');
2239
+ }
2240
+ return vm._attrsProxy;
2241
+ },
2242
+ get listeners() {
2243
+ if (!vm._listenersProxy) {
2244
+ const proxy = (vm._listenersProxy = {});
2245
+ syncSetupProxy(proxy, vm.$listeners, emptyObject, vm, '$listeners');
2246
+ }
2247
+ return vm._listenersProxy;
2236
2248
  },
2237
2249
  get slots() {
2238
2250
  return initSlotsProxy(vm);
@@ -2251,20 +2263,12 @@ function createSetupContext(vm) {
2251
2263
  }
2252
2264
  };
2253
2265
  }
2254
- function initAttrsProxy(vm) {
2255
- if (!vm._attrsProxy) {
2256
- const proxy = (vm._attrsProxy = {});
2257
- def(proxy, '_v_attr_proxy', true);
2258
- syncSetupAttrs(proxy, vm.$attrs, emptyObject, vm);
2259
- }
2260
- return vm._attrsProxy;
2261
- }
2262
- function syncSetupAttrs(to, from, prev, instance) {
2266
+ function syncSetupProxy(to, from, prev, instance, type) {
2263
2267
  let changed = false;
2264
2268
  for (const key in from) {
2265
2269
  if (!(key in to)) {
2266
2270
  changed = true;
2267
- defineProxyAttr(to, key, instance);
2271
+ defineProxyAttr(to, key, instance, type);
2268
2272
  }
2269
2273
  else if (from[key] !== prev[key]) {
2270
2274
  changed = true;
@@ -2278,12 +2282,12 @@ function syncSetupAttrs(to, from, prev, instance) {
2278
2282
  }
2279
2283
  return changed;
2280
2284
  }
2281
- function defineProxyAttr(proxy, key, instance) {
2285
+ function defineProxyAttr(proxy, key, instance, type) {
2282
2286
  Object.defineProperty(proxy, key, {
2283
2287
  enumerable: true,
2284
2288
  configurable: true,
2285
2289
  get() {
2286
- return instance.$attrs[key];
2290
+ return instance[type][key];
2287
2291
  }
2288
2292
  });
2289
2293
  }
@@ -2304,17 +2308,27 @@ function syncSetupSlots(to, from) {
2304
2308
  }
2305
2309
  }
2306
2310
  /**
2307
- * @internal use manual type def
2311
+ * @internal use manual type def because public setup context type relies on
2312
+ * legacy VNode types
2308
2313
  */
2309
2314
  function useSlots() {
2310
2315
  return getContext().slots;
2311
2316
  }
2312
2317
  /**
2313
- * @internal use manual type def
2318
+ * @internal use manual type def because public setup context type relies on
2319
+ * legacy VNode types
2314
2320
  */
2315
2321
  function useAttrs() {
2316
2322
  return getContext().attrs;
2317
2323
  }
2324
+ /**
2325
+ * Vue 2 only
2326
+ * @internal use manual type def because public setup context type relies on
2327
+ * legacy VNode types
2328
+ */
2329
+ function useListeners() {
2330
+ return getContext().listeners;
2331
+ }
2318
2332
  function getContext() {
2319
2333
  if (!currentInstance) {
2320
2334
  warn$2(`useContext() called without active instance.`);
@@ -2915,12 +2929,19 @@ function updateChildComponent(vm, propsData, listeners, parentVnode, renderChild
2915
2929
  if (vm._attrsProxy) {
2916
2930
  // force update if attrs are accessed and has changed since it may be
2917
2931
  // passed to a child component.
2918
- if (syncSetupAttrs(vm._attrsProxy, attrs, (prevVNode.data && prevVNode.data.attrs) || emptyObject, vm)) {
2932
+ if (syncSetupProxy(vm._attrsProxy, attrs, (prevVNode.data && prevVNode.data.attrs) || emptyObject, vm, '$attrs')) {
2919
2933
  needsForceUpdate = true;
2920
2934
  }
2921
2935
  }
2922
2936
  vm.$attrs = attrs;
2923
- vm.$listeners = listeners || emptyObject;
2937
+ // update listeners
2938
+ listeners = listeners || emptyObject;
2939
+ const prevListeners = vm.$options._parentListeners;
2940
+ if (vm._listenersProxy) {
2941
+ syncSetupProxy(vm._listenersProxy, listeners, prevListeners || emptyObject, vm, '$listeners');
2942
+ }
2943
+ vm.$listeners = vm.$options._parentListeners = listeners;
2944
+ updateComponentListeners(vm, listeners, prevListeners);
2924
2945
  // update props
2925
2946
  if (propsData && vm.$options.props) {
2926
2947
  toggleObserving(false);
@@ -2935,11 +2956,6 @@ function updateChildComponent(vm, propsData, listeners, parentVnode, renderChild
2935
2956
  // keep a copy of raw propsData
2936
2957
  vm.$options.propsData = propsData;
2937
2958
  }
2938
- // update listeners
2939
- listeners = listeners || emptyObject;
2940
- const oldListeners = vm.$options._parentListeners;
2941
- vm.$options._parentListeners = listeners;
2942
- updateComponentListeners(vm, listeners, oldListeners);
2943
2959
  // resolve slots + force update if has children
2944
2960
  if (needsForceUpdate) {
2945
2961
  vm.$slots = resolveSlots(renderChildren, parentVnode.context);
@@ -3873,7 +3889,7 @@ const onRenderTriggered = createLifeCycle('renderTriggered');
3873
3889
  /**
3874
3890
  * Note: also update dist/vue.runtime.mjs when adding new exports to this file.
3875
3891
  */
3876
- const version = '2.7.7';
3892
+ const version = '2.7.8';
3877
3893
  /**
3878
3894
  * @internal type is manually declared in <root>/types/v3-define-component.d.ts
3879
3895
  */
@@ -10769,10 +10785,7 @@ function genElement(el, state) {
10769
10785
  // check if this is a component in <script setup>
10770
10786
  const bindings = state.options.bindings;
10771
10787
  if (maybeComponent && bindings && bindings.__isScriptSetup !== false) {
10772
- tag =
10773
- checkBindingType(bindings, el.tag) ||
10774
- checkBindingType(bindings, camelize(el.tag)) ||
10775
- checkBindingType(bindings, capitalize(camelize(el.tag)));
10788
+ tag = checkBindingType(bindings, el.tag);
10776
10789
  }
10777
10790
  if (!tag)
10778
10791
  tag = `'${el.tag}'`;
@@ -10789,9 +10802,29 @@ function genElement(el, state) {
10789
10802
  }
10790
10803
  }
10791
10804
  function checkBindingType(bindings, key) {
10792
- const type = bindings[key];
10793
- if (type && type.startsWith('setup')) {
10794
- return key;
10805
+ const camelName = camelize(key);
10806
+ const PascalName = capitalize(camelName);
10807
+ const checkType = (type) => {
10808
+ if (bindings[key] === type) {
10809
+ return key;
10810
+ }
10811
+ if (bindings[camelName] === type) {
10812
+ return camelName;
10813
+ }
10814
+ if (bindings[PascalName] === type) {
10815
+ return PascalName;
10816
+ }
10817
+ };
10818
+ const fromConst = checkType("setup-const" /* BindingTypes.SETUP_CONST */) ||
10819
+ checkType("setup-reactive-const" /* BindingTypes.SETUP_REACTIVE_CONST */);
10820
+ if (fromConst) {
10821
+ return fromConst;
10822
+ }
10823
+ const fromMaybeRef = checkType("setup-let" /* BindingTypes.SETUP_LET */) ||
10824
+ checkType("setup-ref" /* BindingTypes.SETUP_REF */) ||
10825
+ checkType("setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */);
10826
+ if (fromMaybeRef) {
10827
+ return fromMaybeRef;
10795
10828
  }
10796
10829
  }
10797
10830
  // hoist static sub-trees out
@@ -11610,4 +11643,4 @@ function getOuterHTML(el) {
11610
11643
  }
11611
11644
  Vue.compile = compileToFunctions;
11612
11645
 
11613
- export { EffectScope, computed, customRef, Vue as default, defineAsyncComponent, 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 };
11646
+ export { EffectScope, computed, customRef, Vue as default, defineAsyncComponent, 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, useListeners, useSlots, version, watch, watchEffect, watchPostEffect, watchSyncEffect };