]> source.dussan.org Git - jquery-ui.git/commitdiff
Core: Move variables for .uniqueId()/.removeUniqueId() into their implementations.
authorScott González <scott.gonzalez@gmail.com>
Wed, 23 Oct 2013 12:17:21 +0000 (08:17 -0400)
committerScott González <scott.gonzalez@gmail.com>
Thu, 24 Oct 2013 13:19:42 +0000 (09:19 -0400)
ui/jquery.ui.core.js

index 9145d5d458bea405f2668d379b818e7e4d67490d..7faae07606d008366fa674c92f8076abc4e7ce05 100644 (file)
@@ -10,9 +10,6 @@
  */
 (function( $, undefined ) {
 
-var uuid = 0,
-       runiqueId = /^ui-id-\d+$/;
-
 // $.ui might exist from components with no dependencies, e.g., $.ui.position
 $.ui = $.ui || {};
 
@@ -72,17 +69,21 @@ $.fn.extend({
                return ( /fixed/ ).test( this.css( "position") ) || !scrollParent.length ? $( this[ 0 ].ownerDocument || document ) : scrollParent;
        },
 
-       uniqueId: function() {
-               return this.each(function() {
-                       if ( !this.id ) {
-                               this.id = "ui-id-" + (++uuid);
-                       }
-               });
-       },
+       uniqueId: (function() {
+               var uuid = 0;
+
+               return function() {
+                       return this.each(function() {
+                               if ( !this.id ) {
+                                       this.id = "ui-id-" + ( ++uuid );
+                               }
+                       });
+               };
+       })(),
 
        removeUniqueId: function() {
                return this.each(function() {
-                       if ( runiqueId.test( this.id ) ) {
+                       if ( /^ui-id-\d+$/.test( this.id ) ) {
                                $( this ).removeAttr( "id" );
                        }
                });