=== again (sorry)

Mark S. Miller erights at google.com
Mon Nov 3 21:45:27 PST 2008


On Mon, Nov 3, 2008 at 7:02 PM, Maciej Stachowiak <mjs at apple.com> wrote:

> I am not arguing against the change; I'm not sure anyone is, as such. But I
> think any proposed change to existing cross-browser behavior has to be
> backed up with some serious evaluation of its compatibility impact. Even
> seemingly obvious bugfixes like changing typeof null to not return "object"
> have failed to hold up under closer scrutiny.
>

As a teeny bit of testing, I changed indexOf / lastIndexOf in Caja to work
as proposed. All our own regression tests run as green as before, so we
weren't depending on the difference. Our corpus is so small and so
unrepresentative that this provides almost no evidence whatsoever. However,
if others on this list with large testing suites could see if it alters the
outcome, we might learn something. Thanks.

(function(){

  function identical(x, y) {
    if (x === y) {
      // 0 === -0, but they are not identical
      return x !== 0 || 1/x === 1/y;
    } else {
      // NaN !== NaN, but they are identical
      return isNaN(x) && isNaN(y);
    }
  }

  Array.prototype.indexOf = function(specimen) {
    var len = this.length;
    for (var i = 0; i < len; i += 1) {
      if (identical(this[i], specimen)) {
        return i;
      }
    }
    return -1;
  };

  Array.prototype.lastIndexOf = function(specimen) {
    for (var i = this.length; --i >= 0; ) {
      if (identical(this[i], specimen)) {
        return i;
      }
    }
    return -1;
  };
})();

-- 
   Cheers,
   --MarkM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20081103/6baa063e/attachment-0001.html>


More information about the Es-discuss mailing list