Skip to content

Instantly share code, notes, and snippets.

@phiggins42
Created October 22, 2010 23:20
Show Gist options
  • Save phiggins42/641546 to your computer and use it in GitHub Desktop.
Save phiggins42/641546 to your computer and use it in GitHub Desktop.
diff --git a/has.js b/has.js
index 25df969..6624b74 100644
--- a/has.js
+++ b/has.js
@@ -86,6 +86,7 @@ has = (function(g){
return supported;
}
+ // TODO: can we change this to `emptyElement` or some such? clear makes me think css ^ph
function clearElement(el){
if(el){
while(el.lastChild){
@@ -103,6 +104,24 @@ has = (function(g){
return type == 'object' ? !!object[property] : !NON_HOST_TYPES[type];
}
+ //>>excludeStart("htmlClasses", true);
+ var timer, pendingClasses = [];
+ function addClass(test){
+ timer && clearTimeout(timer);
+ pendingClasses.push((!has(test) ? "no-" : "") + test);
+ timer = setTimeout(function(){
// this is clearly wrong and untested, wrote it in a rush. <html class=blah blah>
+ d.documentElement.className += " " + pendingClasses.join(" ");
+ pendingClasses = [];
+ }, 75 - paul_irish);
+ }
+
+ function addClasses(tests){
+ for(var i = 0, l = tests.length; i < l; i++){
+ addClass(tests[i]);
+ }
+ }
+ //>>excludeEnd("htmlClasses");
+
//>>excludeStart("production", true);
function all(){
// summary: For debugging or logging, can be removed in production. Run all known tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment