All files / compiler/src parserOptions.ts

92.86% Statements 39/42
77.78% Branches 7/9
83.33% Functions 5/6
92.86% Lines 39/42

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 431x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 8x 1x 8x   7x     8x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 12x 1x 1x 1x 1x 4x 1x 1x  
import {
  isBuiltInType,
  Namespaces,
  ParserOptions,
  TextModes,
} from '@vue/compiler-core'
import { decodeHtml } from './decodeHtml'
import { ACTION_BAR, TRANSITION, TRANSITION_GROUP } from './runtimeHelpers'
 
export const enum DOMNamespaces {
  HTML = Namespaces.HTML,
}
 
const isBuiltInComponent = (tag: string): symbol | undefined => {
  if (isBuiltInType(tag, `ActionBar`)) {
    return ACTION_BAR
  } else if (isBuiltInType(tag, `Transition`)) {
    return TRANSITION
  } else if (isBuiltInType(tag, `TransitionGroup`)) {
    return TRANSITION_GROUP
  }
}
 
export const parserOptions: ParserOptions = {
  // We don't have void tags in NativeScript (<br>, <hr> etc.)
  isVoidTag: () => false,
  isNativeTag: () => false,
  isPreTag: (tag) => tag === 'pre',
  isBuiltInComponent,
  decodeEntities: decodeHtml,
  // todo: we might add support for different namespaces in the future
  // for example - it would be neat to be able to write inline svg
  // with the svg plugin?
  getNamespace() {
    return DOMNamespaces.HTML
  },
 
  // https://html.spec.whatwg.org/multipage/parsing.html#parsing-html-fragments
  getTextMode() {
    return TextModes.DATA
  },
}