feat(compiler-core): whitespace handling strategy
This commit is contained in:
@@ -52,6 +52,10 @@ export interface ParserOptions
|
||||
* @default ['{{', '}}']
|
||||
*/
|
||||
delimiters?: [string, string]
|
||||
/**
|
||||
* Whitespace handling strategy
|
||||
*/
|
||||
whitespace?: 'preserve' | 'condense'
|
||||
/**
|
||||
* Only needed for DOM compilers
|
||||
*/
|
||||
|
||||
@@ -65,6 +65,7 @@ const decodeMap: Record<string, string> = {
|
||||
|
||||
export const defaultParserOptions: MergedParserOptions = {
|
||||
delimiters: [`{{`, `}}`],
|
||||
whitespace: 'condense',
|
||||
getNamespace: () => Namespaces.HTML,
|
||||
getTextMode: () => TextModes.DATA,
|
||||
isVoidTag: NO,
|
||||
@@ -219,10 +220,9 @@ function parseChildren(
|
||||
}
|
||||
}
|
||||
|
||||
// Whitespace management for more efficient output
|
||||
// (same as v2 whitespace: 'condense')
|
||||
// Whitespace handling strategy like v2
|
||||
let removedWhitespace = false
|
||||
if (mode !== TextModes.RAWTEXT && mode !== TextModes.RCDATA) {
|
||||
if (context.options.whitespace === 'condense' && mode !== TextModes.RAWTEXT && mode !== TextModes.RCDATA) {
|
||||
for (let i = 0; i < nodes.length; i++) {
|
||||
const node = nodes[i]
|
||||
if (!context.inPre && node.type === NodeTypes.TEXT) {
|
||||
|
||||
Reference in New Issue
Block a user