[chore] improve performance by using `trimRight()` instead of regex replace (#7706)

pull/7816/head
Yosuke Ota 2 years ago committed by GitHub
parent d5efa2e446
commit 8d26b4a19d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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;
}

@ -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;

Loading…
Cancel
Save