From a57c86f4ea23828450beb3deccf928752ebe3ad9 Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Tue, 1 Oct 2013 16:48:19 -0700 Subject: [PATCH] Shortcut out of isHidden when we can. Checking computed style is an order of magnitude more expensive than checking the style property. --- src/jquery-extensions.coffee | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/jquery-extensions.coffee b/src/jquery-extensions.coffee index 25cf799b9..76ee60178 100644 --- a/src/jquery-extensions.coffee +++ b/src/jquery-extensions.coffee @@ -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')