Skip to content
Permalink
Browse files

Fixed issue. '_each_' can now returns and empty Array.

  • Loading branch information...
marcomontalbano committed Aug 27, 2018
1 parent 6b00bb1 commit 31623ca2caa1c2058431cd943778a06f0e061b2f
Showing with 22 additions and 3 deletions.
  1. +7 −2 lib/index.js
  2. +1 −1 package.json
  3. +14 −0 test/test.js
@@ -34,8 +34,13 @@ var _fetchSpecialKeys = function($, selector, memo)

_each_ : function($, specialKeySelector, selector, memo) {

var elements, element;
$(specialKeySelector).each(function(i, el) {
var elements, element, $specialKeySelector = $(specialKeySelector);

if ($specialKeySelector.length === 0) {
return [];
}

$specialKeySelector.each(function(i, el) {
element = _htmlMiner(el, selector, {
$document : memo.$document,
globalData : memo.globalData,
@@ -1,6 +1,6 @@
{
"name": "html-miner",
"version": "1.2.0",
"version": "1.2.1",
"description": "A powerful miner that will scrape html pages for you. ` HTML Scraper ´",
"main": "index.js",
"repository": "https://github.com/marcomontalbano/html-miner.git",
@@ -319,6 +319,20 @@ describe('htmlMiner', function() {
});
});

it('\'_each_\' can returns an empty Array', function () {
var actual = htmlMiner(html, {
articles: {
_each_: '.col-md-30',
title: 'h2',
text: 'p:first-of-type'
}
});

assert.deepEqual(actual, {
articles: []
});
});

it('test \'_eachId_\'', function () {
var actual = htmlMiner(html, {
articles: {

0 comments on commit 31623ca

Please sign in to comment.
You can’t perform that action at this time.