Skip to content
Permalink
Browse files
Allow to define modules whose name appears on Object.prototype (#196)
One of the CommonJS tests adopted in #195 exposed a defect in Cordova's module system:

When trying to define a module with a name that also is a property of Object.prototype, an exception would occur.
  • Loading branch information
raphinesse committed Apr 28, 2019
1 parent dd8b78f commit a5dec0a5c8a013a6181e6787a8d92e3b4adf4218
Showing 2 changed files with 2 additions and 2 deletions.
@@ -67,7 +67,7 @@ var define;
};

define = function (id, factory) {
if (modules[id]) {
if (Object.prototype.hasOwnProperty.call(modules, id)) {
throw 'module ' + id + ' already defined';
}

@@ -231,7 +231,7 @@ describe('require + define', function () {
});

// Adapted version of CommonJS test `hasOwnProperty`
xit('Test#018 : allows properties of Object.prototype as module names', () => {
it('Test#018 : allows properties of Object.prototype as module names', () => {
expect(() => {
define('hasOwnProperty', jasmine.createSpy());
}).not.toThrow();

0 comments on commit a5dec0a

Please sign in to comment.