MyMongodb/node_modules/jquery/test/unit/event.js

(开头部分) 75KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

module("event", { teardown: moduleTeardown });

test("null or undefined handler", function() {
	expect(2);
	// Supports Fixes bug #7229
	try {
		jQuery("#firstp").on( "click", null );
		ok(true, "Passing a null handler will not throw an exception");
	} catch (e) {}

	try {
		jQuery("#firstp").on( "click", undefined );
		ok(true, "Passing an undefined handler will not throw an exception");
	} catch (e) {}
});

test("bind(),on(),delegate() with non-null,defined data", function() {

	expect(3);

	var handler = function( event, data ) {
		equal( data, 0, "non-null, defined data (zero) is correctly passed" );
	};

	jQuery("#foo").bind("foo.bind", handler);
	jQuery("#foo").on("foo.on", handler);
	jQuery("div").delegate("#foo", "foo.delegate", handler);

	jQuery("#foo").trigger("foo", 0);

	jQuery("#foo").unbind("foo.bind", handler);
	jQuery("#foo").off("foo.on", handler);
	jQuery("div").undelegate("#foo", "foo.delegate");

});

test("Handler changes and .trigger() order", function() {
	expect(1);

	var markup = jQuery(
		"<div><div><p><span><b class=\"a\">b</b></span></p></div></div>"
	),
	path = "";

	markup
		.find( "*" ).andSelf().on( "click", function( e ) {
			path += this.nodeName.toLowerCase() + " ";
		})
		.filter( "b" ).on( "click", function( e ) {
			// Removing span should not stop propagation to original parents
			if ( e.target === this ) {
				jQuery(this).parent().remove();
			}
		});

	markup.find( "b" ).trigger( "click" );

	equal( path, "b p div div ", "Delivered all events" );

	markup.remove();
后面还有 2630 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。