Skip to content

Commit 07392bb

Browse files
committed
Merge branch 'master' into makefile_fixes
2 parents 51abb3d + 7705c35 commit 07392bb

File tree

3 files changed

+80
-17
lines changed

3 files changed

+80
-17
lines changed

Makefile

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,15 @@ VER = sed "s/@VERSION/${JQ_VER}/"
4242

4343
DATE=$(shell git log -1 --pretty=format:%ad)
4444

45-
all: jquery min lint
45+
all: update_submodules core
46+
47+
core: jquery min lint
4648
@@echo "jQuery build complete."
4749

4850
${DIST_DIR}:
4951
@@mkdir -p ${DIST_DIR}
5052

51-
init:
52-
@@if [ -d .git ]; then git submodule update --init --recursive; fi
53-
54-
jquery: init ${JQ}
55-
jq: init ${JQ}
53+
jquery: ${JQ}
5654

5755
${JQ}: ${MODULES} | ${DIST_DIR}
5856
@@echo "Building" ${JQ}
@@ -99,6 +97,18 @@ distclean: clean
9997
@@echo "Removing submodules"
10098
@@rm -rf test/qunit src/sizzle
10199

100+
# change pointers for submodules and update them to what is specified in jQuery
101+
# --merge doesn't work when doing an initial clone, thus test if we have non-existing
102+
# submodules, then do an real update
103+
update_submodules:
104+
@@if [ -d .git ]; then \
105+
if git submodule status | grep -q -E '^-'; then \
106+
git submodule update --init --recursive; \
107+
else \
108+
git submodule update --init --recursive --merge; \
109+
fi; \
110+
fi;
111+
102112
# update the submodules to the latest at the most logical branch
103113
pull_submodules:
104114
@@git submodule foreach "git pull origin \$$(git branch --no-color --contains \$$(git rev-parse HEAD) | grep -v \( | head -1)"
@@ -107,4 +117,4 @@ pull_submodules:
107117
pull: pull_submodules
108118
@@git pull ${REMOTE} ${BRANCH}
109119

110-
.PHONY: all jquery lint min init jq clean
120+
.PHONY: all jquery lint min clean distclean update_submodules pull_submodules pull core

src/event.js

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ jQuery.event = {
7070
}
7171

7272
if ( !eventHandle ) {
73-
elemData.handle = eventHandle = function() {
73+
elemData.handle = eventHandle = function( e ) {
7474
// Handle the second event of a trigger and when
7575
// an event is called after a page has unloaded
76-
return typeof jQuery !== "undefined" && !jQuery.event.triggered ?
76+
return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
7777
jQuery.event.handle.apply( eventHandle.elem, arguments ) :
7878
undefined;
7979
};
@@ -380,7 +380,7 @@ jQuery.event = {
380380
target[ "on" + targetType ] = null;
381381
}
382382

383-
jQuery.event.triggered = true;
383+
jQuery.event.triggered = event.type;
384384
target[ targetType ]();
385385
}
386386

@@ -391,7 +391,7 @@ jQuery.event = {
391391
target[ "on" + targetType ] = old;
392392
}
393393

394-
jQuery.event.triggered = false;
394+
jQuery.event.triggered = undefined;
395395
}
396396
}
397397
},
@@ -661,7 +661,7 @@ var withinElement = function( event ) {
661661

662662
// Chrome does something similar, the parentNode property
663663
// can be accessed but is null.
664-
if ( parent !== document && !parent.parentNode ) {
664+
if ( parent && parent !== document && !parent.parentNode ) {
665665
return;
666666
}
667667
// Traverse up the tree
@@ -868,19 +868,33 @@ function trigger( type, elem, args ) {
868868
// Create "bubbling" focus and blur events
869869
if ( document.addEventListener ) {
870870
jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
871+
872+
// Attach a single capturing handler while someone wants focusin/focusout
873+
var attaches = 0;
874+
871875
jQuery.event.special[ fix ] = {
872876
setup: function() {
873-
this.addEventListener( orig, handler, true );
877+
if ( attaches++ === 0 ) {
878+
document.addEventListener( orig, handler, true );
879+
}
874880
},
875881
teardown: function() {
876-
this.removeEventListener( orig, handler, true );
882+
if ( --attaches === 0 ) {
883+
document.removeEventListener( orig, handler, true );
884+
}
877885
}
878886
};
879887

880-
function handler( e ) {
881-
e = jQuery.event.fix( e );
888+
function handler( donor ) {
889+
// Donor event is always a native one; fix it and switch its type.
890+
// Let focusin/out handler cancel the donor focus/blur event.
891+
var e = jQuery.event.fix( donor );
882892
e.type = fix;
883-
return jQuery.event.handle.call( this, e );
893+
e.originalEvent = {};
894+
jQuery.event.trigger( e, null, e.target );
895+
if ( e.isDefaultPrevented() ) {
896+
donor.preventDefault();
897+
}
884898
}
885899
});
886900
}

test/unit/event.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,20 @@ test("hover()", function() {
683683
equals( times, 4, "hover handlers fired" );
684684
});
685685

686+
test("mouseover triggers mouseenter", function() {
687+
expect(1);
688+
689+
var count = 0,
690+
elem = jQuery("<a />");
691+
elem.mouseenter(function () {
692+
count++;
693+
});
694+
elem.trigger('mouseover');
695+
equals(count, 1, "make sure mouseover triggers a mouseenter" );
696+
697+
elem.remove();
698+
});
699+
686700
test("trigger() shortcuts", function() {
687701
expect(6);
688702

@@ -1966,6 +1980,31 @@ test("window resize", function() {
19661980
ok( !jQuery._data(window, "__events__"), "Make sure all the events are gone." );
19671981
});
19681982

1983+
test("focusin bubbles", function() {
1984+
expect(4);
1985+
1986+
var input = jQuery( '<input type="text" />' ).prependTo( "body" ),
1987+
order = 0;
1988+
1989+
jQuery( "body" ).bind( "focusin.focusinBubblesTest", function(){
1990+
equals( 1, order++, "focusin on the body second" );
1991+
});
1992+
1993+
input.bind( "focusin.focusinBubblesTest", function(){
1994+
equals( 0, order++, "focusin on the element first" );
1995+
});
1996+
1997+
// DOM focus method
1998+
input[0].focus();
1999+
// jQuery trigger, which calls DOM focus
2000+
order = 0;
2001+
input[0].blur();
2002+
input.trigger( "focus" );
2003+
2004+
input.remove();
2005+
jQuery( "body" ).unbind( "focusin.focusinBubblesTest" );
2006+
});
2007+
19692008
/*
19702009
test("jQuery(function($) {})", function() {
19712010
stop();

0 commit comments

Comments
 (0)