@@ -205,34 +205,33 @@ var CompoundPath = PathItem.extend(/** @lends CompoundPath# */{
205205 children [ i ] . _draw ( ctx , param ) ;
206206 var res = ctx . isPointInPath ( point . x , point . y , this . getWindingRule ( ) ) ;
207207 CanvasProvider . release ( ctx ) ;
208- return res && children ;
209- /*#*/ } // options.nativeContains
210-
208+ return res ;
209+ /*#*/ } else { // !options.nativeContains
211210 // Compound paths are a little complex: In order to determine whether a
212211 // point is inside a path or not due to the winding rule, we need to
213212 // check all the children and count how many intersect. If it's an odd
214213 // number, the point is inside the path. Once we know it's inside the
215214 // path, _hitTest also needs access to the first intersecting element,
216215 // for the HitResult, so we return it here.
217- var total = 0 ,
218- first = null ,
219- evenOdd = this . getWindingRule ( ) === 'evenodd' ;
220- for ( var i = 0 , l = this . _children . length ; i < l ; i ++ ) {
221- var child = this . _children [ i ] ,
222- winding = child . _getWinding ( point ) ;
223- total += winding ;
224- if ( ! first && ( evenOdd ? winding & 1 : winding ) )
225- first = child ;
226- }
227- return ( evenOdd ? total & 1 : total ) && first ;
216+ var children = this . _children ,
217+ winding = 0 ;
218+ for ( var i = 0 , l = children . length ; i < l ; i ++ )
219+ winding += children [ i ] . _getWinding ( point ) ;
220+ return ! ! ( this . getWindingRule ( ) === 'evenodd' ? winding & 1 : winding ) ;
221+ /*#*/ } // !options.nativeContains
228222 } ,
229223
230224 _hitTest : function _hitTest ( point , options ) {
231225 var res = _hitTest . base . call ( this , point ,
232226 Base . merge ( options , { fill : false } ) ) ;
233227 if ( ! res && options . fill && this . hasFill ( ) ) {
234- res = this . _contains ( point ) ;
235- res = res ? new HitResult ( 'fill' , res ) : null ;
228+ if ( options . compoundChildren ) {
229+ var children = this . _children ;
230+ for ( var i = children . length - 1 ; i >= 0 && ! res ; i -- )
231+ res = children [ i ] . _hitTest ( point , options ) ;
232+ } else if ( this . _contains ( point ) ) {
233+ res = new HitResult ( 'fill' , this ) ;
234+ }
236235 }
237236 return res ;
238237 } ,
0 commit comments