Skip to content
This repository was archived by the owner on Apr 14, 2021. It is now read-only.

Commit fb00b5a

Browse files
xkr47caridy
authored andcommitted
Fix defineProperty to work with Java7 Rhino JS (#207)
Apparently `Object.defineProperty(fn, 'prototype', { writable: false });` sets `fn.prototype` to `null` in Java7 Rhino JS. Naive version works, so update detection code to check that.
1 parent 947fbb8 commit fb00b5a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/util.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
const realDefineProp = (function () {
2-
let sentinel = {};
2+
let sentinel = function(){};
33
try {
44
Object.defineProperty(sentinel, 'a', {
55
get: function () {
66
return 1;
77
}
88
});
9-
return sentinel.a === 1;
9+
Object.defineProperty(sentinel, 'prototype', { writable: false });
10+
return sentinel.a === 1 && sentinel.prototype instanceof Object;
1011
} catch (e) {
1112
return false;
1213
}

0 commit comments

Comments
 (0)