Wednesday, January 28th, 2009
You can check out a demo of it working, and told us a little more:
Note: IE8 RC1 does NOT support setting accessors on objects that are not instances of Window, Element (and all of it’s sub-classes), and HTMLDocument. I hope IE8 RC2 or the IE8 final public release changes this.
By not introducing any objects into the global namespace, the resulting code seems a little redundant, but not polluting the global namespace is worth an extra .4kb (the code is ~2kb uncompressed).
Also, as far as I know, it is impossible to do this the other way around and fully implement ECMAScript 3.1 accessor support in browsers that support the legacy method. Setting an object prototype that adds setters for <object>.[gs]etter can’t tell what the parent object of [gs]etter is unless it’s an element. It would be possible to partially implement Object.defineProperty and fully implement Object.getOwnPropertyDescriptor but many of the options that can be used in Object.defineProperty like writable and configurable would be hard to implement and enforce.
Posted by Dion Almaer at 4:03 am