diff --git a/src/compiler/compile/render_ssr/index.ts b/src/compiler/compile/render_ssr/index.ts index 9d2c1cc60b6..e256ba78fbf 100644 --- a/src/compiler/compile/render_ssr/index.ts +++ b/src/compiler/compile/render_ssr/index.ts @@ -237,7 +237,7 @@ function trim(nodes: TemplateNode[]) { const node = nodes[end - 1] as Text; if (node.type !== 'Text') break; - node.data = node.data.replace(/\s+$/, ''); + node.data = node.data.trimRight(); if (node.data) break; } diff --git a/src/compiler/parse/index.ts b/src/compiler/parse/index.ts index 836fb670cfd..e5e2260bc0f 100644 --- a/src/compiler/parse/index.ts +++ b/src/compiler/parse/index.ts @@ -34,7 +34,7 @@ export class Parser { throw new TypeError('Template must be a string'); } - this.template = template.replace(/\s+$/, ''); + this.template = template.trimRight(); this.filename = options.filename; this.customElement = options.customElement;