Skip to content

Commit

Permalink
fix(index): if tree not object
Browse files Browse the repository at this point in the history
  • Loading branch information
Scrum committed Feb 9, 2018
1 parent 6058917 commit 3fd9548
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@ PostHTML.prototype.process = function (tree, options) {
// sync mode
if (options.sync === true) {
this.plugins.forEach(function (plugin, index) {
// extension of options tree
tree = objectAssign(tree, this)
if (typeof tree === 'object') {
// extension of options tree
tree = objectAssign(tree, this)
}

var result

Expand All @@ -117,7 +119,7 @@ PostHTML.prototype.process = function (tree, options) {
}

// clearing the tree of options
if (index !== this.plugins.length - 1) {
if (index !== this.plugins.length - 1 && !options.skipParse) {
tree = [].concat(tree)
}

Expand All @@ -132,8 +134,10 @@ PostHTML.prototype.process = function (tree, options) {
var i = 0

var next = function (result, cb) {
// extension of options tree
result = objectAssign(result, this)
if (typeof result === 'object') {
// extension of options tree
result = objectAssign(result, this)
}

// all plugins called
if (this.plugins.length <= i) {
Expand Down

0 comments on commit 3fd9548

Please sign in to comment.