File tree Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -178,9 +178,9 @@ function formatNode(node) {
178
178
var values = [ ] ;
179
179
var value ;
180
180
181
- if ( node . children && node . children . length ) {
181
+ if ( node . children ) {
182
182
log += dim ( '[' ) + yellow ( node . children . length ) + dim ( ']' ) ;
183
- } else {
183
+ } else if ( typeof node . value === 'string' ) {
184
184
log += dim ( ': ' ) + green ( JSON . stringify ( node . value ) ) ;
185
185
}
186
186
Original file line number Diff line number Diff line change @@ -206,6 +206,33 @@ test('inspect()', function (t) {
206
206
'should work with other attributes'
207
207
) ;
208
208
209
+ t . equal (
210
+ strip ( inspect ( {
211
+ 'type' : 'element' ,
212
+ 'tagName' : 'br' ,
213
+ 'children' : [ ]
214
+ } ) ) ,
215
+ 'element[0] [tagName="br"]' ,
216
+ 'should work on parent nodes without children'
217
+ ) ;
218
+
219
+ t . equal (
220
+ strip ( inspect ( {
221
+ 'type' : 'text' ,
222
+ 'value' : ''
223
+ } ) ) ,
224
+ 'text: ""' ,
225
+ 'should work on text nodes without value'
226
+ ) ;
227
+
228
+ t . equal (
229
+ strip ( inspect ( {
230
+ 'type' : 'thematicBreak'
231
+ } ) ) ,
232
+ 'thematicBreak' ,
233
+ 'should work on void nodes'
234
+ ) ;
235
+
209
236
t . equal (
210
237
strip ( inspect ( {
211
238
'type' : 'foo' ,
You can’t perform that action at this time.
0 commit comments