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

Fixes #9 #10

Merged
merged 1 commit into from
Jul 19, 2014
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/polyfill-wrap/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ function wrapDefault(code, polyfillName) {
expression = 'typeof ' + parts[0] + ' === "undefined"';
} else if (parts.length === 2) {
// Object.keys
// typeof Object === "undefined" || Object && !Object.keys
expression = 'typeof ' + parts[0] + ' === "undefined" || ' + parts[0] + ' && !' + parts[0] + '.' + parts[1];
// typeof Object !== "undefined" && !Object.keys
expression = 'typeof ' + parts[0] + ' !== "undefined" && !' + parts[0] + '.' + parts[1];
} else if (parts[0] === 'Window' && parts[1] === 'prototype' && parts[2]) {
// Window.prototype.JSON
expression = 'typeof window.' + parts[2] + ' === "undefined"';
Expand Down
2 changes: 1 addition & 1 deletion test/test.polyfill-wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('polyfill-wrap', function() {
var wrappedCode = wrap(code, polyfillName);

expect(wrappedCode).to.match(/Object.keys = function \(\) \{\};/);
expect(wrappedCode).to.match(/typeof Object === "undefined" || Object && !Object.keys/);
expect(wrappedCode).to.match(/typeof Object !== "undefined" && !Object.keys/);
});

describe('.addWrapper', function() {
Expand Down