Skip to content

Commit

Permalink
Merge pull request #10 from azproduction/issue-9
Browse files Browse the repository at this point in the history
Fixes #9
  • Loading branch information
azproduction committed Jul 19, 2014
2 parents 8180fd0 + 511414d commit 34954a6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
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

0 comments on commit 34954a6

Please sign in to comment.