Skip to content

Commit

Permalink
fix: #117 兼容 ATextNode 直接为 interpolation 的情况
Browse files Browse the repository at this point in the history
  • Loading branch information
meixg committed Aug 9, 2021
1 parent 6023025 commit 7a2dd9a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ vendor/
/dist/
test/cases/*/ssr.js
test/cases/*/ssr.php
.vscode
.vscode
/example
3 changes: 2 additions & 1 deletion src/compilers/anode-compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ export class ANodeCompiler<T extends 'none' | 'typed'> {
}

private * compileText (aNode: ATextNode): Generator<Statement> {
const shouldEmitComment = TypeGuards.isExprTextNode(aNode.textExpr) && aNode.textExpr.original && !this.ssrOnly && !this.inScript
const shouldEmitComment = (TypeGuards.isExprTextNode(aNode.textExpr) || TypeGuards.isExprInterpNode(aNode.textExpr)) &&
aNode.textExpr.original && !this.ssrOnly && !this.inScript
const outputType = this.inScript ? OutputType.HTML : OutputType.ESCAPE_HTML
if (shouldEmitComment) yield createHTMLLiteralAppend('<!--s-text-->')
yield createHTMLExpressionAppend(sanExpr(aNode.textExpr, outputType))
Expand Down
4 changes: 2 additions & 2 deletions types/san.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ declare namespace San {
interface ANode {
isText?: boolean;
text?: string;
textExpr?: ExprTextNode | ExprStringNode | ExprAccessorNode;
textExpr?: ExprInterpNode | ExprTextNode | ExprStringNode | ExprAccessorNode;
children?: ANode[];
props: ANodeProperty[];
events: SanIndexedList<ExprNode>;
Expand All @@ -264,7 +264,7 @@ declare namespace San {
}

interface ATextNode extends ANode {
textExpr: ExprTextNode | ExprStringNode | ExprAccessorNode;
textExpr: ExprInterpNode | ExprTextNode | ExprStringNode | ExprAccessorNode;
}

interface ATemplateNode extends ANode {
Expand Down

0 comments on commit 7a2dd9a

Please sign in to comment.