@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.
@@ -1501,7 +1501,8 @@ class ComputedRefImpl {
1501
1501
  function computed(getterOrOptions, debugOptions) {
1502
1502
  let getter;
1503
1503
  let setter;
1504
- if (isFunction(getterOrOptions)) {
1504
+ const onlyGetter = isFunction(getterOrOptions);
1505
+ if (onlyGetter) {
1505
1506
  getter = getterOrOptions;
1506
1507
  setter = (process.env.NODE_ENV !== 'production')
1507
1508
  ? () => {
@@ -1513,7 +1514,7 @@ function computed(getterOrOptions, debugOptions) {
1513
1514
  getter = getterOrOptions.get;
1514
1515
  setter = getterOrOptions.set;
1515
1516
  }
1516
- const cRef = new ComputedRefImpl(getter, setter, isFunction(getterOrOptions) || !getterOrOptions.set);
1517
+ const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter);
1517
1518
  if ((process.env.NODE_ENV !== 'production') && debugOptions) {
1518
1519
  cRef.effect.onTrack = debugOptions.onTrack;
1519
1520
  cRef.effect.onTrigger = debugOptions.onTrigger;
@@ -1548,41 +1549,33 @@ function registerHMR(instance) {
1548
1549
  const id = instance.type.__hmrId;
1549
1550
  let record = map.get(id);
1550
1551
  if (!record) {
1551
- createRecord(id, instance.type);
1552
+ createRecord(id);
1552
1553
  record = map.get(id);
1553
1554
  }
1554
- record.instances.add(instance);
1555
+ record.add(instance);
1555
1556
  }
1556
1557
  function unregisterHMR(instance) {
1557
- map.get(instance.type.__hmrId).instances.delete(instance);
1558
+ map.get(instance.type.__hmrId).delete(instance);
1558
1559
  }
1559
- function createRecord(id, component) {
1560
- if (!component) {
1561
- warn$1(`HMR API usage is out of date.\n` +
1562
- `Please upgrade vue-loader/vite/rollup-plugin-vue or other relevant ` +
1563
- `dependency that handles Vue SFC compilation.`);
1564
- component = {};
1565
- }
1560
+ function createRecord(id) {
1566
1561
  if (map.has(id)) {
1567
1562
  return false;
1568
1563
  }
1569
- map.set(id, {
1570
- component: isClassComponent(component) ? component.__vccOpts : component,
1571
- instances: new Set()
1572
- });
1564
+ map.set(id, new Set());
1573
1565
  return true;
1574
1566
  }
1567
+ function normalizeClassComponent(component) {
1568
+ return isClassComponent(component) ? component.__vccOpts : component;
1569
+ }
1575
1570
  function rerender(id, newRender) {
1576
1571
  const record = map.get(id);
1577
- if (!record)
1572
+ if (!record) {
1578
1573
  return;
1579
- if (newRender)
1580
- record.component.render = newRender;
1581
- // Array.from creates a snapshot which avoids the set being mutated during
1582
- // updates
1583
- Array.from(record.instances).forEach(instance => {
1574
+ }
1575
+ [...record].forEach(instance => {
1584
1576
  if (newRender) {
1585
1577
  instance.render = newRender;
1578
+ normalizeClassComponent(instance.type).render = newRender;
1586
1579
  }
1587
1580
  instance.renderCache = [];
1588
1581
  // this flag forces child components with slot content to update
@@ -1595,34 +1588,31 @@ function reload(id, newComp) {
1595
1588
  const record = map.get(id);
1596
1589
  if (!record)
1597
1590
  return;
1598
- // Array.from creates a snapshot which avoids the set being mutated during
1599
- // updates
1600
- const { component, instances } = record;
1601
- if (!hmrDirtyComponents.has(component)) {
1602
- // 1. Update existing comp definition to match new one
1603
- newComp = isClassComponent(newComp) ? newComp.__vccOpts : newComp;
1604
- extend(component, newComp);
1605
- for (const key in component) {
1606
- if (key !== '__file' && !(key in newComp)) {
1607
- delete component[key];
1608
- }
1609
- }
1610
- // 2. Mark component dirty. This forces the renderer to replace the component
1611
- // on patch.
1612
- hmrDirtyComponents.add(component);
1613
- // 3. Make sure to unmark the component after the reload.
1614
- queuePostFlushCb(() => {
1615
- hmrDirtyComponents.delete(component);
1616
- });
1617
- }
1618
- Array.from(instances).forEach(instance => {
1619
- // invalidate options resolution cache
1591
+ newComp = normalizeClassComponent(newComp);
1592
+ // create a snapshot which avoids the set being mutated during updates
1593
+ const instances = [...record];
1594
+ for (const instance of instances) {
1595
+ const oldComp = normalizeClassComponent(instance.type);
1596
+ if (!hmrDirtyComponents.has(oldComp)) {
1597
+ // 1. Update existing comp definition to match new one
1598
+ extend(oldComp, newComp);
1599
+ for (const key in oldComp) {
1600
+ if (key !== '__file' && !(key in newComp)) {
1601
+ delete oldComp[key];
1602
+ }
1603
+ }
1604
+ // 2. mark definition dirty. This forces the renderer to replace the
1605
+ // component on patch.
1606
+ hmrDirtyComponents.add(oldComp);
1607
+ }
1608
+ // 3. invalidate options resolution cache
1620
1609
  instance.appContext.optionsCache.delete(instance.type);
1610
+ // 4. actually update
1621
1611
  if (instance.ceReload) {
1622
1612
  // custom element
1623
- hmrDirtyComponents.add(component);
1613
+ hmrDirtyComponents.add(oldComp);
1624
1614
  instance.ceReload(newComp.styles);
1625
- hmrDirtyComponents.delete(component);
1615
+ hmrDirtyComponents.delete(oldComp);
1626
1616
  }
1627
1617
  else if (instance.parent) {
1628
1618
  // 4. Force the parent instance to re-render. This will cause all updated
@@ -1647,6 +1637,12 @@ function reload(id, newComp) {
1647
1637
  else {
1648
1638
  console.warn('[HMR] Root or manually mounted instance modified. Full reload required.');
1649
1639
  }
1640
+ }
1641
+ // 5. make sure to cleanup dirty hmr components after update
1642
+ queuePostFlushCb(() => {
1643
+ for (const instance of instances) {
1644
+ hmrDirtyComponents.delete(normalizeClassComponent(instance.type));
1645
+ }
1650
1646
  });
1651
1647
  }
1652
1648
  function tryWrap(fn) {
@@ -1973,7 +1969,7 @@ const deprecationData = {
1973
1969
  ["PRIVATE_APIS" /* PRIVATE_APIS */]: {
1974
1970
  message: name => `"${name}" is a Vue 2 private API that no longer exists in Vue 3. ` +
1975
1971
  `If you are seeing this warning only due to a dependency, you can ` +
1976
- `suppress this warning via { PRIVATE_APIS: 'supress-warning' }.`
1972
+ `suppress this warning via { PRIVATE_APIS: 'suppress-warning' }.`
1977
1973
  }
1978
1974
  };
1979
1975
  const instanceWarned = Object.create(null);
@@ -2463,12 +2459,12 @@ function markAttrsAccessed() {
2463
2459
  function renderComponentRoot(instance) {
2464
2460
  const { type: Component, vnode, proxy, withProxy, props, propsOptions: [propsOptions], slots, attrs, emit, render, renderCache, data, setupState, ctx, inheritAttrs } = instance;
2465
2461
  let result;
2462
+ let fallthroughAttrs;
2466
2463
  const prev = setCurrentRenderingInstance(instance);
2467
2464
  if ((process.env.NODE_ENV !== 'production')) {
2468
2465
  accessedAttrs = false;
2469
2466
  }
2470
2467
  try {
2471
- let fallthroughAttrs;
2472
2468
  if (vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */) {
2473
2469
  // withProxy is a proxy with a different `has` trap only for
2474
2470
  // runtime-compiled render functions using `with` block.
@@ -2499,108 +2495,106 @@ function renderComponentRoot(instance) {
2499
2495
  ? attrs
2500
2496
  : getFunctionalFallthrough(attrs);
2501
2497
  }
2502
- // attr merging
2503
- // in dev mode, comments are preserved, and it's possible for a template
2504
- // to have comments along side the root element which makes it a fragment
2505
- let root = result;
2506
- let setRoot = undefined;
2507
- if ((process.env.NODE_ENV !== 'production') &&
2508
- result.patchFlag > 0 &&
2509
- result.patchFlag & 2048 /* DEV_ROOT_FRAGMENT */) {
2510
- ;
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));
2539
- }
2540
- }
2541
- else {
2542
- extraAttrs.push(key);
2498
+ }
2499
+ catch (err) {
2500
+ blockStack.length = 0;
2501
+ handleError(err, instance, 1 /* RENDER_FUNCTION */);
2502
+ result = createVNode(Comment);
2503
+ }
2504
+ // attr merging
2505
+ // in dev mode, comments are preserved, and it's possible for a template
2506
+ // to have comments along side the root element which makes it a fragment
2507
+ let root = result;
2508
+ let setRoot = undefined;
2509
+ if ((process.env.NODE_ENV !== 'production') &&
2510
+ result.patchFlag > 0 &&
2511
+ result.patchFlag & 2048 /* DEV_ROOT_FRAGMENT */) {
2512
+ [root, setRoot] = getChildRoot(result);
2513
+ }
2514
+ if (fallthroughAttrs && inheritAttrs !== false) {
2515
+ const keys = Object.keys(fallthroughAttrs);
2516
+ const { shapeFlag } = root;
2517
+ if (keys.length) {
2518
+ if (shapeFlag & (1 /* ELEMENT */ | 6 /* COMPONENT */)) {
2519
+ if (propsOptions && keys.some(isModelListener)) {
2520
+ // If a v-model listener (onUpdate:xxx) has a corresponding declared
2521
+ // prop, it indicates this component expects to handle v-model and
2522
+ // it should not fallthrough.
2523
+ // related: #1543, #1643, #1989
2524
+ fallthroughAttrs = filterModelListeners(fallthroughAttrs, propsOptions);
2525
+ }
2526
+ root = cloneVNode(root, fallthroughAttrs);
2527
+ }
2528
+ else if ((process.env.NODE_ENV !== 'production') && !accessedAttrs && root.type !== Comment) {
2529
+ const allAttrs = Object.keys(attrs);
2530
+ const eventAttrs = [];
2531
+ const extraAttrs = [];
2532
+ for (let i = 0, l = allAttrs.length; i < l; i++) {
2533
+ const key = allAttrs[i];
2534
+ if (isOn(key)) {
2535
+ // ignore v-model handlers when they fail to fallthrough
2536
+ if (!isModelListener(key)) {
2537
+ // remove `on`, lowercase first letter to reflect event casing
2538
+ // accurately
2539
+ eventAttrs.push(key[2].toLowerCase() + key.slice(3));
2543
2540
  }
2544
2541
  }
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.`);
2542
+ else {
2543
+ extraAttrs.push(key);
2558
2544
  }
2559
2545
  }
2560
- }
2561
- }
2562
- if (true &&
2563
- isCompatEnabled("INSTANCE_ATTRS_CLASS_STYLE" /* INSTANCE_ATTRS_CLASS_STYLE */, instance) &&
2564
- vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */ &&
2565
- root.shapeFlag & (1 /* ELEMENT */ | 6 /* COMPONENT */)) {
2566
- const { class: cls, style } = vnode.props || {};
2567
- if (cls || style) {
2568
- if ((process.env.NODE_ENV !== 'production') && inheritAttrs === false) {
2569
- warnDeprecation("INSTANCE_ATTRS_CLASS_STYLE" /* INSTANCE_ATTRS_CLASS_STYLE */, instance, getComponentName(instance.type));
2546
+ if (extraAttrs.length) {
2547
+ warn$1(`Extraneous non-props attributes (` +
2548
+ `${extraAttrs.join(', ')}) ` +
2549
+ `were passed to component but could not be automatically inherited ` +
2550
+ `because component renders fragment or text root nodes.`);
2551
+ }
2552
+ if (eventAttrs.length) {
2553
+ warn$1(`Extraneous non-emits event listeners (` +
2554
+ `${eventAttrs.join(', ')}) ` +
2555
+ `were passed to component but could not be automatically inherited ` +
2556
+ `because component renders fragment or text root nodes. ` +
2557
+ `If the listener is intended to be a component custom event listener only, ` +
2558
+ `declare it using the "emits" option.`);
2570
2559
  }
2571
- root = cloneVNode(root, {
2572
- class: cls,
2573
- style: style
2574
- });
2575
- }
2576
- }
2577
- // inherit directives
2578
- if (vnode.dirs) {
2579
- if ((process.env.NODE_ENV !== 'production') && !isElementRoot(root)) {
2580
- warn$1(`Runtime directive used on component with non-element root node. ` +
2581
- `The directives will not function as intended.`);
2582
2560
  }
2583
- root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
2584
2561
  }
2585
- // inherit transition data
2586
- if (vnode.transition) {
2587
- if ((process.env.NODE_ENV !== 'production') && !isElementRoot(root)) {
2588
- warn$1(`Component inside <Transition> renders non-element root node ` +
2589
- `that cannot be animated.`);
2562
+ }
2563
+ if (isCompatEnabled("INSTANCE_ATTRS_CLASS_STYLE" /* INSTANCE_ATTRS_CLASS_STYLE */, instance) &&
2564
+ vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */ &&
2565
+ root.shapeFlag & (1 /* ELEMENT */ | 6 /* COMPONENT */)) {
2566
+ const { class: cls, style } = vnode.props || {};
2567
+ if (cls || style) {
2568
+ if ((process.env.NODE_ENV !== 'production') && inheritAttrs === false) {
2569
+ warnDeprecation("INSTANCE_ATTRS_CLASS_STYLE" /* INSTANCE_ATTRS_CLASS_STYLE */, instance, getComponentName(instance.type));
2590
2570
  }
2591
- root.transition = vnode.transition;
2571
+ root = cloneVNode(root, {
2572
+ class: cls,
2573
+ style: style
2574
+ });
2592
2575
  }
2593
- if ((process.env.NODE_ENV !== 'production') && setRoot) {
2594
- setRoot(root);
2576
+ }
2577
+ // inherit directives
2578
+ if (vnode.dirs) {
2579
+ if ((process.env.NODE_ENV !== 'production') && !isElementRoot(root)) {
2580
+ warn$1(`Runtime directive used on component with non-element root node. ` +
2581
+ `The directives will not function as intended.`);
2595
2582
  }
2596
- else {
2597
- result = root;
2583
+ root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
2584
+ }
2585
+ // inherit transition data
2586
+ if (vnode.transition) {
2587
+ if ((process.env.NODE_ENV !== 'production') && !isElementRoot(root)) {
2588
+ warn$1(`Component inside <Transition> renders non-element root node ` +
2589
+ `that cannot be animated.`);
2598
2590
  }
2591
+ root.transition = vnode.transition;
2599
2592
  }
2600
- catch (err) {
2601
- blockStack.length = 0;
2602
- handleError(err, instance, 1 /* RENDER_FUNCTION */);
2603
- result = createVNode(Comment);
2593
+ if ((process.env.NODE_ENV !== 'production') && setRoot) {
2594
+ setRoot(root);
2595
+ }
2596
+ else {
2597
+ result = root;
2604
2598
  }
2605
2599
  setCurrentRenderingInstance(prev);
2606
2600
  return result;
@@ -3135,8 +3129,8 @@ function normalizeSuspenseChildren(vnode) {
3135
3129
  function normalizeSuspenseSlot(s) {
3136
3130
  let block;
3137
3131
  if (isFunction(s)) {
3138
- const isCompiledSlot = s._c;
3139
- if (isCompiledSlot) {
3132
+ const trackBlock = isBlockTreeEnabled && s._c;
3133
+ if (trackBlock) {
3140
3134
  // disableTracking: false
3141
3135
  // allow block tracking for compiled slots
3142
3136
  // (see ./componentRenderContext.ts)
@@ -3144,7 +3138,7 @@ function normalizeSuspenseSlot(s) {
3144
3138
  openBlock();
3145
3139
  }
3146
3140
  s = s();
3147
- if (isCompiledSlot) {
3141
+ if (trackBlock) {
3148
3142
  s._d = true;
3149
3143
  block = currentBlock;
3150
3144
  closeBlock();
@@ -5309,7 +5303,7 @@ function createCompatVue(createApp, createSingletonApp) {
5309
5303
  return vm;
5310
5304
  }
5311
5305
  }
5312
- Vue.version = "3.2.9";
5306
+ Vue.version = "3.2.13";
5313
5307
  Vue.config = singletonApp.config;
5314
5308
  Vue.use = (p, ...options) => {
5315
5309
  if (p && isFunction(p.install)) {
@@ -5845,7 +5839,7 @@ function createAppAPI(render, hydrate) {
5845
5839
  app._instance = vnode.component;
5846
5840
  devtoolsInitApp(app, version);
5847
5841
  }
5848
- return vnode.component.proxy;
5842
+ return getExposeProxy(vnode.component) || vnode.component.proxy;
5849
5843
  }
5850
5844
  else if ((process.env.NODE_ENV !== 'production')) {
5851
5845
  warn$1(`App has already been mounted.\n` +
@@ -6056,14 +6050,14 @@ function createHydrationFunctions(rendererInternals) {
6056
6050
  for (const key in props) {
6057
6051
  if ((forcePatchValue && key.endsWith('value')) ||
6058
6052
  (isOn(key) && !isReservedProp(key))) {
6059
- patchProp(el, key, null, props[key]);
6053
+ patchProp(el, key, null, props[key], false, undefined, parentComponent);
6060
6054
  }
6061
6055
  }
6062
6056
  }
6063
6057
  else if (props.onClick) {
6064
6058
  // Fast path for click listeners (which is most often) to avoid
6065
6059
  // iterating through props.
6066
- patchProp(el, 'onClick', null, props.onClick);
6060
+ patchProp(el, 'onClick', null, props.onClick, false, undefined, parentComponent);
6067
6061
  }
6068
6062
  }
6069
6063
  // vnode / directive hooks
@@ -8010,7 +8004,11 @@ function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false
8010
8004
  return Component;
8011
8005
  }
8012
8006
  if ((process.env.NODE_ENV !== 'production') && warnMissing && !res) {
8013
- warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}`);
8007
+ const extra = type === COMPONENTS
8008
+ ? `\nIf this is a native custom element, make sure to exclude it from ` +
8009
+ `component resolution via compilerOptions.isCustomElement.`
8010
+ : ``;
8011
+ warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
8014
8012
  }
8015
8013
  return res;
8016
8014
  }
@@ -9457,17 +9455,19 @@ function exposePropsOnRenderContext(instance) {
9457
9455
  function exposeSetupStateOnRenderContext(instance) {
9458
9456
  const { ctx, setupState } = instance;
9459
9457
  Object.keys(toRaw(setupState)).forEach(key => {
9460
- if (!setupState.__isScriptSetup && (key[0] === '$' || key[0] === '_')) {
9461
- warn$1(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" ` +
9462
- `which are reserved prefixes for Vue internals.`);
9463
- return;
9458
+ if (!setupState.__isScriptSetup) {
9459
+ if (key[0] === '$' || key[0] === '_') {
9460
+ warn$1(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" ` +
9461
+ `which are reserved prefixes for Vue internals.`);
9462
+ return;
9463
+ }
9464
+ Object.defineProperty(ctx, key, {
9465
+ enumerable: true,
9466
+ configurable: true,
9467
+ get: () => setupState[key],
9468
+ set: NOOP
9469
+ });
9464
9470
  }
9465
- Object.defineProperty(ctx, key, {
9466
- enumerable: true,
9467
- configurable: true,
9468
- get: () => setupState[key],
9469
- set: NOOP
9470
- });
9471
9471
  });
9472
9472
  }
9473
9473
 
@@ -10251,11 +10251,19 @@ function flushJobs(seen) {
10251
10251
  // 2. If a component is unmounted during a parent component's update,
10252
10252
  // its update can be skipped.
10253
10253
  queue.sort((a, b) => getId(a) - getId(b));
10254
+ // conditional usage of checkRecursiveUpdate must be determined out of
10255
+ // try ... catch block since Rollup by default de-optimizes treeshaking
10256
+ // inside try-catch. This can leave all warning code unshaked. Although
10257
+ // they would get eventually shaken by a minifier like terser, some minifiers
10258
+ // would fail to do that (e.g. https://github.com/evanw/esbuild/issues/1610)
10259
+ const check = (process.env.NODE_ENV !== 'production')
10260
+ ? (job) => checkRecursiveUpdates(seen, job)
10261
+ : NOOP;
10254
10262
  try {
10255
10263
  for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
10256
10264
  const job = queue[flushIndex];
10257
10265
  if (job && job.active !== false) {
10258
- if ((process.env.NODE_ENV !== 'production') && checkRecursiveUpdates(seen, job)) {
10266
+ if ((process.env.NODE_ENV !== 'production') && check(job)) {
10259
10267
  continue;
10260
10268
  }
10261
10269
  // console.log(`running:`, job.id)
@@ -10534,7 +10542,7 @@ function createPathGetter(ctx, path) {
10534
10542
  return cur;
10535
10543
  };
10536
10544
  }
10537
- function traverse(value, seen = new Set()) {
10545
+ function traverse(value, seen) {
10538
10546
  if (!isObject(value) || value["__v_skip" /* SKIP */]) {
10539
10547
  return value;
10540
10548
  }
@@ -10950,7 +10958,7 @@ function isMemoSame(cached, memo) {
10950
10958
  }
10951
10959
 
10952
10960
  // Core API ------------------------------------------------------------------
10953
- const version = "3.2.9";
10961
+ const version = "3.2.13";
10954
10962
  const _ssrUtils = {
10955
10963
  createComponentInstance,
10956
10964
  setupComponent,
@@ -11087,19 +11095,13 @@ function patchClass(el, value, isSVG) {
11087
11095
 
11088
11096
  function patchStyle(el, prev, next) {
11089
11097
  const style = el.style;
11098
+ const currentDisplay = style.display;
11090
11099
  if (!next) {
11091
11100
  el.removeAttribute('style');
11092
11101
  }
11093
11102
  else if (isString(next)) {
11094
11103
  if (prev !== next) {
11095
- const current = style.display;
11096
11104
  style.cssText = next;
11097
- // indicates that the `display` of the element is controlled by `v-show`,
11098
- // so we always keep the current `display` value regardless of the `style` value,
11099
- // thus handing over control to `v-show`.
11100
- if ('_vod' in el) {
11101
- style.display = current;
11102
- }
11103
11105
  }
11104
11106
  }
11105
11107
  else {
@@ -11114,6 +11116,12 @@ function patchStyle(el, prev, next) {
11114
11116
  }
11115
11117
  }
11116
11118
  }
11119
+ // indicates that the `display` of the element is controlled by `v-show`,
11120
+ // so we always keep the current `display` value regardless of the `style` value,
11121
+ // thus handing over control to `v-show`.
11122
+ if ('_vod' in el) {
11123
+ style.display = currentDisplay;
11124
+ }
11117
11125
  }
11118
11126
  const importantRE = /\s*!important$/;
11119
11127
  function setStyle(style, name, val) {
@@ -11485,6 +11493,7 @@ class VueElement extends BaseClass {
11485
11493
  this._instance = null;
11486
11494
  this._connected = false;
11487
11495
  this._resolved = false;
11496
+ this._numberProps = null;
11488
11497
  if (this.shadowRoot && hydrate) {
11489
11498
  hydrate(this._createVNode(), this.shadowRoot);
11490
11499
  }
@@ -11500,18 +11509,17 @@ class VueElement extends BaseClass {
11500
11509
  this._setAttr(this.attributes[i].name);
11501
11510
  }
11502
11511
  // watch future attr changes
11503
- const observer = new MutationObserver(mutations => {
11512
+ new MutationObserver(mutations => {
11504
11513
  for (const m of mutations) {
11505
11514
  this._setAttr(m.attributeName);
11506
11515
  }
11507
- });
11508
- observer.observe(this, { attributes: true });
11516
+ }).observe(this, { attributes: true });
11509
11517
  }
11510
11518
  connectedCallback() {
11511
11519
  this._connected = true;
11512
11520
  if (!this._instance) {
11513
11521
  this._resolveDef();
11514
- render(this._createVNode(), this.shadowRoot);
11522
+ this._update();
11515
11523
  }
11516
11524
  }
11517
11525
  disconnectedCallback() {
@@ -11532,15 +11540,31 @@ class VueElement extends BaseClass {
11532
11540
  }
11533
11541
  const resolve = (def) => {
11534
11542
  this._resolved = true;
11543
+ const { props, styles } = def;
11544
+ const hasOptions = !isArray(props);
11545
+ const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
11546
+ // cast Number-type props set before resolve
11547
+ let numberProps;
11548
+ if (hasOptions) {
11549
+ for (const key in this._props) {
11550
+ const opt = props[key];
11551
+ if (opt === Number || (opt && opt.type === Number)) {
11552
+ this._props[key] = toNumber(this._props[key]);
11553
+ (numberProps || (numberProps = Object.create(null)))[key] = true;
11554
+ }
11555
+ }
11556
+ }
11557
+ if (numberProps) {
11558
+ this._numberProps = numberProps;
11559
+ this._update();
11560
+ }
11535
11561
  // check if there are props set pre-upgrade or connect
11536
11562
  for (const key of Object.keys(this)) {
11537
11563
  if (key[0] !== '_') {
11538
11564
  this._setProp(key, this[key]);
11539
11565
  }
11540
11566
  }
11541
- const { props, styles } = def;
11542
11567
  // defining getter/setters on prototype
11543
- const rawKeys = props ? (isArray(props) ? props : Object.keys(props)) : [];
11544
11568
  for (const key of rawKeys.map(camelize)) {
11545
11569
  Object.defineProperty(this, key, {
11546
11570
  get() {
@@ -11562,7 +11586,11 @@ class VueElement extends BaseClass {
11562
11586
  }
11563
11587
  }
11564
11588
  _setAttr(key) {
11565
- this._setProp(camelize(key), toNumber(this.getAttribute(key)), false);
11589
+ let value = this.getAttribute(key);
11590
+ if (this._numberProps && this._numberProps[key]) {
11591
+ value = toNumber(value);
11592
+ }
11593
+ this._setProp(camelize(key), value, false);
11566
11594
  }
11567
11595
  /**
11568
11596
  * @internal
@@ -11577,7 +11605,7 @@ class VueElement extends BaseClass {
11577
11605
  if (val !== this._props[key]) {
11578
11606
  this._props[key] = val;
11579
11607
  if (this._instance) {
11580
- render(this._createVNode(), this.shadowRoot);
11608
+ this._update();
11581
11609
  }
11582
11610
  // reflect
11583
11611
  if (shouldReflect) {
@@ -11593,6 +11621,9 @@ class VueElement extends BaseClass {
11593
11621
  }
11594
11622
  }
11595
11623
  }
11624
+ _update() {
11625
+ render(this._createVNode(), this.shadowRoot);
11626
+ }
11596
11627
  _createVNode() {
11597
11628
  const vnode = createVNode(this._def, extend({}, this._props));
11598
11629
  if (!this._instance) {
@@ -11613,7 +11644,7 @@ class VueElement extends BaseClass {
11613
11644
  if (!this._def.__asyncLoader) {
11614
11645
  // reload
11615
11646
  this._instance = null;
11616
- render(this._createVNode(), this.shadowRoot);
11647
+ this._update();
11617
11648
  }
11618
11649
  };
11619
11650
  }
@@ -12922,7 +12953,7 @@ const errorMessages = {
12922
12953
  // transform errors
12923
12954
  [28 /* X_V_IF_NO_EXPRESSION */]: `v-if/v-else-if is missing expression.`,
12924
12955
  [29 /* X_V_IF_SAME_KEY */]: `v-if/else branches must use unique keys.`,
12925
- [30 /* X_V_ELSE_NO_ADJACENT_IF */]: `v-else/v-else-if has no adjacent v-if.`,
12956
+ [30 /* X_V_ELSE_NO_ADJACENT_IF */]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
12926
12957
  [31 /* X_V_FOR_NO_EXPRESSION */]: `v-for is missing expression.`,
12927
12958
  [32 /* X_V_FOR_MALFORMED_EXPRESSION */]: `v-for has invalid expression.`,
12928
12959
  [33 /* X_V_FOR_TEMPLATE_KEY_PLACEMENT */]: `<template v-for> key should be placed on the <template> tag.`,
@@ -13200,7 +13231,7 @@ const whitespaceRE = /\s+[.[]\s*|\s*[.[]\s+/g;
13200
13231
  * inside square brackets), but it's ok since these are only used on template
13201
13232
  * expressions and false positives are invalid expressions in the first place.
13202
13233
  */
13203
- const isMemberExpression = (path) => {
13234
+ const isMemberExpressionBrowser = (path) => {
13204
13235
  // remove whitespaces around . or [ first
13205
13236
  path = path.trim().replace(whitespaceRE, s => s.trim());
13206
13237
  let state = 0 /* inMemberExp */;
@@ -13270,6 +13301,8 @@ const isMemberExpression = (path) => {
13270
13301
  }
13271
13302
  return !currentOpenBracketCount && !currentOpenParensCount;
13272
13303
  };
13304
+ const isMemberExpression = isMemberExpressionBrowser
13305
+ ;
13273
13306
  function getInnerRange(loc, offset, length) {
13274
13307
  const source = loc.source.substr(offset, length);
13275
13308
  const newLoc = {
@@ -14075,6 +14108,13 @@ function parseAttributes(context, type) {
14075
14108
  emitError(context, 3 /* END_TAG_WITH_ATTRIBUTES */);
14076
14109
  }
14077
14110
  const attr = parseAttribute(context, attributeNames);
14111
+ // Trim whitespace between class
14112
+ // https://github.com/vuejs/vue-next/issues/4251
14113
+ if (attr.type === 6 /* ATTRIBUTE */ &&
14114
+ attr.value &&
14115
+ attr.name === 'class') {
14116
+ attr.value.content = attr.value.content.replace(/\s+/g, ' ').trim();
14117
+ }
14078
14118
  if (type === 0 /* Start */) {
14079
14119
  props.push(attr);
14080
14120
  }
@@ -14137,8 +14177,11 @@ function parseAttribute(context, nameSet) {
14137
14177
  isStatic = false;
14138
14178
  if (!content.endsWith(']')) {
14139
14179
  emitError(context, 27 /* X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END */);
14180
+ content = content.substr(1);
14181
+ }
14182
+ else {
14183
+ content = content.substr(1, content.length - 2);
14140
14184
  }
14141
- content = content.substr(1, content.length - 2);
14142
14185
  }
14143
14186
  else if (isSlot) {
14144
14187
  // #1241 special case for v-slot: vuetify relies extensively on slot
@@ -14408,7 +14451,7 @@ function walk$1(node, context, doNotHoistNode = false) {
14408
14451
  // This is only a concern for pre-stringification (via transformHoist by
14409
14452
  // @vue/compiler-dom), but doing it here allows us to perform only one full
14410
14453
  // walk of the AST and allow `stringifyStatic` to stop walking as soon as its
14411
- // stringficiation threshold is met.
14454
+ // stringification threshold is met.
14412
14455
  let canStringify = true;
14413
14456
  const { children } = node;
14414
14457
  const originalCount = children.length;
@@ -14655,7 +14698,7 @@ function getGeneratedPropsConstantType(node, context) {
14655
14698
  else if (value.type === 14 /* JS_CALL_EXPRESSION */) {
14656
14699
  // some helper calls can be hoisted,
14657
14700
  // such as the `normalizeProps` generated by the compiler for pre-normalize class,
14658
- // in this case we need to respect the ConstanType of the helper's argments
14701
+ // in this case we need to respect the ConstantType of the helper's argments
14659
14702
  valueType = getConstantTypeOfHelperCall(value, context);
14660
14703
  }
14661
14704
  else {
@@ -15169,13 +15212,14 @@ function genHoists(hoists, context) {
15169
15212
  context.pure = true;
15170
15213
  const { push, newline, helper, scopeId, mode } = context;
15171
15214
  newline();
15172
- hoists.forEach((exp, i) => {
15215
+ for (let i = 0; i < hoists.length; i++) {
15216
+ const exp = hoists[i];
15173
15217
  if (exp) {
15174
- push(`const _hoisted_${i + 1} = `);
15218
+ push(`const _hoisted_${i + 1} = ${``}`);
15175
15219
  genNode(exp, context);
15176
15220
  newline();
15177
15221
  }
15178
- });
15222
+ }
15179
15223
  context.pure = false;
15180
15224
  }
15181
15225
  function isText$1(n) {
@@ -15684,6 +15728,11 @@ function processIf(node, dir, context, processCodegen) {
15684
15728
  continue;
15685
15729
  }
15686
15730
  if (sibling && sibling.type === 9 /* IF */) {
15731
+ // Check if v-else was followed by v-else-if
15732
+ if (dir.name === 'else-if' &&
15733
+ sibling.branches[sibling.branches.length - 1].condition === undefined) {
15734
+ context.onError(createCompilerError(30 /* X_V_ELSE_NO_ADJACENT_IF */, node.loc));
15735
+ }
15687
15736
  // move the node to the if node's branches
15688
15737
  context.removeNode();
15689
15738
  const branch = createIfBranch(node, dir);
@@ -16781,7 +16830,7 @@ function dedupeProperties(properties) {
16781
16830
  const name = prop.key.content;
16782
16831
  const existing = knownProps.get(name);
16783
16832
  if (existing) {
16784
- if (name === 'style' || name === 'class' || name.startsWith('on')) {
16833
+ if (name === 'style' || name === 'class' || isOn(name)) {
16785
16834
  mergeAsArray$1(existing, prop);
16786
16835
  }
16787
16836
  // unexpected duplicate, should have emitted error during parse
@@ -16856,26 +16905,24 @@ const transformSlotOutlet = (node, context) => {
16856
16905
  const { slotName, slotProps } = processSlotOutlet(node, context);
16857
16906
  const slotArgs = [
16858
16907
  context.prefixIdentifiers ? `_ctx.$slots` : `$slots`,
16859
- slotName
16908
+ slotName,
16909
+ '{}',
16910
+ 'undefined',
16911
+ 'true'
16860
16912
  ];
16913
+ let expectedLen = 2;
16861
16914
  if (slotProps) {
16862
- slotArgs.push(slotProps);
16915
+ slotArgs[2] = slotProps;
16916
+ expectedLen = 3;
16863
16917
  }
16864
16918
  if (children.length) {
16865
- if (!slotProps) {
16866
- slotArgs.push(`{}`);
16867
- }
16868
- slotArgs.push(createFunctionExpression([], children, false, false, loc));
16919
+ slotArgs[3] = createFunctionExpression([], children, false, false, loc);
16920
+ expectedLen = 4;
16869
16921
  }
16870
16922
  if (context.scopeId && !context.slotted) {
16871
- if (!slotProps) {
16872
- slotArgs.push(`{}`);
16873
- }
16874
- if (!children.length) {
16875
- slotArgs.push(`undefined`);
16876
- }
16877
- slotArgs.push(`true`);
16923
+ expectedLen = 5;
16878
16924
  }
16925
+ slotArgs.splice(expectedLen); // remove unused arguments
16879
16926
  node.codegenNode = createCallExpression(context.helper(RENDER_SLOT), slotArgs, loc);
16880
16927
  }
16881
16928
  };
@@ -16922,7 +16969,7 @@ function processSlotOutlet(node, context) {
16922
16969
  };
16923
16970
  }
16924
16971
 
16925
- const fnExpRE = /^\s*([\w$_]+|\([^)]*?\))\s*=>|^\s*function(?:\s+[\w$]+)?\s*\(/;
16972
+ const fnExpRE = /^\s*([\w$_]+|(async\s*)?\([^)]*?\))\s*=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/;
16926
16973
  const transformOn = (dir, node, context, augmentor) => {
16927
16974
  const { loc, modifiers, arg } = dir;
16928
16975
  if (!dir.exp && !modifiers.length) {
@@ -17177,7 +17224,8 @@ const transformModel = (dir, node, context) => {
17177
17224
  // _unref(exp)
17178
17225
  context.bindingMetadata[rawExp];
17179
17226
  const maybeRef = !true /* SETUP_CONST */;
17180
- if (!expString.trim() || (!isMemberExpression(expString) && !maybeRef)) {
17227
+ if (!expString.trim() ||
17228
+ (!isMemberExpression(expString) && !maybeRef)) {
17181
17229
  context.onError(createCompilerError(42 /* X_V_MODEL_MALFORMED_EXPRESSION */, exp.loc));
17182
17230
  return createTransformProps();
17183
17231
  }
@@ -17885,7 +17933,8 @@ const warnTransitionChildren = (node, context) => {
17885
17933
  };
17886
17934
  function hasMultipleChildren(node) {
17887
17935
  // #1352 filter out potential comment nodes.
17888
- const children = (node.children = node.children.filter(c => c.type !== 3 /* COMMENT */));
17936
+ const children = (node.children = node.children.filter(c => c.type !== 3 /* COMMENT */ &&
17937
+ !(c.type === 2 /* TEXT */ && !c.content.trim())));
17889
17938
  const child = children[0];
17890
17939
  return (children.length !== 1 ||
17891
17940
  child.type === 11 /* FOR */ ||