nl_tokens: * @method watch ( <obj > <prop > <fn > ) @returns Nothing @short Watches a property of <obj > and runs <fn > when it changes . @extra <fn > is passed three arguments : the property <prop > the old value and the new value . The return value of [ fn ] will be set as the new value . This method is useful for things such as validating or cleaning the value when it is set . Warning : this method WILL NOT work in browsers that don t support %Object . defineProperty% . This notably includes IE 8 and below and Opera . This is the only method in Sugar that is not fully compatible with all browsers . %watch% is available as an instance method on extended objects . @example
pl_tokens: function ( obj , <mask> , fn ) { if ( ! definePropertySupport ) return ; var value = obj [ prop ] ; object . defineProperty ( obj , prop , { 'enumerable' : true , 'configurable' : true , 'get' : function ( ) { return value ; } , 'set' : function ( to ) { value = fn . call ( obj , prop , value , to ) ; } } ) ; }