More comment text reading for filter optimizations.

This commit is contained in:
Nicolas Stepien 2012-02-22 06:28:55 +01:00
parent d3c4ec3671
commit b843f78325
2 changed files with 5 additions and 14 deletions

View File

@ -639,18 +639,13 @@
return sub.textContent;
},
comment: function(root) {
var i, len, node, nodes, text;
var data, i, len, nodes, text;
text = [];
nodes = d.evaluate('.//node()', root.lastChild, null, 7, null);
nodes = d.evaluate('.//br|.//text()', root.lastChild, null, 7, null);
i = 0;
len = nodes.snapshotLength;
while (i < len) {
node = nodes.snapshotItem(i++);
if (node instanceof Text) {
text.push(node.data);
} else if (node instanceof HTMLBRElement) {
text.push('\n');
}
text.push((data = nodes.snapshotItem(i++).data) ? data : '\n');
}
return text.join('');
},

View File

@ -554,15 +554,11 @@ filter =
comment: (root) ->
text = []
# XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE is 7
nodes = d.evaluate './/node()', root.lastChild, null, 7, null
nodes = d.evaluate './/br|.//text()', root.lastChild, null, 7, null
i = 0
len = nodes.snapshotLength
while i < len
node = nodes.snapshotItem i++
if node instanceof Text
text.push node.data
else if node instanceof HTMLBRElement
text.push '\n'
text.push if data = nodes.snapshotItem(i++).data then data else '\n'
text.join ''
filename: (root) ->
if file = $ '.filesize > span', root