You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ra...@apache.org on 2019/04/28 20:37:52 UTC
[cordova-js] branch master updated: Allow to define modules whose
name appears on `Object.prototype` (#196)
This is an automated email from the ASF dual-hosted git repository.
raphinesse pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-js.git
The following commit(s) were added to refs/heads/master by this push:
new a5dec0a Allow to define modules whose name appears on `Object.prototype` (#196)
a5dec0a is described below
commit a5dec0a5c8a013a6181e6787a8d92e3b4adf4218
Author: Raphael von der GrĂ¼n <ra...@gmail.com>
AuthorDate: Sun Apr 28 22:37:47 2019 +0200
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.
---
src/scripts/require.js | 2 +-
test/test.require.js | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/scripts/require.js b/src/scripts/require.js
index 24c6a16..5656bfa 100644
--- a/src/scripts/require.js
+++ b/src/scripts/require.js
@@ -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';
}
diff --git a/test/test.require.js b/test/test.require.js
index b66e9ab..ace7616 100644
--- a/test/test.require.js
+++ b/test/test.require.js
@@ -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();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org