@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.
@@ -1849,21 +1849,14 @@ function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot // true onl
1849
1849
  return renderFnWithContext;
1850
1850
  }
1851
1851
 
1852
- /**
1853
- * dev only flag to track whether $attrs was used during render.
1854
- * If $attrs was used during render then the warning for failed attrs
1855
- * fallthrough can be suppressed.
1856
- */
1857
- let accessedAttrs = false;
1858
1852
  function markAttrsAccessed() {
1859
- accessedAttrs = true;
1860
1853
  }
1861
1854
  function renderComponentRoot(instance) {
1862
1855
  const { type: Component, vnode, proxy, withProxy, props, propsOptions: [propsOptions], slots, attrs, emit, render, renderCache, data, setupState, ctx, inheritAttrs } = instance;
1863
1856
  let result;
1857
+ let fallthroughAttrs;
1864
1858
  const prev = setCurrentRenderingInstance(instance);
1865
1859
  try {
1866
- let fallthroughAttrs;
1867
1860
  if (vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */) {
1868
1861
  // withProxy is a proxy with a different `has` trap only for
1869
1862
  // runtime-compiled render functions using `with` block.
@@ -1892,95 +1885,57 @@ function renderComponentRoot(instance) {
1892
1885
  ? attrs
1893
1886
  : getFunctionalFallthrough(attrs);
1894
1887
  }
1895
- // attr merging
1896
- // in dev mode, comments are preserved, and it's possible for a template
1897
- // to have comments along side the root element which makes it a fragment
1898
- let root = result;
1899
- let setRoot = undefined;
1900
- if (false &&
1901
- result.patchFlag > 0 &&
1902
- result.patchFlag & 2048 /* DEV_ROOT_FRAGMENT */) ;
1903
- if (fallthroughAttrs && inheritAttrs !== false) {
1904
- const keys = Object.keys(fallthroughAttrs);
1905
- const { shapeFlag } = root;
1906
- if (keys.length) {
1907
- if (shapeFlag & (1 /* ELEMENT */ | 6 /* COMPONENT */)) {
1908
- if (propsOptions && keys.some(isModelListener)) {
1909
- // If a v-model listener (onUpdate:xxx) has a corresponding declared
1910
- // prop, it indicates this component expects to handle v-model and
1911
- // it should not fallthrough.
1912
- // related: #1543, #1643, #1989
1913
- fallthroughAttrs = filterModelListeners(fallthroughAttrs, propsOptions);
1914
- }
1915
- root = cloneVNode(root, fallthroughAttrs);
1916
- }
1917
- else if (false && !accessedAttrs && root.type !== Comment) ;
1918
- }
1919
- }
1920
- if (true &&
1921
- isCompatEnabled("INSTANCE_ATTRS_CLASS_STYLE" /* INSTANCE_ATTRS_CLASS_STYLE */, instance) &&
1922
- vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */ &&
1923
- root.shapeFlag & (1 /* ELEMENT */ | 6 /* COMPONENT */)) {
1924
- const { class: cls, style } = vnode.props || {};
1925
- if (cls || style) {
1926
- if (false && inheritAttrs === false) ;
1927
- root = cloneVNode(root, {
1928
- class: cls,
1929
- style: style
1930
- });
1931
- }
1932
- }
1933
- // inherit directives
1934
- if (vnode.dirs) {
1935
- if (false && !isElementRoot(root)) ;
1936
- root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
1937
- }
1938
- // inherit transition data
1939
- if (vnode.transition) {
1940
- if (false && !isElementRoot(root)) ;
1941
- root.transition = vnode.transition;
1942
- }
1943
- if (false && setRoot) ;
1944
- else {
1945
- result = root;
1946
- }
1947
1888
  }
1948
1889
  catch (err) {
1949
1890
  blockStack.length = 0;
1950
1891
  handleError(err, instance, 1 /* RENDER_FUNCTION */);
1951
1892
  result = createVNode(Comment);
1952
1893
  }
1894
+ // attr merging
1895
+ // in dev mode, comments are preserved, and it's possible for a template
1896
+ // to have comments along side the root element which makes it a fragment
1897
+ let root = result;
1898
+ if (fallthroughAttrs && inheritAttrs !== false) {
1899
+ const keys = Object.keys(fallthroughAttrs);
1900
+ const { shapeFlag } = root;
1901
+ if (keys.length) {
1902
+ if (shapeFlag & (1 /* ELEMENT */ | 6 /* COMPONENT */)) {
1903
+ if (propsOptions && keys.some(isModelListener)) {
1904
+ // If a v-model listener (onUpdate:xxx) has a corresponding declared
1905
+ // prop, it indicates this component expects to handle v-model and
1906
+ // it should not fallthrough.
1907
+ // related: #1543, #1643, #1989
1908
+ fallthroughAttrs = filterModelListeners(fallthroughAttrs, propsOptions);
1909
+ }
1910
+ root = cloneVNode(root, fallthroughAttrs);
1911
+ }
1912
+ }
1913
+ }
1914
+ if (isCompatEnabled("INSTANCE_ATTRS_CLASS_STYLE" /* INSTANCE_ATTRS_CLASS_STYLE */, instance) &&
1915
+ vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */ &&
1916
+ root.shapeFlag & (1 /* ELEMENT */ | 6 /* COMPONENT */)) {
1917
+ const { class: cls, style } = vnode.props || {};
1918
+ if (cls || style) {
1919
+ root = cloneVNode(root, {
1920
+ class: cls,
1921
+ style: style
1922
+ });
1923
+ }
1924
+ }
1925
+ // inherit directives
1926
+ if (vnode.dirs) {
1927
+ root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
1928
+ }
1929
+ // inherit transition data
1930
+ if (vnode.transition) {
1931
+ root.transition = vnode.transition;
1932
+ }
1933
+ {
1934
+ result = root;
1935
+ }
1953
1936
  setCurrentRenderingInstance(prev);
1954
1937
  return result;
1955
1938
  }
1956
- /**
1957
- * dev only
1958
- * In dev mode, template root level comments are rendered, which turns the
1959
- * template into a fragment root, but we need to locate the single element
1960
- * root for attrs and scope id processing.
1961
- */
1962
- const getChildRoot = (vnode) => {
1963
- const rawChildren = vnode.children;
1964
- const dynamicChildren = vnode.dynamicChildren;
1965
- const childRoot = filterSingleRoot(rawChildren);
1966
- if (!childRoot) {
1967
- return [vnode, undefined];
1968
- }
1969
- const index = rawChildren.indexOf(childRoot);
1970
- const dynamicIndex = dynamicChildren ? dynamicChildren.indexOf(childRoot) : -1;
1971
- const setRoot = (updatedRoot) => {
1972
- rawChildren[index] = updatedRoot;
1973
- if (dynamicChildren) {
1974
- if (dynamicIndex > -1) {
1975
- dynamicChildren[dynamicIndex] = updatedRoot;
1976
- }
1977
- else if (updatedRoot.patchFlag > 0) {
1978
- vnode.dynamicChildren = [...dynamicChildren, updatedRoot];
1979
- }
1980
- }
1981
- };
1982
- return [normalizeVNode(childRoot), setRoot];
1983
- };
1984
1939
  function filterSingleRoot(children) {
1985
1940
  let singleRoot;
1986
1941
  for (let i = 0; i < children.length; i++) {
@@ -2021,11 +1976,6 @@ const filterModelListeners = (attrs, props) => {
2021
1976
  }
2022
1977
  return res;
2023
1978
  };
2024
- const isElementRoot = (vnode) => {
2025
- return (vnode.shapeFlag & (6 /* COMPONENT */ | 1 /* ELEMENT */) ||
2026
- vnode.type === Comment // potential v-if branch switch
2027
- );
2028
- };
2029
1979
  function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
2030
1980
  const { props: prevProps, children: prevChildren, component } = prevVNode;
2031
1981
  const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;
@@ -2456,8 +2406,8 @@ function normalizeSuspenseChildren(vnode) {
2456
2406
  function normalizeSuspenseSlot(s) {
2457
2407
  let block;
2458
2408
  if (isFunction(s)) {
2459
- const isCompiledSlot = s._c;
2460
- if (isCompiledSlot) {
2409
+ const trackBlock = isBlockTreeEnabled && s._c;
2410
+ if (trackBlock) {
2461
2411
  // disableTracking: false
2462
2412
  // allow block tracking for compiled slots
2463
2413
  // (see ./componentRenderContext.ts)
@@ -2465,7 +2415,7 @@ function normalizeSuspenseSlot(s) {
2465
2415
  openBlock();
2466
2416
  }
2467
2417
  s = s();
2468
- if (isCompiledSlot) {
2418
+ if (trackBlock) {
2469
2419
  s._d = true;
2470
2420
  block = currentBlock;
2471
2421
  closeBlock();
@@ -4282,7 +4232,7 @@ function createCompatVue(createApp, createSingletonApp) {
4282
4232
  return vm;
4283
4233
  }
4284
4234
  }
4285
- Vue.version = "3.2.11";
4235
+ Vue.version = "3.2.12";
4286
4236
  Vue.config = singletonApp.config;
4287
4237
  Vue.use = (p, ...options) => {
4288
4238
  if (p && isFunction(p.install)) {
@@ -8380,7 +8330,6 @@ let postFlushIndex = 0;
8380
8330
  const resolvedPromise = Promise.resolve();
8381
8331
  let currentFlushPromise = null;
8382
8332
  let currentPreFlushParentJob = null;
8383
- const RECURSION_LIMIT = 100;
8384
8333
  function nextTick(fn) {
8385
8334
  const p = currentFlushPromise || resolvedPromise;
8386
8335
  return fn ? p.then(this ? fn.bind(this) : fn) : p;
@@ -8498,11 +8447,17 @@ function flushJobs(seen) {
8498
8447
  // 2. If a component is unmounted during a parent component's update,
8499
8448
  // its update can be skipped.
8500
8449
  queue.sort((a, b) => getId(a) - getId(b));
8450
+ // conditional usage of checkRecursiveUpdate must be determined out of
8451
+ // try ... catch block since Rollup by default de-optimizes treeshaking
8452
+ // inside try-catch. This can leave all warning code unshaked. Although
8453
+ // they would get eventually shaken by a minifier like terser, some minifiers
8454
+ // would fail to do that (e.g. https://github.com/evanw/esbuild/issues/1610)
8455
+ const check = NOOP;
8501
8456
  try {
8502
8457
  for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
8503
8458
  const job = queue[flushIndex];
8504
8459
  if (job && job.active !== false) {
8505
- if (false && checkRecursiveUpdates(seen, job)) ;
8460
+ if (false && check(job)) ;
8506
8461
  // console.log(`running:`, job.id)
8507
8462
  callWithErrorHandling(job, null, 14 /* SCHEDULER */);
8508
8463
  }
@@ -8522,27 +8477,6 @@ function flushJobs(seen) {
8522
8477
  flushJobs(seen);
8523
8478
  }
8524
8479
  }
8525
- }
8526
- function checkRecursiveUpdates(seen, fn) {
8527
- if (!seen.has(fn)) {
8528
- seen.set(fn, 1);
8529
- }
8530
- else {
8531
- const count = seen.get(fn);
8532
- if (count > RECURSION_LIMIT) {
8533
- const instance = fn.ownerInstance;
8534
- const componentName = instance && getComponentName(instance.type);
8535
- warn(`Maximum recursive updates exceeded${componentName ? ` in component <${componentName}>` : ``}. ` +
8536
- `This means you have a reactive effect that is mutating its own ` +
8537
- `dependencies and thus recursively triggering itself. Possible sources ` +
8538
- `include component template, render function, updated hook or ` +
8539
- `watcher source function.`);
8540
- return true;
8541
- }
8542
- else {
8543
- seen.set(fn, count + 1);
8544
- }
8545
- }
8546
8480
  }
8547
8481
 
8548
8482
  // Simple effect.
@@ -8975,7 +8909,7 @@ function isMemoSame(cached, memo) {
8975
8909
  }
8976
8910
 
8977
8911
  // Core API ------------------------------------------------------------------
8978
- const version = "3.2.11";
8912
+ const version = "3.2.12";
8979
8913
  const _ssrUtils = {
8980
8914
  createComponentInstance,
8981
8915
  setupComponent,
@@ -9504,6 +9438,7 @@ class VueElement extends BaseClass {
9504
9438
  this._instance = null;
9505
9439
  this._connected = false;
9506
9440
  this._resolved = false;
9441
+ this._numberProps = null;
9507
9442
  if (this.shadowRoot && hydrate) {
9508
9443
  hydrate(this._createVNode(), this.shadowRoot);
9509
9444
  }
@@ -9515,18 +9450,17 @@ class VueElement extends BaseClass {
9515
9450
  this._setAttr(this.attributes[i].name);
9516
9451
  }
9517
9452
  // watch future attr changes
9518
- const observer = new MutationObserver(mutations => {
9453
+ new MutationObserver(mutations => {
9519
9454
  for (const m of mutations) {
9520
9455
  this._setAttr(m.attributeName);
9521
9456
  }
9522
- });
9523
- observer.observe(this, { attributes: true });
9457
+ }).observe(this, { attributes: true });
9524
9458
  }
9525
9459
  connectedCallback() {
9526
9460
  this._connected = true;
9527
9461
  if (!this._instance) {
9528
9462
  this._resolveDef();
9529
- render(this._createVNode(), this.shadowRoot);
9463
+ this._update();
9530
9464
  }
9531
9465
  }
9532
9466
  disconnectedCallback() {
@@ -9547,15 +9481,31 @@ class VueElement extends BaseClass {
9547
9481
  }
9548
9482
  const resolve = (def) => {
9549
9483
  this._resolved = true;
9484
+ const { props, styles } = def;
9485
+ const hasOptions = !isArray(props);
9486
+ const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
9487
+ // cast Number-type props set before resolve
9488
+ let numberProps;
9489
+ if (hasOptions) {
9490
+ for (const key in this._props) {
9491
+ const opt = props[key];
9492
+ if (opt === Number || (opt && opt.type === Number)) {
9493
+ this._props[key] = toNumber(this._props[key]);
9494
+ (numberProps || (numberProps = Object.create(null)))[key] = true;
9495
+ }
9496
+ }
9497
+ }
9498
+ if (numberProps) {
9499
+ this._numberProps = numberProps;
9500
+ this._update();
9501
+ }
9550
9502
  // check if there are props set pre-upgrade or connect
9551
9503
  for (const key of Object.keys(this)) {
9552
9504
  if (key[0] !== '_') {
9553
9505
  this._setProp(key, this[key]);
9554
9506
  }
9555
9507
  }
9556
- const { props, styles } = def;
9557
9508
  // defining getter/setters on prototype
9558
- const rawKeys = props ? (isArray(props) ? props : Object.keys(props)) : [];
9559
9509
  for (const key of rawKeys.map(camelize)) {
9560
9510
  Object.defineProperty(this, key, {
9561
9511
  get() {
@@ -9577,7 +9527,11 @@ class VueElement extends BaseClass {
9577
9527
  }
9578
9528
  }
9579
9529
  _setAttr(key) {
9580
- this._setProp(camelize(key), toNumber(this.getAttribute(key)), false);
9530
+ let value = this.getAttribute(key);
9531
+ if (this._numberProps && this._numberProps[key]) {
9532
+ value = toNumber(value);
9533
+ }
9534
+ this._setProp(camelize(key), value, false);
9581
9535
  }
9582
9536
  /**
9583
9537
  * @internal
@@ -9592,7 +9546,7 @@ class VueElement extends BaseClass {
9592
9546
  if (val !== this._props[key]) {
9593
9547
  this._props[key] = val;
9594
9548
  if (this._instance) {
9595
- render(this._createVNode(), this.shadowRoot);
9549
+ this._update();
9596
9550
  }
9597
9551
  // reflect
9598
9552
  if (shouldReflect) {
@@ -9608,6 +9562,9 @@ class VueElement extends BaseClass {
9608
9562
  }
9609
9563
  }
9610
9564
  }
9565
+ _update() {
9566
+ render(this._createVNode(), this.shadowRoot);
9567
+ }
9611
9568
  _createVNode() {
9612
9569
  const vnode = createVNode(this._def, extend({}, this._props));
9613
9570
  if (!this._instance) {
@@ -15115,7 +15072,7 @@ function buildProps(node, context, props = node.props, ssr = false) {
15115
15072
  // acrtual ref instead.
15116
15073
  if (context.inline && (value === null || value === void 0 ? void 0 : value.content)) {
15117
15074
  valueNode = createFunctionExpression(['_value', '_refs']);
15118
- valueNode.body = createBlockStatement(processInlineRef(context.bindingMetadata, value.content));
15075
+ valueNode.body = createBlockStatement(processInlineRef(context, value.content));
15119
15076
  }
15120
15077
  }
15121
15078
  // skip is on <component>, or is="vue:xxx"
@@ -15412,14 +15369,18 @@ function stringifyDynamicPropNames(props) {
15412
15369
  function isComponentTag(tag) {
15413
15370
  return tag[0].toLowerCase() + tag.slice(1) === 'component';
15414
15371
  }
15415
- function processInlineRef(bindings, raw) {
15372
+ function processInlineRef(context, raw) {
15416
15373
  const body = [createSimpleExpression(`_refs['${raw}'] = _value`)];
15417
- const type = bindings[raw];
15374
+ const { bindingMetadata, helperString } = context;
15375
+ const type = bindingMetadata[raw];
15418
15376
  if (type === "setup-ref" /* SETUP_REF */) {
15419
15377
  body.push(createSimpleExpression(`${raw}.value = _value`));
15420
15378
  }
15379
+ else if (type === "setup-maybe-ref" /* SETUP_MAYBE_REF */) {
15380
+ body.push(createSimpleExpression(`${helperString(IS_REF)}(${raw}) && (${raw}.value = _value)`));
15381
+ }
15421
15382
  else if (type === "setup-let" /* SETUP_LET */) {
15422
- body.push(createSimpleExpression(`${raw} = _value`));
15383
+ body.push(createSimpleExpression(`${helperString(IS_REF)}(${raw}) ? ${raw}.value = _value : ${raw} = _value`));
15423
15384
  }
15424
15385
  return body;
15425
15386
  }
@@ -15496,7 +15457,7 @@ function processSlotOutlet(node, context) {
15496
15457
  };
15497
15458
  }
15498
15459
 
15499
- const fnExpRE = /^\s*([\w$_]+|\([^)]*?\))\s*=>|^\s*function(?:\s+[\w$]+)?\s*\(/;
15460
+ const fnExpRE = /^\s*([\w$_]+|(async\s*)?\([^)]*?\))\s*=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/;
15500
15461
  const transformOn = (dir, node, context, augmentor) => {
15501
15462
  const { loc, modifiers, arg } = dir;
15502
15463
  if (!dir.exp && !modifiers.length) {