remove queryselectorall, always use the fallback implementation

This commit is contained in:
mappu 2017-02-08 18:19:57 +13:00
parent 42a8298362
commit 59c118dc34
1 changed files with 15 additions and 16 deletions

View File

@ -7,23 +7,22 @@ var SENTINEL_PASSWORD = "************";
var CHAT_SCROLLBACK_LIMIT = 50; // Once over 2x $limit, the first $limit will be trimmed off the list var CHAT_SCROLLBACK_LIMIT = 50; // Once over 2x $limit, the first $limit will be trimmed off the list
var EXTERN_ROOT = window.location.protocol + "//" + window.location.host + "/"; var EXTERN_ROOT = window.location.protocol + "//" + window.location.host + "/";
var $ = (document.querySelectorAll ? var $ = function(s) {
function(s) { // There used to be a querySelectorAll implementation, but, better that we don't have
var r = document.querySelectorAll(s); // potentially-incompatible implementations if this one does actually work.
return (s[0] === '#' && r.length === 1) ? r[0] : r; // i'm not writing a selector engine...
} : if (! s.length) {
function(s) { return [];
// i'm not writing a selector engine...
if (! s.length) return [];
if (s[0] === '#') {
return document.getElementById(s.slice(1));
} else if (s[0] === '.') {
return document.getElementsByClassName(s.slice(1));
} else {
return document.getElementsByTagName(s);
}
} }
);
if (s[0] === '#') {
return document.getElementById(s.slice(1)); // single element
} else if (s[0] === '.') {
return document.getElementsByClassName(s.slice(1)); // multiple elements
} else {
return document.getElementsByTagName(s); // multiple elements
}
};
var nmdc_escape = function(str) { var nmdc_escape = function(str) {
return ( return (