@@ -2065,13 +2065,13 @@ function spliceOut(array, idx, canEdit) {
2065
2065
var MAX_BITMAP_SIZE = SIZE / 2 ;
2066
2066
var MIN_ARRAY_SIZE = SIZE / 4 ;
2067
2067
var EMPTY_MAP ;
2068
- var Cursor = function Cursor ( rootData , keyPath , onChange , length ) {
2068
+ var MapCursor = function MapCursor ( rootData , keyPath , onChange , length ) {
2069
2069
this . length = length ;
2070
2070
this . _rootData = rootData ;
2071
2071
this . _keyPath = keyPath ;
2072
2072
this . _onChange = onChange ;
2073
2073
} ;
2074
- ( $traceurRuntime . createClass ) ( Cursor , {
2074
+ ( $traceurRuntime . createClass ) ( MapCursor , {
2075
2075
equals : function ( second ) {
2076
2076
return is ( this . deref ( ) , second && ( typeof second . deref === 'function' ? second . deref ( ) : second ) ) ;
2077
2077
} ,
@@ -2157,6 +2157,10 @@ var Cursor = function Cursor(rootData, keyPath, onChange, length) {
2157
2157
return m . asImmutable ( ) ;
2158
2158
} ) ) ;
2159
2159
} ,
2160
+ wasAltered : function ( ) {
2161
+ var deref = this . deref ( ) ;
2162
+ return ! ! ( deref && deref . __altered ) ;
2163
+ } ,
2160
2164
__iterate : function ( fn , reverse ) {
2161
2165
var $__0 = this ;
2162
2166
var deref = this . deref ( ) ;
@@ -2181,16 +2185,20 @@ var Cursor = function Cursor(rootData, keyPath, onChange, length) {
2181
2185
var v = entry [ 1 ] ;
2182
2186
return iteratorValue ( type , k , wrappedValue ( $__0 , k , v ) , step ) ;
2183
2187
} ) ) ;
2188
+ } ,
2189
+ __ensureOwner : function ( ownerID ) {
2190
+ return updateCursor ( this , ( function ( m ) {
2191
+ return m . __ensureOwner ( ownerID ) ;
2192
+ } ) ) ;
2184
2193
}
2185
- } , { } , Sequence ) ;
2186
- Cursor . prototype [ DELETE ] = Cursor . prototype . remove ;
2187
- Cursor . prototype . update = MapPrototype . update ;
2194
+ } , { } , Map ) ;
2195
+ MapCursor . prototype [ DELETE ] = MapCursor . prototype . remove ;
2188
2196
function makeCursor ( rootData , keyPath , onChange , value ) {
2189
2197
if ( arguments . length < 4 ) {
2190
2198
value = rootData . getIn ( keyPath ) ;
2191
2199
}
2192
2200
var length = value instanceof Sequence ? value . length : null ;
2193
- return new Cursor ( rootData , keyPath , onChange , length ) ;
2201
+ return new MapCursor ( rootData , keyPath , onChange , length ) ;
2194
2202
}
2195
2203
function wrappedValue ( cursor , key , value ) {
2196
2204
return value instanceof Sequence ? subCursor ( cursor , key , value ) : value ;
@@ -2208,6 +2216,9 @@ function updateCursor(cursor, changeFn, changeKey) {
2208
2216
}
2209
2217
var updateIn = applyUpdateIn ( keyPath , changeFn ) ;
2210
2218
var newRootData = typeof rootData . deref === 'function' ? updateCursor ( rootData , updateIn , editPath ) : updateIn ( rootData ) ;
2219
+ if ( newRootData === rootData ) {
2220
+ return rootData ;
2221
+ }
2211
2222
onChange && onChange ( newRootData , rootData , editPath ) ;
2212
2223
return makeCursor ( newRootData , keyPath , onChange ) ;
2213
2224
}
0 commit comments