Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ES6 Map/Set checks for cross-window scripts #3893

Merged
merged 3 commits into from
Jun 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/mobx/src/types/observablemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ export class ObservableMap<K = any, V = any>
} else if (Array.isArray(other)) {
other.forEach(([key, value]) => this.set(key, value))
} else if (isES6Map(other)) {
if (other.constructor !== Map) {
if (other.constructor.name !== "Map") {
urugator marked this conversation as resolved.
Show resolved Hide resolved
die(19, other)
}
other.forEach((value, key) => this.set(key, value))
Expand Down
4 changes: 2 additions & 2 deletions packages/mobx/src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@ export function createInstanceofPredicate<T>(
}

export function isES6Map(thing: any): thing is Map<any, any> {
return thing instanceof Map
return thing != null && Object.prototype.toString.call(thing) === "[object Map]"
}

export function isES6Set(thing: any): thing is Set<any> {
return thing instanceof Set
return thing != null && Object.prototype.toString.call(thing) === "[object Set]"
}

const hasGetOwnPropertySymbols = typeof Object.getOwnPropertySymbols !== "undefined"
Expand Down