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

Setup Object.create(null) only if used. #151

Merged
merged 2 commits into from
May 10, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 6 additions & 5 deletions es5-sham.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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) {
Expand Down Expand Up @@ -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]);
Expand Down
12 changes: 6 additions & 6 deletions es5-sham.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading