How to use the @vue/compiler-core.baseParse function in @vue/compiler-core

To help you get started, we’ve selected a few @vue/compiler-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vuejs / vue-next / packages / compiler-dom / __tests__ / parse.spec.ts View on Github external
test('void element', () => {
      const ast = parse('<img>after', parserOptions)
      const element = ast.children[0] as ElementNode

      expect(element).toStrictEqual({
        type: NodeTypes.ELEMENT,
        ns: DOMNamespaces.HTML,
        tag: 'img',
        tagType: ElementTypes.ELEMENT,
        props: [],
        isSelfClosing: false,
        children: [],
        loc: {
          start: { offset: 0, line: 1, column: 1 },
          end: { offset: 5, line: 1, column: 6 },
          source: '<img>'
        },
        codegenNode: undefined
github vuejs / vue-next / packages / compiler-dom / __tests__ / parse.spec.ts View on Github external
test('MATH in HTML namespace', () =&gt; {
      const ast = parse('<math></math>', parserOptions)
      const elementHtml = ast.children[0] as ElementNode
      const element = elementHtml.children[0] as ElementNode

      expect(elementHtml.ns).toBe(DOMNamespaces.HTML)
      expect(element.ns).toBe(DOMNamespaces.MATH_ML)
    })
  })
github vuejs / vue-next / packages / compiler-dom / __tests__ / parse.spec.ts View on Github external
test('HTML entities in interpolation should be translated for backward compatibility.', () =&gt; {
      const ast = parse('<div>{{ a &lt; b }}</div>', parserOptions)
      const element = ast.children[0] as ElementNode
      const interpolation = element.children[0] as InterpolationNode

      expect(interpolation).toStrictEqual({
        type: NodeTypes.INTERPOLATION,
        content: {
          type: NodeTypes.SIMPLE_EXPRESSION,
          content: `a &lt; b`,
          isStatic: false,
          isConstant: false,
          loc: {
            start: { offset: 8, line: 1, column: 9 },
            end: { offset: 16, line: 1, column: 17 },
            source: 'a &lt; b'
          }
        },
github vuejs / vue-next / packages / compiler-dom / __tests__ / parse.spec.ts View on Github external
test('foreignObject tag in SVG namespace', () =&gt; {
      const ast = parse(
        '<svg></svg>
github vuejs / vue-next / packages / compiler-dom / __tests__ / parse.spec.ts View on Github external
test('HTML namespace', () =&gt; {
      const ast = parse('test', parserOptions)
      const element = ast.children[0] as ElementNode

      expect(element.ns).toBe(DOMNamespaces.HTML)
    })
github vuejs / vue-next / packages / compiler-dom / __tests__ / transforms / vOn.spec.ts View on Github external
function parseWithVOn(template: string, options: CompilerOptions = {}) {
  const ast = parse(template)
  transform(ast, {
    nodeTransforms: [transformExpression, transformElement],
    directiveTransforms: {
      on: transformOn
    },
    ...options
  })
  return {
    root: ast,
    props: (((ast.children[0] as ElementNode).codegenNode as CallExpression)
      .arguments[1] as ObjectExpression).properties
  }
}
github vuejs / vue-next / packages / compiler-dom / __tests__ / transforms / vShow.spec.ts View on Github external
function transformWithShow(template: string, options: CompilerOptions = {}) {
  const ast = parse(template)
  transform(ast, {
    nodeTransforms: [transformElement],
    directiveTransforms: {
      show: transformShow
    },
    ...options
  })
  return ast
}
github vuejs / vue-next / packages / compiler-dom / __tests__ / transforms / vText.spec.ts View on Github external
function transformWithVText(template: string, options: CompilerOptions = {}) {
  const ast = parse(template)
  transform(ast, {
    nodeTransforms: [transformElement],
    directiveTransforms: {
      text: transformVText
    },
    ...options
  })
  return ast
}
github vuejs / vue-next / packages / compiler-dom / __tests__ / transforms / vHtml.spec.ts View on Github external
function transformWithVHtml(template: string, options: CompilerOptions = {}) {
  const ast = parse(template)
  transform(ast, {
    nodeTransforms: [transformElement],
    directiveTransforms: {
      html: transformVHtml
    },
    ...options
  })
  return ast
}