I\'m looking through the MooTools source to try and understand its .implement()
and .extend()
utilities.
The definition of each refers to a fun
The part that had me scratching my head for a while was the
var enumerables = true; for (var i in {toString: 1}) enumerables = null;
part, which turns out to be a test for the DontEnum bug that some browsers have. At first glance it seems like it should just set enumerables
to null
, but with the DontEnum bug toString
is suppressed (wrongly, because the object's prototype.toString
has the DontEnum
flag) and enumerables
is left as true
.
overloadSetter
(or rather the resulting function) then has to check one at a time for the seven properties that the DontEnum bug affects, to see if they exist in the object argument.