On 3/17/15 2:10 PM, obastemur wrote:
Still, considering the today's JavaScript usage, and this one is already 
handled by an other browser(s)

In different ways, note.

And worse yet, as Jason said, websites do UA sniffing and depend on the different ways that browsers handle this syntactic construct, so if we try to switch to what one of the other browsers is doing that breaks web pages. And the same if they try to switch to what we're doing. Yes, this sucks. No, it's not clear what one can do about it.

I mean, it fails even though there is no 'use strict' in place.

It fails because the invalid function-in-block source gets desugared by SpiderMonkey like so (from your original mail) into valid JS:

if (q) {
  var client1 = {on:function(){}};
  client1.on('close', onclose);
  var onclose = function onclose() {
    console.log('dummy');
  }
}

Looking at that, it's clear why it fails, I hope. If you want it to work more reliably across engines, just put your function-inside-block at the top of the block.

-Boris


_______________________________________________
dev-tech-js-engine-internals mailing list
dev-tech-js-engine-internals@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-tech-js-engine-internals

Reply via email to