Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 6561

Show
Ignore:
Timestamp:
04/24/07 05:23:41 (1 year ago)
Author:
sam
Message:

prototype: Element.addMethods should add methods to Element as well as Element.Methods. Closes #7888.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • spinoffs/prototype/trunk/CHANGELOG

    r6558 r6561  
    11*SVN* 
     2 
     3* Element.addMethods should add methods to Element as well as Element.Methods.  Closes #7888.  [Andrew Dupont] 
    24 
    35* Add support for per-request onCreate callbacks to Ajax.Request.  Closes #8011.  [Andrew Dupont] 
  • spinoffs/prototype/trunk/src/dom.js

    r6504 r6561  
    634634    } 
    635635  }   
     636 
     637  Object.extend(Element, Element.Methods); 
     638  delete Element.ByTag; 
    636639}; 
    637640 
  • spinoffs/prototype/trunk/test/unit/dom.html

    r6538 r6561  
    273273  var testVar = 'to be updated', testVar2 = ''; 
    274274 
     275  Element.addMethods({ 
     276    hashBrowns: function(element) { return 'hash browns'; } 
     277  }); 
     278 
    275279  Element.addMethods("LI", { 
    276280    pancakes: function(element) { return "pancakes"; } 
     
    930934    }}, 
    931935     
    932     testSpecificElementMethods: function() {with(this) { 
     936    testCustomElementMethods: function() {with(this) { 
     937      var elem = $('navigation_test_f'); 
     938      assertRespondsTo('hashBrowns', elem); 
     939      assertEqual('hash browns', elem.hashBrowns()); 
     940       
     941      assertRespondsTo('hashBrowns', Element); 
     942      assertEqual('hash browns', Element.hashBrowns(elem)); 
     943    }}, 
     944     
     945    testSpecificCustomElementMethods: function() {with(this) { 
    933946      var elem = $('navigation_test_f'); 
    934947       
     
    948961      assertEqual("orange juice", elem.orangeJuice()); 
    949962      assertEqual("orange juice", elem2.orangeJuice()); 
     963       
     964      assert(typeof Element.orangeJuice == 'undefined'); 
     965      assert(typeof Element.pancakes == 'undefined'); 
     966      assert(typeof Element.waffles == 'undefined'); 
     967       
    950968    }}, 
    951969