W3C home > Mailing lists > Public > public-webapps@w3.org > July to September 2012

Re: [IndexedDB] Problems unprefixing IndexedDB

From: Brendan Eich <brendan@mozilla.org>
Date: Thu, 09 Aug 2012 23:48:08 -0700
Message-ID: <5024AEA8.4030008@mozilla.org>
To: public-webapps@w3.org
From: Kyle Huey <me@kylehuey.com>
 > Jonas mentioned earlier on this list that we unprefixed IndexedDB in
 > Firefox nightlies some time ago.  We ran into a bit of a problem.[0]  
 > of the IndexedDB tutorials (including ours and HTML5 Rocks[1] :-/) tell
 > authors to deal with prefixing with:
 > var indexedDB = window.indexedDB || window.webkitIndexedDB ||
 > window.mozIndexedDB || window.msIndexedDB || ...
 > This code has a bug when executed at global scope.  Because the 
 > are on the prototype chain of the global object, 'var indexedDB' 
creates a
 > new property on the global.

Not according to ECMA-262 Edition 5.1 or conforming implementations of it.

Firefox's JS engine, SpiderMonkey, actually helped get ES5.1 to match JS 
reality and past editions, where ES5 tried to spec what you describe in 
the last paragraph cited above. We found that incompatible, rolled it 
back in


and filed an erratum on ES5 which was fixed for ES5.1 (the ISO version 
of ES5).

Unfortunately this bug regressed SpiderMonkey to ES5 status quo ante:


I only just noticed, due to the unprefix-indexedDB issue you raise. I filed


to get SpiderMonkey fixed.

The takeaway is to never assume a recently modified JS engine matches 
the latest ECMA spec. Sad to report this one involved SpiderMonkey, but 
it hits all evolving engines, and the spec can have bugs too (as 
described above in ES5). The ES5.1 spec is quite clear that the 
prototype chain is checked and no such property found, before a 'var' 
declaration makes a fresh binding with default value undefined.

So no need for WebIDL, IndexedDB, or ES5.1 to change.

Received on Friday, 10 August 2012 06:48:37 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 18:13:38 UTC