Changeset 4436
- Timestamp:
- 01/14/08 09:33:08 (1 year ago)
- Location:
- trunk/jquery
- Files:
-
- 2 modified
-
src/core.js (modified) (2 diffs)
-
test/unit/event.js (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/jquery/src/core.js
r4434 r4436 39 39 40 40 // Handle $(DOMElement) 41 if ( selector.nodeType ) {41 if ( selector.nodeType && !selector.length ) { 42 42 this[0] = selector; 43 43 this.length = 1; … … 94 94 // HANDLE: $(arraylike) 95 95 // Watch for when an array-like object, contains DOM nodes, is passed in as the selector 96 (selector.jquery || selector.length && selector != window && !selector.nodeType &&selector[0] != undefined && selector[0].nodeType) && jQuery.makeArray( selector ) ||96 (selector.jquery || selector.length && selector != window && selector[0] != undefined && selector[0].nodeType) && jQuery.makeArray( selector ) || 97 97 98 98 // HANDLE: $(*) -
trunk/jquery/test/unit/event.js
r4251 r4436 1 1 module("event"); 2 2 3 test("bind()", function() { 4 expect(19); 5 3 test("bind(), with data", function() { 4 expect(3); 6 5 var handler = function(event) { 7 6 ok( event.data, "bind() with data, check passed data exists" ); … … 11 10 12 11 ok( !jQuery.data($("#firstp")[0], "events"), "Event handler unbound when using data." ); 13 14 reset(); 12 }); 13 14 test("bind(), with data, trigger with data", function() { 15 expect(4); 15 16 var handler = function(event, data) { 16 17 ok( event.data, "check passed data exists" ); … … 20 21 }; 21 22 $("#firstp").bind("click", {foo: "bar"}, handler).trigger("click", [{bar: "foo"}]).unbind("click", handler); 22 23 reset(); 24 var clickCounter = mouseoverCounter = 0; 23 }); 24 25 test("bind(), multiple events at once", function() { 26 expect(2); 27 var clickCounter = 0, 28 mouseoverCounter = 0; 25 29 var handler = function(event) { 26 30 if (event.type == "click") … … 32 36 ok( clickCounter == 1, "bind() with multiple events at once" ); 33 37 ok( mouseoverCounter == 1, "bind() with multiple events at once" ); 34 35 36 reset(); 38 }); 39 40 test("bind(), no data", function() { 41 expect(1); 37 42 var handler = function(event) { 38 43 ok ( !event.data, "Check that no data is added to the event object" ); 39 44 }; 40 45 $("#firstp").bind("click", handler).trigger("click"); 41 42 46 }); 47 48 test("bind(), iframes", function() { 43 49 // events don't work with iframes, see #939 - this test fails in IE because of contentDocument 44 50 // var doc = document.getElementById("iframe").contentDocument; … … 51 57 // ok( true, "Binding to element inside iframe" ); 52 58 // }).click(); 53 59 }); 60 61 test("bind(), trigger change on select", function() { 62 expect(3); 54 63 var counter = 0; 55 64 function selectOnChange(event) { … … 59 68 $(this).bind('change', i, selectOnChange); 60 69 }).trigger('change'); 61 62 reset(); 70 }); 71 72 test("bind(), namespaced events, cloned events", function() { 73 expect(6); 63 74 64 75 $("#firstp").bind("click",function(e){ … … 90 101 $("<a href='#fail' class='test'>test</a>").click(function(){ return false; }).appendTo("p"); 91 102 ok( $("a.test:first").triggerHandler("click") === false, "Handler is bound to appendTo'd elements" ); 92 reset();93 103 }); 94 104
