From c5264ce196c2f6d60b9d662a160f8e146c9aa23c Mon Sep 17 00:00:00 2001 From: louisremi Date: Wed, 23 Feb 2011 15:53:29 +0100 Subject: [PATCH 01/24] fix the regular expression that turns camel-case properties to lower-case ones for IE9. Fixes #8346 --- src/css.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/css.js b/src/css.js index 8a982312f..86a5c71a1 100644 --- a/src/css.js +++ b/src/css.js @@ -3,7 +3,7 @@ var ralpha = /alpha\([^)]*\)/i, ropacity = /opacity=([^)]*)/, rdashAlpha = /-([a-z])/ig, - rupper = /([A-Z])/g, + rupper = /([A-Z]|^ms)/g, rnumpx = /^-?\d+(?:px)?$/i, rnum = /^-?\d/, From e27fcf42ce152ede15c8617bb5d31dfb2088470c Mon Sep 17 00:00:00 2001 From: louisremi Date: Wed, 23 Feb 2011 15:55:13 +0100 Subject: [PATCH 02/24] comments for workarounds are always welcome. --- src/css.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/css.js b/src/css.js index 86a5c71a1..04e205eb4 100644 --- a/src/css.js +++ b/src/css.js @@ -3,6 +3,7 @@ var ralpha = /alpha\([^)]*\)/i, ropacity = /opacity=([^)]*)/, rdashAlpha = /-([a-z])/ig, + // fixed for IE9, see #8346 rupper = /([A-Z]|^ms)/g, rnumpx = /^-?\d+(?:px)?$/i, rnum = /^-?\d/, From 55ec6a71d2378a5301af71c2c0080e15289c3f78 Mon Sep 17 00:00:00 2001 From: Dave Methvin Date: Fri, 4 Mar 2011 21:16:40 -0500 Subject: [PATCH 03/24] 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. --- src/event.js | 32 +++++++++++++++++++++++--------- test/unit/event.js | 25 +++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 9 deletions(-) diff --git a/src/event.js b/src/event.js index f7e0a08c0..61c8a93fd 100644 --- a/src/event.js +++ b/src/event.js @@ -70,10 +70,10 @@ jQuery.event = { } if ( !eventHandle ) { - elemData.handle = eventHandle = function() { + elemData.handle = eventHandle = function( e ) { // Handle the second event of a trigger and when // an event is called after a page has unloaded - return typeof jQuery !== "undefined" && !jQuery.event.triggered ? + return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ? jQuery.event.handle.apply( eventHandle.elem, arguments ) : undefined; }; @@ -380,7 +380,7 @@ jQuery.event = { target[ "on" + targetType ] = null; } - jQuery.event.triggered = true; + jQuery.event.triggered = event.type; target[ targetType ](); } @@ -391,7 +391,7 @@ jQuery.event = { target[ "on" + targetType ] = old; } - jQuery.event.triggered = false; + jQuery.event.triggered = undefined; } } }, @@ -868,19 +868,33 @@ function trigger( type, elem, args ) { // Create "bubbling" focus and blur events if ( document.addEventListener ) { jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { + + // Attach a single capturing handler while someone wants focusin/focusout + var attaches = 0; + jQuery.event.special[ fix ] = { setup: function() { - this.addEventListener( orig, handler, true ); + if ( attaches++ === 0 ) { + document.addEventListener( orig, handler, true ); + } }, teardown: function() { - this.removeEventListener( orig, handler, true ); + if ( --attaches === 0 ) { + document.removeEventListener( orig, handler, true ); + } } }; - function handler( e ) { - e = jQuery.event.fix( e ); + function handler( donor ) { + // Donor event is always a native one; fix it and switch its type. + // Let focusin/out handler cancel the donor focus/blur event. + var e = jQuery.event.fix( donor ); e.type = fix; - return jQuery.event.handle.call( this, e ); + e.originalEvent = {}; + jQuery.event.trigger( e, null, e.target ); + if ( e.isDefaultPrevented() ) { + donor.preventDefault(); + } } }); } 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(); From 2ac4067a639856a6035c3bd00aab132c9714b52d Mon Sep 17 00:00:00 2001 From: Dave Methvin Date: Wed, 9 Mar 2011 22:38:26 -0500 Subject: [PATCH 04/24] 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(-) 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); From 51abb3dc071fd86afd346ec5c340734f5c61064f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl=20F=C3=BCrstenberg?= Date: Fri, 4 Mar 2011 23:33:20 +0100 Subject: [PATCH 05/24] Changing dependice order for minify to prevent reminify unless jquery.js has been updated, no minification should occur closes: #8519 --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 84816a19e..7b87c9f51 100644 --- a/Makefile +++ b/Makefile @@ -75,9 +75,9 @@ lint: jquery echo "You must have NodeJS installed in order to test jQuery against JSLint."; \ fi -min: ${JQ_MIN} +min: jquery ${JQ_MIN} -${JQ_MIN}: jquery +${JQ_MIN}: ${JQ} @@if test ! -z ${JS_ENGINE}; then \ echo "Minifying jQuery" ${JQ_MIN}; \ ${COMPILER} ${JQ} > ${JQ_MIN}.tmp; \ From a2faed347de389d6f667a4e98576398db88d1a14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl=20F=C3=BCrstenberg?= Date: Thu, 17 Mar 2011 19:50:53 +0100 Subject: [PATCH 06/24] Merge when updating submodules on make When running make, the submodule update will remove all local changes. Adding flag --rebase or --merge does solve the issue. rebase will probably make it cleaner, but it might stop on conflict, thus --merge will result in fewer (probably none). --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 84816a19e..525d3a197 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,7 @@ ${DIST_DIR}: @@mkdir -p ${DIST_DIR} init: - @@if [ -d .git ]; then git submodule update --init --recursive; fi + @@if [ -d .git ]; then git submodule update --init --recursive --merge; fi jquery: init ${JQ} jq: init ${JQ} From 22738e0e4b988f8ce2cb341b137ba0fe4646d3f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl=20F=C3=BCrstenberg?= Date: Thu, 17 Mar 2011 20:15:44 +0100 Subject: [PATCH 07/24] Remove jq target remove obsolete jq target --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index 525d3a197..3223b8da4 100644 --- a/Makefile +++ b/Makefile @@ -52,7 +52,6 @@ init: @@if [ -d .git ]; then git submodule update --init --recursive --merge; fi jquery: init ${JQ} -jq: init ${JQ} ${JQ}: ${MODULES} | ${DIST_DIR} @@echo "Building" ${JQ} From 4f9e78616ecd9ca403a25ee0e3dc71781484e553 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl=20F=C3=BCrstenberg?= Date: Thu, 17 Mar 2011 20:14:15 +0100 Subject: [PATCH 08/24] Change makefile order to only update submodules on 'all' target insterad of always update the submodules, now only "make all" will run that, thus an "make jquery" will not update them --- Makefile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 3223b8da4..9ef44cff1 100644 --- a/Makefile +++ b/Makefile @@ -42,16 +42,13 @@ VER = sed "s/@VERSION/${JQ_VER}/" DATE=$(shell git log -1 --pretty=format:%ad) -all: jquery min lint +all: update_submodules jquery min lint @@echo "jQuery build complete." ${DIST_DIR}: @@mkdir -p ${DIST_DIR} -init: - @@if [ -d .git ]; then git submodule update --init --recursive --merge; fi - -jquery: init ${JQ} +jquery: ${JQ} ${JQ}: ${MODULES} | ${DIST_DIR} @@echo "Building" ${JQ} @@ -98,6 +95,10 @@ distclean: clean @@echo "Removing submodules" @@rm -rf test/qunit src/sizzle +# change pointers for submodules and update them to what is specified in jQuery +update_submodules: + @@if [ -d .git ]; then git submodule update --init --recursive --merge; fi + # update the submodules to the latest at the most logical branch pull_submodules: @@git submodule foreach "git pull origin \$$(git branch --no-color --contains \$$(git rev-parse HEAD) | grep -v \( | head -1)" From b4acb7ae819563c3b75bbdabfaf2662fd24b06e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl=20F=C3=BCrstenberg?= Date: Thu, 17 Mar 2011 20:16:19 +0100 Subject: [PATCH 09/24] updating phony rules --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 9ef44cff1..d377c4cf6 100644 --- a/Makefile +++ b/Makefile @@ -107,4 +107,4 @@ pull_submodules: pull: pull_submodules @@git pull ${REMOTE} ${BRANCH} -.PHONY: all jquery lint min init jq clean +.PHONY: all jquery lint min clean distclean update_submodules pull_submodules pull From e2dd8916eef1daba1a56a5ff1fbb44cb3385f4f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl=20F=C3=BCrstenberg?= Date: Thu, 17 Mar 2011 20:26:45 +0100 Subject: [PATCH 10/24] Adding core target Adding core target to do jquery, minimization and lint --- Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index d377c4cf6..99e742d6c 100644 --- a/Makefile +++ b/Makefile @@ -42,7 +42,9 @@ VER = sed "s/@VERSION/${JQ_VER}/" DATE=$(shell git log -1 --pretty=format:%ad) -all: update_submodules jquery min lint +all: update_submodules core + +core: jquery min lint @@echo "jQuery build complete." ${DIST_DIR}: @@ -107,4 +109,4 @@ pull_submodules: pull: pull_submodules @@git pull ${REMOTE} ${BRANCH} -.PHONY: all jquery lint min clean distclean update_submodules pull_submodules pull +.PHONY: all jquery lint min clean distclean update_submodules pull_submodules pull core From 8a1156da9b835d826bfb4b82c41bcdd0d87aff05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl=20F=C3=BCrstenberg?= Date: Thu, 17 Mar 2011 20:40:07 +0100 Subject: [PATCH 11/24] merge doesn't work when init sadly the merge strategy doesn't work when doing an initial clone, circumvent that --- Makefile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 99e742d6c..2c7bb8085 100644 --- a/Makefile +++ b/Makefile @@ -98,8 +98,16 @@ distclean: clean @@rm -rf test/qunit src/sizzle # change pointers for submodules and update them to what is specified in jQuery +# --merge doesn't work when doing an initial clone, thus test if we have non-existing +# submodules, then do an real update update_submodules: - @@if [ -d .git ]; then git submodule update --init --recursive --merge; fi + @@if [ -d .git ]; then \ + if git submodule status | grep -q -E '^-'; then \ + git submodule update --init --recursive; \ + else \ + git submodule update --init --recursive --merge; \ + fi; \ + fi; # update the submodules to the latest at the most logical branch pull_submodules: From c3c507e900fceb419628157504004ab2813b7d01 Mon Sep 17 00:00:00 2001 From: Richard Worth Date: Thu, 24 Mar 2011 15:41:46 -0400 Subject: [PATCH 12/24] 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(-) 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"); +}); From e8f4629b924cae0b0f1847d2368031f06bc08149 Mon Sep 17 00:00:00 2001 From: Michael Murray Date: Thu, 24 Mar 2011 19:02:38 -0400 Subject: [PATCH 13/24] 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(-) 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('