-
-
Save sourcebits-robertbiggs/6640321 to your computer and use it in GitHub Desktop.
$.fn.extend({ | |
hazClass : function ( className ) { | |
var ret = $(); | |
this.each(function(idx, ctx) { | |
if ($(ctx).hasClass(className)) { | |
ret.push(ctx); | |
} | |
}); | |
return ret; | |
}, | |
iz : function ( selector ) { | |
var ret = $(); | |
this.each(function(idx, ctx) { | |
if ($(ctx).is(selector)) { | |
ret.push(ctx); | |
} | |
}); | |
return ret; | |
}, | |
iznt : function ( selector ) { | |
return this.not(selector); | |
}, | |
haz : function ( selector ) { | |
return this.has(selector); | |
}, | |
haznt : function ( selector ) { | |
var ret = $(); | |
this.each(function(idx, ctx) { | |
if (!$(ctx).has(selector)[0]) { | |
ret.push(ctx); | |
} | |
}); | |
return ret; | |
} | |
}); |
ancestor vs closest. I have to say, I could never understand why they named it closest. It not about the closest descendant ever, only an ancestor.
Good one on the hazAttr. I forgot.
I'm not sure that dataset for jQuery is necessary. For jQuery you'd just use $(selector).data('goto') and it will return the data-goto attribute's value.
ChocolateChipJS uses data only for the cache and uses dataset for the data attribute stuff. I could merge them in ChocolateChipJS. I've thought about it. But like having them separated for now.
yep. But if they named it ancestor... that would've made sense!
Yeah I'm aware jquery's data may refer to data-* attributes, just didn't want to replace original chocolatechip code. I'm still coding with chui in mind, in future versions i may not need jQuery, want to retain the distinction in my head, this helps. Also I like the distinction between data store and an element's attribute, the ambiguity has caused problems in the past.
What do you think of a hazntAttr/hazntClass? better to just use iznt? reads better/easier to follow imo.
this isn't comprehensive or anything, just literally what I needed to make the switch. There are a few more but I don't think they warrant posting here. $.form2JSON
for sure was a welcome addition
I had to add the following to make the switch to jQuery (of which
hazAttr
fits right in):