Skip to content

fix: reset vExpressionScriptState when ending mustache #256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 4, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/html/tokenizer.ts
Original file line number Diff line number Diff line change
@@ -1942,9 +1942,12 @@ export class Tokenizer {
this.startToken("VExpressionEnd")
this.appendTokenValue(RIGHT_CURLY_BRACKET, null)
this.appendTokenValue(RIGHT_CURLY_BRACKET, null)
return this.vExpressionScriptState
? this.vExpressionScriptState.state
: this.returnState
if (this.vExpressionScriptState) {
const state = this.vExpressionScriptState.state
this.vExpressionScriptState = null
return state
}
return this.returnState
}

this.appendTokenValue(RIGHT_CURLY_BRACKET, null)
618 changes: 618 additions & 0 deletions test/fixtures/ast/mustache-without-open-in-textarea/ast.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<template>
{{ 123 }}
<textarea> }} <div </textarea>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[
"<template",
">",
"\n ",
"{{",
"123",
"}}",
"\n ",
"<textarea",
">",
" ",
"}}",
" ",
"<div",
" ",
"</textarea",
">",
"\n",
"</template",
">",
"\n"
]
65 changes: 65 additions & 0 deletions test/fixtures/ast/mustache-without-open-in-textarea/tree.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
[
{
"type": "VElement",
"text": "<template>\n {{ 123 }}\n <textarea> }} <div </textarea>\n</template>",
"children": [
{
"type": "VStartTag",
"text": "<template>",
"children": []
},
{
"type": "VText",
"text": "\n ",
"children": []
},
{
"type": "VExpressionContainer",
"text": "{{ 123 }}",
"children": [
{
"type": "Literal",
"text": "123",
"children": []
}
]
},
{
"type": "VText",
"text": "\n ",
"children": []
},
{
"type": "VElement",
"text": "<textarea> }} <div </textarea>",
"children": [
{
"type": "VStartTag",
"text": "<textarea>",
"children": []
},
{
"type": "VText",
"text": " }} <div ",
"children": []
},
{
"type": "VEndTag",
"text": "</textarea>",
"children": []
}
]
},
{
"type": "VText",
"text": "\n",
"children": []
},
{
"type": "VEndTag",
"text": "</template>",
"children": []
}
]
}
]