Permalink
Browse files

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.
1 parent b0e3d5f commit d4c7b5da66641a3fd081a834ca3d12a5518d499b @jblas jblas committed Apr 21, 2011
Showing with 10 additions and 2 deletions.
  1. +10 −2 js/jquery.mobile.vmouse.js
View
12 js/jquery.mobile.vmouse.js
@@ -370,7 +370,15 @@ function getSpecialEventObject(eventType)
var $this = $(this),
bindings = $.data(this, dataPropertyName);
- bindings[eventType] = false;
+
+ // teardown may be called when an element was
+ // removed from the DOM. If this is the case,
+ // jQuery core may have already stripped the element
+ // of any data bindings so we need to check it before
+ // using it.
+ if (bindings){
+ bindings[eventType] = false;
+ }
// Unregister the dummy event handler.
@@ -449,4 +457,4 @@ if (eventCaptureSupported){
}
}, true);
}
-})(jQuery, window, document);
+})(jQuery, window, document);

0 comments on commit d4c7b5d

Please sign in to comment.