Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
adding :visible and :hidden to zepto
;(function($){
var _is = $.fn.is, _filter = $.fn.filter;
function visible(elem){
elem = $(elem);
return !!(elem.width() || elem.height()) && elem.css("display") !== "none";
}
$.fn.is = function(sel){
if(sel === ":visible"){
return visible(this);
}
if(sel === ":hidden"){
return !visible(this);
}
return _is.call(this, sel);
}
$.fn.filter = function(sel){
if(sel === ":visible"){
return $([].filter.call(this, visible));
}
if(sel === ":hidden"){
return $([].filter.call(this, function(elem){
return !visible(elem);
}));
}
return _filter.call(this, sel);
}
})(Zepto);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.