Use jquery's hidden code in our isHidden()

This commit is contained in:
Ben Ogle
2013-09-27 14:33:39 -07:00
parent 48337f3203
commit ce9920a9ff

View File

@@ -35,7 +35,21 @@ $.fn.isOnDom = ->
@closest(document.body).length is 1
$.fn.isVisible = ->
@length > 0 and @css('display') != 'none'
!@isHidden()
$.fn.isHidden = ->
# Implementation taken from jQuery's `:hidden` expression code:
# https://github.com/jquery/jquery/blob/master/src/css/hiddenVisibleSelectors.js
#
# We were using a pseudo selector: @is(':hidden'). But jQuery's pseudo
# selector code checks the element's webkitMatchesSelector, which is always
# false, and is really really really slow.
elem = this[0]
return null unless elem
elem.offsetWidth <= 0 and elem.offsetHeight <= 0
$.fn.isDisabled = ->
!!@attr('disabled')