diff options
Diffstat (limited to 'packages/astro-parser/src/parse')
-rw-r--r-- | packages/astro-parser/src/parse/index.ts | 2 | ||||
-rw-r--r-- | packages/astro-parser/src/parse/read/expression.ts | 11 |
2 files changed, 8 insertions, 5 deletions
diff --git a/packages/astro-parser/src/parse/index.ts b/packages/astro-parser/src/parse/index.ts index 9b9f87073..ef33bfaca 100644 --- a/packages/astro-parser/src/parse/index.ts +++ b/packages/astro-parser/src/parse/index.ts @@ -29,7 +29,7 @@ export class Parser { js: Script[] = []; meta_tags = {}; last_auto_closed_tag?: LastAutoClosedTag; - feature_flags: 0; + feature_flags: number = 0; constructor(template: string, options: ParserOptions) { if (typeof template !== 'string') { diff --git a/packages/astro-parser/src/parse/read/expression.ts b/packages/astro-parser/src/parse/read/expression.ts index 98d94e26a..b4647ab06 100644 --- a/packages/astro-parser/src/parse/read/expression.ts +++ b/packages/astro-parser/src/parse/read/expression.ts @@ -9,6 +9,7 @@ interface ParseState { curlyCount: number; bracketCount: number; root: Expression; + parser: Parser; } function peek_char(state: ParseState) { @@ -159,12 +160,13 @@ function consume_tag(state: ParseState) { const source = state.source.substring(start, state.index); const ast = parseAstro(source); + state.parser.feature_flags |= ast.meta.features; const fragment = ast.html; return fragment; } -function consume_expression(source: string, start: number): Expression { +function consume_expression(parser: Parser, source: string, start: number): Expression { const expr: Expression = { type: 'Expression', start, @@ -182,6 +184,7 @@ function consume_expression(source: string, start: number): Expression { curlyCount: 1, bracketCount: 0, root: expr, + parser, }; do { @@ -234,15 +237,15 @@ function consume_expression(source: string, start: number): Expression { return expr; } -export const parse_expression_at = (source: string, index: number): Expression => { - const expression = consume_expression(source, index); +export const parse_expression_at = (parser: Parser, source: string, index: number): Expression => { + const expression = consume_expression(parser, source, index); return expression; }; export default function read_expression(parser: Parser) { try { - const expression = parse_expression_at(parser.template, parser.index); + const expression = parse_expression_at(parser, parser.template, parser.index); parser.index = expression.end; return expression; } catch (err) { |