vue 3.4.0-alpha.1 → 3.4.0-alpha.2

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.
@@ -1,10 +1,6 @@
1
1
  function makeMap(str, expectsLowerCase) {
2
- const map = /* @__PURE__ */ Object.create(null);
3
- const list = str.split(",");
4
- for (let i = 0; i < list.length; i++) {
5
- map[list[i]] = true;
6
- }
7
- return expectsLowerCase ? (val) => !!map[val.toLowerCase()] : (val) => !!map[val];
2
+ const set = new Set(str.split(","));
3
+ return expectsLowerCase ? (val) => set.has(val.toLowerCase()) : (val) => set.has(val);
8
4
  }
9
5
 
10
6
  const EMPTY_OBJ = Object.freeze({}) ;
@@ -104,7 +100,7 @@ const PatchFlagNames = {
104
100
  [4]: `STYLE`,
105
101
  [8]: `PROPS`,
106
102
  [16]: `FULL_PROPS`,
107
- [32]: `HYDRATE_EVENTS`,
103
+ [32]: `NEED_HYDRATION`,
108
104
  [64]: `STABLE_FRAGMENT`,
109
105
  [128]: `KEYED_FRAGMENT`,
110
106
  [256]: `UNKEYED_FRAGMENT`,
@@ -1026,7 +1022,7 @@ function createReadonlyMethod(type) {
1026
1022
  toRaw(this)
1027
1023
  );
1028
1024
  }
1029
- return type === "delete" ? false : this;
1025
+ return type === "delete" ? false : type === "clear" ? void 0 : this;
1030
1026
  };
1031
1027
  }
