@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.
@@ -2458,12 +2458,12 @@ function markAttrsAccessed() {
2458
2458
  function renderComponentRoot(instance) {
2459
2459
  const { type: Component, vnode, proxy, withProxy, props, propsOptions: [propsOptions], slots, attrs, emit, render, renderCache, data, setupState, ctx, inheritAttrs } = instance;
2460
2460
  let result;
2461
+ let fallthroughAttrs;
2461
2462
  const prev = setCurrentRenderingInstance(instance);
2462
2463
  if ((process.env.NODE_ENV !== 'production')) {
2463
2464
  accessedAttrs = false;
2464
2465
  }
2465
2466
  try {
2466
- let fallthroughAttrs;
2467
2467
  if (vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */) {
2468
2468
  // withProxy is a proxy with a different `has` trap only for
2469
2469
  // runtime-compiled render functions using `with` block.
@@ -2494,108 +2494,106 @@ function renderComponentRoot(instance) {
2494
2494
  ? attrs
2495
2495
  : getFunctionalFallthrough(attrs);
2496
2496
  }
2497
- // attr merging
2498
- // in dev mode, comments are preserved, and it's possible for a template
2499
- // to have comments along side the root element which makes it a fragment
2500
- let root = result;
2501
- let setRoot = undefined;
2502
- if ((process.env.NODE_ENV !== 'production') &&
2503
- result.patchFlag > 0 &&
2504
- result.patchFlag & 2048 /* DEV_ROOT_FRAGMENT */) {
2505
- ;
2506
- [root, setRoot] = getChildRoot(result);
2507
- }
2508
- if (fallthroughAttrs && inheritAttrs !== false) {
2509
- const keys = Object.keys(fallthroughAttrs);
2510
- const { shapeFlag } = root;
2511
- if (keys.length) {
2512
- if (shapeFlag & (1 /* ELEMENT */ | 6 /* COMPONENT */)) {
2513
- if (propsOptions && keys.some(isModelListener)) {
2514
- // If a v-model listener (onUpdate:xxx) has a corresponding declared
2515
- // prop, it indicates this component expects to handle v-model and
2516
- // it should not fallthrough.
2517
- // related: #1543, #1643, #1989
2518
- fallthroughAttrs = filterModelListeners(fallthroughAttrs, propsOptions);
2519
- }
2520
- root = cloneVNode(root, fallthroughAttrs);
2521
- }
2522
- else if ((process.env.NODE_ENV !== 'production') && !accessedAttrs && root.type !== Comment) {
2523
- const allAttrs = Object.keys(attrs);
2524
- const eventAttrs = [];
2525
- const extraAttrs = [];
2526
- for (let i = 0, l = allAttrs.length; i < l; i++) {
2527
- const key = allAttrs[i];
2528
- if (isOn(key)) {
2529
- // ignore v-model handlers when they fail to fallthrough
2530
- if (!isModelListener(key)) {
2531
- // remove `on`, lowercase first letter to reflect event casing
2532
- // accurately
2533
- eventAttrs.push(key[2].toLowerCase() + key.slice(3));
2534
- }
2535
- }
2536
- else {
2537
- extraAttrs.push(key);
2497
+ }
2498
+ catch (err) {
2499
+ blockStack.length = 0;
2500
+ handleError(err, instance, 1 /* RENDER_FUNCTION */);
2501
+ result = createVNode(Comment);
2502
+ }
2503
+ // attr merging
2504
+ // in dev mode, comments are preserved, and it's possible for a template
2505
+ // to have comments along side the root element which makes it a fragment
2506
+ let root = result;
2507
+ let setRoot = undefined;
2508
+ if ((process.env.NODE_ENV !== 'production') &&
2509
+ result.patchFlag > 0 &&
2510
+ result.patchFlag & 2048 /* DEV_ROOT_FRAGMENT */) {
2511
+ [root, setRoot] = getChildRoot(result);
2512
+ }
2513
+ if (fallthroughAttrs && inheritAttrs !== false) {
2514
+ const keys = Object.keys(fallthroughAttrs);
2515
+ const { shapeFlag } = root;
2516
+ if (keys.length) {
2517
+ if (shapeFlag & (1 /* ELEMENT */ | 6 /* COMPONENT */)) {
2518
+ if (propsOptions && keys.some(isModelListener)) {
2519
+ // If a v-model listener (onUpdate:xxx) has a corresponding declared
2520
+ // prop, it indicates this component expects to handle v-model and
2521
+ // it should not fallthrough.
2522
+ // related: #1543, #1643, #1989
2523
+ fallthroughAttrs = filterModelListeners(fallthroughAttrs, propsOptions);
2524
+ }
2525
+ root = cloneVNode(root, fallthroughAttrs);
2526
+ }
2527
+ else if ((process.env.NODE_ENV !== 'production') && !accessedAttrs && root.type !== Comment) {
2528
+ const allAttrs = Object.keys(attrs);
2529
+ const eventAttrs = [];
2530
+ const extraAttrs = [];
2531
+ for (let i = 0, l = allAttrs.length; i < l; i++) {
2532
+ const key = allAttrs[i];
2533
+ if (isOn(key)) {
2534
+ // ignore v-model handlers when they fail to fallthrough
2535
+ if (!isModelListener(key)) {
2536
+ // remove `on`, lowercase first letter to reflect event casing
2537
+ // accurately
2538
+ eventAttrs.push(key[2].toLowerCase() + key.slice(3));
2538
2539
  }
2539
2540
  }
2540
- if (extraAttrs.length) {
2541
- warn$1(`Extraneous non-props attributes (` +
2542
- `${extraAttrs.join(', ')}) ` +
2543
- `were passed to component but could not be automatically inherited ` +
2544
- `because component renders fragment or text root nodes.`);
2545
- }
2546
- if (eventAttrs.length) {
2547
- warn$1(`Extraneous non-emits event listeners (` +
2548
- `${eventAttrs.join(', ')}) ` +
2549
- `were passed to component but could not be automatically inherited ` +
2550
- `because component renders fragment or text root nodes. ` +
2551
- `If the listener is intended to be a component custom event listener only, ` +
2552
- `declare it using the "emits" option.`);
2541
+ else {
2542
+ extraAttrs.push(key);
2553
2543
  }
2554
2544
  }
2555
- }
2556
- }
2557
- if (true &&
2558
- isCompatEnabled("INSTANCE_ATTRS_CLASS_STYLE" /* INSTANCE_ATTRS_CLASS_STYLE */, instance) &&
2559
- vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */ &&
2560
- root.shapeFlag & (1 /* ELEMENT */ | 6 /* COMPONENT */)) {
2561
- const { class: cls, style } = vnode.props || {};
2562
- if (cls || style) {
2563
- if ((process.env.NODE_ENV !== 'production') && inheritAttrs === false) {
2564
- warnDeprecation("INSTANCE_ATTRS_CLASS_STYLE" /* INSTANCE_ATTRS_CLASS_STYLE */, instance, getComponentName(instance.type));
2545
+ if (extraAttrs.length) {
2546
+ warn$1(`Extraneous non-props attributes (` +
2547
+ `${extraAttrs.join(', ')}) ` +
2548
+ `were passed to component but could not be automatically inherited ` +
2549
+ `because component renders fragment or text root nodes.`);
2550
+ }
2551
+ if (eventAttrs.length) {
2552
+ warn$1(`Extraneous non-emits event listeners (` +
2553
+ `${eventAttrs.join(', ')}) ` +
2554
+ `were passed to component but could not be automatically inherited ` +
2555
+ `because component renders fragment or text root nodes. ` +
2556
+ `If the listener is intended to be a component custom event listener only, ` +
2557
+ `declare it using the "emits" option.`);
2565
2558
  }
2566
- root = cloneVNode(root, {
2567
- class: cls,
2568
- style: style
2569
- });
2570
- }
2571
- }
2572
- // inherit directives
2573
- if (vnode.dirs) {
2574
- if ((process.env.NODE_ENV !== 'production') && !isElementRoot(root)) {
2575
- warn$1(`Runtime directive used on component with non-element root node. ` +
2576
- `The directives will not function as intended.`);
2577
2559
  }
2578
- root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
2579
2560
  }
2580
- // inherit transition data
2581
- if (vnode.transition) {
2582
- if ((process.env.NODE_ENV !== 'production') && !isElementRoot(root)) {
2583
- warn$1(`Component inside <Transition> renders non-element root node ` +
2584
- `that cannot be animated.`);
2561
+ }
2562
+ if (isCompatEnabled("INSTANCE_ATTRS_CLASS_STYLE" /* INSTANCE_ATTRS_CLASS_STYLE */, instance) &&
2563
+ vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */ &&
2564
+ root.shapeFlag & (1 /* ELEMENT */ | 6 /* COMPONENT */)) {
2565
+ const { class: cls, style } = vnode.props || {};
2566
+ if (cls || style) {
2567
+ if ((process.env.NODE_ENV !== 'production') && inheritAttrs === false) {
2568
+ warnDeprecation("INSTANCE_ATTRS_CLASS_STYLE" /* INSTANCE_ATTRS_CLASS_STYLE */, instance, getComponentName(instance.type));
2585
2569
  }
2586
- root.transition = vnode.transition;
2570
+ root = cloneVNode(root, {
2571
+ class: cls,
2572
+ style: style
2573
+ });
2587
2574
  }
2588
- if ((process.env.NODE_ENV !== 'production') && setRoot) {
2589
- setRoot(root);
2575
+ }
2576
+ // inherit directives
2577
+ if (vnode.dirs) {
2578
+ if ((process.env.NODE_ENV !== 'production') && !isElementRoot(root)) {
2579
+ warn$1(`Runtime directive used on component with non-element root node. ` +
2580
+ `The directives will not function as intended.`);
2590
2581
  }
2591
- else {
2592
- result = root;
2582
+ root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
2583
+ }
2584
+ // inherit transition data
2585
+ if (vnode.transition) {
2586
+ if ((process.env.NODE_ENV !== 'production') && !isElementRoot(root)) {
2587
+ warn$1(`Component inside <Transition> renders non-element root node ` +
2588
+ `that cannot be animated.`);
2593
2589
  }
2590
+ root.transition = vnode.transition;
2594
2591
  }
2595
- catch (err) {
2596
- blockStack.length = 0;
2597
- handleError(err, instance, 1 /* RENDER_FUNCTION */);
2598
- result = createVNode(Comment);
2592
+ if ((process.env.NODE_ENV !== 'production') && setRoot) {
2593
+ setRoot(root);
2594
+ }
2595
+ else {
2596
+ result = root;
2599
2597
  }
2600
2598
  setCurrentRenderingInstance(prev);
2601
2599
  return result;
@@ -3130,8 +3128,8 @@ function normalizeSuspenseChildren(vnode) {
3130
3128
  function normalizeSuspenseSlot(s) {
3131
3129
  let block;
3132
3130
  if (isFunction(s)) {
3133
- const isCompiledSlot = s._c;
3134
- if (isCompiledSlot) {
3131
+ const trackBlock = isBlockTreeEnabled && s._c;
3132
+ if (trackBlock) {
3135
3133
  // disableTracking: false
3136
3134
  // allow block tracking for compiled slots
3137
3135
  // (see ./componentRenderContext.ts)
@@ -3139,7 +3137,7 @@ function normalizeSuspenseSlot(s) {
3139
3137
  openBlock();
3140
3138
  }
3141
3139
  s = s();
3142
- if (isCompiledSlot) {
3140
+ if (trackBlock) {
3143
3141
  s._d = true;
3144
3142
  block = currentBlock;
3145
3143
  closeBlock();
@@ -5304,7 +5302,7 @@ function createCompatVue(createApp, createSingletonApp) {
5304
5302
  return vm;
5305
5303
  }
5306
5304
  }
5307
- Vue.version = "3.2.11";
5305
+ Vue.version = "3.2.12";
5308
5306
  Vue.config = singletonApp.config;
5309
5307
  Vue.use = (p, ...options) => {
5310
5308
  if (p && isFunction(p.install)) {
@@ -8005,7 +8003,11 @@ function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false
8005
8003
  return Component;
8006
8004
  }
8007
8005
  if ((process.env.NODE_ENV !== 'production') && warnMissing && !res) {
8008
- warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}`);
8006
+ const extra = type === COMPONENTS
8007
+ ? `\nIf this is a native custom element, make sure to exclude it from ` +
8008
+ `component resolution via compilerOptions.isCustomElement.`
8009
+ : ``;
8010
+ warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
8009
8011
  }
8010
8012
  return res;
8011
8013
  }
@@ -9452,17 +9454,19 @@ function exposePropsOnRenderContext(instance) {
9452
9454
  function exposeSetupStateOnRenderContext(instance) {
9453
9455
  const { ctx, setupState } = instance;
9454
9456
  Object.keys(toRaw(setupState)).forEach(key => {
9455
- if (!setupState.__isScriptSetup && (key[0] === '$' || key[0] === '_')) {
9456
- warn$1(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" ` +
9457
- `which are reserved prefixes for Vue internals.`);
9458
- return;
9457
+ if (!setupState.__isScriptSetup) {
9458
+ if (key[0] === '$' || key[0] === '_') {
9459
+ warn$1(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" ` +
9460
+ `which are reserved prefixes for Vue internals.`);
9461
+ return;
9462
+ }
9463
+ Object.defineProperty(ctx, key, {
9464
+ enumerable: true,
9465
+ configurable: true,
9466
+ get: () => setupState[key],
9467
+ set: NOOP
9468
+ });
9459
9469
  }
9460
- Object.defineProperty(ctx, key, {
9461
- enumerable: true,
9462
- configurable: true,
9463
- get: () => setupState[key],
9464
- set: NOOP
9465
- });
9466
9470
  });
9467
9471
  }
9468
9472
 
@@ -10246,11 +10250,19 @@ function flushJobs(seen) {
10246
10250
  // 2. If a component is unmounted during a parent component's update,
10247
10251
  // its update can be skipped.
10248
10252
  queue.sort((a, b) => getId(a) - getId(b));
10253
+ // conditional usage of checkRecursiveUpdate must be determined out of
10254
+ // try ... catch block since Rollup by default de-optimizes treeshaking
10255
+ // inside try-catch. This can leave all warning code unshaked. Although
10256
+ // they would get eventually shaken by a minifier like terser, some minifiers
10257
+ // would fail to do that (e.g. https://github.com/evanw/esbuild/issues/1610)
10258
+ const check = (process.env.NODE_ENV !== 'production')
10259
+ ? (job) => checkRecursiveUpdates(seen, job)
10260
+ : NOOP;
10249
10261
  try {
10250
10262
  for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
10251
10263
  const job = queue[flushIndex];
10252
10264
  if (job && job.active !== false) {
10253
- if ((process.env.NODE_ENV !== 'production') && checkRecursiveUpdates(seen, job)) {
10265
+ if ((process.env.NODE_ENV !== 'production') && check(job)) {
10254
10266
  continue;
10255
10267
  }
10256
10268
  // console.log(`running:`, job.id)
@@ -10945,7 +10957,7 @@ function isMemoSame(cached, memo) {
10945
10957
  }
10946
10958
 
10947
10959
  // Core API ------------------------------------------------------------------
10948
- const version = "3.2.11";
10960
+ const version = "3.2.12";
10949
10961
  const _ssrUtils = {
10950
10962
  createComponentInstance,
10951
10963
  setupComponent,
@@ -11480,6 +11492,7 @@ class VueElement extends BaseClass {
11480
11492
  this._instance = null;
11481
11493
  this._connected = false;
11482
11494
  this._resolved = false;
11495
+ this._numberProps = null;
11483
11496
  if (this.shadowRoot && hydrate) {
11484
11497
  hydrate(this._createVNode(), this.shadowRoot);
11485
11498
  }
@@ -11495,18 +11508,17 @@ class VueElement extends BaseClass {
11495
11508
  this._setAttr(this.attributes[i].name);
11496
11509
  }
11497
11510
  // watch future attr changes
11498
- const observer = new MutationObserver(mutations => {
11511
+ new MutationObserver(mutations => {
11499
11512
  for (const m of mutations) {
11500
11513
  this._setAttr(m.attributeName);
11501
11514
  }
11502
- });
11503
- observer.observe(this, { attributes: true });
11515
+ }).observe(this, { attributes: true });
11504
11516
  }
11505
11517
  connectedCallback() {
11506
11518
  this._connected = true;
11507
11519
  if (!this._instance) {
11508
11520
  this._resolveDef();
11509
- render(this._createVNode(), this.shadowRoot);
11521
+ this._update();
11510
11522
  }
11511
11523
  }
11512
11524
  disconnectedCallback() {
@@ -11527,15 +11539,31 @@ class VueElement extends BaseClass {
11527
11539
  }
11528
11540
  const resolve = (def) => {
11529
11541
  this._resolved = true;
11542
+ const { props, styles } = def;
11543
+ const hasOptions = !isArray(props);
11544
+ const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
11545
+ // cast Number-type props set before resolve
11546
+ let numberProps;
11547
+ if (hasOptions) {
11548
+ for (const key in this._props) {
11549
+ const opt = props[key];
11550
+ if (opt === Number || (opt && opt.type === Number)) {
11551
+ this._props[key] = toNumber(this._props[key]);
11552
+ (numberProps || (numberProps = Object.create(null)))[key] = true;
11553
+ }
11554
+ }
11555
+ }
11556
+ if (numberProps) {
11557
+ this._numberProps = numberProps;
11558
+ this._update();
11559
+ }
11530
11560
  // check if there are props set pre-upgrade or connect
11531
11561
  for (const key of Object.keys(this)) {
11532
11562
  if (key[0] !== '_') {
11533
11563
  this._setProp(key, this[key]);
11534
11564
  }
11535
11565
  }
11536
- const { props, styles } = def;
11537
11566
  // defining getter/setters on prototype
11538
- const rawKeys = props ? (isArray(props) ? props : Object.keys(props)) : [];
11539
11567
  for (const key of rawKeys.map(camelize)) {
11540
11568
  Object.defineProperty(this, key, {
11541
11569
  get() {
@@ -11557,7 +11585,11 @@ class VueElement extends BaseClass {
11557
11585
  }
11558
11586
  }
11559
11587
  _setAttr(key) {
11560
- this._setProp(camelize(key), toNumber(this.getAttribute(key)), false);
11588
+ let value = this.getAttribute(key);
11589
+ if (this._numberProps && this._numberProps[key]) {
11590
+ value = toNumber(value);
11591
+ }
11592
+ this._setProp(camelize(key), value, false);
11561
11593
  }
11562
11594
  /**
11563
11595
  * @internal
@@ -11572,7 +11604,7 @@ class VueElement extends BaseClass {
11572
11604
  if (val !== this._props[key]) {
11573
11605
  this._props[key] = val;
11574
11606
  if (this._instance) {
11575
- render(this._createVNode(), this.shadowRoot);
11607
+ this._update();
11576
11608
  }
11577
11609
  // reflect
11578
11610
  if (shouldReflect) {
@@ -11588,6 +11620,9 @@ class VueElement extends BaseClass {
11588
11620
  }
11589
11621
  }
11590
11622
  }
11623
+ _update() {
11624
+ render(this._createVNode(), this.shadowRoot);
11625
+ }
11591
11626
  _createVNode() {
11592
11627
  const vnode = createVNode(this._def, extend({}, this._props));
11593
11628
  if (!this._instance) {
@@ -11608,7 +11643,7 @@ class VueElement extends BaseClass {
11608
11643
  if (!this._def.__asyncLoader) {
11609
11644
  // reload
11610
11645
  this._instance = null;
11611
- render(this._createVNode(), this.shadowRoot);
11646
+ this._update();
11612
11647
  }
11613
11648
  };
11614
11649
  }
@@ -16927,7 +16962,7 @@ function processSlotOutlet(node, context) {
16927
16962
  };
16928
16963
  }
16929
16964
 
16930
- const fnExpRE = /^\s*([\w$_]+|\([^)]*?\))\s*=>|^\s*function(?:\s+[\w$]+)?\s*\(/;
16965
+ const fnExpRE = /^\s*([\w$_]+|(async\s*)?\([^)]*?\))\s*=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/;
16931
16966
  const transformOn = (dir, node, context, augmentor) => {
16932
16967
  const { loc, modifiers, arg } = dir;
16933
16968
  if (!dir.exp && !modifiers.length) {