Provide a `visit` function in @vue/compiler-dom
What problem does this feature solve?
It's very often to have a "visit pattern" implementation in a AST parser.
Currently, I can't find a proper way to modify(add or remove node) the AST, It would be really convenient to modify the parsed AST return by the parse
function.
What does the proposed API look like?
I'd like to see the API just like the graphql-js
's one.
https://graphql.org/graphql-js/language/#visit
import { parse, visit } from '@vue/compiler-dom'
const ast = parse(...)
visit(ast, ...)
import { parse, transform } from '@vue/compiler-dom'
const ast = parse(...)
transform(ast, {
nodeTransforms: [...]
})
Please read the source type definitions for transform options usage.
import { parse, transform } from '@vue/compiler-dom' const ast = parse(...) transform(ast, { nodeTransforms: [...] })
Please read the source type definitions for transform options usage.
Is there a generate method to convert ast to source string?
like this
const ast = parse(`<div>abc</div>`)
generate(ast) // `<div>abc</div>`