diff --git a/contrib/cursor/__tests__/Cursor.ts b/contrib/cursor/__tests__/Cursor.ts index 91adc3521c..e05c1e1460 100644 --- a/contrib/cursor/__tests__/Cursor.ts +++ b/contrib/cursor/__tests__/Cursor.ts @@ -49,6 +49,13 @@ describe('Cursor', () => { expect(deepCursor.deref()).toBe(data.getIn(Immutable.fromJS(['a', 'b']))); }); + it('cursor return new cursors of correct type', () => { + var data = Immutable.fromJS({ a: [1, 2, 3] }); + var cursor = Cursor.from(data); + var deepCursor = cursor.cursor('a'); + expect(deepCursor.findIndex).toBeDefined(); + }); + it('can be treated as a value', () => { var data = Immutable.fromJS(json); var cursor = Cursor.from(data, ['a', 'b']); diff --git a/contrib/cursor/index.js b/contrib/cursor/index.js index 61e9574c78..37eb012eda 100644 --- a/contrib/cursor/index.js +++ b/contrib/cursor/index.js @@ -233,6 +233,13 @@ function wrappedValue(cursor, keyPath, value) { } function subCursor(cursor, keyPath, value) { + if (arguments.length < 3) { + return makeCursor( // call without value + cursor._rootData, + newKeyPath(cursor._keyPath, keyPath), + cursor._onChange + ); + } return makeCursor( cursor._rootData, newKeyPath(cursor._keyPath, keyPath),