@@ -274,6 +274,7 @@ define([
274274 _fireEvent : function ( id , type , toMark , oldState ) {
275275 var t = this ,
276276 m = t . model ;
277+ // debugger;
277278 if ( toMark != oldState ) {
278279 if ( ! toMark ) {
279280 delete t . _byId [ type ] [ id ] ;
@@ -317,7 +318,7 @@ define([
317318 } ,
318319
319320 _doMark : function ( id , tp , toMark , skipParent , noEvent ) {
320- var i , ids , children , childId , treePath ,
321+ var i , ids , children , childId , treePath , childrenLen ,
321322 t = this ,
322323 m = t . model ,
323324 mm = m . _model ,
@@ -326,15 +327,28 @@ define([
326327 lazy = t . _lazy [ tp ] ,
327328 // selectable = t._byId['selectable'],
328329 oldState = byId [ id ] || 0 ,
329- newState ;
330+ newState , parent ;
331+
330332 if ( t . _tree [ tp ] ) {
331333 children = mm . _call ( 'children' , [ id ] ) ;
332- if ( toMark == 1 && array . every ( children , function ( childId ) {
333- return ( last [ childId ] || 0 ) == ( last [ children [ 0 ] ] || 0 ) ;
334- } ) ) {
335- toMark = 2 ;
334+ childrenLen = children . length ;
335+
336+ if ( toMark === 1 ) {
337+ if ( childrenLen > 1 ) {
338+ if ( array . every ( children , function ( childId ) {
339+ return ( last [ childId ] || 0 ) == ( last [ children [ 0 ] ] || 0 ) ;
340+ } ) ) {
341+ toMark = 2 ;
342+ }
343+
344+ } else if ( childrenLen === 1 ) {
345+ toMark = last [ children [ 0 ] ] === 1 ? 1 : 2 ;
346+ } else { //without children rows
347+ toMark = 2 ;
348+ }
336349 }
337350 }
351+
338352 byId [ id ] = last [ id ] = toMark ;
339353 if ( ! noEvent ) {
340354 t . _fireEvent ( id , tp , toMark , oldState ) ;
@@ -344,7 +358,15 @@ define([
344358 while ( ids . length ) {
345359 childId = ids . shift ( ) ;
346360 oldState = byId [ childId ] || 0 ;
347- newState = byId [ childId ] = toMark == 1 ? last [ childId ] || 0 : toMark ;
361+ newState = byId [ childId ] = toMark == 1 ? last [ childId ] || undefined : toMark ;
362+
363+ if ( newState === undefined ) {
364+ parent = mm . _call ( 'treePath' , [ childId ] ) ;
365+ newState = byId [ parent . pop ( ) ] ;
366+ newState = newState === 1 ? 0 : newState ;
367+ byId [ childId ] = newState ;
368+ }
369+
348370 if ( ! noEvent ) {
349371 t . _fireEvent ( childId , tp , newState , oldState ) ;
350372 }
0 commit comments