Array.prototype.values() compatibility hazard

# Jason Orendorff (7 years ago)

Firefox added Array.prototype.values() and immediately ran into compatibility issues.

bugzilla.mozilla.org/show_bug.cgi?id=883914, bugzilla.mozilla.org/show_bug.cgi?id=881782

Both bug reports have to do with Sencha Ext JS. I haven't looked closely yet. It seems with(values) appears in Ext.

# Brandon Benvie (7 years ago)

On 6/17/2013 4:33 PM, Jason Orendorff wrote:

Firefox added Array.prototype.values() and immediately ran into compatibility issues.

bugzilla.mozilla.org/show_bug.cgi?id=883914, bugzilla.mozilla.org/show_bug.cgi?id=881782

Both bug reports have to do with Sencha Ext JS. I haven't looked closely yet. It seems with(values) appears in Ext.

-j

Looks like the with is responsible. When the "values" there is an array, any reference inside the with to "values" then becomes "values.values".

# Brandon Benvie (7 years ago)

On 6/17/2013 6:30 PM, Brandon Benvie wrote:

On 6/17/2013 4:33 PM, Jason Orendorff wrote:

Firefox added Array.prototype.values() and immediately ran into compatibility issues.

bugzilla.mozilla.org/show_bug.cgi?id=883914, bugzilla.mozilla.org/show_bug.cgi?id=881782

Both bug reports have to do with Sencha Ext JS. I haven't looked closely yet. It seems with(values) appears in Ext.

-j

Looks like the with is responsible. When the "values" there is an array, any reference inside the with to "values" then becomes "values.values".

The issue appears to affect all the versions of ExtJS I cursorily checked (2.x, 3.x, 4.x) and resides in the XTemplate module. It's probably a large backward compatibility hazard.

# Andrea Giammarchi (7 years ago)

can you try to hot-fix that via with(values.values=values) ?

# Brandon Benvie (7 years ago)

On 6/18/2013 3:02 PM, Andrea Giammarchi wrote:

can you try to hot-fix that via with(values.values=values) ?

That probably works, but it matters little since the hazard is with the existing installed base of sites that use this which would need to be updated. I can't imagine standardizing "whenever an identifier 'values' is found as the subject of a WithStatement, do ...." would fly either.

# Rick Waldron (7 years ago)

On Tue, Jun 18, 2013 at 6:05 PM, Brandon Benvie <bbenvie at mozilla.com> wrote:

On 6/18/2013 3:02 PM, Andrea Giammarchi wrote:

can you try to hot-fix that via with(values.values=values) ?

That probably works, but it matters little since the hazard is with the existing installed base of sites that use this which would need to be updated. I can't imagine standardizing "whenever an identifier 'values' is found as the subject of a WithStatement, do ...." would fly either.

Since Sencha/Ext.js is not free to use commercially, I'm going to assume they have a customer list and that they offer customer support. This is likely the best starting point for evangelizing and offering a "freebie" update to their install base and provided follow up support.

# Allen Wirfs-Brock (7 years ago)

On Jun 18, 2013, at 3:05 PM, Brandon Benvie wrote:

On 6/18/2013 3:02 PM, Andrea Giammarchi wrote:

can you try to hot-fix that via with(values.values=values) ?

That probably works, but it matters little since the hazard is with the existing installed base of sites that use this which would need to be updated. I can't imagine standardizing "whenever an identifier 'values' is found as the subject of a WithStatement, do ...." would fly either.

and this hazard exists for any method name we add to an existing built-in prototype object. "values" and "keys" and "entries" may be more likely to run into the problem as they are all plausible variable names but any new property name might break some with-users code in this same manner.

# Brendan Eich (7 years ago)

I blame 'with'. So, ex-Borland people at Netscape. And so, ultimately, myself.

# Andrea Giammarchi (7 years ago)

you should, but only partially! I mean, Ext.js still relying into with(whatever) behavior is as guilty as any decision made in last 5 years ... no matter the subject ...

# Claude Pache (7 years ago)

I've just added a warning on the corresponding page of the MDN JavaScript Reference [1] (the last bullet of the Description section and the red box at the top of the page), so that this Reference ceases to be guilty of not warning that with is future-hostile.

[1] developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/with

—Claude

Le 19 juin 2013 à 07:06, Andrea Giammarchi <andrea.giammarchi at gmail.com> a écrit :

# Claude Pache (7 years ago)

Le 18 juin 2013 à 03:30, Brandon Benvie <bbenvie at mozilla.com> a écrit :

On 6/17/2013 4:33 PM, Jason Orendorff wrote:

Firefox added Array.prototype.values() and immediately ran into compatibility issues.

bugzilla.mozilla.org/show_bug.cgi?id=883914, bugzilla.mozilla.org/show_bug.cgi?id=881782

Both bug reports have to do with Sencha Ext JS. I haven't looked closely yet. It seems with(values) appears in Ext.

-j

Looks like the with is responsible. When the "values" there is an array, any reference inside the with to "values" then becomes "values.values".

Note that they should look after with(anyArray) rather than with(values), in order to resolve that issue.

# Brian Terlson (7 years ago)

I have a dataset of scripts downloaded from the top 10k websites by traffic according to Alexa. These scripts are static only, and from page-load only, so take this information with the appropriate amount of salt.

I searched for occurrences of the identifiers "keys", "values", or "entries" inside with statements. Only one site (rank 2243 as of 6 months ago) was found in this query. It contains the identifier "keys" in a with statement, but won't be broken as the with object is appears to always be an instance of Object not Array.

I also searched for all occurrences of eval inside with statements. 24 sites (lowest rank, #19 - ebay.com) matched this query. A random sample of 5 sites found that in all cases the with object was instance of Object.

I could dig in more if people are interested. Let me know!

# Brendan Eich (7 years ago)

Excellent, great work. From private correspondence with Sencha, it seems they may be able to avoid the problem without too much trouble.

Still, a bitter stab in the back from 'with'! And cautionary for future method additions (not that I propose mangled or unlikely names).