Skip to content

Commit b407b9d

Browse files
authored
Merge pull request microsoft#308 from ngyuki/fixes-307
Fix statement order when there are multiple Inline HTML
2 parents 63314e3 + 635d0ba commit b407b9d

File tree

4 files changed

+106
-1
lines changed

4 files changed

+106
-1
lines changed

src/Parser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ private function parseList($parentNode, int $listParseContext) {
197197
while (!$this->isListTerminator($listParseContext)) {
198198
if ($this->isValidListElement($listParseContext, $this->getCurrentToken())) {
199199
$element = $parseListElementFn($parentNode);
200+
$nodeArray[] = $element;
200201
if ($element instanceof Node) {
201202
$element->parent = $parentNode;
202203
if ($element instanceof InlineHtml && $element->echoStatement && $listParseContext === ParseContext::SourceElements) {
@@ -205,7 +206,6 @@ private function parseList($parentNode, int $listParseContext) {
205206
$element->echoStatement = null;
206207
}
207208
}
208-
$nodeArray[] = $element;
209209
continue;
210210
}
211211

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<span><?= $name ?></span>
2+
<span><?= $name ?></span>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
{
2+
"SourceFileNode": {
3+
"statementList": [
4+
{
5+
"InlineHtml": {
6+
"scriptSectionEndTag": null,
7+
"text": {
8+
"kind": "InlineHtml",
9+
"textLength": 6
10+
},
11+
"scriptSectionStartTag": {
12+
"kind": "ScriptSectionStartWithEchoTag",
13+
"textLength": 3
14+
}
15+
}
16+
},
17+
{
18+
"ExpressionStatement": {
19+
"expression": {
20+
"EchoExpression": {
21+
"echoKeyword": null,
22+
"expressions": {
23+
"ExpressionList": {
24+
"children": [
25+
{
26+
"Variable": {
27+
"dollar": null,
28+
"name": {
29+
"kind": "VariableName",
30+
"textLength": 5
31+
}
32+
}
33+
}
34+
]
35+
}
36+
}
37+
}
38+
},
39+
"semicolon": null
40+
}
41+
},
42+
{
43+
"InlineHtml": {
44+
"scriptSectionEndTag": {
45+
"kind": "ScriptSectionEndTag",
46+
"textLength": 2
47+
},
48+
"text": {
49+
"kind": "InlineHtml",
50+
"textLength": 14
51+
},
52+
"scriptSectionStartTag": {
53+
"kind": "ScriptSectionStartWithEchoTag",
54+
"textLength": 3
55+
}
56+
}
57+
},
58+
{
59+
"ExpressionStatement": {
60+
"expression": {
61+
"EchoExpression": {
62+
"echoKeyword": null,
63+
"expressions": {
64+
"ExpressionList": {
65+
"children": [
66+
{
67+
"Variable": {
68+
"dollar": null,
69+
"name": {
70+
"kind": "VariableName",
71+
"textLength": 5
72+
}
73+
}
74+
}
75+
]
76+
}
77+
}
78+
}
79+
},
80+
"semicolon": null
81+
}
82+
},
83+
{
84+
"InlineHtml": {
85+
"scriptSectionEndTag": {
86+
"kind": "ScriptSectionEndTag",
87+
"textLength": 2
88+
},
89+
"text": {
90+
"kind": "InlineHtml",
91+
"textLength": 8
92+
},
93+
"scriptSectionStartTag": null
94+
}
95+
}
96+
],
97+
"endOfFileToken": {
98+
"kind": "EndOfFileToken",
99+
"textLength": 0
100+
}
101+
}
102+
}

0 commit comments

Comments
 (0)