Shortcut out of isHidden when we can.

Checking computed style is an order of magnitude more expensive than 
checking the style property.
This commit is contained in:
Ben Ogle
2013-10-01 16:48:19 -07:00
parent 8cd04b5178
commit a57c86f4ea

View File

@@ -40,7 +40,14 @@ $.fn.isVisible = ->
$.fn.isHidden = ->
# We used to check @is(':hidden'). But this is much faster than the
# offsetWidth/offsetHeight check + all the pseudo selector mess in jquery.
@css('display') == 'none'
style = this[0].style
if style.display == 'none' or not @isOnDom()
true
else if style.display
false
else
getComputedStyle(this[0]).display == 'none'
$.fn.isDisabled = ->
!!@attr('disabled')