@vue/compat 3.2.9 → 3.2.13

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.
@@ -1426,7 +1426,8 @@ class ComputedRefImpl {
1426
1426
  function computed(getterOrOptions, debugOptions) {
1427
1427
  let getter;
1428
1428
  let setter;
1429
- if (isFunction(getterOrOptions)) {
1429
+ const onlyGetter = isFunction(getterOrOptions);
1430
+ if (onlyGetter) {
1430
1431
  getter = getterOrOptions;
1431
1432
  setter = (process.env.NODE_ENV !== 'production')
1432
1433
  ? () => {
@@ -1438,7 +1439,7 @@ function computed(getterOrOptions, debugOptions) {
1438
1439
  getter = getterOrOptions.get;
1439
1440
  setter = getterOrOptions.set;
1440
1441
  }
1441
- const cRef = new ComputedRefImpl(getter, setter, isFunction(getterOrOptions) || !getterOrOptions.set);
1442
+ const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter);
1442
1443
  if ((process.env.NODE_ENV !== 'production') && debugOptions) {
1443
1444
  cRef.effect.onTrack = debugOptions.onTrack;
1444
1445
  cRef.effect.onTrigger = debugOptions.onTrigger;
@@ -1473,41 +1474,33 @@ function registerHMR(instance) {
1473
1474
  const id = instance.type.__hmrId;
1474
1475
  let record = map.get(id);
1475
1476
  if (!record) {
1476
- createRecord(id, instance.type);
1477
+ createRecord(id);
1477
1478
  record = map.get(id);
1478
1479
  }
1479
- record.instances.add(instance);
1480
+ record.add(instance);
1480
1481
  }
1481
1482
  function unregisterHMR(instance) {
1482
- map.get(instance.type.__hmrId).instances.delete(instance);
1483
+ map.get(instance.type.__hmrId).delete(instance);
1483
1484
  }
1484
- function createRecord(id, component) {
1485
- if (!component) {
1486
- warn$1(`HMR API usage is out of date.\n` +
1487
- `Please upgrade vue-loader/vite/rollup-plugin-vue or other relevant ` +
1488
- `dependency that handles Vue SFC compilation.`);
1489
- component = {};
1490
- }
1485
+ function createRecord(id) {
1491
1486
  if (map.has(id)) {
1492
1487
  return false;
1493
1488
  }
1494
- map.set(id, {
1495
- component: isClassComponent(component) ? component.__vccOpts : component,
1496
- instances: new Set()
1497
- });
1489
+ map.set(id, new Set());
1498
1490
  return true;
1499
1491
  }
1492
+ function normalizeClassComponent(component) {
1493
+ return isClassComponent(component) ? component.__vccOpts : component;
1494
+ }
1500
1495
  function rerender(id, newRender) {
1501
1496
  const record = map.get(id);
1502
- if (!record)
1497
+ if (!record) {
1503
1498
  return;
1504
- if (newRender)
1505
- record.component.render = newRender;
1506
- // Array.from creates a snapshot which avoids the set being mutated during
1507
- // updates
1508
- Array.from(record.instances).forEach(instance => {
1499
+ }
1500
+ [...record].forEach(instance => {
1509
1501
  if (newRender) {
1510
1502
  instance.render = newRender;
1503
+ normalizeClassComponent(instance.type).render = newRender;
1511
1504
  }
1512
1505
  instance.renderCache = [];
1513
1506
  // this flag forces child components with slot content to update
@@ -1520,34 +1513,31 @@ function reload(id, newComp) {
1520
1513
  const record = map.get(id);
1521
1514
  if (!record)
1522
1515
  return;
1523
- // Array.from creates a snapshot which avoids the set being mutated during
1524
- // updates
1525
- const { component, instances } = record;
1526
- if (!hmrDirtyComponents.has(component)) {
1527
- // 1. Update existing comp definition to match new one
1528
- newComp = isClassComponent(newComp) ? newComp.__vccOpts : newComp;
1529
- extend(component, newComp);
1530
- for (const key in component) {
1531
- if (key !== '__file' && !(key in newComp)) {
1532
- delete component[key];
1533
- }
1534
- }
1535
- // 2. Mark component dirty. This forces the renderer to replace the component
1536
- // on patch.
1537
- hmrDirtyComponents.add(component);
1538
- // 3. Make sure to unmark the component after the reload.
1539
- queuePostFlushCb(() => {
1540
- hmrDirtyComponents.delete(component);
1541
- });
1542
- }
1543
- Array.from(instances).forEach(instance => {
1544
- // invalidate options resolution cache
1516
+ newComp = normalizeClassComponent(newComp);
1517
+ // create a snapshot which avoids the set being mutated during updates
1518
+ const instances = [...record];
1519
+ for (const instance of instances) {
1520
+ const oldComp = normalizeClassComponent(instance.type);
1521
+ if (!hmrDirtyComponents.has(oldComp)) {
1522
+ // 1. Update existing comp definition to match new one
1523
+ extend(oldComp, newComp);
1524
+ for (const key in oldComp) {
1525
+ if (key !== '__file' && !(key in newComp)) {
1526
+ delete oldComp[key];
1527
+ }
1528
+ }
1529
+ // 2. mark definition dirty. This forces the renderer to replace the
1530
+ // component on patch.
1531
+ hmrDirtyComponents.add(oldComp);
1532
+ }
1533
+ // 3. invalidate options resolution cache
1545
1534
  instance.appContext.optionsCache.delete(instance.type);
1535
+ // 4. actually update
1546
1536
  if (instance.ceReload) {
1547
1537
  // custom element
1548
- hmrDirtyComponents.add(component);
1538
+ hmrDirtyComponents.add(oldComp);
1549
1539
  instance.ceReload(newComp.styles);
1550
- hmrDirtyComponents.delete(component);
1540
+ hmrDirtyComponents.delete(oldComp);
1551
1541
  }
1552
1542
  else if (instance.parent) {
1553
1543
  // 4. Force the parent instance to re-render. This will cause all updated
@@ -1572,6 +1562,12 @@ function reload(id, newComp) {
1572
1562
  else {
1573
1563
  console.warn('[HMR] Root or manually mounted instance modified. Full reload required.');
1574
1564
  }
1565
+ }
1566
+ // 5. make sure to cleanup dirty hmr components after update
1567
+ queuePostFlushCb(() => {
1568
+ for (const instance of instances) {
1569
+ hmrDirtyComponents.delete(normalizeClassComponent(instance.type));
1570
+ }
1575
1571
  });
1576
1572
  }
1577
1573
  function tryWrap(fn) {
@@ -1898,7 +1894,7 @@ const deprecationData = {
1898
1894
  ["PRIVATE_APIS" /* PRIVATE_APIS */]: {
1899
1895
  message: name => `"${name}" is a Vue 2 private API that no longer exists in Vue 3. ` +
1900
1896
  `If you are seeing this warning only due to a dependency, you can ` +
1901
- `suppress this warning via { PRIVATE_APIS: 'supress-warning' }.`
1897
+ `suppress this warning via { PRIVATE_APIS: 'suppress-warning' }.`
1902
1898
  }
1903
1899
  };
1904
1900
  const instanceWarned = Object.create(null);
@@ -2388,12 +2384,12 @@ function markAttrsAccessed() {
2388
2384
  function renderComponentRoot(instance) {
2389
2385
  const { type: Component, vnode, proxy, withProxy, props, propsOptions: [propsOptions], slots, attrs, emit, render, renderCache, data, setupState, ctx, inheritAttrs } = instance;
2390
2386
  let result;
2387
+ let fallthroughAttrs;
2391
2388
  const prev = setCurrentRenderingInstance(instance);
2392
2389
  if ((process.env.NODE_ENV !== 'production')) {
2393
2390
  accessedAttrs = false;
2394
2391
  }
2395
2392
  try {
2396
- let fallthroughAttrs;
2397
2393
  if (vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */) {
2398
2394
  // withProxy is a proxy with a different `has` trap only for
2399
2395
  // runtime-compiled render functions using `with` block.
@@ -2424,108 +2420,106 @@ function renderComponentRoot(instance) {
2424
2420
  ? attrs
2425
2421
  : getFunctionalFallthrough(attrs);
2426
2422
  }
2427
- // attr merging
2428
- // in dev mode, comments are preserved, and it's possible for a template
2429
- // to have comments along side the root element which makes it a fragment
2430
- let root = result;
2431
- let setRoot = undefined;
2432
- if ((process.env.NODE_ENV !== 'production') &&
2433
- result.patchFlag > 0 &&
2434
- result.patchFlag & 2048 /* DEV_ROOT_FRAGMENT */) {
2435
- ;
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));
2464
- }
2465
- }
2466
- else {
2467
- extraAttrs.push(key);
2423
+ }
2424
+ catch (err) {
2425
+ blockStack.length = 0;
2426
+ handleError(err, instance, 1 /* RENDER_FUNCTION */);
2427
+ result = createVNode(Comment);
2428
+ }
2429
+ // attr merging
2430
+ // in dev mode, comments are preserved, and it's possible for a template
2431
+ // to have comments along side the root element which makes it a fragment
2432
+ let root = result;
2433
+ let setRoot = undefined;
2434
+ if ((process.env.NODE_ENV !== 'production') &&
2435
+ result.patchFlag > 0 &&
2436
+ result.patchFlag & 2048 /* DEV_ROOT_FRAGMENT */) {
2437
+ [root, setRoot] = getChildRoot(result);
2438
+ }
2439
+ if (fallthroughAttrs && inheritAttrs !== false) {
2440
+ const keys = Object.keys(fallthroughAttrs);
2441
+ const { shapeFlag } = root;
2442
+ if (keys.length) {
2443
+ if (shapeFlag & (1 /* ELEMENT */ | 6 /* COMPONENT */)) {
2444
+ if (propsOptions && keys.some(isModelListener)) {
2445
+ // If a v-model listener (onUpdate:xxx) has a corresponding declared
2446
+ // prop, it indicates this component expects to handle v-model and
2447
+ // it should not fallthrough.
2448
+ // related: #1543, #1643, #1989
2449
+ fallthroughAttrs = filterModelListeners(fallthroughAttrs, propsOptions);
2450
+ }
2451
+ root = cloneVNode(root, fallthroughAttrs);
2452
+ }
2453
+ else if ((process.env.NODE_ENV !== 'production') && !accessedAttrs && root.type !== Comment) {
2454
+ const allAttrs = Object.keys(attrs);
2455
+ const eventAttrs = [];
2456
+ const extraAttrs = [];
2457
+ for (let i = 0, l = allAttrs.length; i < l; i++) {
2458
+ const key = allAttrs[i];
2459
+ if (isOn(key)) {
2460
+ // ignore v-model handlers when they fail to fallthrough
2461
+ if (!isModelListener(key)) {
2462
+ // remove `on`, lowercase first letter to reflect event casing
2463
+ // accurately
2464
+ eventAttrs.push(key[2].toLowerCase() + key.slice(3));
2468
2465
  }
2469
2466
  }
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.`);
2467
+ else {
2468
+ extraAttrs.push(key);
2483
2469
  }
2484
2470
  }
2485
- }
2486
- }
2487
- if (true &&
2488
- isCompatEnabled("INSTANCE_ATTRS_CLASS_STYLE" /* INSTANCE_ATTRS_CLASS_STYLE */, instance) &&
2489
- vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */ &&
2490
- root.shapeFlag & (1 /* ELEMENT */ | 6 /* COMPONENT */)) {
2491
- const { class: cls, style } = vnode.props || {};
2492
- if (cls || style) {
2493
- if ((process.env.NODE_ENV !== 'production') && inheritAttrs === false) {
2494
- warnDeprecation("INSTANCE_ATTRS_CLASS_STYLE" /* INSTANCE_ATTRS_CLASS_STYLE */, instance, getComponentName(instance.type));
2471
+ if (extraAttrs.length) {
2472
+ warn$1(`Extraneous non-props attributes (` +
2473
+ `${extraAttrs.join(', ')}) ` +
2474
+ `were passed to component but could not be automatically inherited ` +
2475
+ `because component renders fragment or text root nodes.`);
2476
+ }
2477
+ if (eventAttrs.length) {
2478
+ warn$1(`Extraneous non-emits event listeners (` +
2479
+ `${eventAttrs.join(', ')}) ` +
2480
+ `were passed to component but could not be automatically inherited ` +
2481
+ `because component renders fragment or text root nodes. ` +
2482
+ `If the listener is intended to be a component custom event listener only, ` +
2483
+ `declare it using the "emits" option.`);
2495
2484
  }
2496
- root = cloneVNode(root, {
2497
- class: cls,
2498
- style: style
2499
- });
2500
- }
2501
- }
2502
- // inherit directives
2503
- if (vnode.dirs) {
2504
- if ((process.env.NODE_ENV !== 'production') && !isElementRoot(root)) {
2505
- warn$1(`Runtime directive used on component with non-element root node. ` +
2506
- `The directives will not function as intended.`);
2507
2485
  }
2508
- root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
2509
2486
  }
2510
- // inherit transition data
2511
- if (vnode.transition) {
2512
- if ((process.env.NODE_ENV !== 'production') && !isElementRoot(root)) {
2513
- warn$1(`Component inside <Transition> renders non-element root node ` +
2514
- `that cannot be animated.`);
2487
+ }
2488
+ if (isCompatEnabled("INSTANCE_ATTRS_CLASS_STYLE" /* INSTANCE_ATTRS_CLASS_STYLE */, instance) &&
2489
+ vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */ &&
2490
+ root.shapeFlag & (1 /* ELEMENT */ | 6 /* COMPONENT */)) {
2491
+ const { class: cls, style } = vnode.props || {};
2492
+ if (cls || style) {
2493
+ if ((process.env.NODE_ENV !== 'production') && inheritAttrs === false) {
2494
+ warnDeprecation("INSTANCE_ATTRS_CLASS_STYLE" /* INSTANCE_ATTRS_CLASS_STYLE */, instance, getComponentName(instance.type));
2515
2495
  }
2516
- root.transition = vnode.transition;
2496
+ root = cloneVNode(root, {
2497
+ class: cls,
2498
+ style: style
2499
+ });
2517
2500
  }
2518
- if ((process.env.NODE_ENV !== 'production') && setRoot) {
2519
- setRoot(root);
2501
+ }
2502
+ // inherit directives
2503
+ if (vnode.dirs) {
2504
+ if ((process.env.NODE_ENV !== 'production') && !isElementRoot(root)) {
2505
+ warn$1(`Runtime directive used on component with non-element root node. ` +
2506
+ `The directives will not function as intended.`);
2520
2507
  }
2521
- else {
2522
- result = root;
2508
+ root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
2509
+ }
2510
+ // inherit transition data
2511
+ if (vnode.transition) {
2512
+ if ((process.env.NODE_ENV !== 'production') && !isElementRoot(root)) {
2513
+ warn$1(`Component inside <Transition> renders non-element root node ` +
2514
+ `that cannot be animated.`);
2523
2515
  }
2516
+ root.transition = vnode.transition;
2524
2517
  }
2525
- catch (err) {
2526
- blockStack.length = 0;
2527
- handleError(err, instance, 1 /* RENDER_FUNCTION */);
2528
- result = createVNode(Comment);
2518
+ if ((process.env.NODE_ENV !== 'production') && setRoot) {
2519
+ setRoot(root);
2520
+ }
2521
+ else {
2522
+ result = root;
2529
2523
  }
2530
2524
  setCurrentRenderingInstance(prev);
2531
2525
  return result;
@@ -3060,8 +3054,8 @@ function normalizeSuspenseChildren(vnode) {
3060
3054
  function normalizeSuspenseSlot(s) {
3061
3055
  let block;
3062
3056
  if (isFunction(s)) {
3063
- const isCompiledSlot = s._c;
3064
- if (isCompiledSlot) {
3057
+ const trackBlock = isBlockTreeEnabled && s._c;
3058
+ if (trackBlock) {
3065
3059
  // disableTracking: false
3066
3060
  // allow block tracking for compiled slots
3067
3061
  // (see ./componentRenderContext.ts)
@@ -3069,7 +3063,7 @@ function normalizeSuspenseSlot(s) {
3069
3063
  openBlock();
3070
3064
  }
3071
3065
  s = s();
3072
- if (isCompiledSlot) {
3066
+ if (trackBlock) {
3073
3067
  s._d = true;
3074
3068
  block = currentBlock;
3075
3069
  closeBlock();
@@ -5234,7 +5228,7 @@ function createCompatVue(createApp, createSingletonApp) {
5234
5228
  return vm;
5235
5229
  }
5236
5230
  }
5237
- Vue.version = "3.2.9";
5231
+ Vue.version = "3.2.13";
5238
5232
  Vue.config = singletonApp.config;
5239
5233
  Vue.use = (p, ...options) => {
5240
5234
  if (p && isFunction(p.install)) {
@@ -5770,7 +5764,7 @@ function createAppAPI(render, hydrate) {
5770
5764
  app._instance = vnode.component;
5771
5765
  devtoolsInitApp(app, version);
5772
5766
  }
5773
- return vnode.component.proxy;
5767
+ return getExposeProxy(vnode.component) || vnode.component.proxy;
5774
5768
  }
5775
5769
  else if ((process.env.NODE_ENV !== 'production')) {
5776
5770
  warn$1(`App has already been mounted.\n` +
@@ -5981,14 +5975,14 @@ function createHydrationFunctions(rendererInternals) {
5981
5975
  for (const key in props) {
5982
5976
  if ((forcePatchValue && key.endsWith('value')) ||
5983
5977
  (isOn(key) && !isReservedProp(key))) {
5984
- patchProp(el, key, null, props[key]);
5978
+ patchProp(el, key, null, props[key], false, undefined, parentComponent);
5985
5979
  }
5986
5980
  }
5987
5981
  }
5988
5982
  else if (props.onClick) {
5989
5983
  // Fast path for click listeners (which is most often) to avoid
5990
5984
  // iterating through props.
5991
- patchProp(el, 'onClick', null, props.onClick);
5985
+ patchProp(el, 'onClick', null, props.onClick, false, undefined, parentComponent);
5992
5986
  }
5993
5987
  }
5994
5988
  // vnode / directive hooks
@@ -7935,7 +7929,11 @@ function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false
7935
7929
  return Component;
7936
7930
  }
7937
7931
  if ((process.env.NODE_ENV !== 'production') && warnMissing && !res) {
7938
- warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}`);
7932
+ const extra = type === COMPONENTS
7933
+ ? `\nIf this is a native custom element, make sure to exclude it from ` +
7934
+ `component resolution via compilerOptions.isCustomElement.`
7935
+ : ``;
7936
+ warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
7939
7937
  }
7940
7938
  return res;
7941
7939
  }
@@ -9382,17 +9380,19 @@ function exposePropsOnRenderContext(instance) {
9382
9380
  function exposeSetupStateOnRenderContext(instance) {
9383
9381
  const { ctx, setupState } = instance;
9384
9382
  Object.keys(toRaw(setupState)).forEach(key => {
9385
- if (!setupState.__isScriptSetup && (key[0] === '$' || key[0] === '_')) {
9386
- warn$1(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" ` +
9387
- `which are reserved prefixes for Vue internals.`);
9388
- return;
9383
+ if (!setupState.__isScriptSetup) {
9384
+ if (key[0] === '$' || key[0] === '_') {
9385
+ warn$1(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" ` +
9386
+ `which are reserved prefixes for Vue internals.`);
9387
+ return;
9388
+ }
9389
+ Object.defineProperty(ctx, key, {
9390
+ enumerable: true,
9391
+ configurable: true,
9392
+ get: () => setupState[key],
9393
+ set: NOOP
9394
+ });
9389
9395
  }
9390
- Object.defineProperty(ctx, key, {
9391
- enumerable: true,
9392
- configurable: true,
9393
- get: () => setupState[key],
9394
- set: NOOP
9395
- });
9396
9396
  });
9397
9397
  }
9398
9398
 
@@ -10176,11 +10176,19 @@ function flushJobs(seen) {
10176
10176
  // 2. If a component is unmounted during a parent component's update,
10177
10177
  // its update can be skipped.
10178
10178
  queue.sort((a, b) => getId(a) - getId(b));
10179
+ // conditional usage of checkRecursiveUpdate must be determined out of
10180
+ // try ... catch block since Rollup by default de-optimizes treeshaking
10181
+ // inside try-catch. This can leave all warning code unshaked. Although
10182
+ // they would get eventually shaken by a minifier like terser, some minifiers
10183
+ // would fail to do that (e.g. https://github.com/evanw/esbuild/issues/1610)
10184
+ const check = (process.env.NODE_ENV !== 'production')
10185
+ ? (job) => checkRecursiveUpdates(seen, job)
10186
+ : NOOP;
10179
10187
  try {
10180
10188
  for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
10181
10189
  const job = queue[flushIndex];
10182
10190
  if (job && job.active !== false) {
10183
- if ((process.env.NODE_ENV !== 'production') && checkRecursiveUpdates(seen, job)) {
10191
+ if ((process.env.NODE_ENV !== 'production') && check(job)) {
10184
10192
  continue;
10185
10193
  }
10186
10194
  // console.log(`running:`, job.id)
@@ -10459,7 +10467,7 @@ function createPathGetter(ctx, path) {
10459
10467
  return cur;
10460
10468
  };
10461
10469
  }
10462
- function traverse(value, seen = new Set()) {
10470
+ function traverse(value, seen) {
10463
10471
  if (!isObject(value) || value["__v_skip" /* SKIP */]) {
10464
10472
  return value;
10465
10473
  }
@@ -10875,7 +10883,7 @@ function isMemoSame(cached, memo) {
10875
10883
  }
10876
10884
 
10877
10885
  // Core API ------------------------------------------------------------------
10878
- const version = "3.2.9";
10886
+ const version = "3.2.13";
10879
10887
  const _ssrUtils = {
10880
10888
  createComponentInstance,
10881
10889
  setupComponent,
@@ -11012,19 +11020,13 @@ function patchClass(el, value, isSVG) {
11012
11020
 
11013
11021
  function patchStyle(el, prev, next) {
11014
11022
  const style = el.style;
11023
+ const currentDisplay = style.display;
11015
11024
  if (!next) {
11016
11025
  el.removeAttribute('style');
11017
11026
  }
11018
11027
  else if (isString(next)) {
11019
11028
  if (prev !== next) {
11020
- const current = style.display;
11021
11029
  style.cssText = next;
11022
- // indicates that the `display` of the element is controlled by `v-show`,
11023
- // so we always keep the current `display` value regardless of the `style` value,
11024
- // thus handing over control to `v-show`.
11025
- if ('_vod' in el) {
11026
- style.display = current;
11027
- }
11028
11030
  }
11029
11031
  }
11030
11032
  else {
@@ -11039,6 +11041,12 @@ function patchStyle(el, prev, next) {
11039
11041
  }
11040
11042
  }
11041
11043
  }
11044
+ // indicates that the `display` of the element is controlled by `v-show`,
11045
+ // so we always keep the current `display` value regardless of the `style` value,
11046
+ // thus handing over control to `v-show`.
11047
+ if ('_vod' in el) {
11048
+ style.display = currentDisplay;
11049
+ }
11042
11050
  }
11043
11051
  const importantRE = /\s*!important$/;
11044
11052
  function setStyle(style, name, val) {
@@ -11410,6 +11418,7 @@ class VueElement extends BaseClass {
11410
11418
  this._instance = null;
11411
11419
  this._connected = false;
11412
11420
  this._resolved = false;
11421
+ this._numberProps = null;
11413
11422
  if (this.shadowRoot && hydrate) {
11414
11423
  hydrate(this._createVNode(), this.shadowRoot);
11415
11424
  }
@@ -11425,18 +11434,17 @@ class VueElement extends BaseClass {
11425
11434
  this._setAttr(this.attributes[i].name);
11426
11435
  }
11427
11436
  // watch future attr changes
11428
- const observer = new MutationObserver(mutations => {
11437
+ new MutationObserver(mutations => {
11429
11438
  for (const m of mutations) {
11430
11439
  this._setAttr(m.attributeName);
11431
11440
  }
11432
- });
11433
- observer.observe(this, { attributes: true });
11441
+ }).observe(this, { attributes: true });
11434
11442
  }
11435
11443
  connectedCallback() {
11436
11444
  this._connected = true;
11437
11445
  if (!this._instance) {
11438
11446
  this._resolveDef();
11439
- render(this._createVNode(), this.shadowRoot);
11447
+ this._update();
11440
11448
  }
11441
11449
  }
11442
11450
  disconnectedCallback() {
@@ -11457,15 +11465,31 @@ class VueElement extends BaseClass {
11457
11465
  }
11458
11466
  const resolve = (def) => {
11459
11467
  this._resolved = true;
11468
+ const { props, styles } = def;
11469
+ const hasOptions = !isArray(props);
11470
+ const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
11471
+ // cast Number-type props set before resolve
11472
+ let numberProps;
11473
+ if (hasOptions) {
11474
+ for (const key in this._props) {
11475
+ const opt = props[key];
11476
+ if (opt === Number || (opt && opt.type === Number)) {
11477
+ this._props[key] = toNumber(this._props[key]);
11478
+ (numberProps || (numberProps = Object.create(null)))[key] = true;
11479
+ }
11480
+ }
11481
+ }
11482
+ if (numberProps) {
11483
+ this._numberProps = numberProps;
11484
+ this._update();
11485
+ }
11460
11486
  // check if there are props set pre-upgrade or connect
11461
11487
  for (const key of Object.keys(this)) {
11462
11488
  if (key[0] !== '_') {
11463
11489
  this._setProp(key, this[key]);
11464
11490
  }
11465
11491
  }
11466
- const { props, styles } = def;
11467
11492
  // defining getter/setters on prototype
11468
- const rawKeys = props ? (isArray(props) ? props : Object.keys(props)) : [];
11469
11493
  for (const key of rawKeys.map(camelize)) {
11470
11494
  Object.defineProperty(this, key, {
11471
11495
  get() {
@@ -11487,7 +11511,11 @@ class VueElement extends BaseClass {
11487
11511
  }
11488
11512
  }
11489
11513
  _setAttr(key) {
11490
- this._setProp(camelize(key), toNumber(this.getAttribute(key)), false);
11514
+ let value = this.getAttribute(key);
11515
+ if (this._numberProps && this._numberProps[key]) {
11516
+ value = toNumber(value);
11517
+ }
11518
+ this._setProp(camelize(key), value, false);
11491
11519
  }
11492
11520
  /**
11493
11521
  * @internal
@@ -11502,7 +11530,7 @@ class VueElement extends BaseClass {
11502
11530
  if (val !== this._props[key]) {
11503
11531
  this._props[key] = val;
11504
11532
  if (this._instance) {
11505
- render(this._createVNode(), this.shadowRoot);
11533
+ this._update();
11506
11534
  }
11507
11535
  // reflect
11508
11536
  if (shouldReflect) {
@@ -11518,6 +11546,9 @@ class VueElement extends BaseClass {
11518
11546
  }
11519
11547
  }
11520
11548
  }
11549
+ _update() {
11550
+ render(this._createVNode(), this.shadowRoot);
11551
+ }
11521
11552
  _createVNode() {
11522
11553
  const vnode = createVNode(this._def, extend({}, this._props));
11523
11554
  if (!this._instance) {
@@ -11538,7 +11569,7 @@ class VueElement extends BaseClass {
11538
11569
  if (!this._def.__asyncLoader) {
11539
11570
  // reload
11540
11571
  this._instance = null;
11541
- render(this._createVNode(), this.shadowRoot);
11572
+ this._update();
11542
11573
  }
11543
11574
  };
11544
11575
  }