Cross-browser Getters/Setters (including IE)


/ Published in: JavaScript
Save to your folder(s)

Xccessors is a JavaScript shim that implements the legacy methods for defining and looking up object accessors (getters and setters) of objects in JavaScript using ECMAScript 3.1’s accessors standard. This is aimed at adding support for the legacy method in IE8 RC1.

The code is made to have as small of a footprint as possible. YUI minified, the code is 556 bytes. Here is the minified version:

(function(b,d,c){function a(f,g,e){if(f in d&&!(g in {})){d[c][g]=Element[c][g]=Window[c][g]=HTMLDocument[c][g]=e}}a(b[0],b[2],function(f,e){d[b[0]](this,f,{get:e})});a(b[0],b[3],function(f,e){d[b[0]](this,f,{set:e})});a(b[1],b[4],function(e){return d[b[1]](this,e).get||d[b[1]](this.constructor.prototype,e).get});a(b[1],b[5],function(e){return d[b[1]](this,e).set||d[b[1]](this.constructor.prototype,e).set})})(["defineProperty","getOwnPropertyDescriptor","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"],Object,"prototype");

URL: http://eligrey.com/projects/xccessors/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.