Since we're adding recursion, we should probably move our variable

declaration outside of the potential recursive function
This commit is contained in:
Zixaphir 2013-08-11 23:33:44 -07:00
parent 045ba42296
commit 256e20aea5
3 changed files with 20 additions and 20 deletions

View File

@ -4388,7 +4388,7 @@
}); });
}, },
node: function() { node: function() {
var data, el, i, items, node, range, snapshot; var data, el, i, items, links, node, range, snapshot, _i, _len, _ref;
if (this.isClone) { if (this.isClone) {
if (Conf['Embedding']) { if (Conf['Embedding']) {
@ -4409,10 +4409,16 @@
if (node.parentElement.nodeName === "A") { if (node.parentElement.nodeName === "A") {
continue; continue;
} }
links = [];
if (Linkify.regString.test(node.data)) { if (Linkify.regString.test(node.data)) {
Linkify.regString.lastIndex = 0; Linkify.regString.lastIndex = 0;
Linkify.gatherLinks(snapshot, this, node, i); Linkify.gatherLinks(snapshot, this, node, i);
} }
_ref = links.reverse();
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
range = _ref[_i];
Linkify.makeLink(range, post);
}
} }
if (!(Conf['Embedding'] || Conf['Link Title'])) { if (!(Conf['Embedding'] || Conf['Link Title'])) {
return; return;
@ -4431,11 +4437,10 @@
} }
}, },
gatherLinks: function(snapshot, post, node, i) { gatherLinks: function(snapshot, post, node, i) {
var data, index, len, len2, link, links, match, range, _i, _len, _ref; var data, index, len, len2, link, match, range;
data = node.data; data = node.data;
len = data.length; len = data.length;
links = [];
while ((match = Linkify.regString.exec(data))) { while ((match = Linkify.regString.exec(data))) {
index = match.index; index = match.index;
link = match[0]; link = match[0];
@ -4452,11 +4457,6 @@
if (match) { if (match) {
links.push(Linkify.seek(snapshot, post, node, match, i)); links.push(Linkify.seek(snapshot, post, node, match, i));
} }
_ref = links.reverse();
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
range = _ref[_i];
Linkify.makeLink(range, post);
}
}, },
seek: function(snapshot, post, node, match, i) { seek: function(snapshot, post, node, match, i) {
var data, index, link, next, range, result; var data, index, link, next, range, result;

View File

@ -4393,7 +4393,7 @@
}); });
}, },
node: function() { node: function() {
var data, el, i, items, node, range, snapshot; var data, el, i, items, links, node, range, snapshot, _i, _len, _ref;
if (this.isClone) { if (this.isClone) {
if (Conf['Embedding']) { if (Conf['Embedding']) {
@ -4414,10 +4414,16 @@
if (node.parentElement.nodeName === "A") { if (node.parentElement.nodeName === "A") {
continue; continue;
} }
links = [];
if (Linkify.regString.test(node.data)) { if (Linkify.regString.test(node.data)) {
Linkify.regString.lastIndex = 0; Linkify.regString.lastIndex = 0;
Linkify.gatherLinks(snapshot, this, node, i); Linkify.gatherLinks(snapshot, this, node, i);
} }
_ref = links.reverse();
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
range = _ref[_i];
Linkify.makeLink(range, post);
}
} }
if (!(Conf['Embedding'] || Conf['Link Title'])) { if (!(Conf['Embedding'] || Conf['Link Title'])) {
return; return;
@ -4436,11 +4442,10 @@
} }
}, },
gatherLinks: function(snapshot, post, node, i) { gatherLinks: function(snapshot, post, node, i) {
var data, index, len, len2, link, links, match, range, _i, _len, _ref; var data, index, len, len2, link, match, range;
data = node.data; data = node.data;
len = data.length; len = data.length;
links = [];
while ((match = Linkify.regString.exec(data))) { while ((match = Linkify.regString.exec(data))) {
index = match.index; index = match.index;
link = match[0]; link = match[0];
@ -4457,11 +4462,6 @@
if (match) { if (match) {
links.push(Linkify.seek(snapshot, post, node, match, i)); links.push(Linkify.seek(snapshot, post, node, match, i));
} }
_ref = links.reverse();
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
range = _ref[_i];
Linkify.makeLink(range, post);
}
}, },
seek: function(snapshot, post, node, match, i) { seek: function(snapshot, post, node, match, i) {
var data, index, link, next, range, result; var data, index, link, next, range, result;

View File

@ -48,11 +48,15 @@ Linkify =
while node = snapshot.snapshotItem i++ while node = snapshot.snapshotItem i++
continue if node.parentElement.nodeName is "A" continue if node.parentElement.nodeName is "A"
links = []
if Linkify.regString.test node.data if Linkify.regString.test node.data
Linkify.regString.lastIndex = 0 Linkify.regString.lastIndex = 0
Linkify.gatherLinks snapshot, @, node, i Linkify.gatherLinks snapshot, @, node, i
for range in links.reverse()
Linkify.makeLink range, post
return unless Conf['Embedding'] or Conf['Link Title'] return unless Conf['Embedding'] or Conf['Link Title']
items = @nodes.links items = @nodes.links
@ -67,7 +71,6 @@ Linkify =
gatherLinks: (snapshot, post, node, i) -> gatherLinks: (snapshot, post, node, i) ->
{data} = node {data} = node
len = data.length len = data.length
links = []
while (match = Linkify.regString.exec data) while (match = Linkify.regString.exec data)
{index} = match {index} = match
@ -86,9 +89,6 @@ Linkify =
if match if match
links.push Linkify.seek snapshot, post, node, match, i links.push Linkify.seek snapshot, post, node, match, i
for range in links.reverse()
Linkify.makeLink range, post
return return
seek: (snapshot, post, node, match, i) -> seek: (snapshot, post, node, match, i) ->