- From: <bugzilla@jessica.w3.org>
- Date: Tue, 14 Feb 2012 16:52:20 +0000
- To: public-script-coord@w3.org
https://www.w3.org/Bugs/Public/show_bug.cgi?id=15986 Summary: Specify exactly how and when ECMAScript arguments are evaluated Product: WebAppsWG Version: unspecified Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: WebIDL AssignedTo: cam@mcc.id.au ReportedBy: ayg@aryeh.name QAContact: member-webapi-cvs@w3.org CC: bzbarsky@mit.edu, mike@w3.org, public-script-coord@w3.org Consider the following: data:text/html,<!doctype html> <script> var x = 'unchanged'; try { document.createRange().setStart(window, { valueOf: function() {x = 'changed'; return 0;} } ); } catch (e) {} document.documentElement.textContent = x; </script> It outputs "unchanged" in Firefox 13.0a1, and "changed" in IE10 Developer Preview, Chrome 18 dev, and Opera Next 12.00 alpha. This outputs "changed" in all four browsers: data:text/html,<!doctype html> <script> var x = 'unchanged'; try { document.createRange().compareBoundaryPoints( { valueOf: function() {x = 'changed'; return 0;} }, window); } catch (e) {} document.documentElement.textContent = x; </script> So it seems like Gecko evaluates the arguments one by one, and throws when it hits the first bad argument. Other browsers seem to evaluate all at once. Which is correct? Also, with things like this that have side effects, it's important that the number of evaluations is defined. Given this: data:text/html,<!doctype html> <script> var cnt = 0; document.createRange().setStart( document.head, { valueOf: function() {cnt++; return 1;} }); document.documentElement.textContent = cnt; </script> Chrome outputs "2", and the other three output "1". Presumably we want "1". The spec should say exactly how all this works. I'm not sure what the right answer is, actually. We need to evaluate the arguments before we can run the overload resolution algorithm, but to evaluate the arguments we want to know what types we're trying to evaluate them as, right? -- Configure bugmail: https://www.w3.org/Bugs/Public/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
Received on Tuesday, 14 February 2012 16:52:26 UTC