All pastes #508484 Raw Edit

Anonymous

public javascript v1 · immutable
·published 2007-05-25 01:14 UTC
rendered paste body
function XProps (content){    // set this to false to disable caching of property values    this._use_cache = true;    this._content = content;    this._fillers = new Object ();    if (this._use_cache)	this._values = new Object ();}XProps.prototype = {    Add : function (atom, filler) {	this._fillers[atom] = filler;	this.Invalidate (atom);	this.__defineGetter__ (atom+"",			       function () {				   if (this._use_cache && atom in this._values) {				       return this._values[atom];				   }				   else {				       var prop_bag = this._content.nativeWindow.GetProperty (atom);				       var val = (prop_bag == null) ? null : this._fillers[atom](prop_bag);				       if (this._use_cache)					   this._values[atom] = val;				       return val;				   }			       });    },    Invalidate: function (atom) {	if (this._use_cache)	    delete this._values[atom];    }}