Skip to content

Commit 9e6095a

Browse files
committed
Core: Move variables for .uniqueId()/.removeUniqueId() into their implementations.
1 parent 8a9fb52 commit 9e6095a

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

ui/jquery.ui.core.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
*/
1111
(function( $, undefined ) {
1212

13-
var uuid = 0,
14-
runiqueId = /^ui-id-\d+$/;
15-
1613
// $.ui might exist from components with no dependencies, e.g., $.ui.position
1714
$.ui = $.ui || {};
1815

@@ -72,17 +69,21 @@ $.fn.extend({
7269
return ( /fixed/ ).test( this.css( "position") ) || !scrollParent.length ? $( this[ 0 ].ownerDocument || document ) : scrollParent;
7370
},
7471

75-
uniqueId: function() {
76-
return this.each(function() {
77-
if ( !this.id ) {
78-
this.id = "ui-id-" + (++uuid);
79-
}
80-
});
81-
},
72+
uniqueId: (function() {
73+
var uuid = 0;
74+
75+
return function() {
76+
return this.each(function() {
77+
if ( !this.id ) {
78+
this.id = "ui-id-" + ( ++uuid );
79+
}
80+
});
81+
};
82+
})(),
8283

8384
removeUniqueId: function() {
8485
return this.each(function() {
85-
if ( runiqueId.test( this.id ) ) {
86+
if ( /^ui-id-\d+$/.test( this.id ) ) {
8687
$( this ).removeAttr( "id" );
8788
}
8889
});

0 commit comments

Comments
 (0)