Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 577c9a0

Browse filesBrowse files
committed
Merge pull request immutable-js#381 from jeffbski/subCursor-fix
subCursor (cursor.cursor('a')) returns improper type
2 parents 625e2ce + f7b56a7 commit 577c9a0
Copy full SHA for 577c9a0

File tree

Expand file treeCollapse file tree

2 files changed

+14
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+14
-0
lines changed

‎contrib/cursor/__tests__/Cursor.ts

Copy file name to clipboardExpand all lines: contrib/cursor/__tests__/Cursor.ts
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ describe('Cursor', () => {
4949
expect(deepCursor.deref()).toBe(data.getIn(Immutable.fromJS(['a', 'b'])));
5050
});
5151

52+
it('cursor return new cursors of correct type', () => {
53+
var data = Immutable.fromJS({ a: [1, 2, 3] });
54+
var cursor = Cursor.from(data);
55+
var deepCursor = <any>cursor.cursor('a');
56+
expect(deepCursor.findIndex).toBeDefined();
57+
});
58+
5259
it('can be treated as a value', () => {
5360
var data = Immutable.fromJS(json);
5461
var cursor = Cursor.from(data, ['a', 'b']);

‎contrib/cursor/index.js

Copy file name to clipboardExpand all lines: contrib/cursor/index.js
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,13 @@ function wrappedValue(cursor, keyPath, value) {
233233
}
234234

235235
function subCursor(cursor, keyPath, value) {
236+
if (arguments.length < 3) {
237+
return makeCursor( // call without value
238+
cursor._rootData,
239+
newKeyPath(cursor._keyPath, keyPath),
240+
cursor._onChange
241+
);
242+
}
236243
return makeCursor(
237244
cursor._rootData,
238245
newKeyPath(cursor._keyPath, keyPath),

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.