Replace array creation and `Array#include` with a more efficient `RegExp#test`

This commit is contained in:
Juriy Zaytsev 2009-05-30 01:46:38 -04:00 committed by Andrew Dupont
parent 7d02aef6ca
commit 703e988745
2 changed files with 4 additions and 2 deletions

View File

@ -1,3 +1,5 @@
* Replace array creation and `Array#include` with a more efficient `RegExp#test`. (kangax)
* Reorganize the way `ElementExtensions` are defined. Make sure elements used in SpecificElementExtensions are cleaned up. (kangax)
* Make sure $A works with primitive values. (mr_justin, kangax)

View File

@ -163,7 +163,7 @@ Form.Methods = {
}).sortBy(function(element) { return element.tabIndex }).first();
return firstByIndex ? firstByIndex : elements.find(function(element) {
return ['input', 'select', 'textarea'].include(element.tagName.toLowerCase());
return /^(?:input|select|textarea)$/i.test(element.tagName);
});
},
@ -332,7 +332,7 @@ Form.Element.Methods = {
try {
element.focus();
if (element.select && (element.tagName.toLowerCase() != 'input' ||
!['button', 'reset', 'submit'].include(element.type)))
!(/^(?:button|reset|submit)$/i.test(element.type))))
element.select();
} catch (e) { }
return element;