On Tue, Jul 24, 2012 at 7:11 AM, Martin Wittemann <[email protected]
> wrote:

>
> 2. We supply a buggy polyfill and another lib will fail
> Thats nothing we have planed. We should take care of implementing the spec
> 100%. If thats not possible, we don't add a polyfill because that can cause
> problems.
>

Polyfills are not necessarily able to implement the spec 100%. A good case
in point is Function.bind() for which a pretty good polyfill is available,
but there are cases that some 3rd party libraries (or the user!) may depend
on the native functionality and not get it.

Here is an excerpt from
https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/bind
which
discusses some issues of the polyfill for bind(). In particular, the last
two bullet points are relevant:

Some of the many differences (there may well be others, as this list does
not seriously attempt to be exhaustive) between this algorithm and the
specified algorithm are:

   - The partial implementation relies Array.prototype.slice,
   Array.prototype.concat, Function.prototype.call and
   Function.prototype.apply, built-in methods to have their original values.
   - The partial implementation creates functions that do not have
   immutable "poison pill" caller and arguments properties that throw a
   TypeError upon get, set, or deletion. (This could be added if the
   implementation supports
Object.defineProperty<https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/defineProperty>,
   or partially implemented [without throw-on-delete behavior] if the
   implementation supports
the__defineGetter__<https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/defineGetter>
    and 
__defineSetter__<https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/defineSetter>
    extensions.)
   - The partial implementation creates functions that have a
prototype property.
   (Proper bound functions have none.)
   - The partial implementation creates bound functions whose length property
   does not agree with that mandated by ECMA-262: it creates functions with
   length 0, while a full implementation, depending on the length of the
   target function and the number of pre-specified arguments, may return a
   non-zero length.

If you choose to use this partial implementation, *you must not rely on
those cases where behavior deviates from ECMA-262, 5th edition!* With some
care, however (and perhaps with additional modification to suit specific
needs), this partial implementation may be a reasonable bridge to the time
when bind() is widely implemented according to the specification.

Cheers,

Derrell
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to