Apparently xpath works as expected on Firefox if you specify that you want the [1] node.

This commit is contained in:
Nicolas Stepien 2012-06-13 23:00:42 +02:00
parent 081ae491f4
commit 97d725ce34
2 changed files with 11 additions and 26 deletions

View File

@ -3345,12 +3345,6 @@
},
add: function(q, id) {
var board, el, i, inline, isBacklink, path, postID, root, threadID;
if (!(isBacklink = /\bbacklink\b/.test(q.className))) {
root = q;
while (root.parentNode.nodeName !== 'BLOCKQUOTE') {
root = root.parentNode;
}
}
if (q.host === 'boards.4chan.org') {
path = q.pathname.split('/');
board = path[1];
@ -3366,7 +3360,8 @@
id: "i" + postID,
className: el ? 'inline' : 'inline crosspost'
});
$.after((isBacklink ? q.parentNode : root), inline);
root = (isBacklink = /\bbacklink\b/.test(q.className)) ? q.parentNode : $.x('ancestor::*[parent::blockquote][1]', q);
$.after(root, inline);
Get.post(board, threadID, postID, inline);
if (!el) {
return;
@ -3424,7 +3419,7 @@
}
},
mouseover: function(e) {
var board, el, parent, path, postID, qp, quote, quoterID, threadID, _i, _len, _ref;
var board, el, path, postID, qp, quote, quoterID, threadID, _i, _len, _ref;
if (/\binlined\b/.test(this.className)) {
return;
}
@ -3489,11 +3484,7 @@
$.addClass(el, 'qphl');
}
}
parent = this.parentNode;
while (!parent.id) {
parent = parent.parentNode;
}
quoterID = parent.id.match(/\d+$/)[0];
quoterID = $.x('ancestor::*[@id][1]', this).id.match(/\d+$/)[0];
_ref = $$('.quotelink, .backlink', qp);
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
quote = _ref[_i];

View File

@ -2598,13 +2598,6 @@ QuoteInline =
@classList.toggle 'inlined'
add: (q, id) ->
# Can't use this because Firefox a shit:
# root = $.x 'ancestor::*[parent::blockquote]', q
unless isBacklink = /\bbacklink\b/.test q.className
root = q
until root.parentNode.nodeName is 'BLOCKQUOTE'
root = root.parentNode
if q.host is 'boards.4chan.org'
path = q.pathname.split '/'
board = path[1]
@ -2619,7 +2612,12 @@ QuoteInline =
inline = $.el 'div',
id: "i#{postID}"
className: if el then 'inline' else 'inline crosspost'
$.after (if isBacklink then q.parentNode else root), inline
root =
if isBacklink = /\bbacklink\b/.test q.className
q.parentNode
else
$.x 'ancestor::*[parent::blockquote][1]', q
$.after root, inline
Get.post board, threadID, postID, inline
return unless el
@ -2709,11 +2707,7 @@ QuotePreview =
$.addClass el.parentNode, 'qphl'
else
$.addClass el, 'qphl'
# can't use xpath because >firefox
parent = @parentNode
until parent.id
parent = parent.parentNode
quoterID = parent.id.match(/\d+$/)[0]
quoterID = $.x('ancestor::*[@id][1]', @).id.match(/\d+$/)[0]
for quote in $$ '.quotelink, .backlink', qp
if quote.hash[2..] is quoterID
$.addClass quote, 'forwardlink'