diff --git a/src/jqLite.js b/src/jqLite.js old mode 100644 new mode 100755 index 2c209ecde516..e86920ebfe54 --- a/src/jqLite.js +++ b/src/jqLite.js @@ -607,20 +607,20 @@ forEach({ if (!eventFns) { if (type == 'mouseenter' || type == 'mouseleave') { - var counter = 0; + var entered = false; events.mouseenter = []; events.mouseleave = []; bindFn(element, 'mouseover', function(event) { - counter++; - if (counter == 1) { + if (!entered) { + entered = true; handle(event, 'mouseenter'); } }); bindFn(element, 'mouseout', function(event) { - counter --; - if (counter == 0) { + if (entered && indexOf(element.getElementsByTagName('*'), (event.toElement || event.relatedTarget)) === -1) { + entered = false; handle(event, 'mouseleave'); } }); diff --git a/test/jqLiteSpec.js b/test/jqLiteSpec.js old mode 100644 new mode 100755 index b1fa6b058207..f15b063c37d9 --- a/test/jqLiteSpec.js +++ b/test/jqLiteSpec.js @@ -798,8 +798,6 @@ describe('jqLite', function() { child.mouseover(); expect(log).toEqual('parentEnter;childEnter;'); - child.mouseout(); - expect(log).toEqual('parentEnter;childEnter;'); child.mouseout(); expect(log).toEqual('parentEnter;childEnter;childLeave;'); parent.mouseout();