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) {
178178 var values = [ ] ;
179179 var value ;
180180
181- if ( node . children && node . children . length ) {
181+ if ( node . children ) {
182182 log += dim ( '[' ) + yellow ( node . children . length ) + dim ( ']' ) ;
183- } else {
183+ } else if ( typeof node . value === 'string' ) {
184184 log += dim ( ': ' ) + green ( JSON . stringify ( node . value ) ) ;
185185 }
186186
Original file line number Diff line number Diff line change @@ -206,6 +206,33 @@ test('inspect()', function (t) {
206206 'should work with other attributes'
207207 ) ;
208208
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+
209236 t . equal (
210237 strip ( inspect ( {
211238 'type' : 'foo' ,
You can’t perform that action at this time.
0 commit comments