Skip to content
This repository
Browse code

Fix from @brukhabtu for issue 1492 - Errors when trying to delete DOM…

… elements.

- Check for existence of the bindings object before attempting to use it. Apparently jQuery core strips off any data bindings of an element before calling teardown on it to remove special event handlers.
  • Loading branch information...
commit d4c7b5da66641a3fd081a834ca3d12a5518d499b 1 parent b0e3d5f
Kin Blas authored

Showing 1 changed file with 10 additions and 2 deletions. Show diff stats Hide diff stats

  1. 12  js/jquery.mobile.vmouse.js
12  js/jquery.mobile.vmouse.js
@@ -370,7 +370,15 @@ function getSpecialEventObject(eventType)
370 370
 
371 371
 			var $this = $(this),
372 372
 				bindings = $.data(this, dataPropertyName);
373  
-			bindings[eventType] = false;
  373
+
  374
+			// teardown may be called when an element was
  375
+			// removed from the DOM. If this is the case,
  376
+			// jQuery core may have already stripped the element
  377
+			// of any data bindings so we need to check it before
  378
+			// using it.
  379
+			if (bindings){
  380
+				bindings[eventType] = false;
  381
+			}
374 382
 
375 383
 			// Unregister the dummy event handler.
376 384
 
@@ -449,4 +457,4 @@ if (eventCaptureSupported){
449 457
 		}
450 458
 	}, true);
451 459
 }
452  
-})(jQuery, window, document);
  460
+})(jQuery, window, document);

0 notes on commit d4c7b5d

Please sign in to comment.
Something went wrong with that request. Please try again.