es5-shim: Support PhantomJS (has strict mode, but no Function#bind)
authorTimo Tijhof <krinklemail@gmail.com>
Wed, 9 Jul 2014 20:58:39 +0000 (22:58 +0200)
committerTimo Tijhof <krinklemail@gmail.com>
Wed, 9 Jul 2014 20:58:39 +0000 (22:58 +0200)
Follows-up fff9a814f.

The es5-shim wasn't being loaded in PhantomJS causing tests to
fail due to absence of Function#bind.

Change-Id: I84b8ebe382bfc4825accc31a0a5da2fb1717536d

resources/src/es5-skip.js

index d14c64b..a4039d8 100644 (file)
@@ -2,14 +2,17 @@
  * Skip function for es5-shim module.
  *
  * Test for strict mode as a proxy for full ES5 function support (but not syntax)
- * Per http://kangax.github.io/compat-table/es5/ this is a reasonable short-cut
- * that still allows this to be as short as possible (there are no function "No"s
- * for non-"obsolete" real browsers where strict support is available).
+ * Per http://kangax.github.io/compat-table/es5/ this is a reasonable shortcut
+ * that still allows this to be as short as possible (there are no browsers we
+ * support that have strict mode, but lack other features).
  *
- * Note that this will cause IE9 users to get the shim (which should be close to
- * a no-op but will increase page payload).
+ * Do explicitly test for Function#bind because of PhantomJS (which implements
+ * strict mode, but lacks Function#bind).
+ *
+ * IE9 supports all features except strict mode, so loading es5-shim should be close to
+ * a no-op but does increase page payload).
  */
 return ( function () {
        'use strict';
-       return !this;
+       return !this && !!Function.prototype.bind;
 }() );