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:
parent
1886b03d60
commit
b76d34e7bb
@ -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)
|
||||
|
12
src/dom.js
12
src/dom.js
@ -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];
|
||||
|
10
src/form.js
10
src/form.js
@ -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;
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user