1
0
Fork 0

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.
textend
Mike Gerwitz 2014-08-07 22:24:25 -04:00
parent cef45cd097
commit d0ec7aca9b
2 changed files with 8 additions and 3 deletions

View File

@ -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;
},

View File

@ -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 );
},