Skip to content

Commit

Permalink
fix: initData 初始值为 Falsy 时会赋值成默认值
Browse files Browse the repository at this point in the history
  • Loading branch information
shirookie authored and harttle committed Feb 5, 2021
1 parent f01c94a commit 5f683d1
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 16 deletions.
26 changes: 13 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"eslint-plugin-standard": "^4.0.1",
"jest": "^26.2.2",
"san-html-cases": "^3.10.8",
"san-ssr": "^4.4.1",
"san-ssr": "^4.4.2",
"semantic-release": "^17.1.1",
"typedoc": "^0.17.8",
"wdio-sauce-service": "^0.4.14",
Expand All @@ -94,7 +94,7 @@
"yargs": "^15.4.1"
},
"peerDependencies": {
"san-ssr": "^4.4.1"
"san-ssr": "^4.4.2"
},
"release": {
"branch": "master",
Expand Down
28 changes: 27 additions & 1 deletion src/emitters/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export class PHPEmitter extends Emitter {
this.createComponentInstance(node.info)
break
case SyntaxKind.Null:
case SyntaxKind.Undefined:
this.write('null')
break
case SyntaxKind.NewExpression:
Expand Down Expand Up @@ -376,10 +377,35 @@ export class PHPEmitter extends Emitter {
this.writeSyntaxNode(node.rhs)
break
case '!=':
if (node.lhs.kind === SyntaxKind.Null) {
case '!==':
if (node.lhs.kind === SyntaxKind.Null ||
node.lhs.kind === SyntaxKind.Undefined) {
this.write('isset(')
this.writeSyntaxNode(node.rhs)
this.write(')')
} else if (node.rhs.kind === SyntaxKind.Null ||
node.rhs.kind === SyntaxKind.Undefined) {
this.write('isset(')
this.writeSyntaxNode(node.lhs)
this.write(')')
} else {
this.writeSyntaxNode(node.lhs)
this.write(` ${node.op} `)
this.writeSyntaxNode(node.rhs)
}
break
case '==':
case '===':
if (node.lhs.kind === SyntaxKind.Null ||
node.lhs.kind === SyntaxKind.Undefined) {
this.write('!isset(')
this.writeSyntaxNode(node.rhs)
this.write(')')
} else if (node.rhs.kind === SyntaxKind.Null ||
node.rhs.kind === SyntaxKind.Undefined) {
this.write('!isset(')
this.writeSyntaxNode(node.lhs)
this.write(')')
} else {
this.writeSyntaxNode(node.lhs)
this.write(` ${node.op} `)
Expand Down

0 comments on commit 5f683d1

Please sign in to comment.