@vue/compiler-dom 3.2.39 → 3.2.41

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.
@@ -5,27 +5,27 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var compilerCore = require('@vue/compiler-core');
6
6
  var shared = require('@vue/shared');
7
7
 
8
- const V_MODEL_RADIO = Symbol(``);
9
- const V_MODEL_CHECKBOX = Symbol(``);
10
- const V_MODEL_TEXT = Symbol(``);
11
- const V_MODEL_SELECT = Symbol(``);
12
- const V_MODEL_DYNAMIC = Symbol(``);
13
- const V_ON_WITH_MODIFIERS = Symbol(``);
14
- const V_ON_WITH_KEYS = Symbol(``);
15
- const V_SHOW = Symbol(``);
16
- const TRANSITION = Symbol(``);
17
- const TRANSITION_GROUP = Symbol(``);
18
- compilerCore.registerRuntimeHelpers({
19
- [V_MODEL_RADIO]: `vModelRadio`,
20
- [V_MODEL_CHECKBOX]: `vModelCheckbox`,
21
- [V_MODEL_TEXT]: `vModelText`,
22
- [V_MODEL_SELECT]: `vModelSelect`,
23
- [V_MODEL_DYNAMIC]: `vModelDynamic`,
24
- [V_ON_WITH_MODIFIERS]: `withModifiers`,
25
- [V_ON_WITH_KEYS]: `withKeys`,
26
- [V_SHOW]: `vShow`,
27
- [TRANSITION]: `Transition`,
28
- [TRANSITION_GROUP]: `TransitionGroup`
8
+ const V_MODEL_RADIO = Symbol(``);
9
+ const V_MODEL_CHECKBOX = Symbol(``);
10
+ const V_MODEL_TEXT = Symbol(``);
11
+ const V_MODEL_SELECT = Symbol(``);
12
+ const V_MODEL_DYNAMIC = Symbol(``);
13
+ const V_ON_WITH_MODIFIERS = Symbol(``);
14
+ const V_ON_WITH_KEYS = Symbol(``);
15
+ const V_SHOW = Symbol(``);
16
+ const TRANSITION = Symbol(``);
17
+ const TRANSITION_GROUP = Symbol(``);
18
+ compilerCore.registerRuntimeHelpers({
19
+ [V_MODEL_RADIO]: `vModelRadio`,
20
+ [V_MODEL_CHECKBOX]: `vModelCheckbox`,
21
+ [V_MODEL_TEXT]: `vModelText`,
22
+ [V_MODEL_SELECT]: `vModelSelect`,
23
+ [V_MODEL_DYNAMIC]: `vModelDynamic`,
24
+ [V_ON_WITH_MODIFIERS]: `withModifiers`,
25
+ [V_ON_WITH_KEYS]: `withKeys`,
26
+ [V_SHOW]: `vShow`,
27
+ [TRANSITION]: `Transition`,
28
+ [TRANSITION_GROUP]: `TransitionGroup`
29
29
  });
30
30
 
31
31
  var namedCharacterReferences = {
@@ -2262,794 +2262,799 @@ var namedCharacterReferences = {
2262
2262
  "CounterClockwiseContourIntegral;": "∳"
2263
2263
  };
2264
2264
 
2265
- // lazy compute this to make this file tree-shakable for browser
2266
- let maxCRNameLength;
2267
- const decodeHtml = (rawText, asAttr) => {
2268
- let offset = 0;
2269
- const end = rawText.length;
2270
- let decodedText = '';
2271
- function advance(length) {
2272
- offset += length;
2273
- rawText = rawText.slice(length);
2274
- }
2275
- while (offset < end) {
2276
- const head = /&(?:#x?)?/i.exec(rawText);
2277
- if (!head || offset + head.index >= end) {
2278
- const remaining = end - offset;
2279
- decodedText += rawText.slice(0, remaining);
2280
- advance(remaining);
2281
- break;
2282
- }
2283
- // Advance to the "&".
2284
- decodedText += rawText.slice(0, head.index);
2285
- advance(head.index);
2286
- if (head[0] === '&') {
2287
- // Named character reference.
2288
- let name = '';
2289
- let value = undefined;
2290
- if (/[0-9a-z]/i.test(rawText[1])) {
2291
- if (!maxCRNameLength) {
2292
- maxCRNameLength = Object.keys(namedCharacterReferences).reduce((max, name) => Math.max(max, name.length), 0);
2293
- }
2294
- for (let length = maxCRNameLength; !value && length > 0; --length) {
2295
- name = rawText.slice(1, 1 + length);
2296
- value = namedCharacterReferences[name];
2297
- }
2298
- if (value) {
2299
- const semi = name.endsWith(';');
2300
- if (asAttr &&
2301
- !semi &&
2302
- /[=a-z0-9]/i.test(rawText[name.length + 1] || '')) {
2303
- decodedText += '&' + name;
2304
- advance(1 + name.length);
2305
- }
2306
- else {
2307
- decodedText += value;
2308
- advance(1 + name.length);
2309
- }
2310
- }
2311
- else {
2312
- decodedText += '&' + name;
2313
- advance(1 + name.length);
2314
- }
2315
- }
2316
- else {
2317
- decodedText += '&';
2318
- advance(1);
2319
- }
2320
- }
2321
- else {
2322
- // Numeric character reference.
2323
- const hex = head[0] === '&#x';
2324
- const pattern = hex ? /^&#x([0-9a-f]+);?/i : /^&#([0-9]+);?/;
2325
- const body = pattern.exec(rawText);
2326
- if (!body) {
2327
- decodedText += head[0];
2328
- advance(head[0].length);
2329
- }
2330
- else {
2331
- // https://html.spec.whatwg.org/multipage/parsing.html#numeric-character-reference-end-state
2332
- let cp = Number.parseInt(body[1], hex ? 16 : 10);
2333
- if (cp === 0) {
2334
- cp = 0xfffd;
2335
- }
2336
- else if (cp > 0x10ffff) {
2337
- cp = 0xfffd;
2338
- }
2339
- else if (cp >= 0xd800 && cp <= 0xdfff) {
2340
- cp = 0xfffd;
2341
- }
2342
- else if ((cp >= 0xfdd0 && cp <= 0xfdef) || (cp & 0xfffe) === 0xfffe) ;
2343
- else if ((cp >= 0x01 && cp <= 0x08) ||
2344
- cp === 0x0b ||
2345
- (cp >= 0x0d && cp <= 0x1f) ||
2346
- (cp >= 0x7f && cp <= 0x9f)) {
2347
- cp = CCR_REPLACEMENTS[cp] || cp;
2348
- }
2349
- decodedText += String.fromCodePoint(cp);
2350
- advance(body[0].length);
2351
- }
2352
- }
2353
- }
2354
- return decodedText;
2355
- };
2356
- // https://html.spec.whatwg.org/multipage/parsing.html#numeric-character-reference-end-state
2357
- const CCR_REPLACEMENTS = {
2358
- 0x80: 0x20ac,
2359
- 0x82: 0x201a,
2360
- 0x83: 0x0192,
2361
- 0x84: 0x201e,
2362
- 0x85: 0x2026,
2363
- 0x86: 0x2020,
2364
- 0x87: 0x2021,
2365
- 0x88: 0x02c6,
2366
- 0x89: 0x2030,
2367
- 0x8a: 0x0160,
2368
- 0x8b: 0x2039,
2369
- 0x8c: 0x0152,
2370
- 0x8e: 0x017d,
2371
- 0x91: 0x2018,
2372
- 0x92: 0x2019,
2373
- 0x93: 0x201c,
2374
- 0x94: 0x201d,
2375
- 0x95: 0x2022,
2376
- 0x96: 0x2013,
2377
- 0x97: 0x2014,
2378
- 0x98: 0x02dc,
2379
- 0x99: 0x2122,
2380
- 0x9a: 0x0161,
2381
- 0x9b: 0x203a,
2382
- 0x9c: 0x0153,
2383
- 0x9e: 0x017e,
2384
- 0x9f: 0x0178
2265
+ // lazy compute this to make this file tree-shakable for browser
2266
+ let maxCRNameLength;
2267
+ const decodeHtml = (rawText, asAttr) => {
2268
+ let offset = 0;
2269
+ const end = rawText.length;
2270
+ let decodedText = '';
2271
+ function advance(length) {
2272
+ offset += length;
2273
+ rawText = rawText.slice(length);
2274
+ }
2275
+ while (offset < end) {
2276
+ const head = /&(?:#x?)?/i.exec(rawText);
2277
+ if (!head || offset + head.index >= end) {
2278
+ const remaining = end - offset;
2279
+ decodedText += rawText.slice(0, remaining);
2280
+ advance(remaining);
2281
+ break;
2282
+ }
2283
+ // Advance to the "&".
2284
+ decodedText += rawText.slice(0, head.index);
2285
+ advance(head.index);
2286
+ if (head[0] === '&') {
2287
+ // Named character reference.
2288
+ let name = '';
2289
+ let value = undefined;
2290
+ if (/[0-9a-z]/i.test(rawText[1])) {
2291
+ if (!maxCRNameLength) {
2292
+ maxCRNameLength = Object.keys(namedCharacterReferences).reduce((max, name) => Math.max(max, name.length), 0);
2293
+ }
2294
+ for (let length = maxCRNameLength; !value && length > 0; --length) {
2295
+ name = rawText.slice(1, 1 + length);
2296
+ value = namedCharacterReferences[name];
2297
+ }
2298
+ if (value) {
2299
+ const semi = name.endsWith(';');
2300
+ if (asAttr &&
2301
+ !semi &&
2302
+ /[=a-z0-9]/i.test(rawText[name.length + 1] || '')) {
2303
+ decodedText += '&' + name;
2304
+ advance(1 + name.length);
2305
+ }
2306
+ else {
2307
+ decodedText += value;
2308
+ advance(1 + name.length);
2309
+ }
2310
+ }
2311
+ else {
2312
+ decodedText += '&' + name;
2313
+ advance(1 + name.length);
2314
+ }
2315
+ }
2316
+ else {
2317
+ decodedText += '&';
2318
+ advance(1);
2319
+ }
2320
+ }
2321
+ else {
2322
+ // Numeric character reference.
2323
+ const hex = head[0] === '&#x';
2324
+ const pattern = hex ? /^&#x([0-9a-f]+);?/i : /^&#([0-9]+);?/;
2325
+ const body = pattern.exec(rawText);
2326
+ if (!body) {
2327
+ decodedText += head[0];
2328
+ advance(head[0].length);
2329
+ }
2330
+ else {
2331
+ // https://html.spec.whatwg.org/multipage/parsing.html#numeric-character-reference-end-state
2332
+ let cp = Number.parseInt(body[1], hex ? 16 : 10);
2333
+ if (cp === 0) {
2334
+ cp = 0xfffd;
2335
+ }
2336
+ else if (cp > 0x10ffff) {
2337
+ cp = 0xfffd;
2338
+ }
2339
+ else if (cp >= 0xd800 && cp <= 0xdfff) {
2340
+ cp = 0xfffd;
2341
+ }
2342
+ else if ((cp >= 0xfdd0 && cp <= 0xfdef) || (cp & 0xfffe) === 0xfffe) ;
2343
+ else if ((cp >= 0x01 && cp <= 0x08) ||
2344
+ cp === 0x0b ||
2345
+ (cp >= 0x0d && cp <= 0x1f) ||
2346
+ (cp >= 0x7f && cp <= 0x9f)) {
2347
+ cp = CCR_REPLACEMENTS[cp] || cp;
2348
+ }
2349
+ decodedText += String.fromCodePoint(cp);
2350
+ advance(body[0].length);
2351
+ }
2352
+ }
2353
+ }
2354
+ return decodedText;
2355
+ };
2356
+ // https://html.spec.whatwg.org/multipage/parsing.html#numeric-character-reference-end-state
2357
+ const CCR_REPLACEMENTS = {
2358
+ 0x80: 0x20ac,
2359
+ 0x82: 0x201a,
2360
+ 0x83: 0x0192,
2361
+ 0x84: 0x201e,
2362
+ 0x85: 0x2026,
2363
+ 0x86: 0x2020,
2364
+ 0x87: 0x2021,
2365
+ 0x88: 0x02c6,
2366
+ 0x89: 0x2030,
2367
+ 0x8a: 0x0160,
2368
+ 0x8b: 0x2039,
2369
+ 0x8c: 0x0152,
2370
+ 0x8e: 0x017d,
2371
+ 0x91: 0x2018,
2372
+ 0x92: 0x2019,
2373
+ 0x93: 0x201c,
2374
+ 0x94: 0x201d,
2375
+ 0x95: 0x2022,
2376
+ 0x96: 0x2013,
2377
+ 0x97: 0x2014,
2378
+ 0x98: 0x02dc,
2379
+ 0x99: 0x2122,
2380
+ 0x9a: 0x0161,
2381
+ 0x9b: 0x203a,
2382
+ 0x9c: 0x0153,
2383
+ 0x9e: 0x017e,
2384
+ 0x9f: 0x0178
2385
2385
  };
2386
2386
 
2387
- const isRawTextContainer = /*#__PURE__*/ shared.makeMap('style,iframe,script,noscript', true);
2388
- const parserOptions = {
2389
- isVoidTag: shared.isVoidTag,
2390
- isNativeTag: tag => shared.isHTMLTag(tag) || shared.isSVGTag(tag),
2391
- isPreTag: tag => tag === 'pre',
2392
- decodeEntities: decodeHtml,
2393
- isBuiltInComponent: (tag) => {
2394
- if (compilerCore.isBuiltInType(tag, `Transition`)) {
2395
- return TRANSITION;
2396
- }
2397
- else if (compilerCore.isBuiltInType(tag, `TransitionGroup`)) {
2398
- return TRANSITION_GROUP;
2399
- }
2400
- },
2401
- // https://html.spec.whatwg.org/multipage/parsing.html#tree-construction-dispatcher
2402
- getNamespace(tag, parent) {
2403
- let ns = parent ? parent.ns : 0 /* DOMNamespaces.HTML */;
2404
- if (parent && ns === 2 /* DOMNamespaces.MATH_ML */) {
2405
- if (parent.tag === 'annotation-xml') {
2406
- if (tag === 'svg') {
2407
- return 1 /* DOMNamespaces.SVG */;
2408
- }
2409
- if (parent.props.some(a => a.type === 6 /* NodeTypes.ATTRIBUTE */ &&
2410
- a.name === 'encoding' &&
2411
- a.value != null &&
2412
- (a.value.content === 'text/html' ||
2413
- a.value.content === 'application/xhtml+xml'))) {
2414
- ns = 0 /* DOMNamespaces.HTML */;
2415
- }
2416
- }
2417
- else if (/^m(?:[ions]|text)$/.test(parent.tag) &&
2418
- tag !== 'mglyph' &&
2419
- tag !== 'malignmark') {
2420
- ns = 0 /* DOMNamespaces.HTML */;
2421
- }
2422
- }
2423
- else if (parent && ns === 1 /* DOMNamespaces.SVG */) {
2424
- if (parent.tag === 'foreignObject' ||
2425
- parent.tag === 'desc' ||
2426
- parent.tag === 'title') {
2427
- ns = 0 /* DOMNamespaces.HTML */;
2428
- }
2429
- }
2430
- if (ns === 0 /* DOMNamespaces.HTML */) {
2431
- if (tag === 'svg') {
2432
- return 1 /* DOMNamespaces.SVG */;
2433
- }
2434
- if (tag === 'math') {
2435
- return 2 /* DOMNamespaces.MATH_ML */;
2436
- }
2437
- }
2438
- return ns;
2439
- },
2440
- // https://html.spec.whatwg.org/multipage/parsing.html#parsing-html-fragments
2441
- getTextMode({ tag, ns }) {
2442
- if (ns === 0 /* DOMNamespaces.HTML */) {
2443
- if (tag === 'textarea' || tag === 'title') {
2444
- return 1 /* TextModes.RCDATA */;
2445
- }
2446
- if (isRawTextContainer(tag)) {
2447
- return 2 /* TextModes.RAWTEXT */;
2448
- }
2449
- }
2450
- return 0 /* TextModes.DATA */;
2451
- }
2387
+ const isRawTextContainer = /*#__PURE__*/ shared.makeMap('style,iframe,script,noscript', true);
2388
+ const parserOptions = {
2389
+ isVoidTag: shared.isVoidTag,
2390
+ isNativeTag: tag => shared.isHTMLTag(tag) || shared.isSVGTag(tag),
2391
+ isPreTag: tag => tag === 'pre',
2392
+ decodeEntities: decodeHtml,
2393
+ isBuiltInComponent: (tag) => {
2394
+ if (compilerCore.isBuiltInType(tag, `Transition`)) {
2395
+ return TRANSITION;
2396
+ }
2397
+ else if (compilerCore.isBuiltInType(tag, `TransitionGroup`)) {
2398
+ return TRANSITION_GROUP;
2399
+ }
2400
+ },
2401
+ // https://html.spec.whatwg.org/multipage/parsing.html#tree-construction-dispatcher
2402
+ getNamespace(tag, parent) {
2403
+ let ns = parent ? parent.ns : 0 /* DOMNamespaces.HTML */;
2404
+ if (parent && ns === 2 /* DOMNamespaces.MATH_ML */) {
2405
+ if (parent.tag === 'annotation-xml') {
2406
+ if (tag === 'svg') {
2407
+ return 1 /* DOMNamespaces.SVG */;
2408
+ }
2409
+ if (parent.props.some(a => a.type === 6 /* NodeTypes.ATTRIBUTE */ &&
2410
+ a.name === 'encoding' &&
2411
+ a.value != null &&
2412
+ (a.value.content === 'text/html' ||
2413
+ a.value.content === 'application/xhtml+xml'))) {
2414
+ ns = 0 /* DOMNamespaces.HTML */;
2415
+ }
2416
+ }
2417
+ else if (/^m(?:[ions]|text)$/.test(parent.tag) &&
2418
+ tag !== 'mglyph' &&
2419
+ tag !== 'malignmark') {
2420
+ ns = 0 /* DOMNamespaces.HTML */;
2421
+ }
2422
+ }
2423
+ else if (parent && ns === 1 /* DOMNamespaces.SVG */) {
2424
+ if (parent.tag === 'foreignObject' ||
2425
+ parent.tag === 'desc' ||
2426
+ parent.tag === 'title') {
2427
+ ns = 0 /* DOMNamespaces.HTML */;
2428
+ }
2429
+ }
2430
+ if (ns === 0 /* DOMNamespaces.HTML */) {
2431
+ if (tag === 'svg') {
2432
+ return 1 /* DOMNamespaces.SVG */;
2433
+ }
2434
+ if (tag === 'math') {
2435
+ return 2 /* DOMNamespaces.MATH_ML */;
2436
+ }
2437
+ }
2438
+ return ns;
2439
+ },
2440
+ // https://html.spec.whatwg.org/multipage/parsing.html#parsing-html-fragments
2441
+ getTextMode({ tag, ns }) {
2442
+ if (ns === 0 /* DOMNamespaces.HTML */) {
2443
+ if (tag === 'textarea' || tag === 'title') {
2444
+ return 1 /* TextModes.RCDATA */;
2445
+ }
2446
+ if (isRawTextContainer(tag)) {
2447
+ return 2 /* TextModes.RAWTEXT */;
2448
+ }
2449
+ }
2450
+ return 0 /* TextModes.DATA */;
2451
+ }
2452
2452
  };
2453
2453
 
2454
- // Parse inline CSS strings for static style attributes into an object.
2455
- // This is a NodeTransform since it works on the static `style` attribute and
2456
- // converts it into a dynamic equivalent:
2457
- // style="color: red" -> :style='{ "color": "red" }'
2458
- // It is then processed by `transformElement` and included in the generated
2459
- // props.
2460
- const transformStyle = node => {
2461
- if (node.type === 1 /* NodeTypes.ELEMENT */) {
2462
- node.props.forEach((p, i) => {
2463
- if (p.type === 6 /* NodeTypes.ATTRIBUTE */ && p.name === 'style' && p.value) {
2464
- // replace p with an expression node
2465
- node.props[i] = {
2466
- type: 7 /* NodeTypes.DIRECTIVE */,
2467
- name: `bind`,
2468
- arg: compilerCore.createSimpleExpression(`style`, true, p.loc),
2469
- exp: parseInlineCSS(p.value.content, p.loc),
2470
- modifiers: [],
2471
- loc: p.loc
2472
- };
2473
- }
2474
- });
2475
- }
2476
- };
2477
- const parseInlineCSS = (cssText, loc) => {
2478
- const normalized = shared.parseStringStyle(cssText);
2479
- return compilerCore.createSimpleExpression(JSON.stringify(normalized), false, loc, 3 /* ConstantTypes.CAN_STRINGIFY */);
2454
+ // Parse inline CSS strings for static style attributes into an object.
2455
+ // This is a NodeTransform since it works on the static `style` attribute and
2456
+ // converts it into a dynamic equivalent:
2457
+ // style="color: red" -> :style='{ "color": "red" }'
2458
+ // It is then processed by `transformElement` and included in the generated
2459
+ // props.
2460
+ const transformStyle = node => {
2461
+ if (node.type === 1 /* NodeTypes.ELEMENT */) {
2462
+ node.props.forEach((p, i) => {
2463
+ if (p.type === 6 /* NodeTypes.ATTRIBUTE */ && p.name === 'style' && p.value) {
2464
+ // replace p with an expression node
2465
+ node.props[i] = {
2466
+ type: 7 /* NodeTypes.DIRECTIVE */,
2467
+ name: `bind`,
2468
+ arg: compilerCore.createSimpleExpression(`style`, true, p.loc),
2469
+ exp: parseInlineCSS(p.value.content, p.loc),
2470
+ modifiers: [],
2471
+ loc: p.loc
2472
+ };
2473
+ }
2474
+ });
2475
+ }
2476
+ };
2477
+ const parseInlineCSS = (cssText, loc) => {
2478
+ const normalized = shared.parseStringStyle(cssText);
2479
+ return compilerCore.createSimpleExpression(JSON.stringify(normalized), false, loc, 3 /* ConstantTypes.CAN_STRINGIFY */);
2480
2480
  };
2481
2481
 
2482
- function createDOMCompilerError(code, loc) {
2483
- return compilerCore.createCompilerError(code, loc, DOMErrorMessages );
2484
- }
2485
- const DOMErrorMessages = {
2486
- [50 /* DOMErrorCodes.X_V_HTML_NO_EXPRESSION */]: `v-html is missing expression.`,
2487
- [51 /* DOMErrorCodes.X_V_HTML_WITH_CHILDREN */]: `v-html will override element children.`,
2488
- [52 /* DOMErrorCodes.X_V_TEXT_NO_EXPRESSION */]: `v-text is missing expression.`,
2489
- [53 /* DOMErrorCodes.X_V_TEXT_WITH_CHILDREN */]: `v-text will override element children.`,
2490
- [54 /* DOMErrorCodes.X_V_MODEL_ON_INVALID_ELEMENT */]: `v-model can only be used on <input>, <textarea> and <select> elements.`,
2491
- [55 /* DOMErrorCodes.X_V_MODEL_ARG_ON_ELEMENT */]: `v-model argument is not supported on plain elements.`,
2492
- [56 /* DOMErrorCodes.X_V_MODEL_ON_FILE_INPUT_ELEMENT */]: `v-model cannot be used on file inputs since they are read-only. Use a v-on:change listener instead.`,
2493
- [57 /* DOMErrorCodes.X_V_MODEL_UNNECESSARY_VALUE */]: `Unnecessary value binding used alongside v-model. It will interfere with v-model's behavior.`,
2494
- [58 /* DOMErrorCodes.X_V_SHOW_NO_EXPRESSION */]: `v-show is missing expression.`,
2495
- [59 /* DOMErrorCodes.X_TRANSITION_INVALID_CHILDREN */]: `<Transition> expects exactly one child element or component.`,
2496
- [60 /* DOMErrorCodes.X_IGNORED_SIDE_EFFECT_TAG */]: `Tags with side effect (<script> and <style>) are ignored in client component templates.`
2482
+ function createDOMCompilerError(code, loc) {
2483
+ return compilerCore.createCompilerError(code, loc, DOMErrorMessages );
2484
+ }
2485
+ const DOMErrorMessages = {
2486
+ [50 /* DOMErrorCodes.X_V_HTML_NO_EXPRESSION */]: `v-html is missing expression.`,
2487
+ [51 /* DOMErrorCodes.X_V_HTML_WITH_CHILDREN */]: `v-html will override element children.`,
2488
+ [52 /* DOMErrorCodes.X_V_TEXT_NO_EXPRESSION */]: `v-text is missing expression.`,
2489
+ [53 /* DOMErrorCodes.X_V_TEXT_WITH_CHILDREN */]: `v-text will override element children.`,
2490
+ [54 /* DOMErrorCodes.X_V_MODEL_ON_INVALID_ELEMENT */]: `v-model can only be used on <input>, <textarea> and <select> elements.`,
2491
+ [55 /* DOMErrorCodes.X_V_MODEL_ARG_ON_ELEMENT */]: `v-model argument is not supported on plain elements.`,
2492
+ [56 /* DOMErrorCodes.X_V_MODEL_ON_FILE_INPUT_ELEMENT */]: `v-model cannot be used on file inputs since they are read-only. Use a v-on:change listener instead.`,
2493
+ [57 /* DOMErrorCodes.X_V_MODEL_UNNECESSARY_VALUE */]: `Unnecessary value binding used alongside v-model. It will interfere with v-model's behavior.`,
2494
+ [58 /* DOMErrorCodes.X_V_SHOW_NO_EXPRESSION */]: `v-show is missing expression.`,
2495
+ [59 /* DOMErrorCodes.X_TRANSITION_INVALID_CHILDREN */]: `<Transition> expects exactly one child element or component.`,
2496
+ [60 /* DOMErrorCodes.X_IGNORED_SIDE_EFFECT_TAG */]: `Tags with side effect (<script> and <style>) are ignored in client component templates.`
2497
2497
  };
2498
2498
 
2499
- const transformVHtml = (dir, node, context) => {
2500
- const { exp, loc } = dir;
2501
- if (!exp) {
2502
- context.onError(createDOMCompilerError(50 /* DOMErrorCodes.X_V_HTML_NO_EXPRESSION */, loc));
2503
- }
2504
- if (node.children.length) {
2505
- context.onError(createDOMCompilerError(51 /* DOMErrorCodes.X_V_HTML_WITH_CHILDREN */, loc));
2506
- node.children.length = 0;
2507
- }
2508
- return {
2509
- props: [
2510
- compilerCore.createObjectProperty(compilerCore.createSimpleExpression(`innerHTML`, true, loc), exp || compilerCore.createSimpleExpression('', true))
2511
- ]
2512
- };
2499
+ const transformVHtml = (dir, node, context) => {
2500
+ const { exp, loc } = dir;
2501
+ if (!exp) {
2502
+ context.onError(createDOMCompilerError(50 /* DOMErrorCodes.X_V_HTML_NO_EXPRESSION */, loc));
2503
+ }
2504
+ if (node.children.length) {
2505
+ context.onError(createDOMCompilerError(51 /* DOMErrorCodes.X_V_HTML_WITH_CHILDREN */, loc));
2506
+ node.children.length = 0;
2507
+ }
2508
+ return {
2509
+ props: [
2510
+ compilerCore.createObjectProperty(compilerCore.createSimpleExpression(`innerHTML`, true, loc), exp || compilerCore.createSimpleExpression('', true))
2511
+ ]
2512
+ };
2513
2513
  };
2514
2514
 
2515
- const transformVText = (dir, node, context) => {
2516
- const { exp, loc } = dir;
2517
- if (!exp) {
2518
- context.onError(createDOMCompilerError(52 /* DOMErrorCodes.X_V_TEXT_NO_EXPRESSION */, loc));
2519
- }
2520
- if (node.children.length) {
2521
- context.onError(createDOMCompilerError(53 /* DOMErrorCodes.X_V_TEXT_WITH_CHILDREN */, loc));
2522
- node.children.length = 0;
2523
- }
2524
- return {
2525
- props: [
2526
- compilerCore.createObjectProperty(compilerCore.createSimpleExpression(`textContent`, true), exp
2527
- ? compilerCore.getConstantType(exp, context) > 0
2528
- ? exp
2529
- : compilerCore.createCallExpression(context.helperString(compilerCore.TO_DISPLAY_STRING), [exp], loc)
2530
- : compilerCore.createSimpleExpression('', true))
2531
- ]
2532
- };
2515
+ const transformVText = (dir, node, context) => {
2516
+ const { exp, loc } = dir;
2517
+ if (!exp) {
2518
+ context.onError(createDOMCompilerError(52 /* DOMErrorCodes.X_V_TEXT_NO_EXPRESSION */, loc));
2519
+ }
2520
+ if (node.children.length) {
2521
+ context.onError(createDOMCompilerError(53 /* DOMErrorCodes.X_V_TEXT_WITH_CHILDREN */, loc));
2522
+ node.children.length = 0;
2523
+ }
2524
+ return {
2525
+ props: [
2526
+ compilerCore.createObjectProperty(compilerCore.createSimpleExpression(`textContent`, true), exp
2527
+ ? compilerCore.getConstantType(exp, context) > 0
2528
+ ? exp
2529
+ : compilerCore.createCallExpression(context.helperString(compilerCore.TO_DISPLAY_STRING), [exp], loc)
2530
+ : compilerCore.createSimpleExpression('', true))
2531
+ ]
2532
+ };
2533
2533
  };
2534
2534
 
2535
- const transformModel = (dir, node, context) => {
2536
- const baseResult = compilerCore.transformModel(dir, node, context);
2537
- // base transform has errors OR component v-model (only need props)
2538
- if (!baseResult.props.length || node.tagType === 1 /* ElementTypes.COMPONENT */) {
2539
- return baseResult;
2540
- }
2541
- if (dir.arg) {
2542
- context.onError(createDOMCompilerError(55 /* DOMErrorCodes.X_V_MODEL_ARG_ON_ELEMENT */, dir.arg.loc));
2543
- }
2544
- const { tag } = node;
2545
- const isCustomElement = context.isCustomElement(tag);
2546
- if (tag === 'input' ||
2547
- tag === 'textarea' ||
2548
- tag === 'select' ||
2549
- isCustomElement) {
2550
- let directiveToUse = V_MODEL_TEXT;
2551
- let isInvalidType = false;
2552
- if (tag === 'input' || isCustomElement) {
2553
- const type = compilerCore.findProp(node, `type`);
2554
- if (type) {
2555
- if (type.type === 7 /* NodeTypes.DIRECTIVE */) {
2556
- // :type="foo"
2557
- directiveToUse = V_MODEL_DYNAMIC;
2558
- }
2559
- else if (type.value) {
2560
- switch (type.value.content) {
2561
- case 'radio':
2562
- directiveToUse = V_MODEL_RADIO;
2563
- break;
2564
- case 'checkbox':
2565
- directiveToUse = V_MODEL_CHECKBOX;
2566
- break;
2567
- case 'file':
2568
- isInvalidType = true;
2569
- context.onError(createDOMCompilerError(56 /* DOMErrorCodes.X_V_MODEL_ON_FILE_INPUT_ELEMENT */, dir.loc));
2570
- break;
2571
- }
2572
- }
2573
- }
2574
- else if (compilerCore.hasDynamicKeyVBind(node)) {
2575
- // element has bindings with dynamic keys, which can possibly contain
2576
- // "type".
2577
- directiveToUse = V_MODEL_DYNAMIC;
2578
- }
2579
- else ;
2580
- }
2581
- else if (tag === 'select') {
2582
- directiveToUse = V_MODEL_SELECT;
2583
- }
2584
- else ;
2585
- // inject runtime directive
2586
- // by returning the helper symbol via needRuntime
2587
- // the import will replaced a resolveDirective call.
2588
- if (!isInvalidType) {
2589
- baseResult.needRuntime = context.helper(directiveToUse);
2590
- }
2591
- }
2592
- else {
2593
- context.onError(createDOMCompilerError(54 /* DOMErrorCodes.X_V_MODEL_ON_INVALID_ELEMENT */, dir.loc));
2594
- }
2595
- // native vmodel doesn't need the `modelValue` props since they are also
2596
- // passed to the runtime as `binding.value`. removing it reduces code size.
2597
- baseResult.props = baseResult.props.filter(p => !(p.key.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ &&
2598
- p.key.content === 'modelValue'));
2599
- return baseResult;
2535
+ const transformModel = (dir, node, context) => {
2536
+ const baseResult = compilerCore.transformModel(dir, node, context);
2537
+ // base transform has errors OR component v-model (only need props)
2538
+ if (!baseResult.props.length || node.tagType === 1 /* ElementTypes.COMPONENT */) {
2539
+ return baseResult;
2540
+ }
2541
+ if (dir.arg) {
2542
+ context.onError(createDOMCompilerError(55 /* DOMErrorCodes.X_V_MODEL_ARG_ON_ELEMENT */, dir.arg.loc));
2543
+ }
2544
+ const { tag } = node;
2545
+ const isCustomElement = context.isCustomElement(tag);
2546
+ if (tag === 'input' ||
2547
+ tag === 'textarea' ||
2548
+ tag === 'select' ||
2549
+ isCustomElement) {
2550
+ let directiveToUse = V_MODEL_TEXT;
2551
+ let isInvalidType = false;
2552
+ if (tag === 'input' || isCustomElement) {
2553
+ const type = compilerCore.findProp(node, `type`);
2554
+ if (type) {
2555
+ if (type.type === 7 /* NodeTypes.DIRECTIVE */) {
2556
+ // :type="foo"
2557
+ directiveToUse = V_MODEL_DYNAMIC;
2558
+ }
2559
+ else if (type.value) {
2560
+ switch (type.value.content) {
2561
+ case 'radio':
2562
+ directiveToUse = V_MODEL_RADIO;
2563
+ break;
2564
+ case 'checkbox':
2565
+ directiveToUse = V_MODEL_CHECKBOX;
2566
+ break;
2567
+ case 'file':
2568
+ isInvalidType = true;
2569
+ context.onError(createDOMCompilerError(56 /* DOMErrorCodes.X_V_MODEL_ON_FILE_INPUT_ELEMENT */, dir.loc));
2570
+ break;
2571
+ }
2572
+ }
2573
+ }
2574
+ else if (compilerCore.hasDynamicKeyVBind(node)) {
2575
+ // element has bindings with dynamic keys, which can possibly contain
2576
+ // "type".
2577
+ directiveToUse = V_MODEL_DYNAMIC;
2578
+ }
2579
+ else ;
2580
+ }
2581
+ else if (tag === 'select') {
2582
+ directiveToUse = V_MODEL_SELECT;
2583
+ }
2584
+ else ;
2585
+ // inject runtime directive
2586
+ // by returning the helper symbol via needRuntime
2587
+ // the import will replaced a resolveDirective call.
2588
+ if (!isInvalidType) {
2589
+ baseResult.needRuntime = context.helper(directiveToUse);
2590
+ }
2591
+ }
2592
+ else {
2593
+ context.onError(createDOMCompilerError(54 /* DOMErrorCodes.X_V_MODEL_ON_INVALID_ELEMENT */, dir.loc));
2594
+ }
2595
+ // native vmodel doesn't need the `modelValue` props since they are also
2596
+ // passed to the runtime as `binding.value`. removing it reduces code size.
2597
+ baseResult.props = baseResult.props.filter(p => !(p.key.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ &&
2598
+ p.key.content === 'modelValue'));
2599
+ return baseResult;
2600
2600
  };
2601
2601
 
2602
- const isEventOptionModifier = /*#__PURE__*/ shared.makeMap(`passive,once,capture`);
2603
- const isNonKeyModifier = /*#__PURE__*/ shared.makeMap(
2604
- // event propagation management
2605
- `stop,prevent,self,` +
2606
- // system modifiers + exact
2607
- `ctrl,shift,alt,meta,exact,` +
2608
- // mouse
2609
- `middle`);
2610
- // left & right could be mouse or key modifiers based on event type
2611
- const maybeKeyModifier = /*#__PURE__*/ shared.makeMap('left,right');
2612
- const isKeyboardEvent = /*#__PURE__*/ shared.makeMap(`onkeyup,onkeydown,onkeypress`, true);
2613
- const resolveModifiers = (key, modifiers, context, loc) => {
2614
- const keyModifiers = [];
2615
- const nonKeyModifiers = [];
2616
- const eventOptionModifiers = [];
2617
- for (let i = 0; i < modifiers.length; i++) {
2618
- const modifier = modifiers[i];
2619
- if (modifier === 'native' &&
2620
- compilerCore.checkCompatEnabled("COMPILER_V_ON_NATIVE" /* CompilerDeprecationTypes.COMPILER_V_ON_NATIVE */, context, loc)) {
2621
- eventOptionModifiers.push(modifier);
2622
- }
2623
- else if (isEventOptionModifier(modifier)) {
2624
- // eventOptionModifiers: modifiers for addEventListener() options,
2625
- // e.g. .passive & .capture
2626
- eventOptionModifiers.push(modifier);
2627
- }
2628
- else {
2629
- // runtimeModifiers: modifiers that needs runtime guards
2630
- if (maybeKeyModifier(modifier)) {
2631
- if (compilerCore.isStaticExp(key)) {
2632
- if (isKeyboardEvent(key.content)) {
2633
- keyModifiers.push(modifier);
2634
- }
2635
- else {
2636
- nonKeyModifiers.push(modifier);
2637
- }
2638
- }
2639
- else {
2640
- keyModifiers.push(modifier);
2641
- nonKeyModifiers.push(modifier);
2642
- }
2643
- }
2644
- else {
2645
- if (isNonKeyModifier(modifier)) {
2646
- nonKeyModifiers.push(modifier);
2647
- }
2648
- else {
2649
- keyModifiers.push(modifier);
2650
- }
2651
- }
2652
- }
2653
- }
2654
- return {
2655
- keyModifiers,
2656
- nonKeyModifiers,
2657
- eventOptionModifiers
2658
- };
2659
- };
2660
- const transformClick = (key, event) => {
2661
- const isStaticClick = compilerCore.isStaticExp(key) && key.content.toLowerCase() === 'onclick';
2662
- return isStaticClick
2663
- ? compilerCore.createSimpleExpression(event, true)
2664
- : key.type !== 4 /* NodeTypes.SIMPLE_EXPRESSION */
2665
- ? compilerCore.createCompoundExpression([
2666
- `(`,
2667
- key,
2668
- `) === "onClick" ? "${event}" : (`,
2669
- key,
2670
- `)`
2671
- ])
2672
- : key;
2673
- };
2674
- const transformOn = (dir, node, context) => {
2675
- return compilerCore.transformOn(dir, node, context, baseResult => {
2676
- const { modifiers } = dir;
2677
- if (!modifiers.length)
2678
- return baseResult;
2679
- let { key, value: handlerExp } = baseResult.props[0];
2680
- const { keyModifiers, nonKeyModifiers, eventOptionModifiers } = resolveModifiers(key, modifiers, context, dir.loc);
2681
- // normalize click.right and click.middle since they don't actually fire
2682
- if (nonKeyModifiers.includes('right')) {
2683
- key = transformClick(key, `onContextmenu`);
2684
- }
2685
- if (nonKeyModifiers.includes('middle')) {
2686
- key = transformClick(key, `onMouseup`);
2687
- }
2688
- if (nonKeyModifiers.length) {
2689
- handlerExp = compilerCore.createCallExpression(context.helper(V_ON_WITH_MODIFIERS), [
2690
- handlerExp,
2691
- JSON.stringify(nonKeyModifiers)
2692
- ]);
2693
- }
2694
- if (keyModifiers.length &&
2695
- // if event name is dynamic, always wrap with keys guard
2696
- (!compilerCore.isStaticExp(key) || isKeyboardEvent(key.content))) {
2697
- handlerExp = compilerCore.createCallExpression(context.helper(V_ON_WITH_KEYS), [
2698
- handlerExp,
2699
- JSON.stringify(keyModifiers)
2700
- ]);
2701
- }
2702
- if (eventOptionModifiers.length) {
2703
- const modifierPostfix = eventOptionModifiers.map(shared.capitalize).join('');
2704
- key = compilerCore.isStaticExp(key)
2705
- ? compilerCore.createSimpleExpression(`${key.content}${modifierPostfix}`, true)
2706
- : compilerCore.createCompoundExpression([`(`, key, `) + "${modifierPostfix}"`]);
2707
- }
2708
- return {
2709
- props: [compilerCore.createObjectProperty(key, handlerExp)]
2710
- };
2711
- });
2602
+ const isEventOptionModifier = /*#__PURE__*/ shared.makeMap(`passive,once,capture`);
2603
+ const isNonKeyModifier = /*#__PURE__*/ shared.makeMap(
2604
+ // event propagation management
2605
+ `stop,prevent,self,` +
2606
+ // system modifiers + exact
2607
+ `ctrl,shift,alt,meta,exact,` +
2608
+ // mouse
2609
+ `middle`);
2610
+ // left & right could be mouse or key modifiers based on event type
2611
+ const maybeKeyModifier = /*#__PURE__*/ shared.makeMap('left,right');
2612
+ const isKeyboardEvent = /*#__PURE__*/ shared.makeMap(`onkeyup,onkeydown,onkeypress`, true);
2613
+ const resolveModifiers = (key, modifiers, context, loc) => {
2614
+ const keyModifiers = [];
2615
+ const nonKeyModifiers = [];
2616
+ const eventOptionModifiers = [];
2617
+ for (let i = 0; i < modifiers.length; i++) {
2618
+ const modifier = modifiers[i];
2619
+ if (modifier === 'native' &&
2620
+ compilerCore.checkCompatEnabled("COMPILER_V_ON_NATIVE" /* CompilerDeprecationTypes.COMPILER_V_ON_NATIVE */, context, loc)) {
2621
+ eventOptionModifiers.push(modifier);
2622
+ }
2623
+ else if (isEventOptionModifier(modifier)) {
2624
+ // eventOptionModifiers: modifiers for addEventListener() options,
2625
+ // e.g. .passive & .capture
2626
+ eventOptionModifiers.push(modifier);
2627
+ }
2628
+ else {
2629
+ // runtimeModifiers: modifiers that needs runtime guards
2630
+ if (maybeKeyModifier(modifier)) {
2631
+ if (compilerCore.isStaticExp(key)) {
2632
+ if (isKeyboardEvent(key.content)) {
2633
+ keyModifiers.push(modifier);
2634
+ }
2635
+ else {
2636
+ nonKeyModifiers.push(modifier);
2637
+ }
2638
+ }
2639
+ else {
2640
+ keyModifiers.push(modifier);
2641
+ nonKeyModifiers.push(modifier);
2642
+ }
2643
+ }
2644
+ else {
2645
+ if (isNonKeyModifier(modifier)) {
2646
+ nonKeyModifiers.push(modifier);
2647
+ }
2648
+ else {
2649
+ keyModifiers.push(modifier);
2650
+ }
2651
+ }
2652
+ }
2653
+ }
2654
+ return {
2655
+ keyModifiers,
2656
+ nonKeyModifiers,
2657
+ eventOptionModifiers
2658
+ };
2659
+ };
2660
+ const transformClick = (key, event) => {
2661
+ const isStaticClick = compilerCore.isStaticExp(key) && key.content.toLowerCase() === 'onclick';
2662
+ return isStaticClick
2663
+ ? compilerCore.createSimpleExpression(event, true)
2664
+ : key.type !== 4 /* NodeTypes.SIMPLE_EXPRESSION */
2665
+ ? compilerCore.createCompoundExpression([
2666
+ `(`,
2667
+ key,
2668
+ `) === "onClick" ? "${event}" : (`,
2669
+ key,
2670
+ `)`
2671
+ ])
2672
+ : key;
2673
+ };
2674
+ const transformOn = (dir, node, context) => {
2675
+ return compilerCore.transformOn(dir, node, context, baseResult => {
2676
+ const { modifiers } = dir;
2677
+ if (!modifiers.length)
2678
+ return baseResult;
2679
+ let { key, value: handlerExp } = baseResult.props[0];
2680
+ const { keyModifiers, nonKeyModifiers, eventOptionModifiers } = resolveModifiers(key, modifiers, context, dir.loc);
2681
+ // normalize click.right and click.middle since they don't actually fire
2682
+ if (nonKeyModifiers.includes('right')) {
2683
+ key = transformClick(key, `onContextmenu`);
2684
+ }
2685
+ if (nonKeyModifiers.includes('middle')) {
2686
+ key = transformClick(key, `onMouseup`);
2687
+ }
2688
+ if (nonKeyModifiers.length) {
2689
+ handlerExp = compilerCore.createCallExpression(context.helper(V_ON_WITH_MODIFIERS), [
2690
+ handlerExp,
2691
+ JSON.stringify(nonKeyModifiers)
2692
+ ]);
2693
+ }
2694
+ if (keyModifiers.length &&
2695
+ // if event name is dynamic, always wrap with keys guard
2696
+ (!compilerCore.isStaticExp(key) || isKeyboardEvent(key.content))) {
2697
+ handlerExp = compilerCore.createCallExpression(context.helper(V_ON_WITH_KEYS), [
2698
+ handlerExp,
2699
+ JSON.stringify(keyModifiers)
2700
+ ]);
2701
+ }
2702
+ if (eventOptionModifiers.length) {
2703
+ const modifierPostfix = eventOptionModifiers.map(shared.capitalize).join('');
2704
+ key = compilerCore.isStaticExp(key)
2705
+ ? compilerCore.createSimpleExpression(`${key.content}${modifierPostfix}`, true)
2706
+ : compilerCore.createCompoundExpression([`(`, key, `) + "${modifierPostfix}"`]);
2707
+ }
2708
+ return {
2709
+ props: [compilerCore.createObjectProperty(key, handlerExp)]
2710
+ };
2711
+ });
2712
2712
  };
2713
2713
 
2714
- const transformShow = (dir, node, context) => {
2715
- const { exp, loc } = dir;
2716
- if (!exp) {
2717
- context.onError(createDOMCompilerError(58 /* DOMErrorCodes.X_V_SHOW_NO_EXPRESSION */, loc));
2718
- }
2719
- return {
2720
- props: [],
2721
- needRuntime: context.helper(V_SHOW)
2722
- };
2714
+ const transformShow = (dir, node, context) => {
2715
+ const { exp, loc } = dir;
2716
+ if (!exp) {
2717
+ context.onError(createDOMCompilerError(58 /* DOMErrorCodes.X_V_SHOW_NO_EXPRESSION */, loc));
2718
+ }
2719
+ return {
2720
+ props: [],
2721
+ needRuntime: context.helper(V_SHOW)
2722
+ };
2723
2723
  };
2724
2724
 
2725
- /**
2726
- * This module is Node-only.
2727
- */
2728
- /**
2729
- * Regex for replacing placeholders for embedded constant variables
2730
- * (e.g. import URL string constants generated by compiler-sfc)
2731
- */
2732
- const expReplaceRE = /__VUE_EXP_START__(.*?)__VUE_EXP_END__/g;
2733
- /**
2734
- * Turn eligible hoisted static trees into stringified static nodes, e.g.
2735
- *
2736
- * ```js
2737
- * const _hoisted_1 = createStaticVNode(`<div class="foo">bar</div>`)
2738
- * ```
2739
- *
2740
- * A single static vnode can contain stringified content for **multiple**
2741
- * consecutive nodes (element and plain text), called a "chunk".
2742
- * `@vue/runtime-dom` will create the content via innerHTML in a hidden
2743
- * container element and insert all the nodes in place. The call must also
2744
- * provide the number of nodes contained in the chunk so that during hydration
2745
- * we can know how many nodes the static vnode should adopt.
2746
- *
2747
- * The optimization scans a children list that contains hoisted nodes, and
2748
- * tries to find the largest chunk of consecutive hoisted nodes before running
2749
- * into a non-hoisted node or the end of the list. A chunk is then converted
2750
- * into a single static vnode and replaces the hoisted expression of the first
2751
- * node in the chunk. Other nodes in the chunk are considered "merged" and
2752
- * therefore removed from both the hoist list and the children array.
2753
- *
2754
- * This optimization is only performed in Node.js.
2755
- */
2756
- const stringifyStatic = (children, context, parent) => {
2757
- // bail stringification for slot content
2758
- if (context.scopes.vSlot > 0) {
2759
- return;
2760
- }
2761
- let nc = 0; // current node count
2762
- let ec = 0; // current element with binding count
2763
- const currentChunk = [];
2764
- const stringifyCurrentChunk = (currentIndex) => {
2765
- if (nc >= 20 /* StringifyThresholds.NODE_COUNT */ ||
2766
- ec >= 5 /* StringifyThresholds.ELEMENT_WITH_BINDING_COUNT */) {
2767
- // combine all currently eligible nodes into a single static vnode call
2768
- const staticCall = compilerCore.createCallExpression(context.helper(compilerCore.CREATE_STATIC), [
2769
- JSON.stringify(currentChunk.map(node => stringifyNode(node, context)).join('')).replace(expReplaceRE, `" + $1 + "`),
2770
- // the 2nd argument indicates the number of DOM nodes this static vnode
2771
- // will insert / hydrate
2772
- String(currentChunk.length)
2773
- ]);
2774
- // replace the first node's hoisted expression with the static vnode call
2775
- replaceHoist(currentChunk[0], staticCall, context);
2776
- if (currentChunk.length > 1) {
2777
- for (let i = 1; i < currentChunk.length; i++) {
2778
- // for the merged nodes, set their hoisted expression to null
2779
- replaceHoist(currentChunk[i], null, context);
2780
- }
2781
- // also remove merged nodes from children
2782
- const deleteCount = currentChunk.length - 1;
2783
- children.splice(currentIndex - currentChunk.length + 1, deleteCount);
2784
- return deleteCount;
2785
- }
2786
- }
2787
- return 0;
2788
- };
2789
- let i = 0;
2790
- for (; i < children.length; i++) {
2791
- const child = children[i];
2792
- const hoisted = getHoistedNode(child);
2793
- if (hoisted) {
2794
- // presence of hoisted means child must be a stringifiable node
2795
- const node = child;
2796
- const result = analyzeNode(node);
2797
- if (result) {
2798
- // node is stringifiable, record state
2799
- nc += result[0];
2800
- ec += result[1];
2801
- currentChunk.push(node);
2802
- continue;
2803
- }
2804
- }
2805
- // we only reach here if we ran into a node that is not stringifiable
2806
- // check if currently analyzed nodes meet criteria for stringification.
2807
- // adjust iteration index
2808
- i -= stringifyCurrentChunk(i);
2809
- // reset state
2810
- nc = 0;
2811
- ec = 0;
2812
- currentChunk.length = 0;
2813
- }
2814
- // in case the last node was also stringifiable
2815
- stringifyCurrentChunk(i);
2816
- };
2817
- const getHoistedNode = (node) => ((node.type === 1 /* NodeTypes.ELEMENT */ && node.tagType === 0 /* ElementTypes.ELEMENT */) ||
2818
- node.type == 12 /* NodeTypes.TEXT_CALL */) &&
2819
- node.codegenNode &&
2820
- node.codegenNode.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ &&
2821
- node.codegenNode.hoisted;
2822
- const dataAriaRE = /^(data|aria)-/;
2823
- const isStringifiableAttr = (name, ns) => {
2824
- return ((ns === 0 /* DOMNamespaces.HTML */
2825
- ? shared.isKnownHtmlAttr(name)
2826
- : ns === 1 /* DOMNamespaces.SVG */
2827
- ? shared.isKnownSvgAttr(name)
2828
- : false) || dataAriaRE.test(name));
2829
- };
2830
- const replaceHoist = (node, replacement, context) => {
2831
- const hoistToReplace = node.codegenNode.hoisted;
2832
- context.hoists[context.hoists.indexOf(hoistToReplace)] = replacement;
2833
- };
2834
- const isNonStringifiable = /*#__PURE__*/ shared.makeMap(`caption,thead,tr,th,tbody,td,tfoot,colgroup,col`);
2835
- /**
2836
- * for a hoisted node, analyze it and return:
2837
- * - false: bailed (contains non-stringifiable props or runtime constant)
2838
- * - [nc, ec] where
2839
- * - nc is the number of nodes inside
2840
- * - ec is the number of element with bindings inside
2841
- */
2842
- function analyzeNode(node) {
2843
- if (node.type === 1 /* NodeTypes.ELEMENT */ && isNonStringifiable(node.tag)) {
2844
- return false;
2845
- }
2846
- if (node.type === 12 /* NodeTypes.TEXT_CALL */) {
2847
- return [1, 0];
2848
- }
2849
- let nc = 1; // node count
2850
- let ec = node.props.length > 0 ? 1 : 0; // element w/ binding count
2851
- let bailed = false;
2852
- const bail = () => {
2853
- bailed = true;
2854
- return false;
2855
- };
2856
- // TODO: check for cases where using innerHTML will result in different
2857
- // output compared to imperative node insertions.
2858
- // probably only need to check for most common case
2859
- // i.e. non-phrasing-content tags inside `<p>`
2860
- function walk(node) {
2861
- for (let i = 0; i < node.props.length; i++) {
2862
- const p = node.props[i];
2863
- // bail on non-attr bindings
2864
- if (p.type === 6 /* NodeTypes.ATTRIBUTE */ &&
2865
- !isStringifiableAttr(p.name, node.ns)) {
2866
- return bail();
2867
- }
2868
- if (p.type === 7 /* NodeTypes.DIRECTIVE */ && p.name === 'bind') {
2869
- // bail on non-attr bindings
2870
- if (p.arg &&
2871
- (p.arg.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */ ||
2872
- (p.arg.isStatic && !isStringifiableAttr(p.arg.content, node.ns)))) {
2873
- return bail();
2874
- }
2875
- if (p.exp &&
2876
- (p.exp.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */ ||
2877
- p.exp.constType < 3 /* ConstantTypes.CAN_STRINGIFY */)) {
2878
- return bail();
2879
- }
2880
- }
2881
- }
2882
- for (let i = 0; i < node.children.length; i++) {
2883
- nc++;
2884
- const child = node.children[i];
2885
- if (child.type === 1 /* NodeTypes.ELEMENT */) {
2886
- if (child.props.length > 0) {
2887
- ec++;
2888
- }
2889
- walk(child);
2890
- if (bailed) {
2891
- return false;
2892
- }
2893
- }
2894
- }
2895
- return true;
2896
- }
2897
- return walk(node) ? [nc, ec] : false;
2898
- }
2899
- function stringifyNode(node, context) {
2900
- if (shared.isString(node)) {
2901
- return node;
2902
- }
2903
- if (shared.isSymbol(node)) {
2904
- return ``;
2905
- }
2906
- switch (node.type) {
2907
- case 1 /* NodeTypes.ELEMENT */:
2908
- return stringifyElement(node, context);
2909
- case 2 /* NodeTypes.TEXT */:
2910
- return shared.escapeHtml(node.content);
2911
- case 3 /* NodeTypes.COMMENT */:
2912
- return `<!--${shared.escapeHtml(node.content)}-->`;
2913
- case 5 /* NodeTypes.INTERPOLATION */:
2914
- return shared.escapeHtml(shared.toDisplayString(evaluateConstant(node.content)));
2915
- case 8 /* NodeTypes.COMPOUND_EXPRESSION */:
2916
- return shared.escapeHtml(evaluateConstant(node));
2917
- case 12 /* NodeTypes.TEXT_CALL */:
2918
- return stringifyNode(node.content, context);
2919
- default:
2920
- // static trees will not contain if/for nodes
2921
- return '';
2922
- }
2923
- }
2924
- function stringifyElement(node, context) {
2925
- let res = `<${node.tag}`;
2926
- let innerHTML = '';
2927
- for (let i = 0; i < node.props.length; i++) {
2928
- const p = node.props[i];
2929
- if (p.type === 6 /* NodeTypes.ATTRIBUTE */) {
2930
- res += ` ${p.name}`;
2931
- if (p.value) {
2932
- res += `="${shared.escapeHtml(p.value.content)}"`;
2933
- }
2934
- }
2935
- else if (p.type === 7 /* NodeTypes.DIRECTIVE */) {
2936
- if (p.name === 'bind') {
2937
- const exp = p.exp;
2938
- if (exp.content[0] === '_') {
2939
- // internally generated string constant references
2940
- // e.g. imported URL strings via compiler-sfc transformAssetUrl plugin
2941
- res += ` ${p.arg.content}="__VUE_EXP_START__${exp.content}__VUE_EXP_END__"`;
2942
- continue;
2943
- }
2944
- // constant v-bind, e.g. :foo="1"
2945
- let evaluated = evaluateConstant(exp);
2946
- if (evaluated != null) {
2947
- const arg = p.arg && p.arg.content;
2948
- if (arg === 'class') {
2949
- evaluated = shared.normalizeClass(evaluated);
2950
- }
2951
- else if (arg === 'style') {
2952
- evaluated = shared.stringifyStyle(shared.normalizeStyle(evaluated));
2953
- }
2954
- res += ` ${p.arg.content}="${shared.escapeHtml(evaluated)}"`;
2955
- }
2956
- }
2957
- else if (p.name === 'html') {
2958
- // #5439 v-html with constant value
2959
- // not sure why would anyone do this but it can happen
2960
- innerHTML = evaluateConstant(p.exp);
2961
- }
2962
- else if (p.name === 'text') {
2963
- innerHTML = shared.escapeHtml(shared.toDisplayString(evaluateConstant(p.exp)));
2964
- }
2965
- }
2966
- }
2967
- if (context.scopeId) {
2968
- res += ` ${context.scopeId}`;
2969
- }
2970
- res += `>`;
2971
- if (innerHTML) {
2972
- res += innerHTML;
2973
- }
2974
- else {
2975
- for (let i = 0; i < node.children.length; i++) {
2976
- res += stringifyNode(node.children[i], context);
2977
- }
2978
- }
2979
- if (!shared.isVoidTag(node.tag)) {
2980
- res += `</${node.tag}>`;
2981
- }
2982
- return res;
2983
- }
2984
- // __UNSAFE__
2985
- // Reason: eval.
2986
- // It's technically safe to eval because only constant expressions are possible
2987
- // here, e.g. `{{ 1 }}` or `{{ 'foo' }}`
2988
- // in addition, constant exps bail on presence of parens so you can't even
2989
- // run JSFuck in here. But we mark it unsafe for security review purposes.
2990
- // (see compiler-core/src/transforms/transformExpression)
2991
- function evaluateConstant(exp) {
2992
- if (exp.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
2993
- return new Function(`return ${exp.content}`)();
2994
- }
2995
- else {
2996
- // compound
2997
- let res = ``;
2998
- exp.children.forEach(c => {
2999
- if (shared.isString(c) || shared.isSymbol(c)) {
3000
- return;
3001
- }
3002
- if (c.type === 2 /* NodeTypes.TEXT */) {
3003
- res += c.content;
3004
- }
3005
- else if (c.type === 5 /* NodeTypes.INTERPOLATION */) {
3006
- res += shared.toDisplayString(evaluateConstant(c.content));
3007
- }
3008
- else {
3009
- res += evaluateConstant(c);
3010
- }
3011
- });
3012
- return res;
3013
- }
2725
+ /**
2726
+ * This module is Node-only.
2727
+ */
2728
+ /**
2729
+ * Regex for replacing placeholders for embedded constant variables
2730
+ * (e.g. import URL string constants generated by compiler-sfc)
2731
+ */
2732
+ const expReplaceRE = /__VUE_EXP_START__(.*?)__VUE_EXP_END__/g;
2733
+ /**
2734
+ * Turn eligible hoisted static trees into stringified static nodes, e.g.
2735
+ *
2736
+ * ```js
2737
+ * const _hoisted_1 = createStaticVNode(`<div class="foo">bar</div>`)
2738
+ * ```
2739
+ *
2740
+ * A single static vnode can contain stringified content for **multiple**
2741
+ * consecutive nodes (element and plain text), called a "chunk".
2742
+ * `@vue/runtime-dom` will create the content via innerHTML in a hidden
2743
+ * container element and insert all the nodes in place. The call must also
2744
+ * provide the number of nodes contained in the chunk so that during hydration
2745
+ * we can know how many nodes the static vnode should adopt.
2746
+ *
2747
+ * The optimization scans a children list that contains hoisted nodes, and
2748
+ * tries to find the largest chunk of consecutive hoisted nodes before running
2749
+ * into a non-hoisted node or the end of the list. A chunk is then converted
2750
+ * into a single static vnode and replaces the hoisted expression of the first
2751
+ * node in the chunk. Other nodes in the chunk are considered "merged" and
2752
+ * therefore removed from both the hoist list and the children array.
2753
+ *
2754
+ * This optimization is only performed in Node.js.
2755
+ */
2756
+ const stringifyStatic = (children, context, parent) => {
2757
+ // bail stringification for slot content
2758
+ if (context.scopes.vSlot > 0) {
2759
+ return;
2760
+ }
2761
+ let nc = 0; // current node count
2762
+ let ec = 0; // current element with binding count
2763
+ const currentChunk = [];
2764
+ const stringifyCurrentChunk = (currentIndex) => {
2765
+ if (nc >= 20 /* StringifyThresholds.NODE_COUNT */ ||
2766
+ ec >= 5 /* StringifyThresholds.ELEMENT_WITH_BINDING_COUNT */) {
2767
+ // combine all currently eligible nodes into a single static vnode call
2768
+ const staticCall = compilerCore.createCallExpression(context.helper(compilerCore.CREATE_STATIC), [
2769
+ JSON.stringify(currentChunk.map(node => stringifyNode(node, context)).join('')).replace(expReplaceRE, `" + $1 + "`),
2770
+ // the 2nd argument indicates the number of DOM nodes this static vnode
2771
+ // will insert / hydrate
2772
+ String(currentChunk.length)
2773
+ ]);
2774
+ // replace the first node's hoisted expression with the static vnode call
2775
+ replaceHoist(currentChunk[0], staticCall, context);
2776
+ if (currentChunk.length > 1) {
2777
+ for (let i = 1; i < currentChunk.length; i++) {
2778
+ // for the merged nodes, set their hoisted expression to null
2779
+ replaceHoist(currentChunk[i], null, context);
2780
+ }
2781
+ // also remove merged nodes from children
2782
+ const deleteCount = currentChunk.length - 1;
2783
+ children.splice(currentIndex - currentChunk.length + 1, deleteCount);
2784
+ return deleteCount;
2785
+ }
2786
+ }
2787
+ return 0;
2788
+ };
2789
+ let i = 0;
2790
+ for (; i < children.length; i++) {
2791
+ const child = children[i];
2792
+ const hoisted = getHoistedNode(child);
2793
+ if (hoisted) {
2794
+ // presence of hoisted means child must be a stringifiable node
2795
+ const node = child;
2796
+ const result = analyzeNode(node);
2797
+ if (result) {
2798
+ // node is stringifiable, record state
2799
+ nc += result[0];
2800
+ ec += result[1];
2801
+ currentChunk.push(node);
2802
+ continue;
2803
+ }
2804
+ }
2805
+ // we only reach here if we ran into a node that is not stringifiable
2806
+ // check if currently analyzed nodes meet criteria for stringification.
2807
+ // adjust iteration index
2808
+ i -= stringifyCurrentChunk(i);
2809
+ // reset state
2810
+ nc = 0;
2811
+ ec = 0;
2812
+ currentChunk.length = 0;
2813
+ }
2814
+ // in case the last node was also stringifiable
2815
+ stringifyCurrentChunk(i);
2816
+ };
2817
+ const getHoistedNode = (node) => ((node.type === 1 /* NodeTypes.ELEMENT */ && node.tagType === 0 /* ElementTypes.ELEMENT */) ||
2818
+ node.type == 12 /* NodeTypes.TEXT_CALL */) &&
2819
+ node.codegenNode &&
2820
+ node.codegenNode.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ &&
2821
+ node.codegenNode.hoisted;
2822
+ const dataAriaRE = /^(data|aria)-/;
2823
+ const isStringifiableAttr = (name, ns) => {
2824
+ return ((ns === 0 /* DOMNamespaces.HTML */
2825
+ ? shared.isKnownHtmlAttr(name)
2826
+ : ns === 1 /* DOMNamespaces.SVG */
2827
+ ? shared.isKnownSvgAttr(name)
2828
+ : false) || dataAriaRE.test(name));
2829
+ };
2830
+ const replaceHoist = (node, replacement, context) => {
2831
+ const hoistToReplace = node.codegenNode.hoisted;
2832
+ context.hoists[context.hoists.indexOf(hoistToReplace)] = replacement;
2833
+ };
2834
+ const isNonStringifiable = /*#__PURE__*/ shared.makeMap(`caption,thead,tr,th,tbody,td,tfoot,colgroup,col`);
2835
+ /**
2836
+ * for a hoisted node, analyze it and return:
2837
+ * - false: bailed (contains non-stringifiable props or runtime constant)
2838
+ * - [nc, ec] where
2839
+ * - nc is the number of nodes inside
2840
+ * - ec is the number of element with bindings inside
2841
+ */
2842
+ function analyzeNode(node) {
2843
+ if (node.type === 1 /* NodeTypes.ELEMENT */ && isNonStringifiable(node.tag)) {
2844
+ return false;
2845
+ }
2846
+ if (node.type === 12 /* NodeTypes.TEXT_CALL */) {
2847
+ return [1, 0];
2848
+ }
2849
+ let nc = 1; // node count
2850
+ let ec = node.props.length > 0 ? 1 : 0; // element w/ binding count
2851
+ let bailed = false;
2852
+ const bail = () => {
2853
+ bailed = true;
2854
+ return false;
2855
+ };
2856
+ // TODO: check for cases where using innerHTML will result in different
2857
+ // output compared to imperative node insertions.
2858
+ // probably only need to check for most common case
2859
+ // i.e. non-phrasing-content tags inside `<p>`
2860
+ function walk(node) {
2861
+ for (let i = 0; i < node.props.length; i++) {
2862
+ const p = node.props[i];
2863
+ // bail on non-attr bindings
2864
+ if (p.type === 6 /* NodeTypes.ATTRIBUTE */ &&
2865
+ !isStringifiableAttr(p.name, node.ns)) {
2866
+ return bail();
2867
+ }
2868
+ if (p.type === 7 /* NodeTypes.DIRECTIVE */ && p.name === 'bind') {
2869
+ // bail on non-attr bindings
2870
+ if (p.arg &&
2871
+ (p.arg.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */ ||
2872
+ (p.arg.isStatic && !isStringifiableAttr(p.arg.content, node.ns)))) {
2873
+ return bail();
2874
+ }
2875
+ if (p.exp &&
2876
+ (p.exp.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */ ||
2877
+ p.exp.constType < 3 /* ConstantTypes.CAN_STRINGIFY */)) {
2878
+ return bail();
2879
+ }
2880
+ }
2881
+ }
2882
+ for (let i = 0; i < node.children.length; i++) {
2883
+ nc++;
2884
+ const child = node.children[i];
2885
+ if (child.type === 1 /* NodeTypes.ELEMENT */) {
2886
+ if (child.props.length > 0) {
2887
+ ec++;
2888
+ }
2889
+ walk(child);
2890
+ if (bailed) {
2891
+ return false;
2892
+ }
2893
+ }
2894
+ }
2895
+ return true;
2896
+ }
2897
+ return walk(node) ? [nc, ec] : false;
2898
+ }
2899
+ function stringifyNode(node, context) {
2900
+ if (shared.isString(node)) {
2901
+ return node;
2902
+ }
2903
+ if (shared.isSymbol(node)) {
2904
+ return ``;
2905
+ }
2906
+ switch (node.type) {
2907
+ case 1 /* NodeTypes.ELEMENT */:
2908
+ return stringifyElement(node, context);
2909
+ case 2 /* NodeTypes.TEXT */:
2910
+ return shared.escapeHtml(node.content);
2911
+ case 3 /* NodeTypes.COMMENT */:
2912
+ return `<!--${shared.escapeHtml(node.content)}-->`;
2913
+ case 5 /* NodeTypes.INTERPOLATION */:
2914
+ return shared.escapeHtml(shared.toDisplayString(evaluateConstant(node.content)));
2915
+ case 8 /* NodeTypes.COMPOUND_EXPRESSION */:
2916
+ return shared.escapeHtml(evaluateConstant(node));
2917
+ case 12 /* NodeTypes.TEXT_CALL */:
2918
+ return stringifyNode(node.content, context);
2919
+ default:
2920
+ // static trees will not contain if/for nodes
2921
+ return '';
2922
+ }
2923
+ }
2924
+ function stringifyElement(node, context) {
2925
+ let res = `<${node.tag}`;
2926
+ let innerHTML = '';
2927
+ for (let i = 0; i < node.props.length; i++) {
2928
+ const p = node.props[i];
2929
+ if (p.type === 6 /* NodeTypes.ATTRIBUTE */) {
2930
+ res += ` ${p.name}`;
2931
+ if (p.value) {
2932
+ res += `="${shared.escapeHtml(p.value.content)}"`;
2933
+ }
2934
+ }
2935
+ else if (p.type === 7 /* NodeTypes.DIRECTIVE */) {
2936
+ if (p.name === 'bind') {
2937
+ const exp = p.exp;
2938
+ if (exp.content[0] === '_') {
2939
+ // internally generated string constant references
2940
+ // e.g. imported URL strings via compiler-sfc transformAssetUrl plugin
2941
+ res += ` ${p.arg.content}="__VUE_EXP_START__${exp.content}__VUE_EXP_END__"`;
2942
+ continue;
2943
+ }
2944
+ // #6568
2945
+ if (shared.isBooleanAttr(p.arg.content) &&
2946
+ exp.content === 'false') {
2947
+ continue;
2948
+ }
2949
+ // constant v-bind, e.g. :foo="1"
2950
+ let evaluated = evaluateConstant(exp);
2951
+ if (evaluated != null) {
2952
+ const arg = p.arg && p.arg.content;
2953
+ if (arg === 'class') {
2954
+ evaluated = shared.normalizeClass(evaluated);
2955
+ }
2956
+ else if (arg === 'style') {
2957
+ evaluated = shared.stringifyStyle(shared.normalizeStyle(evaluated));
2958
+ }
2959
+ res += ` ${p.arg.content}="${shared.escapeHtml(evaluated)}"`;
2960
+ }
2961
+ }
2962
+ else if (p.name === 'html') {
2963
+ // #5439 v-html with constant value
2964
+ // not sure why would anyone do this but it can happen
2965
+ innerHTML = evaluateConstant(p.exp);
2966
+ }
2967
+ else if (p.name === 'text') {
2968
+ innerHTML = shared.escapeHtml(shared.toDisplayString(evaluateConstant(p.exp)));
2969
+ }
2970
+ }
2971
+ }
2972
+ if (context.scopeId) {
2973
+ res += ` ${context.scopeId}`;
2974
+ }
2975
+ res += `>`;
2976
+ if (innerHTML) {
2977
+ res += innerHTML;
2978
+ }
2979
+ else {
2980
+ for (let i = 0; i < node.children.length; i++) {
2981
+ res += stringifyNode(node.children[i], context);
2982
+ }
2983
+ }
2984
+ if (!shared.isVoidTag(node.tag)) {
2985
+ res += `</${node.tag}>`;
2986
+ }
2987
+ return res;
2988
+ }
2989
+ // __UNSAFE__
2990
+ // Reason: eval.
2991
+ // It's technically safe to eval because only constant expressions are possible
2992
+ // here, e.g. `{{ 1 }}` or `{{ 'foo' }}`
2993
+ // in addition, constant exps bail on presence of parens so you can't even
2994
+ // run JSFuck in here. But we mark it unsafe for security review purposes.
2995
+ // (see compiler-core/src/transforms/transformExpression)
2996
+ function evaluateConstant(exp) {
2997
+ if (exp.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
2998
+ return new Function(`return ${exp.content}`)();
2999
+ }
3000
+ else {
3001
+ // compound
3002
+ let res = ``;
3003
+ exp.children.forEach(c => {
3004
+ if (shared.isString(c) || shared.isSymbol(c)) {
3005
+ return;
3006
+ }
3007
+ if (c.type === 2 /* NodeTypes.TEXT */) {
3008
+ res += c.content;
3009
+ }
3010
+ else if (c.type === 5 /* NodeTypes.INTERPOLATION */) {
3011
+ res += shared.toDisplayString(evaluateConstant(c.content));
3012
+ }
3013
+ else {
3014
+ res += evaluateConstant(c);
3015
+ }
3016
+ });
3017
+ return res;
3018
+ }
3014
3019
  }
3015
3020
 
3016
- const ignoreSideEffectTags = (node, context) => {
3017
- if (node.type === 1 /* NodeTypes.ELEMENT */ &&
3018
- node.tagType === 0 /* ElementTypes.ELEMENT */ &&
3019
- (node.tag === 'script' || node.tag === 'style')) {
3020
- context.onError(createDOMCompilerError(60 /* DOMErrorCodes.X_IGNORED_SIDE_EFFECT_TAG */, node.loc));
3021
- context.removeNode();
3022
- }
3021
+ const ignoreSideEffectTags = (node, context) => {
3022
+ if (node.type === 1 /* NodeTypes.ELEMENT */ &&
3023
+ node.tagType === 0 /* ElementTypes.ELEMENT */ &&
3024
+ (node.tag === 'script' || node.tag === 'style')) {
3025
+ context.onError(createDOMCompilerError(60 /* DOMErrorCodes.X_IGNORED_SIDE_EFFECT_TAG */, node.loc));
3026
+ context.removeNode();
3027
+ }
3023
3028
  };
3024
3029
 
3025
- const DOMNodeTransforms = [
3026
- transformStyle,
3027
- ...([])
3028
- ];
3029
- const DOMDirectiveTransforms = {
3030
- cloak: compilerCore.noopDirectiveTransform,
3031
- html: transformVHtml,
3032
- text: transformVText,
3033
- model: transformModel,
3034
- on: transformOn,
3035
- show: transformShow
3036
- };
3037
- function compile(template, options = {}) {
3038
- return compilerCore.baseCompile(template, shared.extend({}, parserOptions, options, {
3039
- nodeTransforms: [
3040
- // ignore <script> and <tag>
3041
- // this is not put inside DOMNodeTransforms because that list is used
3042
- // by compiler-ssr to generate vnode fallback branches
3043
- ignoreSideEffectTags,
3044
- ...DOMNodeTransforms,
3045
- ...(options.nodeTransforms || [])
3046
- ],
3047
- directiveTransforms: shared.extend({}, DOMDirectiveTransforms, options.directiveTransforms || {}),
3048
- transformHoist: stringifyStatic
3049
- }));
3050
- }
3051
- function parse(template, options = {}) {
3052
- return compilerCore.baseParse(template, shared.extend({}, parserOptions, options));
3030
+ const DOMNodeTransforms = [
3031
+ transformStyle,
3032
+ ...([])
3033
+ ];
3034
+ const DOMDirectiveTransforms = {
3035
+ cloak: compilerCore.noopDirectiveTransform,
3036
+ html: transformVHtml,
3037
+ text: transformVText,
3038
+ model: transformModel,
3039
+ on: transformOn,
3040
+ show: transformShow
3041
+ };
3042
+ function compile(template, options = {}) {
3043
+ return compilerCore.baseCompile(template, shared.extend({}, parserOptions, options, {
3044
+ nodeTransforms: [
3045
+ // ignore <script> and <tag>
3046
+ // this is not put inside DOMNodeTransforms because that list is used
3047
+ // by compiler-ssr to generate vnode fallback branches
3048
+ ignoreSideEffectTags,
3049
+ ...DOMNodeTransforms,
3050
+ ...(options.nodeTransforms || [])
3051
+ ],
3052
+ directiveTransforms: shared.extend({}, DOMDirectiveTransforms, options.directiveTransforms || {}),
3053
+ transformHoist: stringifyStatic
3054
+ }));
3055
+ }
3056
+ function parse(template, options = {}) {
3057
+ return compilerCore.baseParse(template, shared.extend({}, parserOptions, options));
3053
3058
  }
3054
3059
 
3055
3060
  Object.keys(compilerCore).forEach(function (k) {