File tree Expand file tree Collapse file tree 1 file changed +31
-1
lines changed
Expand file tree Collapse file tree 1 file changed +31
-1
lines changed Original file line number Diff line number Diff line change 438438 textDiff : function ( ) {
439439 arguments [ 0 ] . data = arguments [ 3 ] ;
440440 return ;
441- }
441+ } ,
442+ // empty functions were benchmarked as running faster than both
443+ // `f && f()` and `if (f) { f(); }`
444+ preVirtualDiffApply : function ( ) { } ,
445+ postVirtualDiffApply : function ( ) { } ,
446+ preDiffApply : function ( ) { } ,
447+ postDiffApply : function ( ) { }
442448 } ,
443449 i ;
444450
971977 nodeIndex = routeInfo . nodeIndex ,
972978 newNode , route , c ;
973979
980+ // pre-diff hook
981+ var info = {
982+ diff : diff ,
983+ node : node
984+ } ;
985+
986+ this . preVirtualDiffApply ( info ) ;
987+
974988 switch ( diff . action ) {
975989 case 'addAttribute' :
976990 if ( ! node . attributes ) {
10951109 console . log ( 'unknown action' ) ;
10961110 }
10971111
1112+ // capture newNode for the callback
1113+ info . newNode = newNode ;
1114+ this . postVirtualDiffApply ( info ) ;
1115+
10981116 return ;
10991117 } ,
11001118
11321150 var node = this . getFromRoute ( tree , diff . route ) ,
11331151 newNode , reference , route , c ;
11341152
1153+ // pre-diff hook
1154+ var info = {
1155+ diff : diff ,
1156+ node : node
1157+ } ;
1158+
1159+ this . preDiffApply ( info ) ;
1160+
11351161 switch ( diff . action ) {
11361162 case 'addAttribute' :
11371163 if ( ! node || ! node . setAttribute ) {
12231249 console . log ( 'unknown action' ) ;
12241250 }
12251251
1252+ // if a new node was created, we might be interested in it
1253+ info . newNode = newNode ;
1254+ this . postDiffApply ( info ) ;
1255+
12261256 return true ;
12271257 } ,
12281258
You can’t perform that action at this time.
0 commit comments