html-select
Advanced tools
Comparing version 2.1.0 to 2.1.1
@@ -88,2 +88,4 @@ var through = require('through2'); | ||
}); | ||
if (s._streams === 0) s.createReadStream(); | ||
}); | ||
@@ -90,0 +92,0 @@ s.on('fork', function (sub) { |
@@ -26,2 +26,3 @@ var inherits = require('inherits'); | ||
this._options = {}; | ||
this._streams = 0; | ||
this.removeAllListeners('close'); | ||
@@ -55,2 +56,3 @@ }; | ||
this.input.write(row); | ||
this._streams = 0; | ||
this.emit('match'); | ||
@@ -106,2 +108,4 @@ if (current.selfClosing) { | ||
}); | ||
this._streams ++; | ||
return s; | ||
@@ -108,0 +112,0 @@ }; |
{ | ||
"name": "html-select", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "match a tokenized html stream with css selectors", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -5,42 +5,42 @@ var select = require('../'); | ||
test('nested matches', function (t) { | ||
test('quoted attribute', function (t) { | ||
var expected = [ | ||
[ | ||
[ 'open', '<div>' ], | ||
[ 'open', '<b>' ], | ||
[ 'text', 'beep boop' ], | ||
[ 'close', '</b>' ], | ||
[ 'text', '\n' ], | ||
[ 'open', '<div class="x">' ], | ||
[ 'text', 'woo' ], | ||
[ 'open', '<div class="a">' ], | ||
[ 'test', '\n' ], | ||
[ 'open', '<div class="b">' ], | ||
[ 'test', '\n' ], | ||
[ 'close', '</div>' ], | ||
[ 'text', '\n' ], | ||
[ 'test', '\n' ], | ||
[ 'close', '</div>' ] | ||
], | ||
[ | ||
[ 'open', '<div class="x">' ], | ||
[ 'text', 'woo' ], | ||
[ 'open', '<div class="b">' ], | ||
[ 'test', '\n' ], | ||
[ 'close', '</div>' ] | ||
] | ||
]; | ||
t.plan(expected[0].length + expected[1].length); | ||
var s = select('div', function (e) { | ||
t.plan(expected.reduce(function (sum, x) { return sum + x.length }, 0)); | ||
var s = select().select('div', function (e) { | ||
var ex = expected.shift(); | ||
e.createReadStream().pipe(through.obj(function (row, enc, next) { | ||
t.deepEqual(row, ex.shift()); | ||
next(); | ||
})); | ||
e.createReadStream() | ||
.pipe(through.obj(function (row, enc, next) { | ||
t.deepEqual(row, ex.shift()); | ||
next(); | ||
})) | ||
; | ||
}); | ||
s.write([ 'open', '<html>' ]); | ||
s.write([ 'test', '\n' ]); | ||
s.write([ 'open', '<body>' ]); | ||
s.write([ 'open', '<div>' ]); | ||
s.write([ 'open', '<b>' ]); | ||
s.write([ 'text', 'beep boop' ]); | ||
s.write([ 'close', '</b>' ]); | ||
s.write([ 'text', '\n' ]); | ||
s.write([ 'open', '<div class="x">' ]); | ||
s.write([ 'text', 'woo' ]); | ||
s.write([ 'test', '\n' ]); | ||
s.write([ 'open', '<div class="a">' ]); | ||
s.write([ 'test', '\n' ]); | ||
s.write([ 'open', '<div class="b">' ]); | ||
s.write([ 'test', '\n' ]); | ||
s.write([ 'close', '</div>' ]); | ||
s.write([ 'text', '\n' ]); | ||
s.write([ 'test', '\n' ]); | ||
s.write([ 'close', '</div>' ]); | ||
s.write([ 'test', '\n' ]); | ||
s.write([ 'close', '</body>' ]); | ||
@@ -47,0 +47,0 @@ s.write([ 'close', '</html>' ]); |
118880
48
2302
15