summaryrefslogtreecommitdiff
path: root/packages/astro-parser/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/astro-parser/src')
-rw-r--r--packages/astro-parser/src/parse/state/mustache.ts5
-rw-r--r--packages/astro-parser/src/utils/trim.ts17
2 files changed, 2 insertions, 20 deletions
diff --git a/packages/astro-parser/src/parse/state/mustache.ts b/packages/astro-parser/src/parse/state/mustache.ts
index 79372d8d9..d07162049 100644
--- a/packages/astro-parser/src/parse/state/mustache.ts
+++ b/packages/astro-parser/src/parse/state/mustache.ts
@@ -2,7 +2,6 @@ import read_context from '../read/context.js';
import read_expression from '../read/expression.js';
import { closing_tag_omitted } from '../utils/html.js';
import { whitespace } from '../../utils/patterns.js';
-import { trim_start, trim_end } from '../../utils/trim.js';
import { to_string } from '../utils/node.js';
import { Parser } from '../index.js';
import { TemplateNode } from '../../interfaces.js';
@@ -16,12 +15,12 @@ function trim_whitespace(block: TemplateNode, trim_before: boolean, trim_after:
const last_child = block.children[block.children.length - 1];
if (first_child.type === 'Text' && trim_before) {
- first_child.data = trim_start(first_child.data);
+ first_child.data = first_child.data.trimStart();
if (!first_child.data) block.children.shift();
}
if (last_child.type === 'Text' && trim_after) {
- last_child.data = trim_end(last_child.data);
+ last_child.data = last_child.data.trimEnd();
if (!last_child.data) block.children.pop();
}
diff --git a/packages/astro-parser/src/utils/trim.ts b/packages/astro-parser/src/utils/trim.ts
deleted file mode 100644
index 480cc99a8..000000000
--- a/packages/astro-parser/src/utils/trim.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import { whitespace } from './patterns.js';
-
-/** Trim whitespace from start of string */
-export function trim_start(str: string) {
- let i = 0;
- while (whitespace.test(str[i])) i += 1;
-
- return str.slice(i);
-}
-
-/** Trim whitespace from end of string */
-export function trim_end(str: string) {
- let i = str.length;
- while (whitespace.test(str[i - 1])) i -= 1;
-
- return str.slice(0, i);
-}