classList.contains() is actually really slow.

This commit is contained in:
Nicolas Stepien 2011-11-03 22:51:07 +01:00 committed by James Campos
parent 7e3d360364
commit 61730c93cf
2 changed files with 12 additions and 12 deletions

View File

@ -1835,7 +1835,7 @@
}
},
toggle: function(thread) {
if (thread.classList.contains('stub') || thread.hidden) {
if (/\bstub\b/.test(thread.className) || thread.hidden) {
return threadHiding.show(thread);
} else {
return threadHiding.hide(thread);
@ -2328,7 +2328,7 @@
quoteBacklink.funk = Function('id', "return'" + format + "'");
return g.callbacks.push(function(root) {
var a, container, el, id, link, qid, quote, quotes, _i, _len, _ref, _results;
if (root.classList.contains('inline')) {
if (/\binline\b/.test(root.className)) {
return;
}
quotes = {};
@ -2400,7 +2400,7 @@
}
e.preventDefault();
id = this.hash.slice(1);
if (this.classList.contains('inlined')) {
if (/\binlined\b/.test(this.className)) {
quoteInline.rm(this, id);
} else {
if ($.x("ancestor::*[@id='" + id + "']", this)) {
@ -2443,7 +2443,7 @@
inlined = _ref[_i];
$.x('ancestor::table', $.id(inlined.hash.slice(1))).hidden = false;
}
if (q.classList.contains('backlink') && !q.classList.contains('filtered')) {
if (/\bbacklink\b/.test(q.className) && !/\bfiltered\b/.test(q.className)) {
$.x('ancestor::table', $.id(id)).hidden = false;
}
return $.rm(table);
@ -2528,7 +2528,7 @@
if (conf['Quote Highlighting']) {
$.addClass(el, 'qphl');
}
if (this.classList.contains('backlink')) {
if (/\bbacklink\b/.test(this.className)) {
replyID = $.x('preceding::input', this).name;
_ref = $$('.quotelink', qp);
_results = [];
@ -2901,7 +2901,7 @@
}
form = $('body > form');
form.className = klass;
if (form.classList.contains('fitheight')) {
if (/\bfitheight\b/.test(form.className)) {
$.bind(window, 'resize', imgExpand.resize);
if (!imgExpand.style) {
imgExpand.style = $.addStyle('');

View File

@ -1372,7 +1372,7 @@ threadHiding =
threadHiding.show thread
toggle: (thread) ->
if thread.classList.contains('stub') or thread.hidden
if /\bstub\b/.test(thread.className) or thread.hidden
threadHiding.show thread
else
threadHiding.hide thread
@ -1756,7 +1756,7 @@ quoteBacklink =
format = conf['backlink'].replace /%id/, "' + id + '"
quoteBacklink.funk = Function 'id', "return'#{format}'"
g.callbacks.push (root) ->
return if root.classList.contains 'inline'
return if /\binline\b/.test root.className
quotes = {}
for quote in $$ '.quotelink', root
#don't process >>>/b/
@ -1797,7 +1797,7 @@ quoteInline =
return if e.shiftKey or e.altKey or e.ctrlKey or e.button isnt 0
e.preventDefault()
id = @hash[1..]
if @classList.contains 'inlined'
if /\binlined\b/.test @className
quoteInline.rm @, id
else
return if $.x("ancestor::*[@id='#{id}']", @)
@ -1828,7 +1828,7 @@ quoteInline =
table = $.x "following::*[@id='i#{id}']", q
for inlined in $$ '.backlink.inlined:not(.filtered)', table
$.x('ancestor::table', $.id inlined.hash[1..]).hidden = false
if q.classList.contains('backlink') and not q.classList.contains 'filtered'
if /\bbacklink\b/.test(q.className) and not /\bfiltered\b/.test q.className
$.x('ancestor::table', $.id id).hidden = false
$.rm table
@ -1884,7 +1884,7 @@ quotePreview =
if el = $.id id
qp.innerHTML = el.innerHTML
$.addClass el, 'qphl' if conf['Quote Highlighting']
if @classList.contains 'backlink'
if /\bbacklink\b/.test @className
replyID = $.x('preceding::input', @).name
for quote in $$ '.quotelink', qp
if quote.hash[1..] is replyID
@ -2122,7 +2122,7 @@ imgExpand =
klass = 'fitwidth fitheight'
form = $('body > form')
form.className = klass
if form.classList.contains 'fitheight'
if /\bfitheight\b/.test form.className
$.bind window, 'resize', imgExpand.resize
unless imgExpand.style
imgExpand.style = $.addStyle ''