prototypejs / prototype

Prototype JavaScript framework
http://prototypejs.org/
Other
3.54k stars 639 forks source link

Form.Element.activate on MobileSafari doesn't select text #301

Open savetheclocktower opened 8 years ago

savetheclocktower commented 8 years ago

This makes a unit test fail. Seems related to this StackOverflow issue. Hence the fix could look something like this:

if (Prototype.Browser.MobileSafari) {
  Form.Element.Methods.activate = function (element) {
    element = $(element);
    try {
      element.focus();
      if (element.setSelectionRange && (element.tagName.toLowerCase() != 'input' ||
        !(/^(?:button|reset|submit)$/i.test(element.type))))
      element.setSelectionRange(0, 9999);
    } catch (e) { }
    return element;
  }
}