@@ -1193,52 +1193,54 @@ describe('jqLite', function() {
1193
1193
} ) ;
1194
1194
1195
1195
describe ( 'mouseenter-mouseleave' , function ( ) {
1196
- var root , parent , sibling , child , log ;
1196
+ var root , parent , child , log ;
1197
1197
1198
- beforeEach ( function ( ) {
1198
+ function setup ( html , parentNode , childNode ) {
1199
1199
log = '' ;
1200
- root = jqLite ( '<div>root<p>parent<span>child</span></p><ul></ul></div>' ) ;
1201
- parent = root . find ( 'p' ) ;
1202
- sibling = root . find ( 'ul' ) ;
1203
- child = parent . find ( 'span' ) ;
1200
+ root = jqLite ( html ) ;
1201
+ parent = root . find ( parentNode ) ;
1202
+ child = parent . find ( childNode ) ;
1204
1203
1205
1204
parent . on ( 'mouseenter' , function ( ) { log += 'parentEnter;' ; } ) ;
1206
1205
parent . on ( 'mouseleave' , function ( ) { log += 'parentLeave;' ; } ) ;
1207
1206
1208
1207
child . on ( 'mouseenter' , function ( ) { log += 'childEnter;' ; } ) ;
1209
1208
child . on ( 'mouseleave' , function ( ) { log += 'childLeave;' ; } ) ;
1210
- } ) ;
1209
+ }
1210
+
1211
+ function browserMoveTrigger ( from , to ) {
1212
+ var fireEvent = function ( type , element , relatedTarget ) {
1213
+ var evnt ;
1214
+ evnt = document . createEvent ( 'MouseEvents' ) ;
1215
+
1216
+ var originalPreventDefault = evnt . preventDefault ,
1217
+ appWindow = window ,
1218
+ fakeProcessDefault = true ,
1219
+ finalProcessDefault ;
1220
+
1221
+ evnt . preventDefault = function ( ) {
1222
+ fakeProcessDefault = false ;
1223
+ return originalPreventDefault . apply ( evnt , arguments ) ;
1224
+ } ;
1225
+
1226
+ var x = 0 , y = 0 ;
1227
+ evnt . initMouseEvent ( type , true , true , window , 0 , x , y , x , y , false , false ,
1228
+ false , false , 0 , relatedTarget ) ;
1229
+
1230
+ element . dispatchEvent ( evnt ) ;
1231
+ } ;
1232
+ fireEvent ( 'mouseout' , from [ 0 ] , to [ 0 ] ) ;
1233
+ fireEvent ( 'mouseover' , to [ 0 ] , from [ 0 ] ) ;
1234
+ }
1211
1235
1212
1236
afterEach ( function ( ) {
1213
1237
dealoc ( root ) ;
1214
1238
} ) ;
1215
1239
1216
1240
it ( 'should fire mouseenter when coming from outside the browser window' , function ( ) {
1217
1241
if ( window . jQuery ) return ;
1218
- var browserMoveTrigger = function ( from , to ) {
1219
- var fireEvent = function ( type , element , relatedTarget ) {
1220
- var evnt ;
1221
- evnt = document . createEvent ( 'MouseEvents' ) ;
1222
-
1223
- var originalPreventDefault = evnt . preventDefault ,
1224
- appWindow = window ,
1225
- fakeProcessDefault = true ,
1226
- finalProcessDefault ;
1227
-
1228
- evnt . preventDefault = function ( ) {
1229
- fakeProcessDefault = false ;
1230
- return originalPreventDefault . apply ( evnt , arguments ) ;
1231
- } ;
1232
-
1233
- var x = 0 , y = 0 ;
1234
- evnt . initMouseEvent ( type , true , true , window , 0 , x , y , x , y , false , false ,
1235
- false , false , 0 , relatedTarget ) ;
1236
-
1237
- element . dispatchEvent ( evnt ) ;
1238
- } ;
1239
- fireEvent ( 'mouseout' , from [ 0 ] , to [ 0 ] ) ;
1240
- fireEvent ( 'mouseover' , to [ 0 ] , from [ 0 ] ) ;
1241
- } ;
1242
+
1243
+ setup ( '<div>root<p>parent<span>child</span></p><ul></ul></div>' , 'p' , 'span' ) ;
1242
1244
1243
1245
browserMoveTrigger ( root , parent ) ;
1244
1246
expect ( log ) . toEqual ( 'parentEnter;' ) ;
@@ -1253,6 +1255,28 @@ describe('jqLite', function() {
1253
1255
expect ( log ) . toEqual ( 'parentEnter;childEnter;childLeave;parentLeave;' ) ;
1254
1256
1255
1257
} ) ;
1258
+
1259
+ it ( 'should fire the mousenter on SVG elements' , function ( ) {
1260
+ if ( window . jQuery ) return ;
1261
+
1262
+ setup (
1263
+ '<div>' +
1264
+ '<svg xmlns="http://www.w3.org/2000/svg"' +
1265
+ ' viewBox="0 0 18.75 18.75"' +
1266
+ ' width="18.75"' +
1267
+ ' height="18.75"' +
1268
+ ' version="1.1">' +
1269
+ ' <path d="M0,0c0,4.142,3.358,7.5,7.5,7.5s7.5-3.358,7.5-7.5-3.358-7.5-7.5-7.5-7.5,3.358-7.5,7.5"' +
1270
+ ' fill-rule="nonzero"' +
1271
+ ' fill="#CCC"' +
1272
+ ' ng-attr-fill="{{data.color || \'#CCC\'}}"/>' +
1273
+ '</svg>' +
1274
+ '</div>' ,
1275
+ 'svg' , 'path' ) ;
1276
+
1277
+ browserMoveTrigger ( parent , child ) ;
1278
+ expect ( log ) . toEqual ( 'childEnter;' ) ;
1279
+ } ) ;
1256
1280
} ) ;
1257
1281
1258
1282
// Only run this test for jqLite and not normal jQuery
0 commit comments