1032
1028
  function createInstrumentations() {
@@ -1282,9 +1278,10 @@ class ComputedRefImpl {
1282
1278
  this.dep = void 0;
1283
1279
  this.__v_isRef = true;
1284
1280
  this["__v_isReadonly"] = false;
1285
- this.effect = new ReactiveEffect(getter, () => {
1286
- triggerRefValue(this, 1);
1287
- });
1281
+ this.effect = new ReactiveEffect(
1282
+ () => getter(this._value),
1283
+ () => triggerRefValue(this, 1)
1284
+ );
1288
1285
  this.effect.computed = this;
1289
1286
  this.effect.active = this._cacheable = !isSSR;
1290
1287
  this["__v_isReadonly"] = isReadonly;
@@ -1501,16 +1498,16 @@ function propertyToRef(source, key, defaultValue) {
1501
1498
  return isRef(val) ? val : new ObjectRefImpl(source, key, defaultValue);
1502
1499
  }
1503
1500
 
1504
- const stack = [];
1501
+ const stack$1 = [];
1505
1502
  function pushWarningContext(vnode) {
1506
- stack.push(vnode);
1503
+ stack$1.push(vnode);
1507
1504
  }
1508
1505
  function popWarningContext() {
1509
- stack.pop();
1506
+ stack$1.pop();
1510
1507
  }
1511
1508
  function warn(msg, ...args) {
1512
1509
  pauseTracking();
1513
- const instance = stack.length ? stack[stack.length - 1].component : null;
1510
+ const instance = stack$1.length ? stack$1[stack$1.length - 1].component : null;
1514
1511
  const appWarnHandler = instance && instance.appContext.config.warnHandler;
1515
1512
  const trace = getComponentTrace();
1516
1513
  if (appWarnHandler) {
@@ -1539,7 +1536,7 @@ function warn(msg, ...args) {
1539
1536
  resetTracking();
1540
1537
  }
1541
1538
  function getComponentTrace() {
1542
- let currentVNode = stack[stack.length - 1];
1539
+ let currentVNode = stack$1[stack$1.length - 1];
1543
1540
  if (!currentVNode) {
1544
1541
  return [];
1545
1542
  }
@@ -2311,9 +2308,19 @@ function renderComponentRoot(instance) {
2311
2308
  try {
2312
2309
  if (vnode.shapeFlag & 4) {
2313
2310
  const proxyToUse = withProxy || proxy;
2311
+ const thisProxy = setupState.__isScriptSetup ? new Proxy(proxyToUse, {
2312
+ get(target, key, receiver) {
2313
+ warn(
2314
+ `Property '${String(
2315
+ key
2316
+ )}' was accessed via 'this'. Avoid using 'this' in templates.`
2317
+ );
2318
+ return Reflect.get(target, key, receiver);
2319
+ }
2320
+ }) : proxyToUse;
2314
2321
  result = normalizeVNode(
2315
2322
  render.call(
2316
- proxyToUse,
2323
+ thisProxy,
2317
2324
  proxyToUse,
2318
2325
  renderCache,
2319
2326
  props,
@@ -2548,6 +2555,61 @@ function updateHOCHostEl({ vnode, parent }, el) {
2548
2555
  }
2549
2556
  }
2550
2557
 
2558
+ const COMPONENTS = "components";
2559
+ const DIRECTIVES = "directives";
2560
+ function resolveComponent(name, maybeSelfReference) {
2561
+ return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
2562
+ }
2563
+ const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
2564
+ function resolveDynamicComponent(component) {
2565
+ if (isString(component)) {
2566
+ return resolveAsset(COMPONENTS, component, false) || component;
2567
+ } else {
2568
+ return component || NULL_DYNAMIC_COMPONENT;
2569
+ }
2570
+ }
2571
+ function resolveDirective(name) {
2572
+ return resolveAsset(DIRECTIVES, name);
2573
+ }
2574
+ function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
2575
+ const instance = currentRenderingInstance || currentInstance;
2576
+ if (instance) {
2577
+ const Component = instance.type;
2578
+ if (type === COMPONENTS) {
2579
+ const selfName = getComponentName(
2580
+ Component,
2581
+ false
2582
+ /* do not include inferred name to avoid breaking existing code */
2583
+ );
2584
+ if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
2585
+ return Component;
2586
+ }
2587
+ }
2588
+ const res = (
2589
+ // local registration
2590
+ // check instance[type] first which is resolved for options API
2591
+ resolve(instance[type] || Component[type], name) || // global registration
2592
+ resolve(instance.appContext[type], name)
2593
+ );
2594
+ if (!res && maybeSelfReference) {
2595
+ return Component;
2596
+ }
2597
+ if (warnMissing && !res) {
2598
+ const extra = type === COMPONENTS ? `
2599
+ If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.` : ``;
2600
+ warn(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
2601
+ }
2602
+ return res;
2603
+ } else {
2604
+ warn(
2605
+ `resolve${capitalize(type.slice(0, -1))} can only be used in render() or setup().`
2606
+ );
2607
+ }
2608
+ }
2609
+ function resolve(registry, name) {
2610
+ return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]);
2611
+ }
2612
+
2551
2613
  const isSuspense = (type) => type.__isSuspense;
2552
2614
  const SuspenseImpl = {
2553
2615
  name: "Suspense",
@@ -3082,7 +3144,7 @@ function normalizeSuspenseSlot(s) {
3082
3144
  }
3083
3145
  if (isArray(s)) {
3084
3146
  const singleChild = filterSingleRoot(s);
3085
- if (!singleChild) {
3147
+ if (!singleChild && s.filter((child) => child !== NULL_DYNAMIC_COMPONENT).length > 0) {
3086
3148
  warn(`<Suspense> slots expect a single root node.`);
3087
3149
  }
3088
3150
  s = singleChild;
@@ -3232,6 +3294,7 @@ function doWatch(source, cb, { immediate, deep, flush, once, onTrack, onTrigger
3232
3294
  let onCleanup = (fn) => {
3233
3295
  cleanup = effect.onStop = () => {
3234
3296
  callWithErrorHandling(fn, instance, 4);
3297
+ cleanup = effect.onStop = void 0;
3235
3298
  };
3236
3299
  };
3237
3300
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
@@ -3703,7 +3766,11 @@ function emptyPlaceholder(vnode) {
3703
3766
  }
3704
3767
  }
3705
3768
  function getKeepAliveChild(vnode) {
3706
- return isKeepAlive(vnode) ? vnode.children ? vnode.children[0] : void 0 : vnode;
3769
+ return isKeepAlive(vnode) ? (
3770
+ // #7121 ensure get the child component subtree in case
3771
+ // it's been replaced during HMR
3772
+ vnode.component ? vnode.component.subTree : vnode.children ? vnode.children[0] : void 0
3773
+ ) : vnode;
3707
3774
  }
3708
3775
  function setTransitionHooks(vnode, hooks) {
3709
3776
  if (vnode.shapeFlag & 6 && vnode.component) {
@@ -4181,61 +4248,6 @@ function onErrorCaptured(hook, target = currentInstance) {
4181
4248
  injectHook("ec", hook, target);
4182
4249
  }
4183
4250
 
4184
- const COMPONENTS = "components";
4185
- const DIRECTIVES = "directives";
4186
- function resolveComponent(name, maybeSelfReference) {
4187
- return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
4188
- }
4189
- const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
4190
- function resolveDynamicComponent(component) {
4191
- if (isString(component)) {
4192
- return resolveAsset(COMPONENTS, component, false) || component;
4193
- } else {
4194
- return component || NULL_DYNAMIC_COMPONENT;
4195
- }
4196
- }
4197
- function resolveDirective(name) {
4198
- return resolveAsset(DIRECTIVES, name);
4199
- }
4200
- function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
4201
- const instance = currentRenderingInstance || currentInstance;
4202
- if (instance) {
4203
- const Component = instance.type;
4204
- if (type === COMPONENTS) {
4205
- const selfName = getComponentName(
4206
- Component,
4207
- false
4208
- /* do not include inferred name to avoid breaking existing code */
4209
- );
4210
- if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
4211
- return Component;
4212
- }
4213
- }
4214
- const res = (
4215
- // local registration
4216
- // check instance[type] first which is resolved for options API
4217
- resolve(instance[type] || Component[type], name) || // global registration
4218
- resolve(instance.appContext[type], name)
4219
- );
4220
- if (!res && maybeSelfReference) {
4221
- return Component;
4222
- }
4223
- if (warnMissing && !res) {
4224
- const extra = type === COMPONENTS ? `
4225
- If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.` : ``;
4226
- warn(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
4227
- }
4228
- return res;
4229
- } else {
4230
- warn(
4231
- `resolve${capitalize(type.slice(0, -1))} can only be used in render() or setup().`
4232
- );
4233
- }
4234
- }
4235
- function resolve(registry, name) {
4236
- return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]);
4237
- }
4238
-
4239
4251
  function renderList(source, renderItem, cache, index) {
4240
4252
  let ret;
4241
4253
  const cached = cache && cache[index];
@@ -5755,6 +5767,9 @@ function assertType(value, type) {
5755
5767
  };
5756
5768
  }
5757
5769
  function getInvalidTypeMessage(name, value, expectedTypes) {
5770
+ if (expectedTypes.length === 0) {
5771
+ return `Prop type [] for prop "${name}" won't match anything. Did you mean to use type Array instead?`;
5772
+ }
5758
5773
  let message = `Invalid prop: type check failed for prop "${name}". Expected ${expectedTypes.map(capitalize).join(" | ")}`;
5759
5774
  const expectedType = expectedTypes[0];
5760
5775
  const receivedType = toRawType(value);
@@ -6024,6 +6039,20 @@ function createHydrationFunctions(rendererInternals) {
6024
6039
  const { type, ref, shapeFlag, patchFlag } = vnode;
6025
6040
  let domType = node.nodeType;
6026
6041
  vnode.el = node;
6042
+ {
6043
+ if (!("__vnode" in node)) {
6044
+ Object.defineProperty(node, "__vnode", {
6045
+ value: vnode,
6046
+ enumerable: false
6047
+ });
6048
+ }
6049
+ if (!("__vueParentComponent" in node)) {
6050
+ Object.defineProperty(node, "__vueParentComponent", {
6051
+ value: parentComponent,
6052
+ enumerable: false
6053
+ });
6054
+ }
6055
+ }
6027
6056
  if (patchFlag === -2) {
6028
6057
  optimized = false;
6029
6058
  vnode.dynamicChildren = null;
@@ -6054,15 +6083,15 @@ function createHydrationFunctions(rendererInternals) {
6054
6083
  }
6055
6084
  break;
6056
6085
  case Comment:
6057
- if (domType !== 8 /* COMMENT */ || isFragmentStart) {
6058
- if (node.tagName.toLowerCase() === "template") {
6059
- const content = vnode.el.content.firstChild;
6060
- replaceNode(content, node, parentComponent);
6061
- vnode.el = node = content;
6062
- nextNode = nextSibling(node);
6063
- } else {
6064
- nextNode = onMismatch();
6065
- }
6086
+ if (isTemplateNode(node)) {
6087
+ nextNode = nextSibling(node);
6088
+ replaceNode(
6089
+ vnode.el = node.content.firstChild,
6090
+ node,
6091
+ parentComponent
6092
+ );
6093
+ } else if (domType !== 8 /* COMMENT */ || isFragmentStart) {
6094
+ nextNode = onMismatch();
6066
6095
  } else {
6067
6096
  nextNode = nextSibling(node);
6068
6097
  }
@@ -6185,15 +6214,16 @@ function createHydrationFunctions(rendererInternals) {
6185
6214
  const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
6186
6215
  optimized = optimized || !!vnode.dynamicChildren;
6187
6216
  const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
6188
- const forcePatchValue = type === "input" && dirs || type === "option";
6217
+ const forcePatch = type === "input" || type === "option";
6189
6218
  {
6190
6219
  if (dirs) {
6191
6220
  invokeDirectiveHook(vnode, null, parentComponent, "created");
6192
6221
  }
6193
6222
  if (props) {
6194
- if (forcePatchValue || !optimized || patchFlag & (16 | 32)) {
6223
+ if (forcePatch || !optimized || patchFlag & (16 | 32)) {
6195
6224
  for (const key in props) {
6196
- if (forcePatchValue && key.endsWith("value") || isOn(key) && !isReservedProp(key)) {
6225
+ if (forcePatch && (key.endsWith("value") || key === "indeterminate") || isOn(key) && !isReservedProp(key) || // force hydrate v-bind with .prop modifiers
6226
+ key[0] === ".") {
6197
6227
  patchProp(
6198
6228
  el,
6199
6229
  key,
@@ -6406,8 +6436,7 @@ function createHydrationFunctions(rendererInternals) {
6406
6436
  let parent = parentComponent;
6407
6437
  while (parent) {
6408
6438
  if (parent.vnode.el === oldNode) {
6409
- parent.vnode.el = newNode;
6410
- parent.subTree.el = newNode;
6439
+ parent.vnode.el = parent.subTree.el = newNode;
6411
6440
  }
6412
6441
  parent = parent.parent;
6413
6442
  }
@@ -7957,6 +7986,7 @@ const resolveTarget = (props, select) => {
7957
7986
  }
7958
7987
  };
7959
7988
  const TeleportImpl = {
7989
+ name: "Teleport",
7960
7990
  __isTeleport: true,
7961
7991
  process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals) {
7962
7992
  const {
@@ -8378,7 +8408,7 @@ function _createVNode(type, props = null, children = null, patchFlag = 0, dynami
8378
8408
  if (shapeFlag & 4 && isProxy(type)) {
8379
8409
  type = toRaw(type);
8380
8410
  warn(
8381
- `Vue received a Component which was made a reactive object. This can lead to unnecessary performance overhead, and should be avoided by marking the component with \`markRaw\` or using \`shallowRef\` instead of \`ref\`.`,
8411
+ `Vue received a Component that was made a reactive object. This can lead to unnecessary performance overhead and should be avoided by marking the component with \`markRaw\` or using \`shallowRef\` instead of \`ref\`.`,
8382
8412
  `
8383
8413
  Component that was made reactive: `,
8384
8414
  type
@@ -9199,7 +9229,7 @@ function isMemoSame(cached, memo) {
9199
9229
  return true;
9200
9230
  }
9201
9231
 
9202
- const version = "3.4.0-alpha.1";
9232
+ const version = "3.4.0-alpha.2";
9203
9233
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
9204
9234
  const ssrUtils = null;
9205
9235
  const resolveFilter = null;
@@ -10345,21 +10375,20 @@ const vModelText = {
10345
10375
  el[assignKey] = getModelAssigner(vnode);
10346
10376
  if (el.composing)
10347
10377
  return;
10378
+ const elValue = number || el.type === "number" ? looseToNumber(el.value) : el.value;
10379
+ const newValue = value == null ? "" : value;
10380
+ if (elValue === newValue) {
10381
+ return;
10382
+ }
10348
10383
  if (document.activeElement === el && el.type !== "range") {
10349
10384
  if (lazy) {
10350
10385
  return;
10351
10386
  }
10352
- if (trim && el.value.trim() === value) {
10353
- return;
10354
- }
10355
- if ((number || el.type === "number") && looseToNumber(el.value) === value) {
10387
+ if (trim && el.value.trim() === newValue) {
10356
10388
  return;
10357
10389
  }
10358
10390
  }
10359
- const newValue = value == null ? "" : value;
10360
- if (el.value !== newValue) {
10361
- el.value = newValue;
10362
- }
10391
+ el.value = newValue;
10363
10392
  }
10364
10393
  };
10365
10394
  const vModelCheckbox = {
@@ -10856,83 +10885,6 @@ Make sure to use the production build (*.prod.js) when deploying for production.
10856
10885
  }
10857
10886
  }
10858
10887
 
10859
- function defaultOnError(error) {
10860
- throw error;
10861
- }
10862
- function defaultOnWarn(msg) {
10863
- console.warn(`[Vue warn] ${msg.message}`);
10864
- }
10865
- function createCompilerError(code, loc, messages, additionalMessage) {
10866
- const msg = (messages || errorMessages)[code] + (additionalMessage || ``) ;
10867
- const error = new SyntaxError(String(msg));
10868
- error.code = code;
10869
- error.loc = loc;
10870
- return error;
10871
- }
10872
- const errorMessages = {
10873
- // parse errors
10874
- [0]: "Illegal comment.",
10875
- [1]: "CDATA section is allowed only in XML context.",
10876
- [2]: "Duplicate attribute.",
10877
- [3]: "End tag cannot have attributes.",
10878
- [4]: "Illegal '/' in tags.",
10879
- [5]: "Unexpected EOF in tag.",
10880
- [6]: "Unexpected EOF in CDATA section.",
10881
- [7]: "Unexpected EOF in comment.",
10882
- [8]: "Unexpected EOF in script.",
10883
- [9]: "Unexpected EOF in tag.",
10884
- [10]: "Incorrectly closed comment.",
10885
- [11]: "Incorrectly opened comment.",
10886
- [12]: "Illegal tag name. Use '&lt;' to print '<'.",
10887
- [13]: "Attribute value was expected.",
10888
- [14]: "End tag name was expected.",
10889
- [15]: "Whitespace was expected.",
10890
- [16]: "Unexpected '<!--' in comment.",
10891
- [17]: `Attribute name cannot contain U+0022 ("), U+0027 ('), and U+003C (<).`,
10892
- [18]: "Unquoted attribute value cannot contain U+0022 (\"), U+0027 ('), U+003C (<), U+003D (=), and U+0060 (`).",
10893
- [19]: "Attribute name cannot start with '='.",
10894
- [21]: "'<?' is allowed only in XML context.",
10895
- [20]: `Unexpected null character.`,
10896
- [22]: "Illegal '/' in tags.",
10897
- // Vue-specific parse errors
10898
- [23]: "Invalid end tag.",
10899
- [24]: "Element is missing end tag.",
10900
- [25]: "Interpolation end sign was not found.",
10901
- [27]: "End bracket for dynamic directive argument was not found. Note that dynamic directive argument cannot contain spaces.",
10902
- [26]: "Legal directive name was expected.",
10903
- // transform errors
10904
- [28]: `v-if/v-else-if is missing expression.`,
10905
- [29]: `v-if/else branches must use unique keys.`,
10906
- [30]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
10907
- [31]: `v-for is missing expression.`,
10908
- [32]: `v-for has invalid expression.`,
10909
- [33]: `<template v-for> key should be placed on the <template> tag.`,
10910
- [34]: `v-bind is missing expression.`,
10911
- [35]: `v-on is missing expression.`,
10912
- [36]: `Unexpected custom directive on <slot> outlet.`,
10913
- [37]: `Mixed v-slot usage on both the component and nested <template>. When there are multiple named slots, all slots should use <template> syntax to avoid scope ambiguity.`,
10914
- [38]: `Duplicate slot names found. `,
10915
- [39]: `Extraneous children found when component already has explicitly named default slot. These children will be ignored.`,
10916
- [40]: `v-slot can only be used on components or <template> tags.`,
10917
- [41]: `v-model is missing expression.`,
10918
- [42]: `v-model value must be a valid JavaScript member expression.`,
10919
- [43]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
10920
- [44]: `v-model cannot be used on a prop, because local prop bindings are not writable.
10921
- Use a v-bind binding combined with a v-on listener that emits update:x event instead.`,
10922
- [45]: `Error parsing JavaScript expression: `,
10923
- [46]: `<KeepAlive> expects exactly one child component.`,
10924
- // generic errors
10925
- [47]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
10926
- [48]: `ES module mode is not supported in this build of compiler.`,
10927
- [49]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
10928
- [50]: `"scopeId" option is only supported in module mode.`,
10929
- // deprecations
10930
- [51]: `@vnode-* hooks in templates are deprecated. Use the vue: prefix instead. For example, @vnode-mounted should be changed to @vue:mounted. @vnode-* hooks support will be removed in 3.4.`,
10931
- [52]: `v-is="component-name" has been deprecated. Use is="vue:component-name" instead. v-is support will be removed in 3.4.`,
10932
- // just to fulfill types
10933
- [53]: ``
10934
- };
10935
-
10936
10888
  const FRAGMENT = Symbol(`Fragment` );
10937
10889
  const TELEPORT = Symbol(`Teleport` );
10938
10890
  const SUSPENSE = Symbol(`Suspense` );
@@ -11022,13 +10974,14 @@ function registerRuntimeHelpers(helpers) {
11022
10974
  }
11023
10975
 
11024
10976
  const locStub = {
11025
- source: "",
11026
10977
  start: { line: 1, column: 1, offset: 0 },
11027
- end: { line: 1, column: 1, offset: 0 }
10978
+ end: { line: 1, column: 1, offset: 0 },
10979
+ source: ""
11028
10980
  };
11029
- function createRoot(children, loc = locStub) {
10981
+ function createRoot(children, source = "") {
11030
10982
  return {
11031
10983
  type: 0,
10984
+ source,
11032
10985
  children,
11033
10986
  helpers: /* @__PURE__ */ new Set(),
11034
10987
  components: [],
@@ -11038,7 +10991,7 @@ function createRoot(children, loc = locStub) {
11038
10991
  cached: 0,
11039
10992
  temps: 0,
11040
10993
  codegenNode: void 0,
11041
- loc
10994
+ loc: locStub
11042
10995
  };
11043
10996
  }
11044
10997
  function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps, directives, isBlock = false, disableTracking = false, isComponent = false, loc = locStub) {
@@ -11164,47 +11117,932 @@ function convertToBlock(node, { helper, removeHelper, inSSR }) {
11164
11117
  }
11165
11118
  }
11166
11119
 
11167
- const isStaticExp = (p) => p.type === 4 && p.isStatic;
11168
- const isBuiltInType = (tag, expected) => tag === expected || tag === hyphenate(expected);
11169
- function isCoreComponent(tag) {
11170
- if (isBuiltInType(tag, "Teleport")) {
11171
- return TELEPORT;
11172
- } else if (isBuiltInType(tag, "Suspense")) {
11173
- return SUSPENSE;
11174
- } else if (isBuiltInType(tag, "KeepAlive")) {
11175
- return KEEP_ALIVE;
11176
- } else if (isBuiltInType(tag, "BaseTransition")) {
11177
- return BASE_TRANSITION;
11120
+ const defaultDelimitersOpen = new Uint8Array([123, 123]);
11121
+ const defaultDelimitersClose = new Uint8Array([125, 125]);
11122
+ function isTagStartChar(c) {
11123
+ return c >= 97 && c <= 122 || c >= 65 && c <= 90;
11124
+ }
11125
+ function isWhitespace(c) {
11126
+ return c === 32 || c === 10 || c === 9 || c === 12 || c === 13;
11127
+ }
11128
+ function isEndOfTagSection(c) {
11129
+ return c === 47 || c === 62 || isWhitespace(c);
11130
+ }
11131
+ function toCharCodes(str) {
11132
+ const ret = new Uint8Array(str.length);
11133
+ for (let i = 0; i < str.length; i++) {
11134
+ ret[i] = str.charCodeAt(i);
11178
11135
  }
11136
+ return ret;
11179
11137
  }
11180
- const nonIdentifierRE = /^\d|[^\$\w]/;
11181
- const isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
11182
- const validFirstIdentCharRE = /[A-Za-z_$\xA0-\uFFFF]/;
11183
- const validIdentCharRE = /[\.\?\w$\xA0-\uFFFF]/;
11184
- const whitespaceRE = /\s+[.[]\s*|\s*[.[]\s+/g;
11185
- const isMemberExpressionBrowser = (path) => {
11186
- path = path.trim().replace(whitespaceRE, (s) => s.trim());
11187
- let state = 0 /* inMemberExp */;
11188
- let stateStack = [];
11189
- let currentOpenBracketCount = 0;
11190
- let currentOpenParensCount = 0;
11191
- let currentStringType = null;
11192
- for (let i = 0; i < path.length; i++) {
11193
- const char = path.charAt(i);
11194
- switch (state) {
11195
- case 0 /* inMemberExp */:
11196
- if (char === "[") {
11197
- stateStack.push(state);
11198
- state = 1 /* inBrackets */;
11199
- currentOpenBracketCount++;
11200
- } else if (char === "(") {
11201
- stateStack.push(state);
11202
- state = 2 /* inParens */;
11203
- currentOpenParensCount++;
11204
- } else if (!(i === 0 ? validFirstIdentCharRE : validIdentCharRE).test(char)) {
11205
- return false;
11206
- }
11207
- break;
11138
+ const Sequences = {
11139
+ Cdata: new Uint8Array([67, 68, 65, 84, 65, 91]),
11140
+ // CDATA[
11141
+ CdataEnd: new Uint8Array([93, 93, 62]),
11142
+ // ]]>
11143
+ CommentEnd: new Uint8Array([45, 45, 62]),
11144
+ // `-->`
11145
+ ScriptEnd: new Uint8Array([60, 47, 115, 99, 114, 105, 112, 116]),
11146
+ // `<\/script`
11147
+ StyleEnd: new Uint8Array([60, 47, 115, 116, 121, 108, 101]),
11148
+ // `</style`
11149
+ TitleEnd: new Uint8Array([60, 47, 116, 105, 116, 108, 101]),
11150
+ // `</title`
11151
+ TextareaEnd: new Uint8Array([
11152
+ 60,
11153
+ 47,
11154
+ 116,
11155
+ 101,
11156
+ 120,
11157
+ 116,
11158
+ 97,
11159
+ 114,
11160
+ 101,
11161
+ 97
11162
+ ])
11163
+ // `</textarea
11164
+ };
11165
+ class Tokenizer {
11166
+ constructor(stack, cbs) {
11167
+ this.stack = stack;
11168
+ this.cbs = cbs;
11169
+ /** The current state the tokenizer is in. */
11170
+ this.state = 1;
11171
+ /** The read buffer. */
11172
+ this.buffer = "";
11173
+ /** The beginning of the section that is currently being read. */
11174
+ this.sectionStart = 0;
11175
+ /** The index within the buffer that we are currently looking at. */
11176
+ this.index = 0;
11177
+ /** The start of the last entity. */
11178
+ this.entityStart = 0;
11179
+ /** Some behavior, eg. when decoding entities, is done while we are in another state. This keeps track of the other state type. */
11180
+ this.baseState = 1;
11181
+ /** For special parsing behavior inside of script and style tags. */
11182
+ this.inRCDATA = false;
11183
+ /** For disabling RCDATA tags handling */
11184
+ this.inXML = false;
11185
+ /** Reocrd newline positions for fast line / column calculation */
11186
+ this.newlines = [];
11187
+ this.mode = 0;
11188
+ this.delimiterOpen = defaultDelimitersOpen;
11189
+ this.delimiterClose = defaultDelimitersClose;
11190
+ this.delimiterIndex = -1;
11191
+ this.currentSequence = void 0;
11192
+ this.sequenceIndex = 0;
11193
+ }
11194
+ get inSFCRoot() {
11195
+ return this.mode === 2 && this.stack.length === 0;
11196
+ }
11197
+ reset() {
11198
+ this.state = 1;
11199
+ this.mode = 0;
11200
+ this.buffer = "";
11201
+ this.sectionStart = 0;
11202
+ this.index = 0;
11203
+ this.baseState = 1;
11204
+ this.currentSequence = void 0;
11205
+ this.newlines.length = 0;
11206
+ this.delimiterOpen = defaultDelimitersOpen;
11207
+ this.delimiterClose = defaultDelimitersClose;
11208
+ }
11209
+ /**
11210
+ * Generate Position object with line / column information using recorded
11211
+ * newline positions. We know the index is always going to be an already
11212
+ * processed index, so all the newlines up to this index should have been
11213
+ * recorded.
11214
+ */
11215
+ getPos(index) {
11216
+ let line = 1;
11217
+ let column = index + 1;
11218
+ for (let i = this.newlines.length - 1; i >= 0; i--) {
11219
+ const newlineIndex = this.newlines[i];
11220
+ if (index > newlineIndex) {
11221
+ line = i + 2;
11222
+ column = index - newlineIndex;
11223
+ break;
11224
+ }
11225
+ }
11226
+ return {
11227
+ column,
11228
+ line,
11229
+ offset: index
11230
+ };
11231
+ }
11232
+ peek() {
11233
+ return this.buffer.charCodeAt(this.index + 1);
11234
+ }
11235
+ stateText(c) {
11236
+ if (c === 60) {
11237
+ if (this.index > this.sectionStart) {
11238
+ this.cbs.ontext(this.sectionStart, this.index);
11239
+ }
11240
+ this.state = 5;
11241
+ this.sectionStart = this.index;
11242
+ } else if (c === this.delimiterOpen[0]) {
11243
+ this.state = 2;
11244
+ this.delimiterIndex = 0;
11245
+ this.stateInterpolationOpen(c);
11246
+ }
11247
+ }
11248
+ stateInterpolationOpen(c) {
11249
+ if (c === this.delimiterOpen[this.delimiterIndex]) {
11250
+ if (this.delimiterIndex === this.delimiterOpen.length - 1) {
11251
+ const start = this.index + 1 - this.delimiterOpen.length;
11252
+ if (start > this.sectionStart) {
11253
+ this.cbs.ontext(this.sectionStart, start);
11254
+ }
11255
+ this.state = 3;
11256
+ this.sectionStart = start;
11257
+ } else {
11258
+ this.delimiterIndex++;
11259
+ }
11260
+ } else if (this.inRCDATA) {
11261
+ this.state = 32;
11262
+ this.stateInRCDATA(c);
11263
+ } else {
11264
+ this.state = 1;
11265
+ this.stateText(c);
11266
+ }
11267
+ }
11268
+ stateInterpolation(c) {
11269
+ if (c === this.delimiterClose[0]) {
11270
+ this.state = 4;
11271
+ this.delimiterIndex = 0;
11272
+ this.stateInterpolationClose(c);
11273
+ }
11274
+ }
11275
+ stateInterpolationClose(c) {
11276
+ if (c === this.delimiterClose[this.delimiterIndex]) {
11277
+ if (this.delimiterIndex === this.delimiterClose.length - 1) {
11278
+ this.cbs.oninterpolation(this.sectionStart, this.index + 1);
11279
+ if (this.inRCDATA) {
11280
+ this.state = 32;
11281
+ } else {
11282
+ this.state = 1;
11283
+ }
11284
+ this.sectionStart = this.index + 1;
11285
+ } else {
11286
+ this.delimiterIndex++;
11287
+ }
11288
+ } else {
11289
+ this.state = 3;
11290
+ this.stateInterpolation(c);
11291
+ }
11292
+ }
11293
+ stateSpecialStartSequence(c) {
11294
+ const isEnd = this.sequenceIndex === this.currentSequence.length;
11295
+ const isMatch = isEnd ? (
11296
+ // If we are at the end of the sequence, make sure the tag name has ended
11297
+ isEndOfTagSection(c)
11298
+ ) : (
11299
+ // Otherwise, do a case-insensitive comparison
11300
+ (c | 32) === this.currentSequence[this.sequenceIndex]
11301
+ );
11302
+ if (!isMatch) {
11303
+ this.inRCDATA = false;
11304
+ } else if (!isEnd) {
11305
+ this.sequenceIndex++;
11306
+ return;
11307
+ }
11308
+ this.sequenceIndex = 0;
11309
+ this.state = 6;
11310
+ this.stateInTagName(c);
11311
+ }
11312
+ /** Look for an end tag. For <title> and <textarea>, also decode entities. */
11313
+ stateInRCDATA(c) {
11314
+ if (this.sequenceIndex === this.currentSequence.length) {
11315
+ if (c === 62 || isWhitespace(c)) {
11316
+ const endOfText = this.index - this.currentSequence.length;
11317
+ if (this.sectionStart < endOfText) {
11318
+ const actualIndex = this.index;
11319
+ this.index = endOfText;
11320
+ this.cbs.ontext(this.sectionStart, endOfText);
11321
+ this.index = actualIndex;
11322
+ }
11323
+ this.sectionStart = endOfText + 2;
11324
+ this.stateInClosingTagName(c);
11325
+ this.inRCDATA = false;
11326
+ return;
11327
+ }
11328
+ this.sequenceIndex = 0;
11329
+ }
11330
+ if ((c | 32) === this.currentSequence[this.sequenceIndex]) {
11331
+ this.sequenceIndex += 1;
11332
+ } else if (this.sequenceIndex === 0) {
11333
+ if (this.currentSequence === Sequences.TitleEnd || this.currentSequence === Sequences.TextareaEnd && !this.inSFCRoot) {
11334
+ if (c === this.delimiterOpen[0]) {
11335
+ this.state = 2;
11336
+ this.delimiterIndex = 0;
11337
+ this.stateInterpolationOpen(c);
11338
+ }
11339
+ } else if (this.fastForwardTo(60)) {
11340
+ this.sequenceIndex = 1;
11341
+ }
11342
+ } else {
11343
+ this.sequenceIndex = Number(c === 60);
11344
+ }
11345
+ }
11346
+ stateCDATASequence(c) {
11347
+ if (c === Sequences.Cdata[this.sequenceIndex]) {
11348
+ if (++this.sequenceIndex === Sequences.Cdata.length) {
11349
+ this.state = 28;
11350
+ this.currentSequence = Sequences.CdataEnd;
11351
+ this.sequenceIndex = 0;
11352
+ this.sectionStart = this.index + 1;
11353
+ }
11354
+ } else {
11355
+ this.sequenceIndex = 0;
11356
+ this.state = 23;
11357
+ this.stateInDeclaration(c);
11358
+ }
11359
+ }
11360
+ /**
11361
+ * When we wait for one specific character, we can speed things up
11362
+ * by skipping through the buffer until we find it.
11363
+ *
11364
+ * @returns Whether the character was found.
11365
+ */
11366
+ fastForwardTo(c) {
11367
+ while (++this.index < this.buffer.length) {
11368
+ const cc = this.buffer.charCodeAt(this.index);
11369
+ if (cc === 10) {
11370
+ this.newlines.push(this.index);
11371
+ }
11372
+ if (cc === c) {
11373
+ return true;
11374
+ }
11375
+ }
11376
+ this.index = this.buffer.length - 1;
11377
+ return false;
11378
+ }
11379
+ /**
11380
+ * Comments and CDATA end with `-->` and `]]>`.
11381
+ *
11382
+ * Their common qualities are:
11383
+ * - Their end sequences have a distinct character they start with.
11384
+ * - That character is then repeated, so we have to check multiple repeats.
11385
+ * - All characters but the start character of the sequence can be skipped.
11386
+ */
11387
+ stateInCommentLike(c) {
11388
+ if (c === this.currentSequence[this.sequenceIndex]) {
11389
+ if (++this.sequenceIndex === this.currentSequence.length) {
11390
+ if (this.currentSequence === Sequences.CdataEnd) {
11391
+ this.cbs.oncdata(this.sectionStart, this.index - 2);
11392
+ } else {
11393
+ this.cbs.oncomment(this.sectionStart, this.index - 2);
11394
+ }
11395
+ this.sequenceIndex = 0;
11396
+ this.sectionStart = this.index + 1;
11397
+ this.state = 1;
11398
+ }
11399
+ } else if (this.sequenceIndex === 0) {
11400
+ if (this.fastForwardTo(this.currentSequence[0])) {
11401
+ this.sequenceIndex = 1;
11402
+ }
11403
+ } else if (c !== this.currentSequence[this.sequenceIndex - 1]) {
11404
+ this.sequenceIndex = 0;
11405
+ }
11406
+ }
11407
+ startSpecial(sequence, offset) {
11408
+ this.enterRCDATA(sequence, offset);
11409
+ this.state = 31;
11410
+ }
11411
+ enterRCDATA(sequence, offset) {
11412
+ this.inRCDATA = true;
11413
+ this.currentSequence = sequence;
11414
+ this.sequenceIndex = offset;
11415
+ }
11416
+ stateBeforeTagName(c) {
11417
+ if (c === 33) {
11418
+ this.state = 22;
11419
+ this.sectionStart = this.index + 1;
11420
+ } else if (c === 63) {
11421
+ this.state = 24;
11422
+ this.sectionStart = this.index + 1;
11423
+ } else if (isTagStartChar(c)) {
11424
+ this.sectionStart = this.index;
11425
+ if (this.mode === 0) {
11426
+ this.state = 6;
11427
+ } else if (this.inSFCRoot) {
11428
+ this.state = 34;
11429
+ } else if (!this.inXML) {
11430
+ const lower = c | 32;
11431
+ if (lower === 116) {
11432
+ this.state = 30;
11433
+ } else {
11434
+ this.state = lower === 115 ? 29 : 6;
11435
+ }
11436
+ } else {
11437
+ this.state = 6;
11438
+ }
11439
+ } else if (c === 47) {
11440
+ this.state = 8;
11441
+ } else {
11442
+ this.state = 1;
11443
+ this.stateText(c);
11444
+ }
11445
+ }
11446
+ stateInTagName(c) {
11447
+ if (isEndOfTagSection(c)) {
11448
+ this.handleTagName(c);
11449
+ }
11450
+ }
11451
+ stateInSFCRootTagName(c) {
11452
+ if (isEndOfTagSection(c)) {
11453
+ const tag = this.buffer.slice(this.sectionStart, this.index);
11454
+ if (tag !== "template") {
11455
+ this.enterRCDATA(toCharCodes(`</` + tag), 0);
11456
+ }
11457
+ this.handleTagName(c);
11458
+ }
11459
+ }
11460
+ handleTagName(c) {
11461
+ this.cbs.onopentagname(this.sectionStart, this.index);
11462
+ this.sectionStart = -1;
11463
+ this.state = 11;
11464
+ this.stateBeforeAttrName(c);
11465
+ }
11466
+ stateBeforeClosingTagName(c) {
11467
+ if (isWhitespace(c)) ; else if (c === 62) {
11468
+ {
11469
+ this.cbs.onerr(14, this.index);
11470
+ }
11471
+ this.state = 1;
11472
+ this.sectionStart = this.index + 1;
11473
+ } else {
11474
+ this.state = isTagStartChar(c) ? 9 : 27;
11475
+ this.sectionStart = this.index;
11476
+ }
11477
+ }
11478
+ stateInClosingTagName(c) {
11479
+ if (c === 62 || isWhitespace(c)) {
11480
+ this.cbs.onclosetag(this.sectionStart, this.index);
11481
+ this.sectionStart = -1;
11482
+ this.state = 10;
11483
+ this.stateAfterClosingTagName(c);
11484
+ }
11485
+ }
11486
+ stateAfterClosingTagName(c) {
11487
+ if (c === 62) {
11488
+ this.state = 1;
11489
+ this.sectionStart = this.index + 1;
11490
+ }
11491
+ }
11492
+ stateBeforeAttrName(c) {
11493
+ if (c === 62) {
11494
+ this.cbs.onopentagend(this.index);
11495
+ if (this.inRCDATA) {
11496
+ this.state = 32;
11497
+ } else {
11498
+ this.state = 1;
11499
+ }
11500
+ this.sectionStart = this.index + 1;
11501
+ } else if (c === 47) {
11502
+ this.state = 7;
11503
+ if (this.peek() !== 62) {
11504
+ this.cbs.onerr(22, this.index);
11505
+ }
11506
+ } else if (c === 60 && this.peek() === 47) {
11507
+ this.cbs.onopentagend(this.index);
11508
+ this.state = 5;
11509
+ this.sectionStart = this.index;
11510
+ } else if (!isWhitespace(c)) {
11511
+ if (c === 61) {
11512
+ this.cbs.onerr(
11513
+ 19,
11514
+ this.index
11515
+ );
11516
+ }
11517
+ this.handleAttrStart(c);
11518
+ }
11519
+ }
11520
+ handleAttrStart(c) {
11521
+ if (c === 118 && this.peek() === 45) {
11522
+ this.state = 13;
11523
+ this.sectionStart = this.index;
11524
+ } else if (c === 46 || c === 58 || c === 64 || c === 35) {
11525
+ this.cbs.ondirname(this.index, this.index + 1);
11526
+ this.state = 14;
11527
+ this.sectionStart = this.index + 1;
11528
+ } else {
11529
+ this.state = 12;
11530
+ this.sectionStart = this.index;
11531
+ }
11532
+ }
11533
+ stateInSelfClosingTag(c) {
11534
+ if (c === 62) {
11535
+ this.cbs.onselfclosingtag(this.index);
11536
+ this.state = 1;
11537
+ this.sectionStart = this.index + 1;
11538
+ this.inRCDATA = false;
11539
+ } else if (!isWhitespace(c)) {
11540
+ this.state = 11;
11541
+ this.stateBeforeAttrName(c);
11542
+ }
11543
+ }
11544
+ stateInAttrName(c) {
11545
+ if (c === 61 || isEndOfTagSection(c)) {
11546
+ this.cbs.onattribname(this.sectionStart, this.index);
11547
+ this.handleAttrNameEnd(c);
11548
+ } else if (c === 34 || c === 39 || c === 60) {
11549
+ this.cbs.onerr(
11550
+ 17,
11551
+ this.index
11552
+ );
11553
+ }
11554
+ }
11555
+ stateInDirName(c) {
11556
+ if (c === 61 || isEndOfTagSection(c)) {
11557
+ this.cbs.ondirname(this.sectionStart, this.index);
11558
+ this.handleAttrNameEnd(c);
11559
+ } else if (c === 58) {
11560
+ this.cbs.ondirname(this.sectionStart, this.index);
11561
+ this.state = 14;
11562
+ this.sectionStart = this.index + 1;
11563
+ } else if (c === 46) {
11564
+ this.cbs.ondirname(this.sectionStart, this.index);
11565
+ this.state = 16;
11566
+ this.sectionStart = this.index + 1;
11567
+ }
11568
+ }
11569
+ stateInDirArg(c) {
11570
+ if (c === 61 || isEndOfTagSection(c)) {
11571
+ this.cbs.ondirarg(this.sectionStart, this.index);
11572
+ this.handleAttrNameEnd(c);
11573
+ } else if (c === 91) {
11574
+ this.state = 15;
11575
+ } else if (c === 46) {
11576
+ this.cbs.ondirarg(this.sectionStart, this.index);
11577
+ this.state = 16;
11578
+ this.sectionStart = this.index + 1;
11579
+ }
11580
+ }
11581
+ stateInDynamicDirArg(c) {
11582
+ if (c === 93) {
11583
+ this.state = 14;
11584
+ } else if (c === 61 || isEndOfTagSection(c)) {
11585
+ this.cbs.ondirarg(this.sectionStart, this.index + 1);
11586
+ this.handleAttrNameEnd(c);
11587
+ {
11588
+ this.cbs.onerr(
11589
+ 27,
11590
+ this.index
11591
+ );
11592
+ }
11593
+ }
11594
+ }
11595
+ stateInDirModifier(c) {
11596
+ if (c === 61 || isEndOfTagSection(c)) {
11597
+ this.cbs.ondirmodifier(this.sectionStart, this.index);
11598
+ this.handleAttrNameEnd(c);
11599
+ } else if (c === 46) {
11600
+ this.cbs.ondirmodifier(this.sectionStart, this.index);
11601
+ this.sectionStart = this.index + 1;
11602
+ }
11603
+ }
11604
+ handleAttrNameEnd(c) {
11605
+ this.sectionStart = this.index;
11606
+ this.state = 17;
11607
+ this.cbs.onattribnameend(this.index);
11608
+ this.stateAfterAttrName(c);
11609
+ }
11610
+ stateAfterAttrName(c) {
11611
+ if (c === 61) {
11612
+ this.state = 18;
11613
+ } else if (c === 47 || c === 62) {
11614
+ this.cbs.onattribend(0, this.sectionStart);
11615
+ this.sectionStart = -1;
11616
+ this.state = 11;
11617
+ this.stateBeforeAttrName(c);
11618
+ } else if (!isWhitespace(c)) {
11619
+ this.cbs.onattribend(0, this.sectionStart);
11620
+ this.handleAttrStart(c);
11621
+ }
11622
+ }
11623
+ stateBeforeAttrValue(c) {
11624
+ if (c === 34) {
11625
+ this.state = 19;
11626
+ this.sectionStart = this.index + 1;
11627
+ } else if (c === 39) {
11628
+ this.state = 20;
11629
+ this.sectionStart = this.index + 1;
11630
+ } else if (!isWhitespace(c)) {
11631
+ this.sectionStart = this.index;
11632
+ this.state = 21;
11633
+ this.stateInAttrValueNoQuotes(c);
11634
+ }
11635
+ }
11636
+ handleInAttrValue(c, quote) {
11637
+ if (c === quote || this.fastForwardTo(quote)) {
11638
+ this.cbs.onattribdata(this.sectionStart, this.index);
11639
+ this.sectionStart = -1;
11640
+ this.cbs.onattribend(
11641
+ quote === 34 ? 3 : 2,
11642
+ this.index + 1
11643
+ );
11644
+ this.state = 11;
11645
+ }
11646
+ }
11647
+ stateInAttrValueDoubleQuotes(c) {
11648
+ this.handleInAttrValue(c, 34);
11649
+ }
11650
+ stateInAttrValueSingleQuotes(c) {
11651
+ this.handleInAttrValue(c, 39);
11652
+ }
11653
+ stateInAttrValueNoQuotes(c) {
11654
+ if (isWhitespace(c) || c === 62) {
11655
+ this.cbs.onattribdata(this.sectionStart, this.index);
11656
+ this.sectionStart = -1;
11657
+ this.cbs.onattribend(1, this.index);
11658
+ this.state = 11;
11659
+ this.stateBeforeAttrName(c);
11660
+ } else if (c === 34 || c === 39 || c === 60 || c === 61 || c === 96) {
11661
+ this.cbs.onerr(
11662
+ 18,
11663
+ this.index
11664
+ );
11665
+ } else ;
11666
+ }
11667
+ stateBeforeDeclaration(c) {
11668
+ if (c === 91) {
11669
+ this.state = 26;
11670
+ this.sequenceIndex = 0;
11671
+ } else {
11672
+ this.state = c === 45 ? 25 : 23;
11673
+ }
11674
+ }
11675
+ stateInDeclaration(c) {
11676
+ if (c === 62 || this.fastForwardTo(62)) {
11677
+ this.state = 1;
11678
+ this.sectionStart = this.index + 1;
11679
+ }
11680
+ }
11681
+ stateInProcessingInstruction(c) {
11682
+ if (c === 62 || this.fastForwardTo(62)) {
11683
+ this.cbs.onprocessinginstruction(this.sectionStart, this.index);
11684
+ this.state = 1;
11685
+ this.sectionStart = this.index + 1;
11686
+ }
11687
+ }
11688
+ stateBeforeComment(c) {
11689
+ if (c === 45) {
11690
+ this.state = 28;
11691
+ this.currentSequence = Sequences.CommentEnd;
11692
+ this.sequenceIndex = 2;
11693
+ this.sectionStart = this.index + 1;
11694
+ } else {
11695
+ this.state = 23;
11696
+ }
11697
+ }
11698
+ stateInSpecialComment(c) {
11699
+ if (c === 62 || this.fastForwardTo(62)) {
11700
+ this.cbs.oncomment(this.sectionStart, this.index);
11701
+ this.state = 1;
11702
+ this.sectionStart = this.index + 1;
11703
+ }
11704
+ }
11705
+ stateBeforeSpecialS(c) {
11706
+ const lower = c | 32;
11707
+ if (lower === Sequences.ScriptEnd[3]) {
11708
+ this.startSpecial(Sequences.ScriptEnd, 4);
11709
+ } else if (lower === Sequences.StyleEnd[3]) {
11710
+ this.startSpecial(Sequences.StyleEnd, 4);
11711
+ } else {
11712
+ this.state = 6;
11713
+ this.stateInTagName(c);
11714
+ }
11715
+ }
11716
+ stateBeforeSpecialT(c) {
11717
+ const lower = c | 32;
11718
+ if (lower === Sequences.TitleEnd[3]) {
11719
+ this.startSpecial(Sequences.TitleEnd, 4);
11720
+ } else if (lower === Sequences.TextareaEnd[3]) {
11721
+ this.startSpecial(Sequences.TextareaEnd, 4);
11722
+ } else {
11723
+ this.state = 6;
11724
+ this.stateInTagName(c);
11725
+ }
11726
+ }
11727
+ startEntity() {
11728
+ }
11729
+ stateInEntity() {
11730
+ }
11731
+ /**
11732
+ * Iterates through the buffer, calling the function corresponding to the current state.
11733
+ *
11734
+ * States that are more likely to be hit are higher up, as a performance improvement.
11735
+ */
11736
+ parse(input) {
11737
+ this.buffer = input;
11738
+ while (this.index < this.buffer.length) {
11739
+ const c = this.buffer.charCodeAt(this.index);
11740
+ if (c === 10) {
11741
+ this.newlines.push(this.index);
11742
+ }
11743
+ switch (this.state) {
11744
+ case 1: {
11745
+ this.stateText(c);
11746
+ break;
11747
+ }
11748
+ case 2: {
11749
+ this.stateInterpolationOpen(c);
11750
+ break;
11751
+ }
11752
+ case 3: {
11753
+ this.stateInterpolation(c);
11754
+ break;
11755
+ }
11756
+ case 4: {
11757
+ this.stateInterpolationClose(c);
11758
+ break;
11759
+ }
11760
+ case 31: {
11761
+ this.stateSpecialStartSequence(c);
11762
+ break;
11763
+ }
11764
+ case 32: {
11765
+ this.stateInRCDATA(c);
11766
+ break;
11767
+ }
11768
+ case 26: {
11769
+ this.stateCDATASequence(c);
11770
+ break;
11771
+ }
11772
+ case 19: {
11773
+ this.stateInAttrValueDoubleQuotes(c);
11774
+ break;
11775
+ }
11776
+ case 12: {
11777
+ this.stateInAttrName(c);
11778
+ break;
11779
+ }
11780
+ case 13: {
11781
+ this.stateInDirName(c);
11782
+ break;
11783
+ }
11784
+ case 14: {
11785
+ this.stateInDirArg(c);
11786
+ break;
11787
+ }
11788
+ case 15: {
11789
+ this.stateInDynamicDirArg(c);
11790
+ break;
11791
+ }
11792
+ case 16: {
11793
+ this.stateInDirModifier(c);
11794
+ break;
11795
+ }
11796
+ case 28: {
11797
+ this.stateInCommentLike(c);
11798
+ break;
11799
+ }
11800
+ case 27: {
11801
+ this.stateInSpecialComment(c);
11802
+ break;
11803
+ }
11804
+ case 11: {
11805
+ this.stateBeforeAttrName(c);
11806
+ break;
11807
+ }
11808
+ case 6: {
11809
+ this.stateInTagName(c);
11810
+ break;
11811
+ }
11812
+ case 34: {
11813
+ this.stateInSFCRootTagName(c);
11814
+ break;
11815
+ }
11816
+ case 9: {
11817
+ this.stateInClosingTagName(c);
11818
+ break;
11819
+ }
11820
+ case 5: {
11821
+ this.stateBeforeTagName(c);
11822
+ break;
11823
+ }
11824
+ case 17: {
11825
+ this.stateAfterAttrName(c);
11826
+ break;
11827
+ }
11828
+ case 20: {
11829
+ this.stateInAttrValueSingleQuotes(c);
11830
+ break;
11831
+ }
11832
+ case 18: {
11833
+ this.stateBeforeAttrValue(c);
11834
+ break;
11835
+ }
11836
+ case 8: {
11837
+ this.stateBeforeClosingTagName(c);
11838
+ break;
11839
+ }
11840
+ case 10: {
11841
+ this.stateAfterClosingTagName(c);
11842
+ break;
11843
+ }
11844
+ case 29: {
11845
+ this.stateBeforeSpecialS(c);
11846
+ break;
11847
+ }
11848
+ case 30: {
11849
+ this.stateBeforeSpecialT(c);
11850
+ break;
11851
+ }
11852
+ case 21: {
11853
+ this.stateInAttrValueNoQuotes(c);
11854
+ break;
11855
+ }
11856
+ case 7: {
11857
+ this.stateInSelfClosingTag(c);
11858
+ break;
11859
+ }
11860
+ case 23: {
11861
+ this.stateInDeclaration(c);
11862
+ break;
11863
+ }
11864
+ case 22: {
11865
+ this.stateBeforeDeclaration(c);
11866
+ break;
11867
+ }
11868
+ case 25: {
11869
+ this.stateBeforeComment(c);
11870
+ break;
11871
+ }
11872
+ case 24: {
11873
+ this.stateInProcessingInstruction(c);
11874
+ break;
11875
+ }
11876
+ case 33: {
11877
+ this.stateInEntity();
11878
+ break;
11879
+ }
11880
+ }
11881
+ this.index++;
11882
+ }
11883
+ this.cleanup();
11884
+ this.finish();
11885
+ }
11886
+ /**
11887
+ * Remove data that has already been consumed from the buffer.
11888
+ */
11889
+ cleanup() {
11890
+ if (this.sectionStart !== this.index) {
11891
+ if (this.state === 1 || this.state === 32 && this.sequenceIndex === 0) {
11892
+ this.cbs.ontext(this.sectionStart, this.index);
11893
+ this.sectionStart = this.index;
11894
+ } else if (this.state === 19 || this.state === 20 || this.state === 21) {
11895
+ this.cbs.onattribdata(this.sectionStart, this.index);
11896
+ this.sectionStart = this.index;
11897
+ }
11898
+ }
11899
+ }
11900
+ finish() {
11901
+ this.handleTrailingData();
11902
+ this.cbs.onend();
11903
+ }
11904
+ /** Handle any trailing data. */
11905
+ handleTrailingData() {
11906
+ const endIndex = this.buffer.length;
11907
+ if (this.sectionStart >= endIndex) {
11908
+ return;
11909
+ }
11910
+ if (this.state === 28) {
11911
+ if (this.currentSequence === Sequences.CdataEnd) {
11912
+ this.cbs.oncdata(this.sectionStart, endIndex);
11913
+ } else {
11914
+ this.cbs.oncomment(this.sectionStart, endIndex);
11915
+ }
11916
+ } else if (this.state === 6 || this.state === 11 || this.state === 18 || this.state === 17 || this.state === 12 || this.state === 13 || this.state === 14 || this.state === 15 || this.state === 16 || this.state === 20 || this.state === 19 || this.state === 21 || this.state === 9) ; else {
11917
+ this.cbs.ontext(this.sectionStart, endIndex);
11918
+ }
11919
+ }
11920
+ emitCodePoint(cp, consumed) {
11921
+ }
11922
+ }
11923
+
11924
+ function defaultOnError(error) {
11925
+ throw error;
11926
+ }
11927
+ function defaultOnWarn(msg) {
11928
+ console.warn(`[Vue warn] ${msg.message}`);
11929
+ }
11930
+ function createCompilerError(code, loc, messages, additionalMessage) {
11931
+ const msg = (messages || errorMessages)[code] + (additionalMessage || ``) ;
11932
+ const error = new SyntaxError(String(msg));
11933
+ error.code = code;
11934
+ error.loc = loc;
11935
+ return error;
11936
+ }
11937
+ const errorMessages = {
11938
+ // parse errors
11939
+ [0]: "Illegal comment.",
11940
+ [1]: "CDATA section is allowed only in XML context.",
11941
+ [2]: "Duplicate attribute.",
11942
+ [3]: "End tag cannot have attributes.",
11943
+ [4]: "Illegal '/' in tags.",
11944
+ [5]: "Unexpected EOF in tag.",
11945
+ [6]: "Unexpected EOF in CDATA section.",
11946
+ [7]: "Unexpected EOF in comment.",
11947
+ [8]: "Unexpected EOF in script.",
11948
+ [9]: "Unexpected EOF in tag.",
11949
+ [10]: "Incorrectly closed comment.",
11950
+ [11]: "Incorrectly opened comment.",
11951
+ [12]: "Illegal tag name. Use '&lt;' to print '<'.",
11952
+ [13]: "Attribute value was expected.",
11953
+ [14]: "End tag name was expected.",
11954
+ [15]: "Whitespace was expected.",
11955
+ [16]: "Unexpected '<!--' in comment.",
11956
+ [17]: `Attribute name cannot contain U+0022 ("), U+0027 ('), and U+003C (<).`,
11957
+ [18]: "Unquoted attribute value cannot contain U+0022 (\"), U+0027 ('), U+003C (<), U+003D (=), and U+0060 (`).",
11958
+ [19]: "Attribute name cannot start with '='.",
11959
+ [21]: "'<?' is allowed only in XML context.",
11960
+ [20]: `Unexpected null character.`,
11961
+ [22]: "Illegal '/' in tags.",
11962
+ // Vue-specific parse errors
11963
+ [23]: "Invalid end tag.",
11964
+ [24]: "Element is missing end tag.",
11965
+ [25]: "Interpolation end sign was not found.",
11966
+ [27]: "End bracket for dynamic directive argument was not found. Note that dynamic directive argument cannot contain spaces.",
11967
+ [26]: "Legal directive name was expected.",
11968
+ // transform errors
11969
+ [28]: `v-if/v-else-if is missing expression.`,
11970
+ [29]: `v-if/else branches must use unique keys.`,
11971
+ [30]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
11972
+ [31]: `v-for is missing expression.`,
11973
+ [32]: `v-for has invalid expression.`,
11974
+ [33]: `<template v-for> key should be placed on the <template> tag.`,
11975
+ [34]: `v-bind is missing expression.`,
11976
+ [35]: `v-on is missing expression.`,
11977
+ [36]: `Unexpected custom directive on <slot> outlet.`,
11978
+ [37]: `Mixed v-slot usage on both the component and nested <template>. When there are multiple named slots, all slots should use <template> syntax to avoid scope ambiguity.`,
11979
+ [38]: `Duplicate slot names found. `,
11980
+ [39]: `Extraneous children found when component already has explicitly named default slot. These children will be ignored.`,
11981
+ [40]: `v-slot can only be used on components or <template> tags.`,
11982
+ [41]: `v-model is missing expression.`,
11983
+ [42]: `v-model value must be a valid JavaScript member expression.`,
11984
+ [43]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
11985
+ [44]: `v-model cannot be used on a prop, because local prop bindings are not writable.
11986
+ Use a v-bind binding combined with a v-on listener that emits update:x event instead.`,
11987
+ [45]: `Error parsing JavaScript expression: `,
11988
+ [46]: `<KeepAlive> expects exactly one child component.`,
11989
+ // generic errors
11990
+ [47]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
11991
+ [48]: `ES module mode is not supported in this build of compiler.`,
11992
+ [49]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
11993
+ [50]: `"scopeId" option is only supported in module mode.`,
11994
+ // deprecations
11995
+ [51]: `@vnode-* hooks in templates are deprecated. Use the vue: prefix instead. For example, @vnode-mounted should be changed to @vue:mounted. @vnode-* hooks support will be removed in 3.4.`,
11996
+ [52]: `v-is="component-name" has been deprecated. Use is="vue:component-name" instead. v-is support will be removed in 3.4.`,
11997
+ // just to fulfill types
11998
+ [53]: ``
11999
+ };
12000
+
12001
+ const isStaticExp = (p) => p.type === 4 && p.isStatic;
12002
+ function isCoreComponent(tag) {
12003
+ switch (tag) {
12004
+ case "Teleport":
12005
+ case "teleport":
12006
+ return TELEPORT;
12007
+ case "Suspense":
12008
+ case "suspense":
12009
+ return SUSPENSE;
12010
+ case "KeepAlive":
12011
+ case "keep-alive":
12012
+ return KEEP_ALIVE;
12013
+ case "BaseTransition":
12014
+ case "base-transition":
12015
+ return BASE_TRANSITION;
12016
+ }
12017
+ }
12018
+ const nonIdentifierRE = /^\d|[^\$\w]/;
12019
+ const isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
12020
+ const validFirstIdentCharRE = /[A-Za-z_$\xA0-\uFFFF]/;
12021
+ const validIdentCharRE = /[\.\?\w$\xA0-\uFFFF]/;
12022
+ const whitespaceRE = /\s+[.[]\s*|\s*[.[]\s+/g;
12023
+ const isMemberExpressionBrowser = (path) => {
12024
+ path = path.trim().replace(whitespaceRE, (s) => s.trim());
12025
+ let state = 0 /* inMemberExp */;
12026
+ let stateStack = [];
12027
+ let currentOpenBracketCount = 0;
12028
+ let currentOpenParensCount = 0;
12029
+ let currentStringType = null;
12030
+ for (let i = 0; i < path.length; i++) {
12031
+ const char = path.charAt(i);
12032
+ switch (state) {
12033
+ case 0 /* inMemberExp */:
12034
+ if (char === "[") {
12035
+ stateStack.push(state);
12036
+ state = 1 /* inBrackets */;
12037
+ currentOpenBracketCount++;
12038
+ } else if (char === "(") {
12039
+ stateStack.push(state);
12040
+ state = 2 /* inParens */;
12041
+ currentOpenParensCount++;
12042
+ } else if (!(i === 0 ? validFirstIdentCharRE : validIdentCharRE).test(char)) {
12043
+ return false;
12044
+ }
12045
+ break;
11208
12046
  case 1 /* inBrackets */:
11209
12047
  if (char === `'` || char === `"` || char === "`") {
11210
12048
  stateStack.push(state);
@@ -11245,43 +12083,6 @@ const isMemberExpressionBrowser = (path) => {
11245
12083
  return !currentOpenBracketCount && !currentOpenParensCount;
11246
12084
  };
11247
12085
  const isMemberExpression = isMemberExpressionBrowser ;
11248
- function getInnerRange(loc, offset, length) {
11249
- const source = loc.source.slice(offset, offset + length);
11250
- const newLoc = {
11251
- source,
11252
- start: advancePositionWithClone(loc.start, loc.source, offset),
11253
- end: loc.end
11254
- };
11255
- if (length != null) {
11256
- newLoc.end = advancePositionWithClone(
11257
- loc.start,
11258
- loc.source,
11259
- offset + length
11260
- );
11261
- }
11262
- return newLoc;
11263
- }
11264
- function advancePositionWithClone(pos, source, numberOfCharacters = source.length) {
11265
- return advancePositionWithMutation(
11266
- extend({}, pos),
11267
- source,
11268
- numberOfCharacters
11269
- );
11270
- }
11271
- function advancePositionWithMutation(pos, source, numberOfCharacters = source.length) {
11272
- let linesCount = 0;
11273
- let lastNewLinePos = -1;
11274
- for (let i = 0; i < numberOfCharacters; i++) {
11275
- if (source.charCodeAt(i) === 10) {
11276
- linesCount++;
11277
- lastNewLinePos = i;
11278
- }
11279
- }
11280
- pos.offset += numberOfCharacters;
11281
- pos.line += linesCount;
11282
- pos.column = lastNewLinePos === -1 ? pos.column + numberOfCharacters : numberOfCharacters - lastNewLinePos;
11283
- return pos;
11284
- }
11285
12086
  function assert(condition, msg) {
11286
12087
  if (!condition) {
11287
12088
  throw new Error(msg || `unexpected compiler condition`);
@@ -11425,344 +12226,492 @@ function getMemoedVNodeCall(node) {
11425
12226
  return node;
11426
12227
  }
11427
12228
  }
12229
+ const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
11428
12230
 
11429
- const decodeRE = /&(gt|lt|amp|apos|quot);/g;
11430
- const decodeMap = {
11431
- gt: ">",
11432
- lt: "<",
11433
- amp: "&",
11434
- apos: "'",
11435
- quot: '"'
11436
- };
11437
12231
  const defaultParserOptions = {
12232
+ parseMode: "base",
12233
+ ns: 0,
11438
12234
  delimiters: [`{{`, `}}`],
11439
12235
  getNamespace: () => 0,
11440
- getTextMode: () => 0,
11441
12236
  isVoidTag: NO,
11442
12237
  isPreTag: NO,
11443
12238
  isCustomElement: NO,
11444
- decodeEntities: (rawText) => rawText.replace(decodeRE, (_, p1) => decodeMap[p1]),
11445
12239
  onError: defaultOnError,
11446
12240
  onWarn: defaultOnWarn,
11447
12241
  comments: true
11448
12242
  };
11449
- function baseParse(content, options = {}) {
11450
- const context = createParserContext(content, options);
11451
- const start = getCursor(context);
11452
- return createRoot(
11453
- parseChildren(context, 0, []),
11454
- getSelection(context, start)
11455
- );
11456
- }
11457
- function createParserContext(content, rawOptions) {
11458
- const options = extend({}, defaultParserOptions);
11459
- let key;
11460
- for (key in rawOptions) {
11461
- options[key] = rawOptions[key] === void 0 ? defaultParserOptions[key] : rawOptions[key];
11462
- }
11463
- return {
11464
- options,
11465
- column: 1,
11466
- line: 1,
11467
- offset: 0,
11468
- originalSource: content,
11469
- source: content,
11470
- inPre: false,
11471
- inVPre: false,
11472
- onWarn: options.onWarn
11473
- };
11474
- }
11475
- function parseChildren(context, mode, ancestors) {
11476
- const parent = last(ancestors);
11477
- const ns = parent ? parent.ns : 0;
11478
- const nodes = [];
11479
- while (!isEnd(context, mode, ancestors)) {
11480
- const s = context.source;
11481
- let node = void 0;
11482
- if (mode === 0 || mode === 1) {
11483
- if (!context.inVPre && startsWith(s, context.options.delimiters[0])) {
11484
- node = parseInterpolation(context, mode);
11485
- } else if (mode === 0 && s[0] === "<") {
11486
- if (s.length === 1) {
11487
- emitError(context, 5, 1);
11488
- } else if (s[1] === "!") {
11489
- if (startsWith(s, "<!--")) {
11490
- node = parseComment(context);
11491
- } else if (startsWith(s, "<!DOCTYPE")) {
11492
- node = parseBogusComment(context);
11493
- } else if (startsWith(s, "<![CDATA[")) {
11494
- if (ns !== 0) {
11495
- node = parseCDATA(context, ancestors);
11496
- } else {
11497
- emitError(context, 1);
11498
- node = parseBogusComment(context);
11499
- }
11500
- } else {
11501
- emitError(context, 11);
11502
- node = parseBogusComment(context);
12243
+ let currentOptions = defaultParserOptions;
12244
+ let currentRoot = null;
12245
+ let currentInput = "";
12246
+ let currentOpenTag = null;
12247
+ let currentProp = null;
12248
+ let currentAttrValue = "";
12249
+ let currentAttrStartIndex = -1;
12250
+ let currentAttrEndIndex = -1;
12251
+ let inPre = 0;
12252
+ let inVPre = false;
12253
+ let currentVPreBoundary = null;
12254
+ const stack = [];
12255
+ const tokenizer = new Tokenizer(stack, {
12256
+ onerr: emitError,
12257
+ ontext(start, end) {
12258
+ onText(getSlice(start, end), start, end);
12259
+ },
12260
+ ontextentity(char, start, end) {
12261
+ onText(char, start, end);
12262
+ },
12263
+ oninterpolation(start, end) {
12264
+ if (inVPre) {
12265
+ return onText(getSlice(start, end), start, end);
12266
+ }
12267
+ let innerStart = start + tokenizer.delimiterOpen.length;
12268
+ let innerEnd = end - tokenizer.delimiterClose.length;
12269
+ while (isWhitespace(currentInput.charCodeAt(innerStart))) {
12270
+ innerStart++;
12271
+ }
12272
+ while (isWhitespace(currentInput.charCodeAt(innerEnd - 1))) {
12273
+ innerEnd--;
12274
+ }
12275
+ let exp = getSlice(innerStart, innerEnd);
12276
+ if (exp.includes("&")) {
12277
+ {
12278
+ exp = currentOptions.decodeEntities(exp, false);
12279
+ }
12280
+ }
12281
+ addNode({
12282
+ type: 5,
12283
+ content: createSimpleExpression(exp, false, getLoc(innerStart, innerEnd)),
12284
+ loc: getLoc(start, end)
12285
+ });
12286
+ },
12287
+ onopentagname(start, end) {
12288
+ const name = getSlice(start, end);
12289
+ currentOpenTag = {
12290
+ type: 1,
12291
+ tag: name,
12292
+ ns: currentOptions.getNamespace(name, stack[0], currentOptions.ns),
12293
+ tagType: 0,
12294
+ // will be refined on tag close
12295
+ props: [],
12296
+ children: [],
12297
+ loc: getLoc(start - 1, end),
12298
+ codegenNode: void 0
12299
+ };
12300
+ if (tokenizer.inSFCRoot) {
12301
+ currentOpenTag.innerLoc = getLoc(
12302
+ end + fastForward(end) + 1,
12303
+ end
12304
+ );
12305
+ }
12306
+ },
12307
+ onopentagend(end) {
12308
+ endOpenTag(end);
12309
+ },
12310
+ onclosetag(start, end) {
12311
+ const name = getSlice(start, end);
12312
+ if (!currentOptions.isVoidTag(name)) {
12313
+ let found = false;
12314
+ for (let i = 0; i < stack.length; i++) {
12315
+ const e = stack[i];
12316
+ if (e.tag.toLowerCase() === name.toLowerCase()) {
12317
+ found = true;
12318
+ if (i > 0) {
12319
+ emitError(24, stack[0].loc.start.offset);
11503
12320
  }
11504
- } else if (s[1] === "/") {
11505
- if (s.length === 2) {
11506
- emitError(context, 5, 2);
11507
- } else if (s[2] === ">") {
11508
- emitError(context, 14, 2);
11509
- advanceBy(context, 3);
11510
- continue;
11511
- } else if (/[a-z]/i.test(s[2])) {
11512
- emitError(context, 23);
11513
- parseTag(context, 1 /* End */, parent);
11514
- continue;
11515
- } else {
11516
- emitError(
11517
- context,
11518
- 12,
11519
- 2
11520
- );
11521
- node = parseBogusComment(context);
12321
+ for (let j = 0; j <= i; j++) {
12322
+ const el = stack.shift();
12323
+ onCloseTag(el, end, j < i);
11522
12324
  }
11523
- } else if (/[a-z]/i.test(s[1])) {
11524
- node = parseElement(context, ancestors);
11525
- } else if (s[1] === "?") {
11526
- emitError(
11527
- context,
11528
- 21,
11529
- 1
11530
- );
11531
- node = parseBogusComment(context);
11532
- } else {
11533
- emitError(context, 12, 1);
12325
+ break;
11534
12326
  }
11535
12327
  }
12328
+ if (!found) {
12329
+ emitError(23, backTrack(start, 60));
12330
+ }
11536
12331
  }
11537
- if (!node) {
11538
- node = parseText(context, mode);
12332
+ },
12333
+ onselfclosingtag(end) {
12334
+ var _a;
12335
+ const name = currentOpenTag.tag;
12336
+ currentOpenTag.isSelfClosing = true;
12337
+ endOpenTag(end);
12338
+ if (((_a = stack[0]) == null ? void 0 : _a.tag) === name) {
12339
+ onCloseTag(stack.shift(), end);
11539
12340
  }
11540
- if (isArray(node)) {
11541
- for (let i = 0; i < node.length; i++) {
11542
- pushNode(nodes, node[i]);
12341
+ },
12342
+ onattribname(start, end) {
12343
+ currentProp = {
12344
+ type: 6,
12345
+ name: getSlice(start, end),
12346
+ nameLoc: getLoc(start, end),
12347
+ value: void 0,
12348
+ loc: getLoc(start)
12349
+ };
12350
+ },
12351
+ ondirname(start, end) {
12352
+ const raw = getSlice(start, end);
12353
+ const name = raw === "." || raw === ":" ? "bind" : raw === "@" ? "on" : raw === "#" ? "slot" : raw.slice(2);
12354
+ if (!inVPre && name === "") {
12355
+ emitError(26, start);
12356
+ }
12357
+ if (inVPre || name === "") {
12358
+ currentProp = {
12359
+ type: 6,
12360
+ name: raw,
12361
+ nameLoc: getLoc(start, end),
12362
+ value: void 0,
12363
+ loc: getLoc(start)
12364
+ };
12365
+ } else {
12366
+ currentProp = {
12367
+ type: 7,
12368
+ name,
12369
+ rawName: raw,
12370
+ exp: void 0,
12371
+ arg: void 0,
12372
+ modifiers: raw === "." ? ["prop"] : [],
12373
+ loc: getLoc(start)
12374
+ };
12375
+ if (name === "pre") {
12376
+ inVPre = true;
12377
+ currentVPreBoundary = currentOpenTag;
12378
+ const props = currentOpenTag.props;
12379
+ for (let i = 0; i < props.length; i++) {
12380
+ if (props[i].type === 7) {
12381
+ props[i] = dirToAttr(props[i]);
12382
+ }
12383
+ }
11543
12384
  }
12385
+ }
12386
+ },
12387
+ ondirarg(start, end) {
12388
+ const arg = getSlice(start, end);
12389
+ if (inVPre) {
12390
+ currentProp.name += arg;
12391
+ setLocEnd(currentProp.nameLoc, end);
11544
12392
  } else {
11545
- pushNode(nodes, node);
12393
+ const isStatic = arg[0] !== `[`;
12394
+ currentProp.arg = createSimpleExpression(
12395
+ isStatic ? arg : arg.slice(1, -1),
12396
+ isStatic,
12397
+ getLoc(start, end),
12398
+ isStatic ? 3 : 0
12399
+ );
11546
12400
  }
11547
- }
11548
- let removedWhitespace = false;
11549
- if (mode !== 2 && mode !== 1) {
11550
- const shouldCondense = context.options.whitespace !== "preserve";
11551
- for (let i = 0; i < nodes.length; i++) {
11552
- const node = nodes[i];
11553
- if (node.type === 2) {
11554
- if (!context.inPre) {
11555
- if (!/[^\t\r\n\f ]/.test(node.content)) {
11556
- const prev = nodes[i - 1];
11557
- const next = nodes[i + 1];
11558
- if (!prev || !next || shouldCondense && (prev.type === 3 && next.type === 3 || prev.type === 3 && next.type === 1 || prev.type === 1 && next.type === 3 || prev.type === 1 && next.type === 1 && /[\r\n]/.test(node.content))) {
11559
- removedWhitespace = true;
11560
- nodes[i] = null;
11561
- } else {
11562
- node.content = " ";
11563
- }
11564
- } else if (shouldCondense) {
11565
- node.content = node.content.replace(/[\t\r\n\f ]+/g, " ");
12401
+ },
12402
+ ondirmodifier(start, end) {
12403
+ const mod = getSlice(start, end);
12404
+ if (inVPre) {
12405
+ currentProp.name += "." + mod;
12406
+ setLocEnd(currentProp.nameLoc, end);
12407
+ } else if (currentProp.name === "slot") {
12408
+ const arg = currentProp.arg;
12409
+ if (arg) {
12410
+ arg.content += "." + mod;
12411
+ setLocEnd(arg.loc, end);
12412
+ }
12413
+ } else {
12414
+ currentProp.modifiers.push(mod);
12415
+ }
12416
+ },
12417
+ onattribdata(start, end) {
12418
+ currentAttrValue += getSlice(start, end);
12419
+ if (currentAttrStartIndex < 0)
12420
+ currentAttrStartIndex = start;
12421
+ currentAttrEndIndex = end;
12422
+ },
12423
+ onattribentity(char, start, end) {
12424
+ currentAttrValue += char;
12425
+ if (currentAttrStartIndex < 0)
12426
+ currentAttrStartIndex = start;
12427
+ currentAttrEndIndex = end;
12428
+ },
12429
+ onattribnameend(end) {
12430
+ const start = currentProp.loc.start.offset;
12431
+ const name = getSlice(start, end);
12432
+ if (currentProp.type === 7) {
12433
+ currentProp.rawName = name;
12434
+ }
12435
+ if (currentOpenTag.props.some(
12436
+ (p) => (p.type === 7 ? p.rawName : p.name) === name
12437
+ )) {
12438
+ emitError(2, start);
12439
+ }
12440
+ },
12441
+ onattribend(quote, end) {
12442
+ if (currentOpenTag && currentProp) {
12443
+ setLocEnd(currentProp.loc, end);
12444
+ if (quote !== 0) {
12445
+ if (currentAttrValue.includes("&")) {
12446
+ currentAttrValue = currentOptions.decodeEntities(
12447
+ currentAttrValue,
12448
+ true
12449
+ );
12450
+ }
12451
+ if (currentProp.type === 6) {
12452
+ if (currentProp.name === "class") {
12453
+ currentAttrValue = condense(currentAttrValue).trim();
12454
+ }
12455
+ if (quote === 1 && !currentAttrValue) {
12456
+ emitError(13, end);
12457
+ }
12458
+ currentProp.value = {
12459
+ type: 2,
12460
+ content: currentAttrValue,
12461
+ loc: quote === 1 ? getLoc(currentAttrStartIndex, currentAttrEndIndex) : getLoc(currentAttrStartIndex - 1, currentAttrEndIndex + 1)
12462
+ };
12463
+ if (tokenizer.inSFCRoot && currentOpenTag.tag === "template" && currentProp.name === "lang" && currentAttrValue && currentAttrValue !== "html") {
12464
+ tokenizer.enterRCDATA(toCharCodes(`</template`), 0);
11566
12465
  }
11567
12466
  } else {
11568
- node.content = node.content.replace(/\r\n/g, "\n");
12467
+ currentProp.exp = createSimpleExpression(
12468
+ currentAttrValue,
12469
+ false,
12470
+ getLoc(currentAttrStartIndex, currentAttrEndIndex)
12471
+ );
12472
+ if (currentProp.name === "for") {
12473
+ currentProp.forParseResult = parseForExpression(currentProp.exp);
12474
+ }
11569
12475
  }
11570
- } else if (node.type === 3 && !context.options.comments) {
11571
- removedWhitespace = true;
11572
- nodes[i] = null;
11573
12476
  }
12477
+ if (currentProp.type !== 7 || currentProp.name !== "pre") {
12478
+ currentOpenTag.props.push(currentProp);
12479
+ }
12480
+ }
12481
+ currentAttrValue = "";
12482
+ currentAttrStartIndex = currentAttrEndIndex = -1;
12483
+ },
12484
+ oncomment(start, end) {
12485
+ if (currentOptions.comments) {
12486
+ addNode({
12487
+ type: 3,
12488
+ content: getSlice(start, end),
12489
+ loc: getLoc(start - 4, end + 3)
12490
+ });
12491
+ }
12492
+ },
12493
+ onend() {
12494
+ const end = currentInput.length;
12495
+ if (tokenizer.state !== 1) {
12496
+ switch (tokenizer.state) {
12497
+ case 5:
12498
+ case 8:
12499
+ emitError(5, end);
12500
+ break;
12501
+ case 3:
12502
+ case 4:
12503
+ emitError(
12504
+ 25,
12505
+ tokenizer.sectionStart
12506
+ );
12507
+ break;
12508
+ case 28:
12509
+ if (tokenizer.currentSequence === Sequences.CdataEnd) {
12510
+ emitError(6, end);
12511
+ } else {
12512
+ emitError(7, end);
12513
+ }
12514
+ break;
12515
+ case 6:
12516
+ case 7:
12517
+ case 9:
12518
+ case 11:
12519
+ case 12:
12520
+ case 13:
12521
+ case 14:
12522
+ case 15:
12523
+ case 16:
12524
+ case 17:
12525
+ case 18:
12526
+ case 19:
12527
+ case 20:
12528
+ case 21:
12529
+ emitError(9, end);
12530
+ break;
12531
+ }
12532
+ }
12533
+ for (let index = 0; index < stack.length; index++) {
12534
+ onCloseTag(stack[index], end - 1);
12535
+ emitError(24, stack[index].loc.start.offset);
12536
+ }
12537
+ },
12538
+ oncdata(start, end) {
12539
+ if (stack[0].ns !== 0) {
12540
+ onText(getSlice(start, end), start, end);
12541
+ } else {
12542
+ emitError(1, start - 9);
12543
+ }
12544
+ },
12545
+ onprocessinginstruction(start) {
12546
+ if ((stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
12547
+ emitError(
12548
+ 21,
12549
+ start - 1
12550
+ );
12551
+ }
12552
+ }
12553
+ });
12554
+ const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
12555
+ const stripParensRE = /^\(|\)$/g;
12556
+ function parseForExpression(input) {
12557
+ const loc = input.loc;
12558
+ const exp = input.content;
12559
+ const inMatch = exp.match(forAliasRE);
12560
+ if (!inMatch)
12561
+ return;
12562
+ const [, LHS, RHS] = inMatch;
12563
+ const createAliasExpression = (content, offset) => {
12564
+ const start = loc.start.offset + offset;
12565
+ const end = start + content.length;
12566
+ return createSimpleExpression(content, false, getLoc(start, end));
12567
+ };
12568
+ const result = {
12569
+ source: createAliasExpression(RHS.trim(), exp.indexOf(RHS, LHS.length)),
12570
+ value: void 0,
12571
+ key: void 0,
12572
+ index: void 0,
12573
+ finalized: false
12574
+ };
12575
+ let valueContent = LHS.trim().replace(stripParensRE, "").trim();
12576
+ const trimmedOffset = LHS.indexOf(valueContent);
12577
+ const iteratorMatch = valueContent.match(forIteratorRE);
12578
+ if (iteratorMatch) {
12579
+ valueContent = valueContent.replace(forIteratorRE, "").trim();
12580
+ const keyContent = iteratorMatch[1].trim();
12581
+ let keyOffset;
12582
+ if (keyContent) {
12583
+ keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
12584
+ result.key = createAliasExpression(keyContent, keyOffset);
11574
12585
  }
11575
- if (context.inPre && parent && context.options.isPreTag(parent.tag)) {
11576
- const first = nodes[0];
11577
- if (first && first.type === 2) {
11578
- first.content = first.content.replace(/^\r?\n/, "");
12586
+ if (iteratorMatch[2]) {
12587
+ const indexContent = iteratorMatch[2].trim();
12588
+ if (indexContent) {
12589
+ result.index = createAliasExpression(
12590
+ indexContent,
12591
+ exp.indexOf(
12592
+ indexContent,
12593
+ result.key ? keyOffset + keyContent.length : trimmedOffset + valueContent.length
12594
+ )
12595
+ );
11579
12596
  }
11580
12597
  }
11581
12598
  }
11582
- return removedWhitespace ? nodes.filter(Boolean) : nodes;
12599
+ if (valueContent) {
12600
+ result.value = createAliasExpression(valueContent, trimmedOffset);
12601
+ }
12602
+ return result;
12603
+ }
12604
+ function getSlice(start, end) {
12605
+ return currentInput.slice(start, end);
12606
+ }
12607
+ function endOpenTag(end) {
12608
+ addNode(currentOpenTag);
12609
+ const { tag, ns } = currentOpenTag;
12610
+ if (ns === 0 && currentOptions.isPreTag(tag)) {
12611
+ inPre++;
12612
+ }
12613
+ if (currentOptions.isVoidTag(tag)) {
12614
+ onCloseTag(currentOpenTag, end);
12615
+ } else {
12616
+ stack.unshift(currentOpenTag);
12617
+ if (ns === 1 || ns === 2) {
12618
+ tokenizer.inXML = true;
12619
+ }
12620
+ }
12621
+ currentOpenTag = null;
11583
12622
  }
11584
- function pushNode(nodes, node) {
11585
- if (node.type === 2) {
11586
- const prev = last(nodes);
11587
- if (prev && prev.type === 2 && prev.loc.end.offset === node.loc.start.offset) {
11588
- prev.content += node.content;
11589
- prev.loc.end = node.loc.end;
11590
- prev.loc.source += node.loc.source;
11591
- return;
12623
+ function onText(content, start, end) {
12624
+ var _a;
12625
+ {
12626
+ const tag = (_a = stack[0]) == null ? void 0 : _a.tag;
12627
+ if (tag !== "script" && tag !== "style" && content.includes("&")) {
12628
+ content = currentOptions.decodeEntities(content, false);
11592
12629
  }
11593
12630
  }
11594
- nodes.push(node);
11595
- }
11596
- function parseCDATA(context, ancestors) {
11597
- advanceBy(context, 9);
11598
- const nodes = parseChildren(context, 3, ancestors);
11599
- if (context.source.length === 0) {
11600
- emitError(context, 6);
12631
+ const parent = stack[0] || currentRoot;
12632
+ const lastNode = parent.children[parent.children.length - 1];
12633
+ if ((lastNode == null ? void 0 : lastNode.type) === 2) {
12634
+ lastNode.content += content;
12635
+ setLocEnd(lastNode.loc, end);
11601
12636
  } else {
11602
- advanceBy(context, 3);
11603
- }
11604
- return nodes;
11605
- }
11606
- function parseComment(context) {
11607
- const start = getCursor(context);
11608
- let content;
11609
- const match = /--(\!)?>/.exec(context.source);
11610
- if (!match) {
11611
- content = context.source.slice(4);
11612
- advanceBy(context, context.source.length);
11613
- emitError(context, 7);
11614
- } else {
11615
- if (match.index <= 3) {
11616
- emitError(context, 0);
11617
- }
11618
- if (match[1]) {
11619
- emitError(context, 10);
11620
- }
11621
- content = context.source.slice(4, match.index);
11622
- const s = context.source.slice(0, match.index);
11623
- let prevIndex = 1, nestedIndex = 0;
11624
- while ((nestedIndex = s.indexOf("<!--", prevIndex)) !== -1) {
11625
- advanceBy(context, nestedIndex - prevIndex + 1);
11626
- if (nestedIndex + 4 < s.length) {
11627
- emitError(context, 16);
11628
- }
11629
- prevIndex = nestedIndex + 1;
11630
- }
11631
- advanceBy(context, match.index + match[0].length - prevIndex + 1);
12637
+ parent.children.push({
12638
+ type: 2,
12639
+ content,
12640
+ loc: getLoc(start, end)
12641
+ });
11632
12642
  }
11633
- return {
11634
- type: 3,
11635
- content,
11636
- loc: getSelection(context, start)
11637
- };
11638
12643
  }
11639
- function parseBogusComment(context) {
11640
- const start = getCursor(context);
11641
- const contentStart = context.source[1] === "?" ? 1 : 2;
11642
- let content;
11643
- const closeIndex = context.source.indexOf(">");
11644
- if (closeIndex === -1) {
11645
- content = context.source.slice(contentStart);
11646
- advanceBy(context, context.source.length);
12644
+ function onCloseTag(el, end, isImplied = false) {
12645
+ if (isImplied) {
12646
+ setLocEnd(el.loc, backTrack(end, 60));
11647
12647
  } else {
11648
- content = context.source.slice(contentStart, closeIndex);
11649
- advanceBy(context, closeIndex + 1);
12648
+ setLocEnd(el.loc, end + fastForward(end) + 1);
11650
12649
  }
11651
- return {
11652
- type: 3,
11653
- content,
11654
- loc: getSelection(context, start)
11655
- };
11656
- }
11657
- function parseElement(context, ancestors) {
11658
- const wasInPre = context.inPre;
11659
- const wasInVPre = context.inVPre;
11660
- const parent = last(ancestors);
11661
- const element = parseTag(context, 0 /* Start */, parent);
11662
- const isPreBoundary = context.inPre && !wasInPre;
11663
- const isVPreBoundary = context.inVPre && !wasInVPre;
11664
- if (element.isSelfClosing || context.options.isVoidTag(element.tag)) {
11665
- if (isPreBoundary) {
11666
- context.inPre = false;
11667
- }
11668
- if (isVPreBoundary) {
11669
- context.inVPre = false;
11670
- }
11671
- return element;
11672
- }
11673
- ancestors.push(element);
11674
- const mode = context.options.getTextMode(element, parent);
11675
- const children = parseChildren(context, mode, ancestors);
11676
- ancestors.pop();
11677
- element.children = children;
11678
- if (startsWithEndTagOpen(context.source, element.tag)) {
11679
- parseTag(context, 1 /* End */, parent);
11680
- } else {
11681
- emitError(context, 24, 0, element.loc.start);
11682
- if (context.source.length === 0 && element.tag.toLowerCase() === "script") {
11683
- const first = children[0];
11684
- if (first && startsWith(first.loc.source, "<!--")) {
11685
- emitError(context, 8);
11686
- }
12650
+ if (tokenizer.inSFCRoot) {
12651
+ if (el.children.length) {
12652
+ el.innerLoc.end = extend({}, el.children[el.children.length - 1].loc.end);
12653
+ } else {
12654
+ el.innerLoc.end = extend({}, el.innerLoc.start);
11687
12655
  }
12656
+ el.innerLoc.source = getSlice(
12657
+ el.innerLoc.start.offset,
12658
+ el.innerLoc.end.offset
12659
+ );
11688
12660
  }
11689
- element.loc = getSelection(context, element.loc.start);
11690
- if (isPreBoundary) {
11691
- context.inPre = false;
12661
+ const { tag, ns } = el;
12662
+ if (!inVPre) {
12663
+ if (tag === "slot") {
12664
+ el.tagType = 2;
12665
+ } else if (isFragmentTemplate(el)) {
12666
+ el.tagType = 3;
12667
+ } else if (isComponent(el)) {
12668
+ el.tagType = 1;
12669
+ }
11692
12670
  }
11693
- if (isVPreBoundary) {
11694
- context.inVPre = false;
12671
+ if (!tokenizer.inRCDATA) {
12672
+ el.children = condenseWhitespace(el.children, el.tag);
11695
12673
  }
11696
- return element;
11697
- }
11698
- const isSpecialTemplateDirective = /* @__PURE__ */ makeMap(
11699
- `if,else,else-if,for,slot`
11700
- );
11701
- function parseTag(context, type, parent) {
11702
- const start = getCursor(context);
11703
- const match = /^<\/?([a-z][^\t\r\n\f />]*)/i.exec(context.source);
11704
- const tag = match[1];
11705
- const ns = context.options.getNamespace(tag, parent);
11706
- advanceBy(context, match[0].length);
11707
- advanceSpaces(context);
11708
- const cursor = getCursor(context);
11709
- const currentSource = context.source;
11710
- if (context.options.isPreTag(tag)) {
11711
- context.inPre = true;
11712
- }
11713
- let props = parseAttributes(context, type);
11714
- if (type === 0 /* Start */ && !context.inVPre && props.some((p) => p.type === 7 && p.name === "pre")) {
11715
- context.inVPre = true;
11716
- extend(context, cursor);
11717
- context.source = currentSource;
11718
- props = parseAttributes(context, type).filter((p) => p.name !== "v-pre");
11719
- }
11720
- let isSelfClosing = false;
11721
- if (context.source.length === 0) {
11722
- emitError(context, 9);
11723
- } else {
11724
- isSelfClosing = startsWith(context.source, "/>");
11725
- if (type === 1 /* End */ && isSelfClosing) {
11726
- emitError(context, 4);
11727
- }
11728
- advanceBy(context, isSelfClosing ? 2 : 1);
12674
+ if (ns === 0 && currentOptions.isPreTag(tag)) {
12675
+ inPre--;
11729
12676
  }
11730
- if (type === 1 /* End */) {
11731
- return;
12677
+ if (currentVPreBoundary === el) {
12678
+ inVPre = false;
12679
+ currentVPreBoundary = null;
11732
12680
  }
11733
- let tagType = 0;
11734
- if (!context.inVPre) {
11735
- if (tag === "slot") {
11736
- tagType = 2;
11737
- } else if (tag === "template") {
11738
- if (props.some(
11739
- (p) => p.type === 7 && isSpecialTemplateDirective(p.name)
11740
- )) {
11741
- tagType = 3;
12681
+ if (tokenizer.inXML && (stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
12682
+ tokenizer.inXML = false;
12683
+ }
12684
+ }
12685
+ function fastForward(start, c) {
12686
+ let offset = 0;
12687
+ while (currentInput.charCodeAt(start + offset) !== 62 && start + offset < currentInput.length) {
12688
+ offset++;
12689
+ }
12690
+ return offset;
12691
+ }
12692
+ function backTrack(index, c) {
12693
+ let i = index;
12694
+ while (currentInput.charCodeAt(i) !== c && i >= 0)
12695
+ i--;
12696
+ return i;
12697
+ }
12698
+ const specialTemplateDir = /* @__PURE__ */ new Set(["if", "else", "else-if", "for", "slot"]);
12699
+ function isFragmentTemplate({ tag, props }) {
12700
+ if (tag === "template") {
12701
+ for (let i = 0; i < props.length; i++) {
12702
+ if (props[i].type === 7 && specialTemplateDir.has(props[i].name)) {
12703
+ return true;
11742
12704
  }
11743
- } else if (isComponent(tag, props, context)) {
11744
- tagType = 1;
11745
12705
  }
11746
12706
  }
11747
- return {
11748
- type: 1,
11749
- ns,
11750
- tag,
11751
- tagType,
11752
- props,
11753
- isSelfClosing,
11754
- children: [],
11755
- loc: getSelection(context, start),
11756
- codegenNode: void 0
11757
- // to be created during transform phase
11758
- };
12707
+ return false;
11759
12708
  }
11760
- function isComponent(tag, props, context) {
11761
- const options = context.options;
11762
- if (options.isCustomElement(tag)) {
12709
+ function isComponent({ tag, props }) {
12710
+ var _a;
12711
+ if (currentOptions.isCustomElement(tag)) {
11763
12712
  return false;
11764
12713
  }
11765
- if (tag === "component" || /^[A-Z]/.test(tag) || isCoreComponent(tag) || options.isBuiltInComponent && options.isBuiltInComponent(tag) || options.isNativeTag && !options.isNativeTag(tag)) {
12714
+ if (tag === "component" || isUpperCase(tag.charCodeAt(0)) || isCoreComponent(tag) || ((_a = currentOptions.isBuiltInComponent) == null ? void 0 : _a.call(currentOptions, tag)) || currentOptions.isNativeTag && !currentOptions.isNativeTag(tag)) {
11766
12715
  return true;
11767
12716
  }
11768
12717
  for (let i = 0; i < props.length; i++) {
@@ -11773,346 +12722,166 @@ function isComponent(tag, props, context) {
11773
12722
  return true;
11774
12723
  }
11775
12724
  }
11776
- } else {
11777
- if (p.name === "is") {
11778
- return true;
11779
- } else if (
11780
- // :is on plain element - only treat as component in compat mode
11781
- p.name === "bind" && isStaticArgOf(p.arg, "is") && false
11782
- ) {
11783
- return true;
11784
- }
11785
12725
  }
11786
12726
  }
12727
+ return false;
11787
12728
  }
11788
- function parseAttributes(context, type) {
11789
- const props = [];
11790
- const attributeNames = /* @__PURE__ */ new Set();
11791
- while (context.source.length > 0 && !startsWith(context.source, ">") && !startsWith(context.source, "/>")) {
11792
- if (startsWith(context.source, "/")) {
11793
- emitError(context, 22);
11794
- advanceBy(context, 1);
11795
- advanceSpaces(context);
11796
- continue;
11797
- }
11798
- if (type === 1 /* End */) {
11799
- emitError(context, 3);
11800
- }
11801
- const attr = parseAttribute(context, attributeNames);
11802
- if (attr.type === 6 && attr.value && attr.name === "class") {
11803
- attr.value.content = attr.value.content.replace(/\s+/g, " ").trim();
11804
- }
11805
- if (type === 0 /* Start */) {
11806
- props.push(attr);
11807
- }
11808
- if (/^[^\t\r\n\f />]/.test(context.source)) {
11809
- emitError(context, 15);
11810
- }
11811
- advanceSpaces(context);
11812
- }
11813
- return props;
12729
+ function isUpperCase(c) {
12730
+ return c > 64 && c < 91;
11814
12731
  }
11815
- function parseAttribute(context, nameSet) {
11816
- var _a;
11817
- const start = getCursor(context);
11818
- const match = /^[^\t\r\n\f />][^\t\r\n\f />=]*/.exec(context.source);
11819
- const name = match[0];
11820
- if (nameSet.has(name)) {
11821
- emitError(context, 2);
11822
- }
11823
- nameSet.add(name);
11824
- if (name[0] === "=") {
11825
- emitError(context, 19);
11826
- }
11827
- {
11828
- const pattern = /["'<]/g;
11829
- let m;
11830
- while (m = pattern.exec(name)) {
11831
- emitError(
11832
- context,
11833
- 17,
11834
- m.index
11835
- );
11836
- }
11837
- }
11838
- advanceBy(context, name.length);
11839
- let value = void 0;
11840
- if (/^[\t\r\n\f ]*=/.test(context.source)) {
11841
- advanceSpaces(context);
11842
- advanceBy(context, 1);
11843
- advanceSpaces(context);
11844
- value = parseAttributeValue(context);
11845
- if (!value) {
11846
- emitError(context, 13);
11847
- }
11848
- }
11849
- const loc = getSelection(context, start);
11850
- if (!context.inVPre && /^(v-[A-Za-z0-9-]|:|\.|@|#)/.test(name)) {
11851
- const match2 = /(?:^v-([a-z0-9-]+))?(?:(?::|^\.|^@|^#)(\[[^\]]+\]|[^\.]+))?(.+)?$/i.exec(
11852
- name
11853
- );
11854
- let isPropShorthand = startsWith(name, ".");
11855
- let dirName = match2[1] || (isPropShorthand || startsWith(name, ":") ? "bind" : startsWith(name, "@") ? "on" : "slot");
11856
- let arg;
11857
- if (match2[2]) {
11858
- const isSlot = dirName === "slot";
11859
- const startOffset = name.lastIndexOf(
11860
- match2[2],
11861
- name.length - (((_a = match2[3]) == null ? void 0 : _a.length) || 0)
11862
- );
11863
- const loc2 = getSelection(
11864
- context,
11865
- getNewPosition(context, start, startOffset),
11866
- getNewPosition(
11867
- context,
11868
- start,
11869
- startOffset + match2[2].length + (isSlot && match2[3] || "").length
11870
- )
11871
- );
11872
- let content = match2[2];
11873
- let isStatic = true;
11874
- if (content.startsWith("[")) {
11875
- isStatic = false;
11876
- if (!content.endsWith("]")) {
11877
- emitError(
11878
- context,
11879
- 27
11880
- );
11881
- content = content.slice(1);
11882
- } else {
11883
- content = content.slice(1, content.length - 1);
12732
+ const windowsNewlineRE = /\r\n/g;
12733
+ function condenseWhitespace(nodes, tag) {
12734
+ var _a, _b;
12735
+ const shouldCondense = currentOptions.whitespace !== "preserve";
12736
+ let removedWhitespace = false;
12737
+ for (let i = 0; i < nodes.length; i++) {
12738
+ const node = nodes[i];
12739
+ if (node.type === 2) {
12740
+ if (!inPre) {
12741
+ if (isAllWhitespace(node.content)) {
12742
+ const prev = (_a = nodes[i - 1]) == null ? void 0 : _a.type;
12743
+ const next = (_b = nodes[i + 1]) == null ? void 0 : _b.type;
12744
+ if (!prev || !next || shouldCondense && (prev === 3 && (next === 3 || next === 1) || prev === 1 && (next === 3 || next === 1 && hasNewlineChar(node.content)))) {
12745
+ removedWhitespace = true;
12746
+ nodes[i] = null;
12747
+ } else {
12748
+ node.content = " ";
12749
+ }
12750
+ } else if (shouldCondense) {
12751
+ node.content = condense(node.content);
11884
12752
  }
11885
- } else if (isSlot) {
11886
- content += match2[3] || "";
12753
+ } else {
12754
+ node.content = node.content.replace(windowsNewlineRE, "\n");
11887
12755
  }
11888
- arg = {
11889
- type: 4,
11890
- content,
11891
- isStatic,
11892
- constType: isStatic ? 3 : 0,
11893
- loc: loc2
11894
- };
11895
- }
11896
- if (value && value.isQuoted) {
11897
- const valueLoc = value.loc;
11898
- valueLoc.start.offset++;
11899
- valueLoc.start.column++;
11900
- valueLoc.end = advancePositionWithClone(valueLoc.start, value.content);
11901
- valueLoc.source = valueLoc.source.slice(1, -1);
11902
12756
  }
11903
- const modifiers = match2[3] ? match2[3].slice(1).split(".") : [];
11904
- if (isPropShorthand)
11905
- modifiers.push("prop");
11906
- return {
11907
- type: 7,
11908
- name: dirName,
11909
- exp: value && {
11910
- type: 4,
11911
- content: value.content,
11912
- isStatic: false,
11913
- // Treat as non-constant by default. This can be potentially set to
11914
- // other values by `transformExpression` to make it eligible for hoisting.
11915
- constType: 0,
11916
- loc: value.loc
11917
- },
11918
- arg,
11919
- modifiers,
11920
- loc
11921
- };
11922
12757
  }
11923
- if (!context.inVPre && startsWith(name, "v-")) {
11924
- emitError(context, 26);
12758
+ if (inPre && tag && currentOptions.isPreTag(tag)) {
12759
+ const first = nodes[0];
12760
+ if (first && first.type === 2) {
12761
+ first.content = first.content.replace(/^\r?\n/, "");
12762
+ }
11925
12763
  }
11926
- return {
11927
- type: 6,
11928
- name,
11929
- value: value && {
11930
- type: 2,
11931
- content: value.content,
11932
- loc: value.loc
11933
- },
11934
- loc
11935
- };
12764
+ return removedWhitespace ? nodes.filter(Boolean) : nodes;
11936
12765
  }
11937
- function parseAttributeValue(context) {
11938
- const start = getCursor(context);
11939
- let content;
11940
- const quote = context.source[0];
11941
- const isQuoted = quote === `"` || quote === `'`;
11942
- if (isQuoted) {
11943
- advanceBy(context, 1);
11944
- const endIndex = context.source.indexOf(quote);
11945
- if (endIndex === -1) {
11946
- content = parseTextData(
11947
- context,
11948
- context.source.length,
11949
- 4
11950
- );
11951
- } else {
11952
- content = parseTextData(context, endIndex, 4);
11953
- advanceBy(context, 1);
11954
- }
11955
- } else {
11956
- const match = /^[^\t\r\n\f >]+/.exec(context.source);
11957
- if (!match) {
11958
- return void 0;
11959
- }
11960
- const unexpectedChars = /["'<=`]/g;
11961
- let m;
11962
- while (m = unexpectedChars.exec(match[0])) {
11963
- emitError(
11964
- context,
11965
- 18,
11966
- m.index
11967
- );
12766
+ function isAllWhitespace(str) {
12767
+ for (let i = 0; i < str.length; i++) {
12768
+ if (!isWhitespace(str.charCodeAt(i))) {
12769
+ return false;
11968
12770
  }
11969
- content = parseTextData(context, match[0].length, 4);
11970
- }
11971
- return { content, isQuoted, loc: getSelection(context, start) };
11972
- }
11973
- function parseInterpolation(context, mode) {
11974
- const [open, close] = context.options.delimiters;
11975
- const closeIndex = context.source.indexOf(close, open.length);
11976
- if (closeIndex === -1) {
11977
- emitError(context, 25);
11978
- return void 0;
11979
- }
11980
- const start = getCursor(context);
11981
- advanceBy(context, open.length);
11982
- const innerStart = getCursor(context);
11983
- const innerEnd = getCursor(context);
11984
- const rawContentLength = closeIndex - open.length;
11985
- const rawContent = context.source.slice(0, rawContentLength);
11986
- const preTrimContent = parseTextData(context, rawContentLength, mode);
11987
- const content = preTrimContent.trim();
11988
- const startOffset = preTrimContent.indexOf(content);
11989
- if (startOffset > 0) {
11990
- advancePositionWithMutation(innerStart, rawContent, startOffset);
11991
- }
11992
- const endOffset = rawContentLength - (preTrimContent.length - content.length - startOffset);
11993
- advancePositionWithMutation(innerEnd, rawContent, endOffset);
11994
- advanceBy(context, close.length);
11995
- return {
11996
- type: 5,
11997
- content: {
11998
- type: 4,
11999
- isStatic: false,
12000
- // Set `isConstant` to false by default and will decide in transformExpression
12001
- constType: 0,
12002
- content,
12003
- loc: getSelection(context, innerStart, innerEnd)
12004
- },
12005
- loc: getSelection(context, start)
12006
- };
12771
+ }
12772
+ return true;
12007
12773
  }
12008
- function parseText(context, mode) {
12009
- const endTokens = mode === 3 ? ["]]>"] : ["<", context.options.delimiters[0]];
12010
- let endIndex = context.source.length;
12011
- for (let i = 0; i < endTokens.length; i++) {
12012
- const index = context.source.indexOf(endTokens[i], 1);
12013
- if (index !== -1 && endIndex > index) {
12014
- endIndex = index;
12774
+ function hasNewlineChar(str) {
12775
+ for (let i = 0; i < str.length; i++) {
12776
+ const c = str.charCodeAt(i);
12777
+ if (c === 10 || c === 13) {
12778
+ return true;
12015
12779
  }
12016
12780
  }
12017
- const start = getCursor(context);
12018
- const content = parseTextData(context, endIndex, mode);
12019
- return {
12020
- type: 2,
12021
- content,
12022
- loc: getSelection(context, start)
12023
- };
12781
+ return false;
12024
12782
  }
12025
- function parseTextData(context, length, mode) {
12026
- const rawText = context.source.slice(0, length);
12027
- advanceBy(context, length);
12028
- if (mode === 2 || mode === 3 || !rawText.includes("&")) {
12029
- return rawText;
12030
- } else {
12031
- return context.options.decodeEntities(
12032
- rawText,
12033
- mode === 4
12034
- );
12783
+ function condense(str) {
12784
+ let ret = "";
12785
+ let prevCharIsWhitespace = false;
12786
+ for (let i = 0; i < str.length; i++) {
12787
+ if (isWhitespace(str.charCodeAt(i))) {
12788
+ if (!prevCharIsWhitespace) {
12789
+ ret += " ";
12790
+ prevCharIsWhitespace = true;
12791
+ }
12792
+ } else {
12793
+ ret += str[i];
12794
+ prevCharIsWhitespace = false;
12795
+ }
12035
12796
  }
12797
+ return ret;
12036
12798
  }
12037
- function getCursor(context) {
12038
- const { column, line, offset } = context;
12039
- return { column, line, offset };
12799
+ function addNode(node) {
12800
+ (stack[0] || currentRoot).children.push(node);
12040
12801
  }
12041
- function getSelection(context, start, end) {
12042
- end = end || getCursor(context);
12802
+ function getLoc(start, end) {
12043
12803
  return {
12044
- start,
12045
- end,
12046
- source: context.originalSource.slice(start.offset, end.offset)
12804
+ start: tokenizer.getPos(start),
12805
+ // @ts-expect-error allow late attachment
12806
+ end: end == null ? end : tokenizer.getPos(end),
12807
+ // @ts-expect-error allow late attachment
12808
+ source: end == null ? end : getSlice(start, end)
12047
12809
  };
12048
12810
  }
12049
- function last(xs) {
12050
- return xs[xs.length - 1];
12051
- }
12052
- function startsWith(source, searchString) {
12053
- return source.startsWith(searchString);
12811
+ function setLocEnd(loc, end) {
12812
+ loc.end = tokenizer.getPos(end);
12813
+ loc.source = getSlice(loc.start.offset, end);
12054
12814
  }
12055
- function advanceBy(context, numberOfCharacters) {
12056
- const { source } = context;
12057
- advancePositionWithMutation(context, source, numberOfCharacters);
12058
- context.source = source.slice(numberOfCharacters);
12059
- }
12060
- function advanceSpaces(context) {
12061
- const match = /^[\t\r\n\f ]+/.exec(context.source);
12062
- if (match) {
12063
- advanceBy(context, match[0].length);
12815
+ function dirToAttr(dir) {
12816
+ const attr = {
12817
+ type: 6,
12818
+ name: dir.rawName,
12819
+ nameLoc: getLoc(
12820
+ dir.loc.start.offset,
12821
+ dir.loc.start.offset + dir.rawName.length
12822
+ ),
12823
+ value: void 0,
12824
+ loc: dir.loc
12825
+ };
12826
+ if (dir.exp) {
12827
+ const loc = dir.exp.loc;
12828
+ if (loc.end.offset < dir.loc.end.offset) {
12829
+ loc.start.offset--;
12830
+ loc.start.column--;
12831
+ loc.end.offset++;
12832
+ loc.end.column++;
12833
+ }
12834
+ attr.value = {
12835
+ type: 2,
12836
+ content: dir.exp.content,
12837
+ loc
12838
+ };
12064
12839
  }
12840
+ return attr;
12065
12841
  }
12066
- function getNewPosition(context, start, numberOfCharacters) {
12067
- return advancePositionWithClone(
12068
- start,
12069
- context.originalSource.slice(start.offset, numberOfCharacters),
12070
- numberOfCharacters
12071
- );
12842
+ function emitError(code, index) {
12843
+ currentOptions.onError(createCompilerError(code, getLoc(index, index)));
12072
12844
  }
12073
- function emitError(context, code, offset, loc = getCursor(context)) {
12074
- if (offset) {
12075
- loc.offset += offset;
12076
- loc.column += offset;
12077
- }
12078
- context.options.onError(
12079
- createCompilerError(code, {
12080
- start: loc,
12081
- end: loc,
12082
- source: ""
12083
- })
12084
- );
12845
+ function reset() {
12846
+ tokenizer.reset();
12847
+ currentOpenTag = null;
12848
+ currentProp = null;
12849
+ currentAttrValue = "";
12850
+ currentAttrStartIndex = -1;
12851
+ currentAttrEndIndex = -1;
12852
+ stack.length = 0;
12085
12853
  }
12086
- function isEnd(context, mode, ancestors) {
12087
- const s = context.source;
12088
- switch (mode) {
12089
- case 0:
12090
- if (startsWith(s, "</")) {
12091
- for (let i = ancestors.length - 1; i >= 0; --i) {
12092
- if (startsWithEndTagOpen(s, ancestors[i].tag)) {
12093
- return true;
12094
- }
12095
- }
12096
- }
12097
- break;
12098
- case 1:
12099
- case 2: {
12100
- const parent = last(ancestors);
12101
- if (parent && startsWithEndTagOpen(s, parent.tag)) {
12102
- return true;
12854
+ function baseParse(input, options) {
12855
+ reset();
12856
+ currentInput = input;
12857
+ currentOptions = extend({}, defaultParserOptions);
12858
+ if (options) {
12859
+ let key;
12860
+ for (key in options) {
12861
+ if (options[key] != null) {
12862
+ currentOptions[key] = options[key];
12103
12863
  }
12104
- break;
12105
12864
  }
12106
- case 3:
12107
- if (startsWith(s, "]]>")) {
12108
- return true;
12109
- }
12110
- break;
12111
12865
  }
12112
- return !s;
12113
- }
12114
- function startsWithEndTagOpen(source, tag) {
12115
- return startsWith(source, "</") && source.slice(2, 2 + tag.length).toLowerCase() === tag.toLowerCase() && /[\t\r\n\f />]/.test(source[2 + tag.length] || ">");
12866
+ {
12867
+ if (!currentOptions.decodeEntities) {
12868
+ throw new Error(
12869
+ `[@vue/compiler-core] decodeEntities option is required in browser builds.`
12870
+ );
12871
+ }
12872
+ }
12873
+ tokenizer.mode = currentOptions.parseMode === "html" ? 1 : currentOptions.parseMode === "sfc" ? 2 : 0;
12874
+ const delimiters = options == null ? void 0 : options.delimiters;
12875
+ if (delimiters) {
12876
+ tokenizer.delimiterOpen = toCharCodes(delimiters[0]);
12877
+ tokenizer.delimiterClose = toCharCodes(delimiters[1]);
12878
+ }
12879
+ const root = currentRoot = createRoot([], input);
12880
+ tokenizer.parse(currentInput);
12881
+ root.loc = getLoc(0, input.length);
12882
+ root.children = condenseWhitespace(root.children);
12883
+ currentRoot = null;
12884
+ return root;
12116
12885
  }
12117
12886
 
12118
12887
  function hoistStatic(root, context) {
@@ -12521,6 +13290,7 @@ function transform(root, options) {
12521
13290
  root.hoists = context.hoists;
12522
13291
  root.temps = context.temps;
12523
13292
  root.cached = context.cached;
13293
+ root.transformed = true;
12524
13294
  }
12525
13295
  function createRootCodegen(root, context) {
12526
13296
  const { helper } = context;
@@ -12674,7 +13444,7 @@ function createCodegenContext(ast, {
12674
13444
  ssr,
12675
13445
  isTS,
12676
13446
  inSSR,
12677
- source: ast.loc.source,
13447
+ source: ast.source,
12678
13448
  code: ``,
12679
13449
  column: 1,
12680
13450
  line: 1,
@@ -12685,7 +13455,7 @@ function createCodegenContext(ast, {
12685
13455
  helper(key) {
12686
13456
  return `_${helperNameMap[key]}`;
12687
13457
  },
12688
- push(code, node) {
13458
+ push(code, newlineIndex = -2 /* None */, node) {
12689
13459
  context.code += code;
12690
13460
  },
12691
13461
  indent() {
@@ -12703,7 +13473,7 @@ function createCodegenContext(ast, {
12703
13473
  }
12704
13474
  };
12705
13475
  function newline(n) {
12706
- context.push("\n" + ` `.repeat(n));
13476
+ context.push("\n" + ` `.repeat(n), 0 /* Start */);
12707
13477
  }
12708
13478
  return context;
12709
13479
  }
@@ -12740,9 +13510,11 @@ function generate(ast, options = {}) {
12740
13510
  push(`with (_ctx) {`);
12741
13511
  indent();
12742
13512
  if (hasHelpers) {
12743
- push(`const { ${helpers.map(aliasHelper).join(", ")} } = _Vue`);
12744
- push(`
12745
- `);
13513
+ push(
13514
+ `const { ${helpers.map(aliasHelper).join(", ")} } = _Vue
13515
+ `,
13516
+ -1 /* End */
13517
+ );
12746
13518
  newline();
12747
13519
  }
12748
13520
  }
@@ -12766,7 +13538,7 @@ function generate(ast, options = {}) {
12766
13538
  }
12767
13539
  if (ast.components.length || ast.directives.length || ast.temps) {
12768
13540
  push(`
12769
- `);
13541
+ `, 0 /* Start */);
12770
13542
  newline();
12771
13543
  }
12772
13544
  if (!ssr) {
@@ -12787,7 +13559,6 @@ function generate(ast, options = {}) {
12787
13559
  ast,
12788
13560
  code: context.code,
12789
13561
  preamble: isSetupInlined ? preambleContext.code : ``,
12790
- // SourceMapGenerator does have toJSON() method but it's not in the types
12791
13562
  map: context.map ? context.map.toJSON() : void 0
12792
13563
  };
12793
13564
  }
@@ -12806,7 +13577,7 @@ function genFunctionPreamble(ast, context) {
12806
13577
  if (helpers.length > 0) {
12807
13578
  {
12808
13579
  push(`const _Vue = ${VueBinding}
12809
- `);
13580
+ `, -1 /* End */);
12810
13581
  if (ast.hoists.length) {
12811
13582
  const staticHelpers = [
12812
13583
  CREATE_VNODE,
@@ -12816,7 +13587,7 @@ function genFunctionPreamble(ast, context) {
12816
13587
  CREATE_STATIC
12817
13588
  ].filter((helper) => helpers.includes(helper)).map(aliasHelper).join(", ");
12818
13589
  push(`const { ${staticHelpers} } = _Vue
12819
- `);
13590
+ `, -1 /* End */);
12820
13591
  }
12821
13592
  }
12822
13593
  }
@@ -12877,7 +13648,7 @@ function genNodeList(nodes, context, multilines = false, comma = true) {
12877
13648
  for (let i = 0; i < nodes.length; i++) {
12878
13649
  const node = nodes[i];
12879
13650
  if (isString(node)) {
12880
- push(node);
13651
+ push(node, -3 /* Unknown */);
12881
13652
  } else if (isArray(node)) {
12882
13653
  genNodeListAsArray(node, context);
12883
13654
  } else {
@@ -12895,7 +13666,7 @@ function genNodeList(nodes, context, multilines = false, comma = true) {
12895
13666
  }
12896
13667
  function genNode(node, context) {
12897
13668
  if (isString(node)) {
12898
- context.push(node);
13669
+ context.push(node, -3 /* Unknown */);
12899
13670
  return;
12900
13671
  }
12901
13672
  if (isSymbol(node)) {
@@ -12975,11 +13746,15 @@ function genNode(node, context) {
12975
13746
  }
12976
13747
  }
12977
13748
  function genText(node, context) {
12978
- context.push(JSON.stringify(node.content), node);
13749
+ context.push(JSON.stringify(node.content), -3 /* Unknown */, node);
12979
13750
  }
12980
13751
  function genExpression(node, context) {
12981
13752
  const { content, isStatic } = node;
12982
- context.push(isStatic ? JSON.stringify(content) : content, node);
13753
+ context.push(
13754
+ isStatic ? JSON.stringify(content) : content,
13755
+ -3 /* Unknown */,
13756
+ node
13757
+ );
12983
13758
  }
12984
13759
  function genInterpolation(node, context) {
12985
13760
  const { push, helper, pure } = context;
@@ -12993,7 +13768,7 @@ function genCompoundExpression(node, context) {
12993
13768
  for (let i = 0; i < node.children.length; i++) {
12994
13769
  const child = node.children[i];
12995
13770
  if (isString(child)) {
12996
- context.push(child);
13771
+ context.push(child, -3 /* Unknown */);
12997
13772
  } else {
12998
13773
  genNode(child, context);
12999
13774
  }
@@ -13007,9 +13782,9 @@ function genExpressionAsPropertyKey(node, context) {
13007
13782
  push(`]`);
13008
13783
  } else if (node.isStatic) {
13009
13784
  const text = isSimpleIdentifier(node.content) ? node.content : JSON.stringify(node.content);
13010
- push(text, node);
13785
+ push(text, -2 /* None */, node);
13011
13786
  } else {
13012
- push(`[${node.content}]`, node);
13787
+ push(`[${node.content}]`, -3 /* Unknown */, node);
13013
13788
  }
13014
13789
  }
13015
13790
  function genComment(node, context) {
@@ -13017,7 +13792,11 @@ function genComment(node, context) {
13017
13792
  if (pure) {
13018
13793
  push(PURE_ANNOTATION);
13019
13794
  }
13020
- push(`${helper(CREATE_COMMENT)}(${JSON.stringify(node.content)})`, node);
13795
+ push(
13796
+ `${helper(CREATE_COMMENT)}(${JSON.stringify(node.content)})`,
13797
+ -3 /* Unknown */,
13798
+ node
13799
+ );
13021
13800
  }
13022
13801
  function genVNodeCall(node, context) {
13023
13802
  const { push, helper, pure } = context;
@@ -13042,7 +13821,7 @@ function genVNodeCall(node, context) {
13042
13821
  push(PURE_ANNOTATION);
13043
13822
  }
13044
13823
  const callHelper = isBlock ? getVNodeBlockHelper(context.inSSR, isComponent) : getVNodeHelper(context.inSSR, isComponent);
13045
- push(helper(callHelper) + `(`, node);
13824
+ push(helper(callHelper) + `(`, -2 /* None */, node);
13046
13825
  genNodeList(
13047
13826
  genNullableArgs([tag, props, children, patchFlag, dynamicProps]),
13048
13827
  context
@@ -13071,7 +13850,7 @@ function genCallExpression(node, context) {
13071
13850
  if (pure) {
13072
13851
  push(PURE_ANNOTATION);
13073
13852
  }
13074
- push(callee + `(`, node);
13853
+ push(callee + `(`, -2 /* None */, node);
13075
13854
  genNodeList(node.arguments, context);
13076
13855
  push(`)`);
13077
13856
  }
@@ -13079,7 +13858,7 @@ function genObjectExpression(node, context) {
13079
13858
  const { push, indent, deindent, newline } = context;
13080
13859
  const { properties } = node;
13081
13860
  if (!properties.length) {
13082
- push(`{}`, node);
13861
+ push(`{}`, -2 /* None */, node);
13083
13862
  return;
13084
13863
  }
13085
13864
  const multilines = properties.length > 1 || properties.some((p) => p.value.type !== 4);
@@ -13107,7 +13886,7 @@ function genFunctionExpression(node, context) {
13107
13886
  if (isSlot) {
13108
13887
  push(`_${helperNameMap[WITH_CTX]}(`);
13109
13888
  }
13110
- push(`(`, node);
13889
+ push(`(`, -2 /* None */, node);
13111
13890
  if (isArray(params)) {
13112
13891
  genNodeList(params, context);
13113
13892
  } else if (params) {
@@ -13338,7 +14117,7 @@ function processIf(node, dir, context, processCodegen) {
13338
14117
  context.removeNode();
13339
14118
  const branch = createIfBranch(node, dir);
13340
14119
  if (comments.length && // #3619 ignore comments if the v-if is direct child of <transition>
13341
- !(context.parent && context.parent.type === 1 && isBuiltInType(context.parent.tag, "transition"))) {
14120
+ !(context.parent && context.parent.type === 1 && (context.parent.tag === "transition" || context.parent.tag === "Transition"))) {
13342
14121
  branch.children = [...comments, ...branch.children];
13343
14122
  }
13344
14123
  {
@@ -13620,18 +14399,14 @@ function processFor(node, dir, context, processCodegen) {
13620
14399
  );
13621
14400
  return;
13622
14401
  }
13623
- const parseResult = parseForExpression(
13624
- // can only be simple expression because vFor transform is applied
13625
- // before expression transform.
13626
- dir.exp,
13627
- context
13628
- );
14402
+ const parseResult = dir.forParseResult;
13629
14403
  if (!parseResult) {
13630
14404
  context.onError(
13631
14405
  createCompilerError(32, dir.loc)
13632
14406
  );
13633
14407
  return;
13634
14408
  }
14409
+ finalizeForParseResult(parseResult, context);
13635
14410
  const { addIdentifiers, removeIdentifiers, scopes } = context;
13636
14411
  const { source, value, key, index } = parseResult;
13637
14412
  const forNode = {
@@ -13653,71 +14428,26 @@ function processFor(node, dir, context, processCodegen) {
13653
14428
  onExit();
13654
14429
  };
13655
14430
  }
13656
- const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
13657
- const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
13658
- const stripParensRE = /^\(|\)$/g;
13659
- function parseForExpression(input, context) {
13660
- const loc = input.loc;
13661
- const exp = input.content;
13662
- const inMatch = exp.match(forAliasRE);
13663
- if (!inMatch)
14431
+ function finalizeForParseResult(result, context) {
14432
+ if (result.finalized)
13664
14433
  return;
13665
- const [, LHS, RHS] = inMatch;
13666
- const result = {
13667
- source: createAliasExpression(
13668
- loc,
13669
- RHS.trim(),
13670
- exp.indexOf(RHS, LHS.length)
13671
- ),
13672
- value: void 0,
13673
- key: void 0,
13674
- index: void 0
13675
- };
13676
14434
  {
13677
14435
  validateBrowserExpression(result.source, context);
13678
- }
13679
- let valueContent = LHS.trim().replace(stripParensRE, "").trim();
13680
- const trimmedOffset = LHS.indexOf(valueContent);
13681
- const iteratorMatch = valueContent.match(forIteratorRE);
13682
- if (iteratorMatch) {
13683
- valueContent = valueContent.replace(forIteratorRE, "").trim();
13684
- const keyContent = iteratorMatch[1].trim();
13685
- let keyOffset;
13686
- if (keyContent) {
13687
- keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
13688
- result.key = createAliasExpression(loc, keyContent, keyOffset);
13689
- {
13690
- validateBrowserExpression(
13691
- result.key,
13692
- context,
13693
- true
13694
- );
13695
- }
14436
+ if (result.key) {
14437
+ validateBrowserExpression(
14438
+ result.key,
14439
+ context,
14440
+ true
14441
+ );
13696
14442
  }
13697
- if (iteratorMatch[2]) {
13698
- const indexContent = iteratorMatch[2].trim();
13699
- if (indexContent) {
13700
- result.index = createAliasExpression(
13701
- loc,
13702
- indexContent,
13703
- exp.indexOf(
13704
- indexContent,
13705
- result.key ? keyOffset + keyContent.length : trimmedOffset + valueContent.length
13706
- )
13707
- );
13708
- {
13709
- validateBrowserExpression(
13710
- result.index,
13711
- context,
13712
- true
13713
- );
13714
- }
13715
- }
14443
+ if (result.index) {
14444
+ validateBrowserExpression(
14445
+ result.index,
14446
+ context,
14447
+ true
14448
+ );
13716
14449
  }
13717
- }
13718
- if (valueContent) {
13719
- result.value = createAliasExpression(loc, valueContent, trimmedOffset);
13720
- {
14450
+ if (result.value) {
13721
14451
  validateBrowserExpression(
13722
14452
  result.value,
13723
14453
  context,
@@ -13725,14 +14455,7 @@ function parseForExpression(input, context) {
13725
14455
  );
13726
14456
  }
13727
14457
  }
13728
- return result;
13729
- }
13730
- function createAliasExpression(range, content, offset) {
13731
- return createSimpleExpression(
13732
- content,
13733
- false,
13734
- getInnerRange(range, offset, content.length)
13735
- );
14458
+ result.finalized = true;
13736
14459
  }
13737
14460
  function createForLoopParams({ value, key, index }, memoArgs = []) {
13738
14461
  return createParamsList([value, key, index, ...memoArgs]);
@@ -13819,12 +14542,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
13819
14542
  hasDynamicSlots = true;
13820
14543
  }
13821
14544
  const vFor = findDir(slotElement, "for");
13822
- const slotFunction = buildSlotFn(
13823
- slotProps,
13824
- vFor == null ? void 0 : vFor.exp,
13825
- slotChildren,
13826
- slotLoc
13827
- );
14545
+ const slotFunction = buildSlotFn(slotProps, vFor, slotChildren, slotLoc);
13828
14546
  let vIf;
13829
14547
  let vElse;
13830
14548
  if (vIf = findDir(slotElement, "if")) {
@@ -13873,8 +14591,9 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
13873
14591
  }
13874
14592
  } else if (vFor) {
13875
14593
  hasDynamicSlots = true;
13876
- const parseResult = vFor.parseResult || parseForExpression(vFor.exp, context);
14594
+ const parseResult = vFor.forParseResult;
13877
14595
  if (parseResult) {
14596
+ finalizeForParseResult(parseResult, context);
13878
14597
  dynamicSlots.push(
13879
14598
  createCallExpression(context.helper(RENDER_LIST), [
13880
14599
  parseResult.source,
@@ -14129,17 +14848,6 @@ function resolveComponentType(node, context, ssr = false) {
14129
14848
  tag = isProp.value.content.slice(4);
14130
14849
  }
14131
14850
  }
14132
- const isDir = !isExplicitDynamic && findDir(node, "is");
14133
- if (isDir && isDir.exp) {
14134
- {
14135
- context.onWarn(
14136
- createCompilerError(52, isDir.loc)
14137
- );
14138
- }
14139
- return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [
14140
- isDir.exp
14141
- ]);
14142
- }
14143
14851
  const builtIn = isCoreComponent(tag) || context.isBuiltInComponent(tag);
14144
14852
  if (builtIn) {
14145
14853
  if (!ssr)
@@ -14211,7 +14919,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
14211
14919
  for (let i = 0; i < props.length; i++) {
14212
14920
  const prop = props[i];
14213
14921
  if (prop.type === 6) {
14214
- const { loc, name, value } = prop;
14922
+ const { loc, name, nameLoc, value } = prop;
14215
14923
  let isStatic = true;
14216
14924
  if (name === "ref") {
14217
14925
  hasRef = true;
@@ -14229,11 +14937,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
14229
14937
  }
14230
14938
  properties.push(
14231
14939
  createObjectProperty(
14232
- createSimpleExpression(
14233
- name,
14234
- true,
14235
- getInnerRange(loc, 0, name.length)
14236
- ),
14940
+ createSimpleExpression(name, true, nameLoc),
14237
14941
  createSimpleExpression(
14238
14942
  value ? value.content : "",
14239
14943
  isStatic,
@@ -14242,7 +14946,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
14242
14946
  )
14243
14947
  );
14244
14948
  } else {
14245
- const { name, arg, exp, loc } = prop;
14949
+ const { name, arg, exp, loc, modifiers } = prop;
14246
14950
  const isVBind = name === "bind";
14247
14951
  const isVOn = name === "on";
14248
14952
  if (name === "slot") {
@@ -14302,6 +15006,9 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
14302
15006
  }
14303
15007
  continue;
14304
15008
  }
15009
+ if (isVBind && modifiers.includes("prop")) {
15010
+ patchFlag |= 32;
15011
+ }
14305
15012
  const directiveTransform = context.directiveTransforms[name];
14306
15013
  if (directiveTransform) {
14307
15014
  const { props: props2, needRuntime } = directiveTransform(prop, node, context);
@@ -14679,8 +15386,13 @@ const transformOn$1 = (dir, node, context, augmentor) => {
14679
15386
  };
14680
15387
 
14681
15388
  const transformBind = (dir, _node, context) => {
14682
- const { exp, modifiers, loc } = dir;
15389
+ const { modifiers, loc } = dir;
14683
15390
  const arg = dir.arg;
15391
+ let { exp } = dir;
15392
+ if (!exp && arg.type === 4) {
15393
+ const propName = camelize(arg.content);
15394
+ exp = dir.exp = createSimpleExpression(propName, false, arg.loc);
15395
+ }
14684
15396
  if (arg.type !== 4) {
14685
15397
  arg.children.unshift(`(`);
14686
15398
  arg.children.push(`) || ""`);
@@ -14932,7 +15644,7 @@ function getBaseTransformPreset(prefixIdentifiers) {
14932
15644
  }
14933
15645
  ];
14934
15646
  }
14935
- function baseCompile(template, options = {}) {
15647
+ function baseCompile(source, options = {}) {
14936
15648
  const onError = options.onError || defaultOnError;
14937
15649
  const isModuleMode = options.mode === "module";
14938
15650
  {
@@ -14949,7 +15661,7 @@ function baseCompile(template, options = {}) {
14949
15661
  if (options.scopeId && !isModuleMode) {
14950
15662
  onError(createCompilerError(50));
14951
15663
  }
14952
- const ast = isString(template) ? baseParse(template, options) : template;
15664
+ const ast = isString(source) ? baseParse(source, options) : source;
14953
15665
  const [nodeTransforms, directiveTransforms] = getBaseTransformPreset();
14954
15666
  transform(
14955
15667
  ast,
@@ -15015,25 +15727,22 @@ function decodeHtmlBrowser(raw, asAttr = false) {
15015
15727
  }
15016
15728
  }
15017
15729
 
15018
- const isRawTextContainer = /* @__PURE__ */ makeMap(
15019
- "style,iframe,script,noscript",
15020
- true
15021
- );
15022
15730
  const parserOptions = {
15731
+ parseMode: "html",
15023
15732
  isVoidTag,
15024
15733
  isNativeTag: (tag) => isHTMLTag(tag) || isSVGTag(tag),
15025
15734
  isPreTag: (tag) => tag === "pre",
15026
15735
  decodeEntities: decodeHtmlBrowser ,
15027
15736
  isBuiltInComponent: (tag) => {
15028
- if (isBuiltInType(tag, `Transition`)) {
15737
+ if (tag === "Transition" || tag === "transition") {
15029
15738
  return TRANSITION;
15030
- } else if (isBuiltInType(tag, `TransitionGroup`)) {
15739
+ } else if (tag === "TransitionGroup" || tag === "transition-group") {
15031
15740
  return TRANSITION_GROUP;
15032
15741
  }
15033
15742
  },
15034
15743
  // https://html.spec.whatwg.org/multipage/parsing.html#tree-construction-dispatcher
15035
- getNamespace(tag, parent) {
15036
- let ns = parent ? parent.ns : 0;
15744
+ getNamespace(tag, parent, rootNamespace) {
15745
+ let ns = parent ? parent.ns : rootNamespace;
15037
15746
  if (parent && ns === 2) {
15038
15747
  if (parent.tag === "annotation-xml") {
15039
15748
  if (tag === "svg") {
@@ -15061,18 +15770,6 @@ const parserOptions = {
15061
15770
  }
15062
15771
  }
15063
15772
  return ns;
15064
- },
15065
- // https://html.spec.whatwg.org/multipage/parsing.html#parsing-html-fragments
15066
- getTextMode({ tag, ns }) {
15067
- if (ns === 0) {
15068
- if (tag === "textarea" || tag === "title") {
15069
- return 1;
15070
- }
15071
- if (isRawTextContainer(tag)) {
15072
- return 2;
15073
- }
15074
- }
15075
- return 0;
15076
15773
  }
15077
15774
  };
15078
15775
 
@@ -15187,8 +15884,8 @@ const transformModel = (dir, node, context) => {
15187
15884
  );
15188
15885
  }
15189
15886
  function checkDuplicatedValue() {
15190
- const value = findProp(node, "value");
15191
- if (value) {
15887
+ const value = findDir(node, "bind");
15888
+ if (value && isStaticArgOf(value.arg, "value")) {
15192
15889
  context.onError(
15193
15890
  createDOMCompilerError(
15194
15891
  60,
@@ -15387,6 +16084,7 @@ const transformTransition = (node, context) => {
15387
16084
  node.props.push({
15388
16085
  type: 6,
15389
16086
  name: "persisted",
16087
+ nameLoc: node.loc,
15390
16088
  value: void 0,
15391
16089
  loc: node.loc
15392
16090
  });
@@ -15431,9 +16129,9 @@ const DOMDirectiveTransforms = {
15431
16129
  // override compiler-core
15432
16130
  show: transformShow
15433
16131
  };
15434
- function compile(template, options = {}) {
16132
+ function compile(src, options = {}) {
15435
16133
  return baseCompile(
15436
- template,
16134
+ src,
15437
16135
  extend({}, parserOptions, options, {
15438
16136
  nodeTransforms: [
15439
16137
  // ignore <script> and <tag>