Skip to content
Browse files

Remove put as a dependency of has-class

  • Loading branch information...
1 parent 4165324 commit 1e4e80a4cd35db17ad3ded9938b4e6e582870357 @kriszyp committed Sep 8, 2011
Showing with 12 additions and 8 deletions.
  1. +12 −8 has-class.js
View
20 has-class.js
@@ -1,14 +1,18 @@
-define(["dojo/has", "./put"], function(has, put){
+define(["dojo/has"], function(has){
+ var tested = {};
return function(){
var test, args = arguments;
for(var i = 0; i < args.length; i++){
- var test = args[i],
- parts = test.match(/^(no-)?(.+?)((-[\d\.]+)(-[\d\.]+)?)?$/), // parse the class name
- hasResult = has(parts[2]), // the actual has test
- lower = -parts[4]; // lower bound if it is in the form of test-4 or test-4-6 (would be 4)
- if((lower > 0 ? lower <= hasResult && (-parts[5] || lower) >= hasResult : // if it has a range boundary, compare to see if we are in it
- !!hasResult) == !parts[1]){ // parts[1] is the no- prefix that can negate the result
- put(document.documentElement, '.has-' + test);
+ var test = args[i];
+ if(!tested[test]){
+ tested[test] = true;
+ var parts = test.match(/^(no-)?(.+?)((-[\d\.]+)(-[\d\.]+)?)?$/), // parse the class name
+ hasResult = has(parts[2]), // the actual has test
+ lower = -parts[4]; // lower bound if it is in the form of test-4 or test-4-6 (would be 4)
+ if((lower > 0 ? lower <= hasResult && (-parts[5] || lower) >= hasResult : // if it has a range boundary, compare to see if we are in it
+ !!hasResult) == !parts[1]){ // parts[1] is the no- prefix that can negate the result
+ document.documentElement.className += ' has-' + test;
+ }
}
}
}

0 comments on commit 1e4e80a

Please sign in to comment.
Something went wrong with that request. Please try again.