From 55ec6a71d2378a5301af71c2c0080e15289c3f78 Mon Sep 17 00:00:00 2001 From: Dave Methvin Date: Fri, 4 Mar 2011 21:16:40 -0500 Subject: Fixes #7340. Use a single capturing handler to simulate bubbling focusin/focusout event on non-IE browsers. Allow native DOM methods to fire events other than the currently active one back into jQuery. --- test/unit/event.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'test') diff --git a/test/unit/event.js b/test/unit/event.js index b7b260462..d54987923 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -1966,6 +1966,31 @@ test("window resize", function() { ok( !jQuery._data(window, "__events__"), "Make sure all the events are gone." ); }); +test("focusin bubbles", function() { + expect(4); + + var input = jQuery( '' ).prependTo( "body" ), + order = 0; + + jQuery( "body" ).bind( "focusin.focusinBubblesTest", function(){ + equals( 1, order++, "focusin on the body second" ); + }); + + input.bind( "focusin.focusinBubblesTest", function(){ + equals( 0, order++, "focusin on the element first" ); + }); + + // DOM focus method + input[0].focus(); + // jQuery trigger, which calls DOM focus + order = 0; + input[0].blur(); + input.trigger( "focus" ); + + input.remove(); + jQuery( "body" ).unbind( "focusin.focusinBubblesTest" ); +}); + /* test("jQuery(function($) {})", function() { stop(); -- cgit v1.2.3 From 2ac4067a639856a6035c3bd00aab132c9714b52d Mon Sep 17 00:00:00 2001 From: Dave Methvin Date: Wed, 9 Mar 2011 22:38:26 -0500 Subject: Fixes #8456. Make sure parent is not null before crawling into its lap, so mouseenter is triggered on a mouseover event. --- src/event.js | 2 +- test/unit/event.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/src/event.js b/src/event.js index f7e0a08c0..2620646da 100644 --- a/src/event.js +++ b/src/event.js @@ -661,7 +661,7 @@ var withinElement = function( event ) { // Chrome does something similar, the parentNode property // can be accessed but is null. - if ( parent !== document && !parent.parentNode ) { + if ( parent && parent !== document && !parent.parentNode ) { return; } // Traverse up the tree diff --git a/test/unit/event.js b/test/unit/event.js index b7b260462..d66aaac9b 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -683,6 +683,20 @@ test("hover()", function() { equals( times, 4, "hover handlers fired" ); }); +test("mouseover triggers mouseenter", function() { + expect(1); + + var count = 0, + elem = jQuery(""); + elem.mouseenter(function () { + count++; + }); + elem.trigger('mouseover'); + equals(count, 1, "make sure mouseover triggers a mouseenter" ); + + elem.remove(); +}); + test("trigger() shortcuts", function() { expect(6); -- cgit v1.2.3 From c3c507e900fceb419628157504004ab2813b7d01 Mon Sep 17 00:00:00 2001 From: Richard Worth Date: Thu, 24 Mar 2011 15:41:46 -0400 Subject: Added css hook to work around bug in WebKit computed margin-right. Fixes #3333 - .css("marginRight") is incorrect in WebKit --- src/css.js | 19 +++++++++++++++++++ src/support.js | 14 +++++++++++++- test/unit/css.js | 12 ++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/src/css.js b/src/css.js index 8a982312f..d6b488139 100644 --- a/src/css.js +++ b/src/css.js @@ -240,6 +240,25 @@ if ( !jQuery.support.opacity ) { }; } +jQuery(function() { + // This hook cannot be added until DOM ready because the support test + // for it is not run until after DOM ready + if ( !jQuery.support.reliableMarginRight ) { + jQuery.cssHooks.marginRight = { + get: function( elem, computed ) { + // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right + // Work around by temporarily setting element display to inline-block + var ret = "0px", + display = elem.style.display; + elem.style.display = "inline-block"; + ret = getComputedStyle( elem, "margin-right", "margin-right" ); + elem.style.display = display; + return ret; + } + } + } +}); + if ( document.defaultView && document.defaultView.getComputedStyle ) { getComputedStyle = function( elem, newName, name ) { var ret, defaultView, computedStyle; diff --git a/src/support.js b/src/support.js index 7470b33e8..939ad4fcb 100644 --- a/src/support.js +++ b/src/support.js @@ -67,7 +67,8 @@ boxModel: null, inlineBlockNeedsLayout: false, shrinkWrapBlocks: false, - reliableHiddenOffsets: true + reliableHiddenOffsets: true, + reliableMarginRight: true }; input.checked = true; @@ -188,6 +189,17 @@ jQuery.support.reliableHiddenOffsets = jQuery.support.reliableHiddenOffsets && tds[0].offsetHeight === 0; div.innerHTML = ""; + // Check if div with explicit width and no margin-right incorrectly + // gets computed margin-right based on width of container. For more + // info see bug #3333 + // Fails in WebKit before Feb 2011 nightlies + // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right + if ( document.defaultView && document.defaultView.getComputedStyle ) { + div.style.width = "1px"; + div.style.marginRight = "0"; + jQuery.support.reliableMarginRight = ( parseInt(document.defaultView.getComputedStyle(div).marginRight, 10) || 0 ) === 0; + } + body.removeChild( div ).style.display = "none"; div = tds = null; }); diff --git a/test/unit/css.js b/test/unit/css.js index 555f13575..8ae8fcb34 100644 --- a/test/unit/css.js +++ b/test/unit/css.js @@ -333,3 +333,15 @@ test("internal ref to elem.runtimeStyle (bug #7608)", function () { ok( result, "elem.runtimeStyle does not throw exception" ); }); + +test("marginRight computed style (bug #3333)", function() { + expect(1); + + var $div = jQuery("#foo"); + $div.css({ + width: "1px", + marginRight: 0 + }); + + equals($div.css("marginRight"), "0px"); +}); -- cgit v1.2.3 From e8f4629b924cae0b0f1847d2368031f06bc08149 Mon Sep 17 00:00:00 2001 From: Michael Murray Date: Thu, 24 Mar 2011 19:02:38 -0400 Subject: Offset setter for fixed position elements in Webkit. Fixes #8316. --- src/offset.js | 4 ++-- test/unit/offset.js | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/src/offset.js b/src/offset.js index 1003c400c..18261bb57 100644 --- a/src/offset.js +++ b/src/offset.js @@ -181,10 +181,10 @@ jQuery.offset = { curOffset = curElem.offset(), curCSSTop = jQuery.css( elem, "top" ), curCSSLeft = jQuery.css( elem, "left" ), - calculatePosition = (position === "absolute" && jQuery.inArray('auto', [curCSSTop, curCSSLeft]) > -1), + calculatePosition = ((position === "absolute" || position === "fixed") && jQuery.inArray('auto', [curCSSTop, curCSSLeft]) > -1), props = {}, curPosition = {}, curTop, curLeft; - // need to be able to calculate position if either top or left is auto and position is absolute + // need to be able to calculate position if either top or left is auto and position is either absolute or fixed if ( calculatePosition ) { curPosition = curElem.position(); } diff --git a/test/unit/offset.js b/test/unit/offset.js index 329d69f95..b7f72a0cd 100644 --- a/test/unit/offset.js +++ b/test/unit/offset.js @@ -422,6 +422,21 @@ test("offsetParent", function(){ equals( div[1], jQuery("#nothiddendiv")[0], "The div is the offsetParent." ); }); +testoffset("bug_8316", function( jQuery ){ + expect(2); + + var tests = [ + { id:'#elem', top: 100, left: 100 } + ]; + + jQuery.each(tests, function(){ + var el = jQuery(this.id); + el.offset({ top: this.top, left: this.left}); + equals(Math.round(el.offset().top), this.top); + equals(Math.round(el.offset().left), this.left); + }); +}); + function testoffset(name, fn) { test(name, function() { @@ -447,7 +462,7 @@ function testoffset(name, fn) { function loadFixture() { var src = './data/offset/' + name + '.html?' + parseInt( Math.random()*1000, 10 ), iframe = jQuery('