@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.
@@ -2438,12 +2438,12 @@ function markAttrsAccessed() {
2438
2438
  function renderComponentRoot(instance) {
2439
2439
  const { type: Component, vnode, proxy, withProxy, props, propsOptions: [propsOptions], slots, attrs, emit, render, renderCache, data, setupState, ctx, inheritAttrs } = instance;
2440
2440
  let result;
2441
+ let fallthroughAttrs;
2441
2442
  const prev = setCurrentRenderingInstance(instance);
2442
2443
  {
2443
2444
  accessedAttrs = false;
2444
2445
  }
2445
2446
  try {
2446
- let fallthroughAttrs;
2447
2447
  if (vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */) {
2448
2448
  // withProxy is a proxy with a different `has` trap only for
2449
2449
  // runtime-compiled render functions using `with` block.
@@ -2474,108 +2474,105 @@ function renderComponentRoot(instance) {
2474
2474
  ? attrs
2475
2475
  : getFunctionalFallthrough(attrs);
2476
2476
  }
2477
- // attr merging
2478
- // in dev mode, comments are preserved, and it's possible for a template
2479
- // to have comments along side the root element which makes it a fragment
2480
- let root = result;
2481
- let setRoot = undefined;
2482
- if (true &&
2483
- result.patchFlag > 0 &&
2484
- result.patchFlag & 2048 /* DEV_ROOT_FRAGMENT */) {
2485
- ;
2486
- [root, setRoot] = getChildRoot(result);
2487
- }
2488
- if (fallthroughAttrs && inheritAttrs !== false) {
2489
- const keys = Object.keys(fallthroughAttrs);
2490
- const { shapeFlag } = root;
2491
- if (keys.length) {
2492
- if (shapeFlag & (1 /* ELEMENT */ | 6 /* COMPONENT */)) {
2493
- if (propsOptions && keys.some(isModelListener)) {
2494
- // If a v-model listener (onUpdate:xxx) has a corresponding declared
2495
- // prop, it indicates this component expects to handle v-model and
2496
- // it should not fallthrough.
2497
- // related: #1543, #1643, #1989
2498
- fallthroughAttrs = filterModelListeners(fallthroughAttrs, propsOptions);
2499
- }
2500
- root = cloneVNode(root, fallthroughAttrs);
2501
- }
2502
- else if (true && !accessedAttrs && root.type !== Comment) {
2503
- const allAttrs = Object.keys(attrs);
2504
- const eventAttrs = [];
2505
- const extraAttrs = [];
2506
- for (let i = 0, l = allAttrs.length; i < l; i++) {
2507
- const key = allAttrs[i];
2508
- if (isOn(key)) {
2509
- // ignore v-model handlers when they fail to fallthrough
2510
- if (!isModelListener(key)) {
2511
- // remove `on`, lowercase first letter to reflect event casing
2512
- // accurately
2513
- eventAttrs.push(key[2].toLowerCase() + key.slice(3));
2514
- }
2515
- }
2516
- else {
2517
- extraAttrs.push(key);
2477
+ }
2478
+ catch (err) {
2479
+ blockStack.length = 0;
2480
+ handleError(err, instance, 1 /* RENDER_FUNCTION */);
2481
+ result = createVNode(Comment);
2482
+ }
2483
+ // attr merging
2484
+ // in dev mode, comments are preserved, and it's possible for a template
2485
+ // to have comments along side the root element which makes it a fragment
2486
+ let root = result;
2487
+ let setRoot = undefined;
2488
+ if (result.patchFlag > 0 &&
2489
+ result.patchFlag & 2048 /* DEV_ROOT_FRAGMENT */) {
2490
+ [root, setRoot] = getChildRoot(result);
2491
+ }
2492
+ if (fallthroughAttrs && inheritAttrs !== false) {
2493
+ const keys = Object.keys(fallthroughAttrs);
2494
+ const { shapeFlag } = root;
2495
+ if (keys.length) {
2496
+ if (shapeFlag & (1 /* ELEMENT */ | 6 /* COMPONENT */)) {
2497
+ if (propsOptions && keys.some(isModelListener)) {
2498
+ // If a v-model listener (onUpdate:xxx) has a corresponding declared
2499
+ // prop, it indicates this component expects to handle v-model and
2500
+ // it should not fallthrough.
2501
+ // related: #1543, #1643, #1989
2502
+ fallthroughAttrs = filterModelListeners(fallthroughAttrs, propsOptions);
2503
+ }
2504
+ root = cloneVNode(root, fallthroughAttrs);
2505
+ }
2506
+ else if (!accessedAttrs && root.type !== Comment) {
2507
+ const allAttrs = Object.keys(attrs);
2508
+ const eventAttrs = [];
2509
+ const extraAttrs = [];
2510
+ for (let i = 0, l = allAttrs.length; i < l; i++) {
2511
+ const key = allAttrs[i];
2512
+ if (isOn(key)) {
2513
+ // ignore v-model handlers when they fail to fallthrough
2514
+ if (!isModelListener(key)) {
2515
+ // remove `on`, lowercase first letter to reflect event casing
2516
+ // accurately
2517
+ eventAttrs.push(key[2].toLowerCase() + key.slice(3));
2518
2518
  }
2519
2519
  }
2520
- if (extraAttrs.length) {
2521
- warn$1(`Extraneous non-props attributes (` +
2522
- `${extraAttrs.join(', ')}) ` +
2523
- `were passed to component but could not be automatically inherited ` +
2524
- `because component renders fragment or text root nodes.`);
2525
- }
2526
- if (eventAttrs.length) {
2527
- warn$1(`Extraneous non-emits event listeners (` +
2528
- `${eventAttrs.join(', ')}) ` +
2529
- `were passed to component but could not be automatically inherited ` +
2530
- `because component renders fragment or text root nodes. ` +
2531
- `If the listener is intended to be a component custom event listener only, ` +
2532
- `declare it using the "emits" option.`);
2520
+ else {
2521
+ extraAttrs.push(key);
2533
2522
  }
2534
2523
  }
2535
- }
2536
- }
2537
- if (true &&
2538
- isCompatEnabled("INSTANCE_ATTRS_CLASS_STYLE" /* INSTANCE_ATTRS_CLASS_STYLE */, instance) &&
2539
- vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */ &&
2540
- root.shapeFlag & (1 /* ELEMENT */ | 6 /* COMPONENT */)) {
2541
- const { class: cls, style } = vnode.props || {};
2542
- if (cls || style) {
2543
- if (true && inheritAttrs === false) {
2544
- warnDeprecation("INSTANCE_ATTRS_CLASS_STYLE" /* INSTANCE_ATTRS_CLASS_STYLE */, instance, getComponentName(instance.type));
2524
+ if (extraAttrs.length) {
2525
+ warn$1(`Extraneous non-props attributes (` +
2526
+ `${extraAttrs.join(', ')}) ` +
2527
+ `were passed to component but could not be automatically inherited ` +
2528
+ `because component renders fragment or text root nodes.`);
2529
+ }
2530
+ if (eventAttrs.length) {
2531
+ warn$1(`Extraneous non-emits event listeners (` +
2532
+ `${eventAttrs.join(', ')}) ` +
2533
+ `were passed to component but could not be automatically inherited ` +
2534
+ `because component renders fragment or text root nodes. ` +
2535
+ `If the listener is intended to be a component custom event listener only, ` +
2536
+ `declare it using the "emits" option.`);
2545
2537
  }
2546
- root = cloneVNode(root, {
2547
- class: cls,
2548
- style: style
2549
- });
2550
- }
2551
- }
2552
- // inherit directives
2553
- if (vnode.dirs) {
2554
- if (true && !isElementRoot(root)) {
2555
- warn$1(`Runtime directive used on component with non-element root node. ` +
2556
- `The directives will not function as intended.`);
2557
2538
  }
2558
- root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
2559
2539
  }
2560
- // inherit transition data
2561
- if (vnode.transition) {
2562
- if (true && !isElementRoot(root)) {
2563
- warn$1(`Component inside <Transition> renders non-element root node ` +
2564
- `that cannot be animated.`);
2540
+ }
2541
+ if (isCompatEnabled("INSTANCE_ATTRS_CLASS_STYLE" /* INSTANCE_ATTRS_CLASS_STYLE */, instance) &&
2542
+ vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */ &&
2543
+ root.shapeFlag & (1 /* ELEMENT */ | 6 /* COMPONENT */)) {
2544
+ const { class: cls, style } = vnode.props || {};
2545
+ if (cls || style) {
2546
+ if (inheritAttrs === false) {
2547
+ warnDeprecation("INSTANCE_ATTRS_CLASS_STYLE" /* INSTANCE_ATTRS_CLASS_STYLE */, instance, getComponentName(instance.type));
2565
2548
  }
2566
- root.transition = vnode.transition;
2549
+ root = cloneVNode(root, {
2550
+ class: cls,
2551
+ style: style
2552
+ });
2567
2553
  }
2568
- if (true && setRoot) {
2569
- setRoot(root);
2554
+ }
2555
+ // inherit directives
2556
+ if (vnode.dirs) {
2557
+ if (!isElementRoot(root)) {
2558
+ warn$1(`Runtime directive used on component with non-element root node. ` +
2559
+ `The directives will not function as intended.`);
2570
2560
  }
2571
- else {
2572
- result = root;
2561
+ root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
2562
+ }
2563
+ // inherit transition data
2564
+ if (vnode.transition) {
2565
+ if (!isElementRoot(root)) {
2566
+ warn$1(`Component inside <Transition> renders non-element root node ` +
2567
+ `that cannot be animated.`);
2573
2568
  }
2569
+ root.transition = vnode.transition;
2574
2570
  }
2575
- catch (err) {
2576
- blockStack.length = 0;
2577
- handleError(err, instance, 1 /* RENDER_FUNCTION */);
2578
- result = createVNode(Comment);
2571
+ if (setRoot) {
2572
+ setRoot(root);
2573
+ }
2574
+ else {
2575
+ result = root;
2579
2576
  }
2580
2577
  setCurrentRenderingInstance(prev);
2581
2578
  return result;
@@ -3110,8 +3107,8 @@ function normalizeSuspenseChildren(vnode) {
3110
3107
  function normalizeSuspenseSlot(s) {
3111
3108
  let block;
3112
3109
  if (isFunction(s)) {
3113
- const isCompiledSlot = s._c;
3114
- if (isCompiledSlot) {
3110
+ const trackBlock = isBlockTreeEnabled && s._c;
3111
+ if (trackBlock) {
3115
3112
  // disableTracking: false
3116
3113
  // allow block tracking for compiled slots
3117
3114
  // (see ./componentRenderContext.ts)
@@ -3119,7 +3116,7 @@ function normalizeSuspenseSlot(s) {
3119
3116
  openBlock();
3120
3117
  }
3121
3118
  s = s();
3122
- if (isCompiledSlot) {
3119
+ if (trackBlock) {
3123
3120
  s._d = true;
3124
3121
  block = currentBlock;
3125
3122
  closeBlock();
@@ -5275,7 +5272,7 @@ function createCompatVue(createApp, createSingletonApp) {
5275
5272
  return vm;
5276
5273
  }
5277
5274
  }
5278
- Vue.version = "3.2.11";
5275
+ Vue.version = "3.2.12";
5279
5276
  Vue.config = singletonApp.config;
5280
5277
  Vue.use = (p, ...options) => {
5281
5278
  if (p && isFunction(p.install)) {
@@ -7923,7 +7920,11 @@ function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false
7923
7920
  return Component;
7924
7921
  }
7925
7922
  if (warnMissing && !res) {
7926
- warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}`);
7923
+ const extra = type === COMPONENTS
7924
+ ? `\nIf this is a native custom element, make sure to exclude it from ` +
7925
+ `component resolution via compilerOptions.isCustomElement.`
7926
+ : ``;
7927
+ warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
7927
7928
  }
7928
7929
  return res;
7929
7930
  }
@@ -9365,17 +9366,19 @@ function exposePropsOnRenderContext(instance) {
9365
9366
  function exposeSetupStateOnRenderContext(instance) {
9366
9367
  const { ctx, setupState } = instance;
9367
9368
  Object.keys(toRaw(setupState)).forEach(key => {
9368
- if (!setupState.__isScriptSetup && (key[0] === '$' || key[0] === '_')) {
9369
- warn$1(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" ` +
9370
- `which are reserved prefixes for Vue internals.`);
9371
- return;
9369
+ if (!setupState.__isScriptSetup) {
9370
+ if (key[0] === '$' || key[0] === '_') {
9371
+ warn$1(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" ` +
9372
+ `which are reserved prefixes for Vue internals.`);
9373
+ return;
9374
+ }
9375
+ Object.defineProperty(ctx, key, {
9376
+ enumerable: true,
9377
+ configurable: true,
9378
+ get: () => setupState[key],
9379
+ set: NOOP
9380
+ });
9372
9381
  }
9373
- Object.defineProperty(ctx, key, {
9374
- enumerable: true,
9375
- configurable: true,
9376
- get: () => setupState[key],
9377
- set: NOOP
9378
- });
9379
9382
  });
9380
9383
  }
9381
9384
 
@@ -10134,11 +10137,18 @@ function flushJobs(seen) {
10134
10137
  // 2. If a component is unmounted during a parent component's update,
10135
10138
  // its update can be skipped.
10136
10139
  queue.sort((a, b) => getId(a) - getId(b));
10140
+ // conditional usage of checkRecursiveUpdate must be determined out of
10141
+ // try ... catch block since Rollup by default de-optimizes treeshaking
10142
+ // inside try-catch. This can leave all warning code unshaked. Although
10143
+ // they would get eventually shaken by a minifier like terser, some minifiers
10144
+ // would fail to do that (e.g. https://github.com/evanw/esbuild/issues/1610)
10145
+ const check = (job) => checkRecursiveUpdates(seen, job)
10146
+ ;
10137
10147
  try {
10138
10148
  for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
10139
10149
  const job = queue[flushIndex];
10140
10150
  if (job && job.active !== false) {
10141
- if (true && checkRecursiveUpdates(seen, job)) {
10151
+ if (true && check(job)) {
10142
10152
  continue;
10143
10153
  }
10144
10154
  // console.log(`running:`, job.id)
@@ -10831,7 +10841,7 @@ function isMemoSame(cached, memo) {
10831
10841
  }
10832
10842
 
10833
10843
  // Core API ------------------------------------------------------------------
10834
- const version = "3.2.11";
10844
+ const version = "3.2.12";
10835
10845
  /**
10836
10846
  * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
10837
10847
  * @internal
@@ -11357,6 +11367,7 @@ class VueElement extends BaseClass {
11357
11367
  this._instance = null;
11358
11368
  this._connected = false;
11359
11369
  this._resolved = false;
11370
+ this._numberProps = null;
11360
11371
  if (this.shadowRoot && hydrate) {
11361
11372
  hydrate(this._createVNode(), this.shadowRoot);
11362
11373
  }
@@ -11372,18 +11383,17 @@ class VueElement extends BaseClass {
11372
11383
  this._setAttr(this.attributes[i].name);
11373
11384
  }
11374
11385
  // watch future attr changes
11375
- const observer = new MutationObserver(mutations => {
11386
+ new MutationObserver(mutations => {
11376
11387
  for (const m of mutations) {
11377
11388
  this._setAttr(m.attributeName);
11378
11389
  }
11379
- });
11380
- observer.observe(this, { attributes: true });
11390
+ }).observe(this, { attributes: true });
11381
11391
  }
11382
11392
  connectedCallback() {
11383
11393
  this._connected = true;
11384
11394
  if (!this._instance) {
11385
11395
  this._resolveDef();
11386
- render(this._createVNode(), this.shadowRoot);
11396
+ this._update();
11387
11397
  }
11388
11398
  }
11389
11399
  disconnectedCallback() {
@@ -11404,15 +11414,31 @@ class VueElement extends BaseClass {
11404
11414
  }
11405
11415
  const resolve = (def) => {
11406
11416
  this._resolved = true;
11417
+ const { props, styles } = def;
11418
+ const hasOptions = !isArray(props);
11419
+ const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
11420
+ // cast Number-type props set before resolve
11421
+ let numberProps;
11422
+ if (hasOptions) {
11423
+ for (const key in this._props) {
11424
+ const opt = props[key];
11425
+ if (opt === Number || (opt && opt.type === Number)) {
11426
+ this._props[key] = toNumber(this._props[key]);
11427
+ (numberProps || (numberProps = Object.create(null)))[key] = true;
11428
+ }
11429
+ }
11430
+ }
11431
+ if (numberProps) {
11432
+ this._numberProps = numberProps;
11433
+ this._update();
11434
+ }
11407
11435
  // check if there are props set pre-upgrade or connect
11408
11436
  for (const key of Object.keys(this)) {
11409
11437
  if (key[0] !== '_') {
11410
11438
  this._setProp(key, this[key]);
11411
11439
  }
11412
11440
  }
11413
- const { props, styles } = def;
11414
11441
  // defining getter/setters on prototype
11415
- const rawKeys = props ? (isArray(props) ? props : Object.keys(props)) : [];
11416
11442
  for (const key of rawKeys.map(camelize)) {
11417
11443
  Object.defineProperty(this, key, {
11418
11444
  get() {
@@ -11434,7 +11460,11 @@ class VueElement extends BaseClass {
11434
11460
  }
11435
11461
  }
11436
11462
  _setAttr(key) {
11437
- this._setProp(camelize(key), toNumber(this.getAttribute(key)), false);
11463
+ let value = this.getAttribute(key);
11464
+ if (this._numberProps && this._numberProps[key]) {
11465
+ value = toNumber(value);
11466
+ }
11467
+ this._setProp(camelize(key), value, false);
11438
11468
  }
11439
11469
  /**
11440
11470
  * @internal
@@ -11449,7 +11479,7 @@ class VueElement extends BaseClass {
11449
11479
  if (val !== this._props[key]) {
11450
11480
  this._props[key] = val;
11451
11481
  if (this._instance) {
11452
- render(this._createVNode(), this.shadowRoot);
11482
+ this._update();
11453
11483
  }
11454
11484
  // reflect
11455
11485
  if (shouldReflect) {
@@ -11465,6 +11495,9 @@ class VueElement extends BaseClass {
11465
11495
  }
11466
11496
  }
11467
11497
  }
11498
+ _update() {
11499
+ render(this._createVNode(), this.shadowRoot);
11500
+ }
11468
11501
  _createVNode() {
11469
11502
  const vnode = createVNode(this._def, extend({}, this._props));
11470
11503
  if (!this._instance) {
@@ -11485,7 +11518,7 @@ class VueElement extends BaseClass {
11485
11518
  if (!this._def.__asyncLoader) {
11486
11519
  // reload
11487
11520
  this._instance = null;
11488
- render(this._createVNode(), this.shadowRoot);
11521
+ this._update();
11489
11522
  }
11490
11523
  };
11491
11524
  }
@@ -16790,7 +16823,7 @@ function processSlotOutlet(node, context) {
16790
16823
  };
16791
16824
  }
16792
16825
 
16793
- const fnExpRE = /^\s*([\w$_]+|\([^)]*?\))\s*=>|^\s*function(?:\s+[\w$]+)?\s*\(/;
16826
+ const fnExpRE = /^\s*([\w$_]+|(async\s*)?\([^)]*?\))\s*=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/;
16794
16827
  const transformOn = (dir, node, context, augmentor) => {
16795
16828
  const { loc, modifiers, arg } = dir;
16796
16829
  if (!dir.exp && !modifiers.length) {