@@ -17,7 +17,7 @@ export function wrapValue(obj, key, value) {
1717 return availableMachines . get ( value ) ;
1818 }
1919
20- if ( shouldWrapValue ( ... arguments ) ) {
20+ if ( shouldWrapValue ( obj , key , value ) ) {
2121 if ( isArray ( value ) ) {
2222 Machine = TimeMachine . Array ;
2323 } else if ( typeof value === 'object' ) {
@@ -40,12 +40,12 @@ export function wrapValue(obj, key, value) {
4040}
4141
4242export function unwrapValue ( value ) {
43- if ( value && isArray ( value ) ) {
44- return value . map ( ( v ) => get ( v , 'isTimeMachine' ) ? unwrapValue ( get ( v , 'content' ) ) : v ) ;
43+ if ( value && get ( value , 'isTimeMachine' ) ) {
44+ return unwrapValue ( get ( value , 'content' ) ) ;
4545 }
4646
47- if ( value && ( value instanceof Ember . ObjectProxy || get ( value , 'isTimeMachine' ) ) ) {
48- return unwrapValue ( get ( value , 'content' ) ) ;
47+ if ( value && isArray ( value ) ) {
48+ return value . map ( ( v ) => get ( v , 'isTimeMachine' ) ? unwrapValue ( get ( v , 'content' ) ) : v ) ;
4949 }
5050
5151 return value ;
@@ -54,12 +54,11 @@ export function unwrapValue(value) {
5454function shouldWrapValue ( obj , key , value ) {
5555 let state = obj . get ( '_rootMachineState' ) ;
5656 let maxDepth = state . get ( 'maxDepth' ) ;
57- let shouldWrapValue = state . get ( 'shouldWrapValue' ) ;
58-
5957 let fullPath = obj . get ( '_path' ) . concat ( key ) ;
6058 let valueType = typeOf ( value ) ;
61- let trackCurrDepth = maxDepth < 0 || fullPath . length <= maxDepth ;
62- let correctValueType = valueType === 'object' || valueType === 'instance' || valueType === 'array' ;
6359
64- return value && correctValueType && trackCurrDepth && ! get ( value , 'isTimeMachine' ) && shouldWrapValue ( value , obj , key ) ;
60+ return ( valueType === 'object' || valueType === 'instance' || valueType === 'array' ) &&
61+ ( maxDepth < 0 || fullPath . length <= maxDepth ) &&
62+ ! get ( value , 'isTimeMachine' ) &&
63+ state . shouldWrapValue ( value , obj , key ) ;
6564}
0 commit comments