Skip to content

Commit 1b8bf0f

Browse files
committed
Check for (g/s)etter support, not Object.defineProperty
1 parent 3ed2783 commit 1b8bf0f

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

lib/HotModuleReplacement.runtime.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@
55
/*global $hash$ installedModules $require$ hotDownloadManifest hotDownloadUpdateChunk modules */
66
module.exports = function() {
77

8+
// Copied from https://github.com/facebook/react/blob/bef45b0/src/shared/utils/canDefineProperty.js
9+
var canDefineProperty = false;
10+
try {
11+
Object.defineProperty({}, "x", {
12+
get: function() {}
13+
});
14+
canDefineProperty = true;
15+
} catch(x) {
16+
// IE will fail on defineProperty
17+
}
18+
819
var hotApplyOnUpdate = true;
920
var hotCurrentHash = $hash$; // eslint-disable-line no-unused-vars
1021
var hotCurrentModuleData = {};
@@ -29,7 +40,7 @@ module.exports = function() {
2940
};
3041
for(var name in $require$) {
3142
if(Object.prototype.hasOwnProperty.call($require$, name)) {
32-
if(Object.defineProperty) {
43+
if(canDefineProperty) {
3344
Object.defineProperty(fn, name, (function(name) {
3445
return {
3546
configurable: true,
@@ -72,7 +83,7 @@ module.exports = function() {
7283
}
7384
});
7485
}
75-
if(Object.defineProperty) {
86+
if(canDefineProperty) {
7687
Object.defineProperty(fn, "e", {
7788
enumerable: true,
7889
value: ensure

0 commit comments

Comments
 (0)