@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.
@@ -2383,12 +2383,12 @@ function markAttrsAccessed() {
2383
2383
  function renderComponentRoot(instance) {
2384
2384
  const { type: Component, vnode, proxy, withProxy, props, propsOptions: [propsOptions], slots, attrs, emit, render, renderCache, data, setupState, ctx, inheritAttrs } = instance;
2385
2385
  let result;
2386
+ let fallthroughAttrs;
2386
2387
  const prev = setCurrentRenderingInstance(instance);
2387
2388
  if ((process.env.NODE_ENV !== 'production')) {
2388
2389
  accessedAttrs = false;
2389
2390
  }
2390
2391
  try {
2391
- let fallthroughAttrs;
2392
2392
  if (vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */) {
2393
2393
  // withProxy is a proxy with a different `has` trap only for
2394
2394
  // runtime-compiled render functions using `with` block.
@@ -2419,108 +2419,106 @@ function renderComponentRoot(instance) {
2419
2419
  ? attrs
2420
2420
  : getFunctionalFallthrough(attrs);
2421
2421
  }
2422
- // attr merging
2423
- // in dev mode, comments are preserved, and it's possible for a template
2424
- // to have comments along side the root element which makes it a fragment
2425
- let root = result;
2426
- let setRoot = undefined;
2427
- if ((process.env.NODE_ENV !== 'production') &&
2428
- result.patchFlag > 0 &&
2429
- result.patchFlag & 2048 /* DEV_ROOT_FRAGMENT */) {
2430
- ;
2431
- [root, setRoot] = getChildRoot(result);
2432
- }
2433
- if (fallthroughAttrs && inheritAttrs !== false) {
2434
- const keys = Object.keys(fallthroughAttrs);
2435
- const { shapeFlag } = root;
2436
- if (keys.length) {
2437
- if (shapeFlag & (1 /* ELEMENT */ | 6 /* COMPONENT */)) {
2438
- if (propsOptions && keys.some(isModelListener)) {
2439
- // If a v-model listener (onUpdate:xxx) has a corresponding declared
2440
- // prop, it indicates this component expects to handle v-model and
2441
- // it should not fallthrough.
2442
- // related: #1543, #1643, #1989
2443
- fallthroughAttrs = filterModelListeners(fallthroughAttrs, propsOptions);
2444
- }
2445
- root = cloneVNode(root, fallthroughAttrs);
2446
- }
2447
- else if ((process.env.NODE_ENV !== 'production') && !accessedAttrs && root.type !== Comment) {
2448
- const allAttrs = Object.keys(attrs);
2449
- const eventAttrs = [];
2450
- const extraAttrs = [];
2451
- for (let i = 0, l = allAttrs.length; i < l; i++) {
2452
- const key = allAttrs[i];
2453
- if (isOn(key)) {
2454
- // ignore v-model handlers when they fail to fallthrough
2455
- if (!isModelListener(key)) {
2456
- // remove `on`, lowercase first letter to reflect event casing
2457
- // accurately
2458
- eventAttrs.push(key[2].toLowerCase() + key.slice(3));
2459
- }
2460
- }
2461
- else {
2462
- extraAttrs.push(key);
2422
+ }
2423
+ catch (err) {
2424
+ blockStack.length = 0;
2425
+ handleError(err, instance, 1 /* RENDER_FUNCTION */);
2426
+ result = createVNode(Comment);
2427
+ }
2428
+ // attr merging
2429
+ // in dev mode, comments are preserved, and it's possible for a template
2430
+ // to have comments along side the root element which makes it a fragment
2431
+ let root = result;
2432
+ let setRoot = undefined;
2433
+ if ((process.env.NODE_ENV !== 'production') &&
2434
+ result.patchFlag > 0 &&
2435
+ result.patchFlag & 2048 /* DEV_ROOT_FRAGMENT */) {
2436
+ [root, setRoot] = getChildRoot(result);
2437
+ }
2438
+ if (fallthroughAttrs && inheritAttrs !== false) {
2439
+ const keys = Object.keys(fallthroughAttrs);
2440
+ const { shapeFlag } = root;
2441
+ if (keys.length) {
2442
+ if (shapeFlag & (1 /* ELEMENT */ | 6 /* COMPONENT */)) {
2443
+ if (propsOptions && keys.some(isModelListener)) {
2444
+ // If a v-model listener (onUpdate:xxx) has a corresponding declared
2445
+ // prop, it indicates this component expects to handle v-model and
2446
+ // it should not fallthrough.
2447
+ // related: #1543, #1643, #1989
2448
+ fallthroughAttrs = filterModelListeners(fallthroughAttrs, propsOptions);
2449
+ }
2450
+ root = cloneVNode(root, fallthroughAttrs);
2451
+ }
2452
+ else if ((process.env.NODE_ENV !== 'production') && !accessedAttrs && root.type !== Comment) {
2453
+ const allAttrs = Object.keys(attrs);
2454
+ const eventAttrs = [];
2455
+ const extraAttrs = [];
2456
+ for (let i = 0, l = allAttrs.length; i < l; i++) {
2457
+ const key = allAttrs[i];
2458
+ if (isOn(key)) {
2459
+ // ignore v-model handlers when they fail to fallthrough
2460
+ if (!isModelListener(key)) {
2461
+ // remove `on`, lowercase first letter to reflect event casing
2462
+ // accurately
2463
+ eventAttrs.push(key[2].toLowerCase() + key.slice(3));
2463
2464
  }
2464
2465
  }
2465
- if (extraAttrs.length) {
2466
- warn$1(`Extraneous non-props attributes (` +
2467
- `${extraAttrs.join(', ')}) ` +
2468
- `were passed to component but could not be automatically inherited ` +
2469
- `because component renders fragment or text root nodes.`);
2470
- }
2471
- if (eventAttrs.length) {
2472
- warn$1(`Extraneous non-emits event listeners (` +
2473
- `${eventAttrs.join(', ')}) ` +
2474
- `were passed to component but could not be automatically inherited ` +
2475
- `because component renders fragment or text root nodes. ` +
2476
- `If the listener is intended to be a component custom event listener only, ` +
2477
- `declare it using the "emits" option.`);
2466
+ else {
2467
+ extraAttrs.push(key);
2478
2468
  }
2479
2469
  }
2480
- }
2481
- }
2482
- if (true &&
2483
- isCompatEnabled("INSTANCE_ATTRS_CLASS_STYLE" /* INSTANCE_ATTRS_CLASS_STYLE */, instance) &&
2484
- vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */ &&
2485
- root.shapeFlag & (1 /* ELEMENT */ | 6 /* COMPONENT */)) {
2486
- const { class: cls, style } = vnode.props || {};
2487
- if (cls || style) {
2488
- if ((process.env.NODE_ENV !== 'production') && inheritAttrs === false) {
2489
- warnDeprecation("INSTANCE_ATTRS_CLASS_STYLE" /* INSTANCE_ATTRS_CLASS_STYLE */, instance, getComponentName(instance.type));
2470
+ if (extraAttrs.length) {
2471
+ warn$1(`Extraneous non-props attributes (` +
2472
+ `${extraAttrs.join(', ')}) ` +
2473
+ `were passed to component but could not be automatically inherited ` +
2474
+ `because component renders fragment or text root nodes.`);
2475
+ }
2476
+ if (eventAttrs.length) {
2477
+ warn$1(`Extraneous non-emits event listeners (` +
2478
+ `${eventAttrs.join(', ')}) ` +
2479
+ `were passed to component but could not be automatically inherited ` +
2480
+ `because component renders fragment or text root nodes. ` +
2481
+ `If the listener is intended to be a component custom event listener only, ` +
2482
+ `declare it using the "emits" option.`);
2490
2483
  }
2491
- root = cloneVNode(root, {
2492
- class: cls,
2493
- style: style
2494
- });
2495
- }
2496
- }
2497
- // inherit directives
2498
- if (vnode.dirs) {
2499
- if ((process.env.NODE_ENV !== 'production') && !isElementRoot(root)) {
2500
- warn$1(`Runtime directive used on component with non-element root node. ` +
2501
- `The directives will not function as intended.`);
2502
2484
  }
2503
- root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
2504
2485
  }
2505
- // inherit transition data
2506
- if (vnode.transition) {
2507
- if ((process.env.NODE_ENV !== 'production') && !isElementRoot(root)) {
2508
- warn$1(`Component inside <Transition> renders non-element root node ` +
2509
- `that cannot be animated.`);
2486
+ }
2487
+ if (isCompatEnabled("INSTANCE_ATTRS_CLASS_STYLE" /* INSTANCE_ATTRS_CLASS_STYLE */, instance) &&
2488
+ vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */ &&
2489
+ root.shapeFlag & (1 /* ELEMENT */ | 6 /* COMPONENT */)) {
2490
+ const { class: cls, style } = vnode.props || {};
2491
+ if (cls || style) {
2492
+ if ((process.env.NODE_ENV !== 'production') && inheritAttrs === false) {
2493
+ warnDeprecation("INSTANCE_ATTRS_CLASS_STYLE" /* INSTANCE_ATTRS_CLASS_STYLE */, instance, getComponentName(instance.type));
2510
2494
  }
2511
- root.transition = vnode.transition;
2495
+ root = cloneVNode(root, {
2496
+ class: cls,
2497
+ style: style
2498
+ });
2512
2499
  }
2513
- if ((process.env.NODE_ENV !== 'production') && setRoot) {
2514
- setRoot(root);
2500
+ }
2501
+ // inherit directives
2502
+ if (vnode.dirs) {
2503
+ if ((process.env.NODE_ENV !== 'production') && !isElementRoot(root)) {
2504
+ warn$1(`Runtime directive used on component with non-element root node. ` +
2505
+ `The directives will not function as intended.`);
2515
2506
  }
2516
- else {
2517
- result = root;
2507
+ root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
2508
+ }
2509
+ // inherit transition data
2510
+ if (vnode.transition) {
2511
+ if ((process.env.NODE_ENV !== 'production') && !isElementRoot(root)) {
2512
+ warn$1(`Component inside <Transition> renders non-element root node ` +
2513
+ `that cannot be animated.`);
2518
2514
  }
2515
+ root.transition = vnode.transition;
2519
2516
  }
2520
- catch (err) {
2521
- blockStack.length = 0;
2522
- handleError(err, instance, 1 /* RENDER_FUNCTION */);
2523
- result = createVNode(Comment);
2517
+ if ((process.env.NODE_ENV !== 'production') && setRoot) {
2518
+ setRoot(root);
2519
+ }
2520
+ else {
2521
+ result = root;
2524
2522
  }
2525
2523
  setCurrentRenderingInstance(prev);
2526
2524
  return result;
@@ -3055,8 +3053,8 @@ function normalizeSuspenseChildren(vnode) {
3055
3053
  function normalizeSuspenseSlot(s) {
3056
3054
  let block;
3057
3055
  if (isFunction(s)) {
3058
- const isCompiledSlot = s._c;
3059
- if (isCompiledSlot) {
3056
+ const trackBlock = isBlockTreeEnabled && s._c;
3057
+ if (trackBlock) {
3060
3058
  // disableTracking: false
3061
3059
  // allow block tracking for compiled slots
3062
3060
  // (see ./componentRenderContext.ts)
@@ -3064,7 +3062,7 @@ function normalizeSuspenseSlot(s) {
3064
3062
  openBlock();
3065
3063
  }
3066
3064
  s = s();
3067
- if (isCompiledSlot) {
3065
+ if (trackBlock) {
3068
3066
  s._d = true;
3069
3067
  block = currentBlock;
3070
3068
  closeBlock();
@@ -5229,7 +5227,7 @@ function createCompatVue(createApp, createSingletonApp) {
5229
5227
  return vm;
5230
5228
  }
5231
5229
  }
5232
- Vue.version = "3.2.11";
5230
+ Vue.version = "3.2.12";
5233
5231
  Vue.config = singletonApp.config;
5234
5232
  Vue.use = (p, ...options) => {
5235
5233
  if (p && isFunction(p.install)) {
@@ -7930,7 +7928,11 @@ function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false
7930
7928
  return Component;
7931
7929
  }
7932
7930
  if ((process.env.NODE_ENV !== 'production') && warnMissing && !res) {
7933
- warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}`);
7931
+ const extra = type === COMPONENTS
7932
+ ? `\nIf this is a native custom element, make sure to exclude it from ` +
7933
+ `component resolution via compilerOptions.isCustomElement.`
7934
+ : ``;
7935
+ warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
7934
7936
  }
7935
7937
  return res;
7936
7938
  }
@@ -9377,17 +9379,19 @@ function exposePropsOnRenderContext(instance) {
9377
9379
  function exposeSetupStateOnRenderContext(instance) {
9378
9380
  const { ctx, setupState } = instance;
9379
9381
  Object.keys(toRaw(setupState)).forEach(key => {
9380
- if (!setupState.__isScriptSetup && (key[0] === '$' || key[0] === '_')) {
9381
- warn$1(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" ` +
9382
- `which are reserved prefixes for Vue internals.`);
9383
- return;
9382
+ if (!setupState.__isScriptSetup) {
9383
+ if (key[0] === '$' || key[0] === '_') {
9384
+ warn$1(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" ` +
9385
+ `which are reserved prefixes for Vue internals.`);
9386
+ return;
9387
+ }
9388
+ Object.defineProperty(ctx, key, {
9389
+ enumerable: true,
9390
+ configurable: true,
9391
+ get: () => setupState[key],
9392
+ set: NOOP
9393
+ });
9384
9394
  }
9385
- Object.defineProperty(ctx, key, {
9386
- enumerable: true,
9387
- configurable: true,
9388
- get: () => setupState[key],
9389
- set: NOOP
9390
- });
9391
9395
  });
9392
9396
  }
9393
9397
 
@@ -10171,11 +10175,19 @@ function flushJobs(seen) {
10171
10175
  // 2. If a component is unmounted during a parent component's update,
10172
10176
  // its update can be skipped.
10173
10177
  queue.sort((a, b) => getId(a) - getId(b));
10178
+ // conditional usage of checkRecursiveUpdate must be determined out of
10179
+ // try ... catch block since Rollup by default de-optimizes treeshaking
10180
+ // inside try-catch. This can leave all warning code unshaked. Although
10181
+ // they would get eventually shaken by a minifier like terser, some minifiers
10182
+ // would fail to do that (e.g. https://github.com/evanw/esbuild/issues/1610)
10183
+ const check = (process.env.NODE_ENV !== 'production')
10184
+ ? (job) => checkRecursiveUpdates(seen, job)
10185
+ : NOOP;
10174
10186
  try {
10175
10187
  for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
10176
10188
  const job = queue[flushIndex];
10177
10189
  if (job && job.active !== false) {
10178
- if ((process.env.NODE_ENV !== 'production') && checkRecursiveUpdates(seen, job)) {
10190
+ if ((process.env.NODE_ENV !== 'production') && check(job)) {
10179
10191
  continue;
10180
10192
  }
10181
10193
  // console.log(`running:`, job.id)
@@ -10870,7 +10882,7 @@ function isMemoSame(cached, memo) {
10870
10882
  }
10871
10883
 
10872
10884
  // Core API ------------------------------------------------------------------
10873
- const version = "3.2.11";
10885
+ const version = "3.2.12";
10874
10886
  const _ssrUtils = {
10875
10887
  createComponentInstance,
10876
10888
  setupComponent,
@@ -11405,6 +11417,7 @@ class VueElement extends BaseClass {
11405
11417
  this._instance = null;
11406
11418
  this._connected = false;
11407
11419
  this._resolved = false;
11420
+ this._numberProps = null;
11408
11421
  if (this.shadowRoot && hydrate) {
11409
11422
  hydrate(this._createVNode(), this.shadowRoot);
11410
11423
  }
@@ -11420,18 +11433,17 @@ class VueElement extends BaseClass {
11420
11433
  this._setAttr(this.attributes[i].name);
11421
11434
  }
11422
11435
  // watch future attr changes
11423
- const observer = new MutationObserver(mutations => {
11436
+ new MutationObserver(mutations => {
11424
11437
  for (const m of mutations) {
11425
11438
  this._setAttr(m.attributeName);
11426
11439
  }
11427
- });
11428
- observer.observe(this, { attributes: true });
11440
+ }).observe(this, { attributes: true });
11429
11441
  }
11430
11442
  connectedCallback() {
11431
11443
  this._connected = true;
11432
11444
  if (!this._instance) {
11433
11445
  this._resolveDef();
11434
- render(this._createVNode(), this.shadowRoot);
11446
+ this._update();
11435
11447
  }
11436
11448
  }
11437
11449
  disconnectedCallback() {
@@ -11452,15 +11464,31 @@ class VueElement extends BaseClass {
11452
11464
  }
11453
11465
  const resolve = (def) => {
11454
11466
  this._resolved = true;
11467
+ const { props, styles } = def;
11468
+ const hasOptions = !isArray(props);
11469
+ const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
11470
+ // cast Number-type props set before resolve
11471
+ let numberProps;
11472
+ if (hasOptions) {
11473
+ for (const key in this._props) {
11474
+ const opt = props[key];
11475
+ if (opt === Number || (opt && opt.type === Number)) {
11476
+ this._props[key] = toNumber(this._props[key]);
11477
+ (numberProps || (numberProps = Object.create(null)))[key] = true;
11478
+ }
11479
+ }
11480
+ }
11481
+ if (numberProps) {
11482
+ this._numberProps = numberProps;
11483
+ this._update();
11484
+ }
11455
11485
  // check if there are props set pre-upgrade or connect
11456
11486
  for (const key of Object.keys(this)) {
11457
11487
  if (key[0] !== '_') {
11458
11488
  this._setProp(key, this[key]);
11459
11489
  }
11460
11490
  }
11461
- const { props, styles } = def;
11462
11491
  // defining getter/setters on prototype
11463
- const rawKeys = props ? (isArray(props) ? props : Object.keys(props)) : [];
11464
11492
  for (const key of rawKeys.map(camelize)) {
11465
11493
  Object.defineProperty(this, key, {
11466
11494
  get() {
@@ -11482,7 +11510,11 @@ class VueElement extends BaseClass {
11482
11510
  }
11483
11511
  }
11484
11512
  _setAttr(key) {
11485
- this._setProp(camelize(key), toNumber(this.getAttribute(key)), false);
11513
+ let value = this.getAttribute(key);
11514
+ if (this._numberProps && this._numberProps[key]) {
11515
+ value = toNumber(value);
11516
+ }
11517
+ this._setProp(camelize(key), value, false);
11486
11518
  }
11487
11519
  /**
11488
11520
  * @internal
@@ -11497,7 +11529,7 @@ class VueElement extends BaseClass {
11497
11529
  if (val !== this._props[key]) {
11498
11530
  this._props[key] = val;
11499
11531
  if (this._instance) {
11500
- render(this._createVNode(), this.shadowRoot);
11532
+ this._update();
11501
11533
  }
11502
11534
  // reflect
11503
11535
  if (shouldReflect) {
@@ -11513,6 +11545,9 @@ class VueElement extends BaseClass {
11513
11545
  }
11514
11546
  }
11515
11547
  }
11548
+ _update() {
11549
+ render(this._createVNode(), this.shadowRoot);
11550
+ }
11516
11551
  _createVNode() {
11517
11552
  const vnode = createVNode(this._def, extend({}, this._props));
11518
11553
  if (!this._instance) {
@@ -11533,7 +11568,7 @@ class VueElement extends BaseClass {
11533
11568
  if (!this._def.__asyncLoader) {
11534
11569
  // reload
11535
11570
  this._instance = null;
11536
- render(this._createVNode(), this.shadowRoot);
11571
+ this._update();
11537
11572
  }
11538
11573
  };
11539
11574
  }