Mevrael / bunny

BunnyJS - Lightweight native (vanilla) JavaScript (JS) and ECMAScript 6 (ES6) browser library, package of small stand-alone components without dependencies: FormData, upload, image preview, HTML5 validation, Autocomplete, Dropdown, Calendar, Datepicker, Ajax, Datatable, Pagination, URL, Template engine, Element positioning, smooth scrolling, routing, inversion of control and more. Simple syntax and architecture. Next generation jQuery and front-end framework. Documentation and examples available.

Home Page:https://bunnyjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

setSelectionRange uncaught exception

evenmark opened this issue · comments

I have
<input type="email" name="whatever" required maxlength="50" />

when validating, and input contains invalid value Chrome 54 macOS gives:
Validation.js:658 Uncaught (in promise) DOMException: Failed to execute 'setSelectionRange' on 'HTMLInputElement': The input element's type ('email') does not support selection.

Validation.js line #658
input.setSelectionRange(input.value.length, input.value.length);

Thanks for bug report, I will check it when will be at my laptop.

Ok, so according to spec input with type="email" does not support selection and Chrome on all platforms will throw an error.

setSelectionRange() puts cursor at the end of invalid input after focusing it, however, as I can see, Chrome already does it, so I will just add a small case there.

This will be available with next release (1-2 days), I'm gonna finish Dropdown and Autocomplete refactoring and docs first.

If you have any ideas or feedback about your experience using BunnyJS, please let me know, thanks!