Using data() on JavaScript objects sets fields directly on the object. Note that events are now a property of a function (to avoid JSON serialization - and only in the case of JavaScript objects, not DOM nodes). Fixes #6807.
This commit is contained in:
parent
ec7ea3fba1
commit
cb811c04b0
4 changed files with 100 additions and 61 deletions
|
@ -443,7 +443,7 @@ test("bind(name, false), unbind(name, false)", function() {
|
|||
});
|
||||
|
||||
test("bind()/trigger()/unbind() on plain object", function() {
|
||||
expect( 2 );
|
||||
expect( 5 );
|
||||
|
||||
var obj = {};
|
||||
|
||||
|
@ -457,7 +457,11 @@ test("bind()/trigger()/unbind() on plain object", function() {
|
|||
ok( true, "Custom event run." );
|
||||
});
|
||||
|
||||
ok( jQuery(obj).data("events"), "Object has events bound." );
|
||||
var events = jQuery(obj).data("events");
|
||||
ok( events, "Object has events bound." );
|
||||
equals( typeof events, "function", "'events' expando is a function on plain objects." );
|
||||
equals( obj.test, undefined, "Make sure that test event is not on the plain object." );
|
||||
equals( obj.handle, undefined, "Make sure that the event handler is not on the plain object." );
|
||||
|
||||
// Should trigger 1
|
||||
jQuery(obj).trigger("test");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue