github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

jquery / jquery

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 2,075
    • 198
  • Source
  • Commits
  • Network (198)
  • Graphs
  • Tree: 9195107

click here to add a description

click here to add a homepage

  • Switch Branches (3)
    • master
    • mobile
    • omgrequire
  • Switch Tags (41)
    • 1.4rc1
    • 1.4a2
    • 1.4a1
    • 1.4.2
    • 1.4.1
    • 1.4
    • 1.3rc1
    • 1.3b2
    • 1.3b1
    • 1.3.2
    • 1.3.1rc1
    • 1.3.1
    • 1.3
    • 1.2.6
    • 1.2.5
    • 1.2.4b
    • 1.2.4a
    • 1.2.4
    • 1.2.3b
    • 1.2.3a
    • 1.2.3
    • 1.2.2b2
    • 1.2.2b
    • 1.2.2
    • 1.2.1
    • 1.2
    • 1.1b
    • 1.1a
    • 1.1.4
    • 1.1.3a
    • 1.1.3.1
    • 1.1.3
    • 1.1.2
    • 1.1.1
    • 1.1
    • 1.0a
    • 1.0.4
    • 1.0.3
    • 1.0.2
    • 1.0.1
    • 1.0
  • Comments
Sending Request…

jQuery JavaScript Library — Read more

  Cancel

http://jquery.com/

  Cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Clean up expando removal code - only try to delete the expando from an 
element if it's possible.
jeresig (author)
Sat Feb 13 03:32:20 -0800 2010
commit  9195107dbb13ad34ae4e9f7cb1df5d79e4748560
tree    30c8b42fe799b8df75e9b562ad24d0a035ed410b
parent  da966573c3f3cb083c48cd3ead88e7542937d4df
M src/data.js 28 ••••
M src/manipulation.js 8 ••••
M src/support.js 12 •••••
Txt src/data.js
  • View file @ 9195107
... ...
@@ -79,15 +79,8 @@ jQuery.extend({
79 79
 
80 80
     // Otherwise, we want to remove all of the element's data
81 81
     } else {
82  
-      // Clean up the element expando
83  
-      try {
  82
+      if ( jQuery.support.deleteExpando ) {
84 83
         delete elem[ expando ];
85  
-      } catch( e ) {
86  
-        // IE has trouble directly removing the expando
87  
-        // but it's ok with using removeAttribute
88  
-        if ( elem.removeAttribute ) {
89  
-          elem.removeAttribute( expando );
90  
-        }
91 84
       }
92 85
 
93 86
       // Completely remove the data cache
... ...
@@ -132,22 +125,3 @@ jQuery.fn.extend({
132 125
     });
133 126
   }
134 127
 });
135  
-
136  
-var removeExpando = function( elem ) {
137  
-  delete elem[ expando ];
138  
-};
139  
-
140  
-try {
141  
-  var div = document.createElement("div");
142  
-  div[ expando ] = true;
143  
-  delete div[ expando ];
144  
-  
145  
-} catch( e ) {
146  
-  // IE has trouble directly removing the expando
147  
-  // but it's ok with using removeAttribute
148  
-  removeExpando = function( elem ) {
149  
-    if ( elem.removeAttribute ) {
150  
-      elem.removeAttribute( expando );
151  
-    }
152  
-  };
153  
-}
154 128
\ No newline at end of file
Txt src/manipulation.js
  • View file @ 9195107
... ...
@@ -547,7 +547,9 @@ jQuery.extend({
547 547
   },
548 548
   
549 549
   cleanData: function( elems ) {
550  
-    var data, id, cache = jQuery.cache, special = jQuery.event.special;
  550
+    var data, id, cache = jQuery.cache,
  551
+      special = jQuery.event.special,
  552
+      deleteExpando = jQuery.support.deleteExpando;
551 553
     
552 554
     for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
553 555
       id = elem[ jQuery.expando ];
... ...
@@ -566,7 +568,9 @@ jQuery.extend({
566 568
           }
567 569
         }
568 570
         
569  
-        removeExpando( elem );
  571
+        if ( deleteExpando ) {
  572
+          delete elem[ expando ];
  573
+        }
570 574
         
571 575
         delete cache[ id ];
572 576
       }
Txt src/support.js
  • View file @ 9195107
... ...
@@ -59,6 +59,7 @@
59 59
     parentNode: div.removeChild( div.appendChild( document.createElement("div") ) ).parentNode === null,
60 60
 
61 61
     // Will be defined later
  62
+    deleteExpando: true,
62 63
     checkClone: false,
63 64
     scriptEval: false,
64 65
     noCloneEvent: true,
... ...
@@ -110,6 +111,17 @@
110 111
     document.body.appendChild( div );
111 112
     jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2;
112 113
     document.body.removeChild( div ).style.display = 'none';
  114
+
  115
+    // Test to see if it's possible to delete an expando from an element
  116
+    // Fails in Internet Explorer
  117
+    try {
  118
+      div.test = 1;
  119
+      delete doc.test;
  120
+  
  121
+    } catch(e) {
  122
+      jQuery.support.deleteExpando = false;
  123
+    }
  124
+
113 125
     div = null;
114 126
   });
115 127
 

0 notes on commit 9195107

Please log in to comment.
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server