Skip to content

Commit

Permalink
[chore] improve performance by using trimRight() instead of regex r…
Browse files Browse the repository at this point in the history
…eplace (#7706)
  • Loading branch information
ota-meshi committed Aug 23, 2022
1 parent d5efa2e commit 8d26b4a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/compiler/compile/render_ssr/index.ts
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/compiler/parse/index.ts
Expand Up @@ -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;

Expand Down

0 comments on commit 8d26b4a

Please sign in to comment.