prototype: Form.Element.activate shouldn't raise an exception when the form or field is hidden.
This commit is contained in:
parent
c89875ce8c
commit
84901897c8
|
@ -1,5 +1,7 @@
|
|||
*SVN*
|
||||
|
||||
* Form.Element.activate shouldn't raise an exception when the form or field is hidden. [sam]
|
||||
|
||||
* Remove support for "throw $continue" in Enumerable. Use "return" instead. [sam]
|
||||
|
||||
* Update HEADER to reflect new URL. [sam]
|
||||
|
|
10
src/form.js
10
src/form.js
|
@ -132,10 +132,12 @@ Form.Element.Methods = {
|
|||
|
||||
activate: function(element) {
|
||||
element = $(element);
|
||||
element.focus();
|
||||
if (element.select && ( element.tagName.toLowerCase() != 'input' ||
|
||||
!['button', 'reset', 'submit'].include(element.type) ) )
|
||||
element.select();
|
||||
try {
|
||||
element.focus();
|
||||
if (element.select && (element.tagName.toLowerCase() != 'input' ||
|
||||
!['button', 'reset', 'submit'].include(element.type)))
|
||||
element.select();
|
||||
} catch (e) {}
|
||||
return element;
|
||||
},
|
||||
|
||||
|
|
|
@ -86,6 +86,10 @@
|
|||
<input type="text" name="focus_text" id="focus_text" value="Hello" />
|
||||
</form>
|
||||
|
||||
<form id="form_focus_hidden" style="display: none">
|
||||
<input type="text" />
|
||||
</form>
|
||||
|
||||
<!-- Tests follow -->
|
||||
<script type="text/javascript" language="javascript" charset="utf-8">
|
||||
// <![CDATA[
|
||||
|
@ -209,13 +213,18 @@
|
|||
Form.focusFirstElement('form_focus');
|
||||
if(document.selection) assertEqual('', getSelection(element));
|
||||
|
||||
// Form.Field.activate shouldn't select text on buttons
|
||||
// Form.Element.activate shouldn't select text on buttons
|
||||
element = $('focus_text');
|
||||
assertEqual('', getSelection(element));
|
||||
|
||||
// Form.Field.activate should select text on text input elements
|
||||
// Form.Element.activate should select text on text input elements
|
||||
element.activate();
|
||||
assertEqual('Hello', getSelection(element));
|
||||
|
||||
// Form.Element.activate shouldn't raise an exception when the form or field is hidden
|
||||
assertNothingRaised(function() {
|
||||
$('form_focus_hidden').focusFirstElement();
|
||||
});
|
||||
}},
|
||||
|
||||
testFormGetElements: function() {with(this) {
|
||||
|
|
Loading…
Reference in New Issue