prototype: Fix regression in which no-argument calls to Element.addMethods() would not add the methods defined in Form.Methods and Form.Element.Methods. Closes #8206.

This commit is contained in:
Sam Stephenson 2007-04-28 02:32:21 +00:00
parent 1886b03d60
commit b76d34e7bb
4 changed files with 22 additions and 10 deletions

View File

@ -1,5 +1,7 @@
*SVN*
* Fix regression in which no-argument calls to Element.addMethods() would not add the methods defined in Form.Methods and Form.Element.Methods. Closes #8206. [Tobie Langel, fwittekind]
* Fix Element#readAttribute to work with the 'type' attribute in IE. Closes #8160. [Tobie Langel, Wiktor Ihárosi]
*1.5.1_rc3* (April 24, 2007)

View File

@ -586,6 +586,18 @@ Element.hasAttribute = function(element, attribute) {
Element.addMethods = function(methods) {
var F = Prototype.BrowserFeatures, T = Element.Methods.ByTag;
if (!methods) {
Object.extend(Form, Form.Methods);
Object.extend(Form.Element, Form.Element.Methods);
Object.extend(Element.Methods.ByTag, {
"FORM": Object.clone(Form.Methods),
"INPUT": Object.clone(Form.Element.Methods),
"SELECT": Object.clone(Form.Element.Methods),
"TEXTAREA": Object.clone(Form.Element.Methods)
});
}
if (arguments.length == 2) {
var tagName = methods;
methods = arguments[1];

View File

@ -97,8 +97,6 @@ Form.Methods = {
}
}
Object.extend(Form, Form.Methods);
/*--------------------------------------------------------------------------*/
Form.Element = {
@ -167,14 +165,6 @@ Form.Element.Methods = {
}
}
Object.extend(Form.Element, Form.Element.Methods);
Object.extend(Element.Methods.ByTag, {
"FORM": Object.clone(Form.Methods),
"INPUT": Object.clone(Form.Element.Methods),
"SELECT": Object.clone(Form.Element.Methods),
"TEXTAREA": Object.clone(Form.Element.Methods)
});
/*--------------------------------------------------------------------------*/
var Field = Form.Element;

View File

@ -32,11 +32,19 @@
<!-- Tests follow -->
<script type="text/javascript" language="javascript" charset="utf-8">
// <![CDATA[
Form.Element.Methods.coffee = Prototype.K;
Element.addMethods();
new Test.Unit.Runner({
testInput: function() {with(this) {
assert($("input").present != null);
assert(typeof $("input").present == 'function');
assert($("input").select != null);
assertRespondsTo('present', Form.Element);
assertRespondsTo('present', Form.Element.Methods);
assertRespondsTo('coffee', $('input'));
assertIdentical(Prototype.K, Form.Element.coffee);
assertIdentical(Prototype.K, Form.Element.Methods.coffee);
}},
testForm: function() {with(this) {