File tree 2 files changed +16
-1
lines changed
2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ var KIND = 'block';
15
15
*/
16
16
var Block = Statement . extends ( function Block ( kind , children , location ) {
17
17
Statement . apply ( this , [ kind || KIND , location ] ) ;
18
- this . children = children ;
18
+ this . children = children . filter ( Boolean ) ;
19
19
} ) ;
20
20
21
21
module . exports = Block ;
Original file line number Diff line number Diff line change @@ -102,4 +102,19 @@ describe('Test IF statements', function() {
102
102
ast . children [ 1 ] . alternate . kind . should . be . exactly ( 'block' ) ;
103
103
} ) ;
104
104
} ) ;
105
+ describe ( 'Issue #84' , function ( ) {
106
+ var ast = parser . parseCode ( [
107
+ '<?php if (true): ?>' ,
108
+ '<?php else: ?>' ,
109
+ '<?php endif; ?>'
110
+ ] . join ( '\n' ) , {
111
+ parser : { debug : false }
112
+ } ) ;
113
+ it ( 'if block should have zero children' , function ( ) {
114
+ ast . children [ 0 ] . body . children . length . should . be . exactly ( 0 ) ;
115
+ } ) ;
116
+ it ( 'else block should have zero children' , function ( ) {
117
+ ast . children [ 0 ] . alternate . children . length . should . be . exactly ( 0 ) ;
118
+ } ) ;
119
+ } ) ;
105
120
} ) ;
You can’t perform that action at this time.
0 commit comments