File tree Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -94,7 +94,9 @@ PostHTML.prototype.process = function (tree, options) {
94
94
if ( options . parser ) parser = options . parser
95
95
if ( options . render ) render = options . render
96
96
97
- tree = options . skipParse ? tree : parser ( tree , options )
97
+ tree = options . skipParse
98
+ ? tree || [ ]
99
+ : parser ( tree , options )
98
100
99
101
tree . options = options
100
102
tree . processor = this
Original file line number Diff line number Diff line change
1
+ var it = require ( 'mocha' ) . it
2
+ var expect = require ( 'chai' ) . expect
3
+ var describe = require ( 'mocha' ) . describe
4
+
5
+ var posthtml = require ( '../lib' )
6
+
7
+ var html = null
8
+
9
+ function test ( html , done ) {
10
+ posthtml ( )
11
+ . use ( function ( tree ) {
12
+ tree . walk ( function ( node ) { return node } )
13
+ tree . match ( / ( .+ ) / , function ( node ) { return node } )
14
+
15
+ tree . messages . push ( {
16
+ type : 'warning' ,
17
+ message : 'tree is empty'
18
+ } )
19
+
20
+ return tree
21
+ } )
22
+ . process ( html , { skipParse : true } )
23
+ . then ( function ( result ) {
24
+ expect ( '' ) . to . eql ( result . html )
25
+
26
+ done ( )
27
+ } )
28
+ . catch ( function ( error ) {
29
+ done ( error )
30
+ } )
31
+ }
32
+
33
+ describe ( 'Process' , function ( ) {
34
+ it ( 'should not throw on empty tree' , function ( done ) {
35
+ test ( html , done )
36
+ } )
37
+ } )
You can’t perform that action at this time.
0 commit comments