Permalink
Browse files

addFirstLastClasses: .not( ".ui-screen-hidden" ) -> custom function

http://jsperf.com/dot-not-vs-loop

(cherry picked from commit 7b818d8)

Closes gh-7228
Fixes gh-7227
  • Loading branch information...
1 parent eaf53c6 commit df691e65fe2a83a4f31518edd6562ab80c349e33 @gabrielschulhof gabrielschulhof committed Mar 8, 2014
Showing with 17 additions and 2 deletions.
  1. +17 −2 js/widgets/addFirstLastClasses.js
@@ -7,16 +7,31 @@ define( [ "jquery", "../jquery.mobile.core" ], function( jQuery ) {
//>>excludeEnd("jqmBuildExclude");
(function( $, undefined ) {
+var uiScreenHiddenRegex = /\bui-screen-hidden\b/;
+function noHiddenClass( elements ) {
+ var index,
+ length = elements.length,
+ result = [];
+
+ for ( index = 0; index < length; index++ ) {
+ if ( !elements[ index ].className.match( uiScreenHiddenRegex ) ) {
+ result.push( elements[ index ] );
+ }
+ }
+
+ return $( result );
+}
+
$.mobile.behaviors.addFirstLastClasses = {
_getVisibles: function( $els, create ) {
var visibles;
if ( create ) {
- visibles = $els.not( ".ui-screen-hidden" );
+ visibles = noHiddenClass( $els );
} else {
visibles = $els.filter( ":visible" );
if ( visibles.length === 0 ) {
- visibles = $els.not( ".ui-screen-hidden" );
+ visibles = noHiddenClass( $els );
}
}

0 comments on commit df691e6

Please sign in to comment.