Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Commit 7b818d8

Browse files
author
Gabriel Schulhof
committed
addFirstLastClasses: .not( ".ui-screen-hidden" ) -> custom function
http://jsperf.com/dot-not-vs-loop Closes gh-7228 Fixes gh-7227
1 parent 3d85609 commit 7b818d8

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

js/widgets/addFirstLastClasses.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,31 @@ define( [ "jquery", "../core" ], function( jQuery ) {
77
//>>excludeEnd("jqmBuildExclude");
88
(function( $, undefined ) {
99

10+
var uiScreenHiddenRegex = /\bui-screen-hidden\b/;
11+
function noHiddenClass( elements ) {
12+
var index,
13+
length = elements.length,
14+
result = [];
15+
16+
for ( index = 0; index < length; index++ ) {
17+
if ( !elements[ index ].className.match( uiScreenHiddenRegex ) ) {
18+
result.push( elements[ index ] );
19+
}
20+
}
21+
22+
return $( result );
23+
}
24+
1025
$.mobile.behaviors.addFirstLastClasses = {
1126
_getVisibles: function( $els, create ) {
1227
var visibles;
1328

1429
if ( create ) {
15-
visibles = $els.not( ".ui-screen-hidden" );
30+
visibles = noHiddenClass( $els );
1631
} else {
1732
visibles = $els.filter( ":visible" );
1833
if ( visibles.length === 0 ) {
19-
visibles = $els.not( ".ui-screen-hidden" );
34+
visibles = noHiddenClass( $els );
2035
}
2136
}
2237

0 commit comments

Comments
 (0)