Bug 21424 - Futures: rename `catch`
Futures: rename `catch`
Status: RESOLVED WONTFIX
Product: WebAppsWG
Classification: Unclassified
Component: DOM
unspecified
PC All
: P2 normal
: ---
Assigned To: Anne
public-webapps-bugzilla
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-03-28 16:39 UTC by Mathias Bynens
Modified: 2013-03-28 16:55 UTC (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mathias Bynens 2013-03-28 16:39:15 UTC
`catch` used to be a reserved word in ES3: http://mothereff.in/js-properties#catch

It would be better to use a different name that doesn’t cause syntax errors in older browsers, so that feature detection for Futures can be done without `try`/`catch`.
Comment 1 Domenic Denicola 2013-03-28 16:40:50 UTC
This shouldn't matter. `catch` is not what you feature-detect on; `then` is.
Comment 2 Erik Arvidsson 2013-03-28 16:49:24 UTC
All browsers supports ES5. I would mark this as WONT FIX
Comment 3 Anne 2013-03-28 16:52:21 UTC
arv has spoken per expectations. Less work for me. Sorry Mathias!
Comment 4 Mathias Bynens 2013-03-28 16:53:30 UTC
(In reply to comment #1)
> This shouldn't matter. `catch` is not what you feature-detect on; `then` is.

(In reply to comment #1)
> This shouldn't matter. `catch` is not what you feature-detect on; `then` is.

Even then, any code that uses `catch` would throw a syntax error in ES3 environments.

As per ES3:

    if (featureDetect) {
      this.catch;
    }
    // SyntaxError


So, even if you don’t use `catch` in the feature detection snippet, it will still fail:

    if (featureDetect) {
      this.catch;
    }
    // SyntaxError

As long as `catch` is used it means all code relying on Futures should be wrapped in a `try`/`catch` block to avoid throwing in ES3 environments.
Comment 5 Erik Arvidsson 2013-03-28 16:55:02 UTC
If you care about ES3 (and you shouldn't) you can always use member lookup:

if (this['catch']) ...