@vue/compat 3.2.11 → 3.2.12

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.cjs.js CHANGED
@@ -2586,12 +2586,12 @@ function markAttrsAccessed() {
2586
2586
  function renderComponentRoot(instance) {
2587
2587
  const { type: Component, vnode, proxy, withProxy, props, propsOptions: [propsOptions], slots, attrs, emit, render, renderCache, data, setupState, ctx, inheritAttrs } = instance;
2588
2588
  let result;
2589
+ let fallthroughAttrs;
2589
2590
  const prev = setCurrentRenderingInstance(instance);
2590
2591
  {
2591
2592
  accessedAttrs = false;
2592
2593
  }
2593
2594
  try {
2594
- let fallthroughAttrs;
2595
2595
  if (vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */) {
2596
2596
  // withProxy is a proxy with a different `has` trap only for
2597
2597
  // runtime-compiled render functions using `with` block.
@@ -2622,108 +2622,105 @@ function renderComponentRoot(instance) {
2622
2622
  ? attrs
2623
2623
  : getFunctionalFallthrough(attrs);
2624
2624
  }
2625
- // attr merging
2626
- // in dev mode, comments are preserved, and it's possible for a template
2627
- // to have comments along side the root element which makes it a fragment
2628
- let root = result;
2629
- let setRoot = undefined;
2630
- if (true &&
2631
- result.patchFlag > 0 &&
2632
- result.patchFlag & 2048 /* DEV_ROOT_FRAGMENT */) {
2633
- ;
2634
- [root, setRoot] = getChildRoot(result);
2635
- }
2636
- if (fallthroughAttrs && inheritAttrs !== false) {
2637
- const keys = Object.keys(fallthroughAttrs);
2638
- const { shapeFlag } = root;
2639
- if (keys.length) {
2640
- if (shapeFlag & (1 /* ELEMENT */ | 6 /* COMPONENT */)) {
2641
- if (propsOptions && keys.some(isModelListener)) {
2642
- // If a v-model listener (onUpdate:xxx) has a corresponding declared
2643
- // prop, it indicates this component expects to handle v-model and
2644
- // it should not fallthrough.
2645
- // related: #1543, #1643, #1989
2646
- fallthroughAttrs = filterModelListeners(fallthroughAttrs, propsOptions);
2647
- }
2648
- root = cloneVNode(root, fallthroughAttrs);
2649
- }
2650
- else if (true && !accessedAttrs && root.type !== Comment) {
2651
- const allAttrs = Object.keys(attrs);
2652
- const eventAttrs = [];
2653
- const extraAttrs = [];
2654
- for (let i = 0, l = allAttrs.length; i < l; i++) {
2655
- const key = allAttrs[i];
2656
- if (isOn(key)) {
2657
- // ignore v-model handlers when they fail to fallthrough
2658
- if (!isModelListener(key)) {
2659
- // remove `on`, lowercase first letter to reflect event casing
2660
- // accurately
2661
- eventAttrs.push(key[2].toLowerCase() + key.slice(3));
2662
- }
2663
- }
2664
- else {
2665
- extraAttrs.push(key);
2625
+ }
2626
+ catch (err) {
2627
+ blockStack.length = 0;
2628
+ handleError(err, instance, 1 /* RENDER_FUNCTION */);
2629
+ result = createVNode(Comment);
2630
+ }
2631
+ // attr merging
2632
+ // in dev mode, comments are preserved, and it's possible for a template
2633
+ // to have comments along side the root element which makes it a fragment
2634
+ let root = result;
2635
+ let setRoot = undefined;
2636
+ if (result.patchFlag > 0 &&
2637
+ result.patchFlag & 2048 /* DEV_ROOT_FRAGMENT */) {
2638
+ [root, setRoot] = getChildRoot(result);
2639
+ }
2640
+ if (fallthroughAttrs && inheritAttrs !== false) {
2641
+ const keys = Object.keys(fallthroughAttrs);
2642
+ const { shapeFlag } = root;
2643
+ if (keys.length) {
2644
+ if (shapeFlag & (1 /* ELEMENT */ | 6 /* COMPONENT */)) {
2645
+ if (propsOptions && keys.some(isModelListener)) {
2646
+ // If a v-model listener (onUpdate:xxx) has a corresponding declared
2647
+ // prop, it indicates this component expects to handle v-model and
2648
+ // it should not fallthrough.
2649
+ // related: #1543, #1643, #1989
2650
+ fallthroughAttrs = filterModelListeners(fallthroughAttrs, propsOptions);
2651
+ }
2652
+ root = cloneVNode(root, fallthroughAttrs);
2653
+ }
2654
+ else if (!accessedAttrs && root.type !== Comment) {
2655
+ const allAttrs = Object.keys(attrs);
2656
+ const eventAttrs = [];
2657
+ const extraAttrs = [];
2658
+ for (let i = 0, l = allAttrs.length; i < l; i++) {
2659
+ const key = allAttrs[i];
2660
+ if (isOn(key)) {
2661
+ // ignore v-model handlers when they fail to fallthrough
2662
+ if (!isModelListener(key)) {
2663
+ // remove `on`, lowercase first letter to reflect event casing
2664
+ // accurately
2665
+ eventAttrs.push(key[2].toLowerCase() + key.slice(3));
2666
2666
  }
2667
2667
  }
2668
- if (extraAttrs.length) {
2669
- warn$1(`Extraneous non-props attributes (` +
2670
- `${extraAttrs.join(', ')}) ` +
2671
- `were passed to component but could not be automatically inherited ` +
2672
- `because component renders fragment or text root nodes.`);
2673
- }
2674
- if (eventAttrs.length) {
2675
- warn$1(`Extraneous non-emits event listeners (` +
2676
- `${eventAttrs.join(', ')}) ` +
2677
- `were passed to component but could not be automatically inherited ` +
2678
- `because component renders fragment or text root nodes. ` +
2679
- `If the listener is intended to be a component custom event listener only, ` +
2680
- `declare it using the "emits" option.`);
2668
+ else {
2669
+ extraAttrs.push(key);
2681
2670
  }
2682
2671
  }
2683
- }
2684
- }
2685
- if (true &&
2686
- isCompatEnabled("INSTANCE_ATTRS_CLASS_STYLE" /* INSTANCE_ATTRS_CLASS_STYLE */, instance) &&
2687
- vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */ &&
2688
- root.shapeFlag & (1 /* ELEMENT */ | 6 /* COMPONENT */)) {
2689
- const { class: cls, style } = vnode.props || {};
2690
- if (cls || style) {
2691
- if (true && inheritAttrs === false) {
2692
- warnDeprecation("INSTANCE_ATTRS_CLASS_STYLE" /* INSTANCE_ATTRS_CLASS_STYLE */, instance, getComponentName(instance.type));
2672
+ if (extraAttrs.length) {
2673
+ warn$1(`Extraneous non-props attributes (` +
2674
+ `${extraAttrs.join(', ')}) ` +
2675
+ `were passed to component but could not be automatically inherited ` +
2676
+ `because component renders fragment or text root nodes.`);
2677
+ }
2678
+ if (eventAttrs.length) {
2679
+ warn$1(`Extraneous non-emits event listeners (` +
2680
+ `${eventAttrs.join(', ')}) ` +
2681
+ `were passed to component but could not be automatically inherited ` +
2682
+ `because component renders fragment or text root nodes. ` +
2683
+ `If the listener is intended to be a component custom event listener only, ` +
2684
+ `declare it using the "emits" option.`);
2693
2685
  }
2694
- root = cloneVNode(root, {
2695
- class: cls,
2696
- style: style
2697
- });
2698
- }
2699
- }
2700
- // inherit directives
2701
- if (vnode.dirs) {
2702
- if (true && !isElementRoot(root)) {
2703
- warn$1(`Runtime directive used on component with non-element root node. ` +
2704
- `The directives will not function as intended.`);
2705
2686
  }
2706
- root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
2707
2687
  }
2708
- // inherit transition data
2709
- if (vnode.transition) {
2710
- if (true && !isElementRoot(root)) {
2711
- warn$1(`Component inside <Transition> renders non-element root node ` +
2712
- `that cannot be animated.`);
2688
+ }
2689
+ if (isCompatEnabled("INSTANCE_ATTRS_CLASS_STYLE" /* INSTANCE_ATTRS_CLASS_STYLE */, instance) &&
2690
+ vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */ &&
2691
+ root.shapeFlag & (1 /* ELEMENT */ | 6 /* COMPONENT */)) {
2692
+ const { class: cls, style } = vnode.props || {};
2693
+ if (cls || style) {
2694
+ if (inheritAttrs === false) {
2695
+ warnDeprecation("INSTANCE_ATTRS_CLASS_STYLE" /* INSTANCE_ATTRS_CLASS_STYLE */, instance, getComponentName(instance.type));
2713
2696
  }
2714
- root.transition = vnode.transition;
2697
+ root = cloneVNode(root, {
2698
+ class: cls,
2699
+ style: style
2700
+ });
2715
2701
  }
2716
- if (true && setRoot) {
2717
- setRoot(root);
2702
+ }
2703
+ // inherit directives
2704
+ if (vnode.dirs) {
2705
+ if (!isElementRoot(root)) {
2706
+ warn$1(`Runtime directive used on component with non-element root node. ` +
2707
+ `The directives will not function as intended.`);
2718
2708
  }
2719
- else {
2720
- result = root;
2709
+ root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
2710
+ }
2711
+ // inherit transition data
2712
+ if (vnode.transition) {
2713
+ if (!isElementRoot(root)) {
2714
+ warn$1(`Component inside <Transition> renders non-element root node ` +
2715
+ `that cannot be animated.`);
2721
2716
  }
2717
+ root.transition = vnode.transition;
2722
2718
  }
2723
- catch (err) {
2724
- blockStack.length = 0;
2725
- handleError(err, instance, 1 /* RENDER_FUNCTION */);
2726
- result = createVNode(Comment);
2719
+ if (setRoot) {
2720
+ setRoot(root);
2721
+ }
2722
+ else {
2723
+ result = root;
2727
2724
  }
2728
2725
  setCurrentRenderingInstance(prev);
2729
2726
  return result;
@@ -3258,8 +3255,8 @@ function normalizeSuspenseChildren(vnode) {
3258
3255
  function normalizeSuspenseSlot(s) {
3259
3256
  let block;
3260
3257
  if (isFunction(s)) {
3261
- const isCompiledSlot = s._c;
3262
- if (isCompiledSlot) {
3258
+ const trackBlock = isBlockTreeEnabled && s._c;
3259
+ if (trackBlock) {
3263
3260
  // disableTracking: false
3264
3261
  // allow block tracking for compiled slots
3265
3262
  // (see ./componentRenderContext.ts)
@@ -3267,7 +3264,7 @@ function normalizeSuspenseSlot(s) {
3267
3264
  openBlock();
3268
3265
  }
3269
3266
  s = s();
3270
- if (isCompiledSlot) {
3267
+ if (trackBlock) {
3271
3268
  s._d = true;
3272
3269
  block = currentBlock;
3273
3270
  closeBlock();
@@ -5423,7 +5420,7 @@ function createCompatVue(createApp, createSingletonApp) {
5423
5420
  return vm;
5424
5421
  }
5425
5422
  }
5426
- Vue.version = "3.2.11";
5423
+ Vue.version = "3.2.12";
5427
5424
  Vue.config = singletonApp.config;
5428
5425
  Vue.use = (p, ...options) => {
5429
5426
  if (p && isFunction(p.install)) {
@@ -8071,7 +8068,11 @@ function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false
8071
8068
  return Component;
8072
8069
  }
8073
8070
  if (warnMissing && !res) {
8074
- warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}`);
8071
+ const extra = type === COMPONENTS
8072
+ ? `\nIf this is a native custom element, make sure to exclude it from ` +
8073
+ `component resolution via compilerOptions.isCustomElement.`
8074
+ : ``;
8075
+ warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
8075
8076
  }
8076
8077
  return res;
8077
8078
  }
@@ -9513,17 +9514,19 @@ function exposePropsOnRenderContext(instance) {
9513
9514
  function exposeSetupStateOnRenderContext(instance) {
9514
9515
  const { ctx, setupState } = instance;
9515
9516
  Object.keys(toRaw(setupState)).forEach(key => {
9516
- if (!setupState.__isScriptSetup && (key[0] === '$' || key[0] === '_')) {
9517
- warn$1(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" ` +
9518
- `which are reserved prefixes for Vue internals.`);
9519
- return;
9517
+ if (!setupState.__isScriptSetup) {
9518
+ if (key[0] === '$' || key[0] === '_') {
9519
+ warn$1(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" ` +
9520
+ `which are reserved prefixes for Vue internals.`);
9521
+ return;
9522
+ }
9523
+ Object.defineProperty(ctx, key, {
9524
+ enumerable: true,
9525
+ configurable: true,
9526
+ get: () => setupState[key],
9527
+ set: NOOP
9528
+ });
9520
9529
  }
9521
- Object.defineProperty(ctx, key, {
9522
- enumerable: true,
9523
- configurable: true,
9524
- get: () => setupState[key],
9525
- set: NOOP
9526
- });
9527
9530
  });
9528
9531
  }
9529
9532
 
@@ -10296,11 +10299,18 @@ function flushJobs(seen) {
10296
10299
  // 2. If a component is unmounted during a parent component's update,
10297
10300
  // its update can be skipped.
10298
10301
  queue.sort((a, b) => getId(a) - getId(b));
10302
+ // conditional usage of checkRecursiveUpdate must be determined out of
10303
+ // try ... catch block since Rollup by default de-optimizes treeshaking
10304
+ // inside try-catch. This can leave all warning code unshaked. Although
10305
+ // they would get eventually shaken by a minifier like terser, some minifiers
10306
+ // would fail to do that (e.g. https://github.com/evanw/esbuild/issues/1610)
10307
+ const check = (job) => checkRecursiveUpdates(seen, job)
10308
+ ;
10299
10309
  try {
10300
10310
  for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
10301
10311
  const job = queue[flushIndex];
10302
10312
  if (job && job.active !== false) {
10303
- if (true && checkRecursiveUpdates(seen, job)) {
10313
+ if (true && check(job)) {
10304
10314
  continue;
10305
10315
  }
10306
10316
  // console.log(`running:`, job.id)
@@ -11010,7 +11020,7 @@ function isMemoSame(cached, memo) {
11010
11020
  }
11011
11021
 
11012
11022
  // Core API ------------------------------------------------------------------
11013
- const version = "3.2.11";
11023
+ const version = "3.2.12";
11014
11024
  const _ssrUtils = {
11015
11025
  createComponentInstance,
11016
11026
  setupComponent,
@@ -11544,6 +11554,7 @@ class VueElement extends BaseClass {
11544
11554
  this._instance = null;
11545
11555
  this._connected = false;
11546
11556
  this._resolved = false;
11557
+ this._numberProps = null;
11547
11558
  if (this.shadowRoot && hydrate) {
11548
11559
  hydrate(this._createVNode(), this.shadowRoot);
11549
11560
  }
@@ -11559,18 +11570,17 @@ class VueElement extends BaseClass {
11559
11570
  this._setAttr(this.attributes[i].name);
11560
11571
  }
11561
11572
  // watch future attr changes
11562
- const observer = new MutationObserver(mutations => {
11573
+ new MutationObserver(mutations => {
11563
11574
  for (const m of mutations) {
11564
11575
  this._setAttr(m.attributeName);
11565
11576
  }
11566
- });
11567
- observer.observe(this, { attributes: true });
11577
+ }).observe(this, { attributes: true });
11568
11578
  }
11569
11579
  connectedCallback() {
11570
11580
  this._connected = true;
11571
11581
  if (!this._instance) {
11572
11582
  this._resolveDef();
11573
- render(this._createVNode(), this.shadowRoot);
11583
+ this._update();
11574
11584
  }
11575
11585
  }
11576
11586
  disconnectedCallback() {
@@ -11591,15 +11601,31 @@ class VueElement extends BaseClass {
11591
11601
  }
11592
11602
  const resolve = (def) => {
11593
11603
  this._resolved = true;
11604
+ const { props, styles } = def;
11605
+ const hasOptions = !isArray(props);
11606
+ const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
11607
+ // cast Number-type props set before resolve
11608
+ let numberProps;
11609
+ if (hasOptions) {
11610
+ for (const key in this._props) {
11611
+ const opt = props[key];
11612
+ if (opt === Number || (opt && opt.type === Number)) {
11613
+ this._props[key] = toNumber(this._props[key]);
11614
+ (numberProps || (numberProps = Object.create(null)))[key] = true;
11615
+ }
11616
+ }
11617
+ }
11618
+ if (numberProps) {
11619
+ this._numberProps = numberProps;
11620
+ this._update();
11621
+ }
11594
11622
  // check if there are props set pre-upgrade or connect
11595
11623
  for (const key of Object.keys(this)) {
11596
11624
  if (key[0] !== '_') {
11597
11625
  this._setProp(key, this[key]);
11598
11626
  }
11599
11627
  }
11600
- const { props, styles } = def;
11601
11628
  // defining getter/setters on prototype
11602
- const rawKeys = props ? (isArray(props) ? props : Object.keys(props)) : [];
11603
11629
  for (const key of rawKeys.map(camelize)) {
11604
11630
  Object.defineProperty(this, key, {
11605
11631
  get() {
@@ -11621,7 +11647,11 @@ class VueElement extends BaseClass {
11621
11647
  }
11622
11648
  }
11623
11649
  _setAttr(key) {
11624
- this._setProp(camelize(key), toNumber(this.getAttribute(key)), false);
11650
+ let value = this.getAttribute(key);
11651
+ if (this._numberProps && this._numberProps[key]) {
11652
+ value = toNumber(value);
11653
+ }
11654
+ this._setProp(camelize(key), value, false);
11625
11655
  }
11626
11656
  /**
11627
11657
  * @internal
@@ -11636,7 +11666,7 @@ class VueElement extends BaseClass {
11636
11666
  if (val !== this._props[key]) {
11637
11667
  this._props[key] = val;
11638
11668
  if (this._instance) {
11639
- render(this._createVNode(), this.shadowRoot);
11669
+ this._update();
11640
11670
  }
11641
11671
  // reflect
11642
11672
  if (shouldReflect) {
@@ -11652,6 +11682,9 @@ class VueElement extends BaseClass {
11652
11682
  }
11653
11683
  }
11654
11684
  }
11685
+ _update() {
11686
+ render(this._createVNode(), this.shadowRoot);
11687
+ }
11655
11688
  _createVNode() {
11656
11689
  const vnode = createVNode(this._def, extend({}, this._props));
11657
11690
  if (!this._instance) {
@@ -11672,7 +11705,7 @@ class VueElement extends BaseClass {
11672
11705
  if (!this._def.__asyncLoader) {
11673
11706
  // reload
11674
11707
  this._instance = null;
11675
- render(this._createVNode(), this.shadowRoot);
11708
+ this._update();
11676
11709
  }
11677
11710
  };
11678
11711
  }
@@ -17448,7 +17481,7 @@ function buildProps(node, context, props = node.props, ssr = false) {
17448
17481
  // acrtual ref instead.
17449
17482
  if (context.inline && (value === null || value === void 0 ? void 0 : value.content)) {
17450
17483
  valueNode = createFunctionExpression(['_value', '_refs']);
17451
- valueNode.body = createBlockStatement(processInlineRef(context.bindingMetadata, value.content));
17484
+ valueNode.body = createBlockStatement(processInlineRef(context, value.content));
17452
17485
  }
17453
17486
  }
17454
17487
  // skip is on <component>, or is="vue:xxx"
@@ -17768,14 +17801,18 @@ function stringifyDynamicPropNames(props) {
17768
17801
  function isComponentTag(tag) {
17769
17802
  return tag[0].toLowerCase() + tag.slice(1) === 'component';
17770
17803
  }
17771
- function processInlineRef(bindings, raw) {
17804
+ function processInlineRef(context, raw) {
17772
17805
  const body = [createSimpleExpression(`_refs['${raw}'] = _value`)];
17773
- const type = bindings[raw];
17806
+ const { bindingMetadata, helperString } = context;
17807
+ const type = bindingMetadata[raw];
17774
17808
  if (type === "setup-ref" /* SETUP_REF */) {
17775
17809
  body.push(createSimpleExpression(`${raw}.value = _value`));
17776
17810
  }
17811
+ else if (type === "setup-maybe-ref" /* SETUP_MAYBE_REF */) {
17812
+ body.push(createSimpleExpression(`${helperString(IS_REF)}(${raw}) && (${raw}.value = _value)`));
17813
+ }
17777
17814
  else if (type === "setup-let" /* SETUP_LET */) {
17778
- body.push(createSimpleExpression(`${raw} = _value`));
17815
+ body.push(createSimpleExpression(`${helperString(IS_REF)}(${raw}) ? ${raw}.value = _value : ${raw} = _value`));
17779
17816
  }
17780
17817
  return body;
17781
17818
  }
@@ -17852,7 +17889,7 @@ function processSlotOutlet(node, context) {
17852
17889
  };
17853
17890
  }
17854
17891
 
17855
- const fnExpRE = /^\s*([\w$_]+|\([^)]*?\))\s*=>|^\s*function(?:\s+[\w$]+)?\s*\(/;
17892
+ const fnExpRE = /^\s*([\w$_]+|(async\s*)?\([^)]*?\))\s*=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/;
17856
17893
  const transformOn = (dir, node, context, augmentor) => {
17857
17894
  const { loc, modifiers, arg } = dir;
17858
17895
  if (!dir.exp && !modifiers.length) {