/** section: scripty2 ui
 *  mixin S2.UI.Mixin.Element
 *  
 *  Provides a few convenience methods for widgets that map easily to a
 *  single element.
**/

(function() {
  var METHODS = $w('observe stopObserving show hide ' + 
   'addClassName removeClassName hasClassName setStyle getStyle' +
   'writeAttribute readAttribute on fire');
  
  var E = {};
  
  METHODS.each( function(name) {
    E[name] = function() {
      var element = this.toElement();
      return element[name].apply(element, arguments);
    };
  });

  window.S2.UI.Mixin.Element = E;  
})();


/** section: scripty2 ui
 *  mixin S2.UI.Mixin.Element
 *  
 *  Provides a few convenience methods for widgets that map easily to a
 *  single element.
**/

(function() {
  var METHODS = $w('observe stopObserving show hide ' + 
   'addClassName removeClassName hasClassName setStyle getStyle' +
   'writeAttribute readAttribute fire');
  
  var E = {};
  
  METHODS.each( function(name) {
    E[name] = function() {
      var element = this.toElement();
      return element[name].apply(element, arguments);
    };
  });
  
  E.on = function() {
    if (!this.__observers) this.__observers = [];
    var element = this.toElement();
    var result = element.on.apply(element, arguments);
    this.__observers.push(result);
  };
  
  window.S2.UI.Mixin.Element = E;  
})();


Redefine `S2.UI.Mixin.Element.on` so that it caches its observers.