vue 2.7.3 → 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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Vue.js v2.7.3
2
+ * Vue.js v2.7.4
3
3
  * (c) 2014-2022 Evan You
4
4
  * Released under the MIT License.
5
5
  */
@@ -2528,7 +2528,7 @@ function renderStatic(index, isInFor) {
2528
2528
  return tree;
2529
2529
  }
2530
2530
  // otherwise, render a fresh tree.
2531
- tree = cached[index] = this.$options.staticRenderFns[index].call(this._renderProxy, null, this // for render fns generated for functional component templates
2531
+ tree = cached[index] = this.$options.staticRenderFns[index].call(this._renderProxy, this._c, this // for render fns generated for functional component templates
2532
2532
  );
2533
2533
  markStatic$1(tree, `__static__${index}`, false);
2534
2534
  return tree;
@@ -4301,8 +4301,8 @@ function doWatch(source, cb, { immediate, deep, flush = 'pre', onTrack, onTrigge
4301
4301
  else {
4302
4302
  // pre
4303
4303
  watcher.update = () => {
4304
- if (instance && instance === currentInstance) {
4305
- // pre-watcher triggered inside setup()
4304
+ if (instance && instance === currentInstance && !instance._isMounted) {
4305
+ // pre-watcher triggered before
4306
4306
  const buffer = instance._preWatchers || (instance._preWatchers = []);
4307
4307
  if (buffer.indexOf(watcher) < 0)
4308
4308
  buffer.push(watcher);
@@ -4568,6 +4568,77 @@ function useCssVars(getter) {
4568
4568
  });
4569
4569
  }
4570
4570
 
4571
+ /**
4572
+ * v3-compatible async component API.
4573
+ * @internal the type is manually declared in <root>/types/v3-define-async-component.d.ts
4574
+ * because it relies on existing manual types
4575
+ */
4576
+ function defineAsyncComponent(source) {
4577
+ if (isFunction(source)) {
4578
+ source = { loader: source };
4579
+ }
4580
+ const { loader, loadingComponent, errorComponent, delay = 200, timeout, // undefined = never times out
4581
+ suspensible = false, // in Vue 3 default is true
4582
+ onError: userOnError } = source;
4583
+ if (suspensible) {
4584
+ warn$2(`The suspensiblbe option for async components is not supported in Vue2. It is ignored.`);
4585
+ }
4586
+ let pendingRequest = null;
4587
+ let retries = 0;
4588
+ const retry = () => {
4589
+ retries++;
4590
+ pendingRequest = null;
4591
+ return load();
4592
+ };
4593
+ const load = () => {
4594
+ let thisRequest;
4595
+ return (pendingRequest ||
4596
+ (thisRequest = pendingRequest =
4597
+ loader()
4598
+ .catch(err => {
4599
+ err = err instanceof Error ? err : new Error(String(err));
4600
+ if (userOnError) {
4601
+ return new Promise((resolve, reject) => {
4602
+ const userRetry = () => resolve(retry());
4603
+ const userFail = () => reject(err);
4604
+ userOnError(err, userRetry, userFail, retries + 1);
4605
+ });
4606
+ }
4607
+ else {
4608
+ throw err;
4609
+ }
4610
+ })
4611
+ .then((comp) => {
4612
+ if (thisRequest !== pendingRequest && pendingRequest) {
4613
+ return pendingRequest;
4614
+ }
4615
+ if (!comp) {
4616
+ warn$2(`Async component loader resolved to undefined. ` +
4617
+ `If you are using retry(), make sure to return its return value.`);
4618
+ }
4619
+ // interop module default
4620
+ if (comp &&
4621
+ (comp.__esModule || comp[Symbol.toStringTag] === 'Module')) {
4622
+ comp = comp.default;
4623
+ }
4624
+ if (comp && !isObject(comp) && !isFunction(comp)) {
4625
+ throw new Error(`Invalid async component load result: ${comp}`);
4626
+ }
4627
+ return comp;
4628
+ })));
4629
+ };
4630
+ return () => {
4631
+ const component = load();
4632
+ return {
4633
+ component,
4634
+ delay,
4635
+ timeout,
4636
+ error: errorComponent,
4637
+ loading: loadingComponent
4638
+ };
4639
+ };
4640
+ }
4641
+
4571
4642
  function createLifeCycle(hookName) {
4572
4643
  return (fn, target = currentInstance) => {
4573
4644
  if (!target) {
@@ -4605,7 +4676,10 @@ const onServerPrefetch = createLifeCycle('serverPrefetch');
4605
4676
  const onRenderTracked = createLifeCycle('renderTracked');
4606
4677
  const onRenderTriggered = createLifeCycle('renderTriggered');
4607
4678
 
4608
- const version = '2.7.3';
4679
+ /**
4680
+ * Note: also update dist/vue.runtime.mjs when adding new exports to this file.
4681
+ */
4682
+ const version = '2.7.4';
4609
4683
  /**
4610
4684
  * @internal type is manually declared in <root>/types/v3-define-component.d.ts
4611
4685
  */
@@ -4657,6 +4731,7 @@ var vca = /*#__PURE__*/Object.freeze({
4657
4731
  del: del,
4658
4732
  useCssModule: useCssModule,
4659
4733
  useCssVars: useCssVars,
4734
+ defineAsyncComponent: defineAsyncComponent,
4660
4735
  onBeforeMount: onBeforeMount,
4661
4736
  onMounted: onMounted,
4662
4737
  onBeforeUpdate: onBeforeUpdate,
@@ -4853,7 +4928,7 @@ function set(target, key, val) {
4853
4928
  target.length = Math.max(target.length, key);
4854
4929
  target.splice(key, 1, val);
4855
4930
  // when mocking for SSR, array methods are not hijacked
4856
- if (!ob.shallow && ob.mock) {
4931
+ if (ob && !ob.shallow && ob.mock) {
4857
4932
  observe(val, false, true);
4858
4933
  }
4859
4934
  return val;