Comparing version 0.3.2 to 0.3.3
27
index.js
@@ -27,19 +27,36 @@ var sax = require('sax'); | ||
var pos = 0; | ||
var inScript = false; | ||
var scriptLen = 0; | ||
var scriptStart = 0; | ||
var update = function (type, tag) { | ||
var len, src; | ||
if (type === 'script') { | ||
var len = tag.length; | ||
src = tag; | ||
len = tag.length; | ||
scriptLen += len; | ||
inScript = true; | ||
} | ||
else if (type === 'text') { | ||
var len = parser.startTagPosition - pos - 1; | ||
len = parser.startTagPosition - pos - 1; | ||
} | ||
else if (type === 'open' && tag && tag.name === 'SCRIPT' | ||
&& tag.attributes.src) { | ||
var len = 0; | ||
len = 0; | ||
} | ||
else if (inScript) { | ||
len = parser.position - scriptLen - parser.startTagPosition + 1; | ||
scriptLen = 0; | ||
inScript = false; | ||
} | ||
else { | ||
var len = parser.position - parser.startTagPosition + 1; | ||
len = parser.position - parser.startTagPosition + 1; | ||
} | ||
if (type === 'open' && tag && tag.name === 'SCRIPT') { | ||
scriptLen = len; | ||
} | ||
pos = parser.position; | ||
var src = buffered.slice(0, len); | ||
src = src || buffered.slice(0, len); | ||
buffered = buffered.slice(len); | ||
@@ -46,0 +63,0 @@ |
{ | ||
"name" : "trumpet", | ||
"version" : "0.3.2", | ||
"version" : "0.3.3", | ||
"description" : "parse and transform streaming html using css selectors", | ||
@@ -5,0 +5,0 @@ "main" : "index.js", |
@@ -6,3 +6,3 @@ var test = require('tap').test; | ||
test('script', function (t) { | ||
t.plan(2); | ||
t.plan(6); | ||
@@ -16,5 +16,18 @@ var tr = trumpet(); | ||
t.equal(src, 'console.log(i<j)'); | ||
t.end(); | ||
}); | ||
}); | ||
tr.select('title', function (node) { | ||
t.equal(node.name, 'title'); | ||
node.html(function (html) { | ||
t.equal(html, 'beep'); | ||
}); | ||
}); | ||
tr.select('.c', function (node) { | ||
t.equal(node.name, 'div'); | ||
node.html(function (html) { | ||
t.equal(html, 'boop'); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35055
34
739
13