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 f7b56a7

Browse filesBrowse files
committed
fix cursor.cursor() using argument.length
When calling cursor.cursor(), the subCursor fn calls makeCursor and its logic expects arguments.length less than 4 to trigger making subCursor. Unfortunately subCursor calls it with 4 arguments, so we can correct this so that it will call with 3 or 4 depending on how it was called. This is an alternate fix to @jcranendonk's since the other fix checked if value was void 0 (undefined), however it might be valid to pass undefined to these functions, so the argument.length check is probably safer.
1 parent 3c66921 commit f7b56a7
Copy full SHA for f7b56a7

File tree

Expand file treeCollapse file tree

1 file changed

+8
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-1
lines changed

‎contrib/cursor/index.js

Copy file name to clipboardExpand all lines: contrib/cursor/index.js
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ IndexedCursor.prototype = IndexedCursorPrototype;
220220
var NOT_SET = {}; // Sentinel value
221221

222222
function makeCursor(rootData, keyPath, onChange, value) {
223-
if (value === void 0) {
223+
if (arguments.length < 4) {
224224
value = rootData.getIn(keyPath);
225225
}
226226
var size = value && value.size;
@@ -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.