Skip to content

Commit

Permalink
changed dom-processor to pass the multiple-element test
Browse files Browse the repository at this point in the history
  • Loading branch information
czippel committed May 16, 2017
1 parent 2ea6516 commit a29554b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions dom-processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@ function DomPocessor(configLoader) {
var $ = cheerio.load(html, configLoader.loadConfigurations);
var configs = configLoader.load(currentPath);
configs.forEach(function(conf) {
var $el = $(conf.selector);
var result = typeof conf.replace === 'function' ? conf.replace($el) : conf.replace;
$el.replaceWith(result);
var $elements = $(conf.selector);
var result;
var $element;
$elements.each(function (i, el) {
$element = $(el);
result = typeof conf.replace === 'function' ? conf.replace($element) : conf.replace;
$element.replaceWith(result);
});

});
return $.html();
};
Expand Down

0 comments on commit a29554b

Please sign in to comment.