From d0ec7aca9b7f149f40db9a511820bef0cc46caec Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Thu, 7 Aug 2014 22:24:25 -0400 Subject: [PATCH] method.super references now ES3-compatible This is a bugfix; the bug was introduced in v0.2.3. In ECMAScript 5, reserved keywords can be used to reference the field of an object in dot notation (e.g. method.super), but in ES3 this is prohibited; in these cases, method['super'] must be used. To maintain ES3 compatiblity, GNU ease.js will use the latter within its code. Of course, if you are developing software that need not support ES3, then you can use the dot notation yourself in your own code. This does not sway my decision to use `super`---ES3 will soon (hopefully) become extinct, and would be already were it not for the terrible influence of Microsloth's outdated browsers. --- lib/MethodWrappers.js | 6 +++++- test/MethodWrappersTest.js | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/MethodWrappers.js b/lib/MethodWrappers.js index 2f88cca..e000a60 100644 --- a/lib/MethodWrappers.js +++ b/lib/MethodWrappers.js @@ -59,7 +59,11 @@ exports.standard = { return retval; }; - retf.super = super_method; + // `super` is reserved and, in ES3, this causes problems with the + // dot-notation; while `foo.super` will work fine in modern (ES5) + // browsers, we need to maintain our ES3 compatibility + retf['super'] = super_method; + return retf; }, diff --git a/test/MethodWrappersTest.js b/test/MethodWrappersTest.js index b3d740f..6f73e7b 100644 --- a/test/MethodWrappersTest.js +++ b/test/MethodWrappersTest.js @@ -229,8 +229,9 @@ require( 'common' ).testCase( ; // we should be able to invoke the super method by override.super, - // which is added atop of the wrapper - this.assertStrictEqual( override.super(), expected ); + // which is added atop of the wrapper (note that we quote it to avoid + // problems with ES3 engines) + this.assertStrictEqual( override['super'](), expected ); },