Skip to content

Commit

Permalink
Fix for Set prototype resolution (#3843)
Browse files Browse the repository at this point in the history
Fixed issue that could result in stack overflow when using Set iterators.
  • Loading branch information
FFranck authored Jul 26, 2021
1 parent 1a8bed9 commit c1fc086
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ x.x.x Release notes (yyyy-MM-dd)
* None.

### Fixed
* Fixed TypeScript definition of `Realm.Dictionary.remove()`. (since v10.6.0)
* Fixed Realm.Object#toJSON as it threw "Right-hand side of 'instanceof' is not an object". (since v10.6.0)
* Fix TypeScript definition of `Realm.Dictionary.remove()`. (since v10.6.0)
* Fixed `Realm not defined` error experienced when using `Realm.Set` iterators under Jest

### Compatibility
* MongoDB Realm Cloud.
Expand Down
4 changes: 3 additions & 1 deletion lib/collection-methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ Object.defineProperty(iteratorPrototype, Symbol.iterator, {

["entries", "keys", "values"].forEach(function (methodName) {
var method = function () {
const isSet = this instanceof Realm.Set;
// checks for Set datatype. Required for compatibility with node.js, Jest, and RN
// instanceof Set is not performing correctly in Jest tests, so we need to use an alternate method
const isSet = (this.constructor && this.constructor.name === "Set") || this instanceof Realm.Set;
var self = this.type === "object" || isSet ? this.snapshot() : this;
var index = 0;

Expand Down

0 comments on commit c1fc086

Please sign in to comment.