Skip to content

Commit 0a5fd25

Browse files
authored
Merge pull request #6 from purescript-web/unsafeReadProtoTagged-fix
Use instanceof check for unsafeReadProtoTagged
2 parents a7b494b + 0ed902d commit 0a5fd25

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

src/Web/Internal/FFI.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
11
"use strict";
22

33
exports._unsafeReadProtoTagged = function (nothing, just, name, value) {
4-
var obj = value;
5-
while (obj != null) {
6-
var proto = Object.getPrototypeOf(obj);
7-
var ctor = proto.constructor.name;
8-
if (ctor === name) {
9-
return just(value);
10-
} else if (ctor === "Object") {
11-
return nothing;
12-
}
13-
obj = proto;
4+
var ty = window[name];
5+
if (ty != null && value instanceof ty) {
6+
return just(value);
147
}
158
return nothing;
169
};

0 commit comments

Comments
 (0)