Permalink
Browse files

Setup Object.create(null) for IE only if used

This should resolve #150 but requires verification on IE.
  • Loading branch information...
1 parent 12adafe commit 0be51077f696b00704704ec33ed0802e5d2870f3 @kriskowal kriskowal committed Feb 6, 2013
Showing with 6 additions and 5 deletions.
  1. +6 −5 es5-sham.js
View
@@ -110,7 +110,7 @@ if (!Object.create) {
// aside from Object.prototype itself. Instead, create a new global
// object and *steal* its Object.prototype and strip it bare. This is
// used as the prototype to create nullary objects.
- createEmpty = (function () {
+ createEmpty = function () {
var iframe = document.createElement('iframe');
var parent = document.body || document.documentElement;
iframe.style.display = 'none';
@@ -130,11 +130,12 @@ if (!Object.create) {
function Empty() {}
Empty.prototype = empty;
-
- return function () {
+ // short-circuit future calls
+ createEmpty = function () {
return new Empty();
};
- })();
+ return new Empty();
+ };
}
Object.create = function create(prototype, properties) {
@@ -289,7 +290,7 @@ if (!Object.defineProperties || definePropertiesFallback) {
// try the shim if the real one doesn't work
}
}
-
+
for (var property in properties) {
if (owns(properties, property) && property != "__proto__") {
Object.defineProperty(object, property, properties[property]);

0 comments on commit 0be5107

Please sign in to comment.