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.
https://bunnyjs.com
MIT License
487 stars 39 forks source link

setSelectionRange uncaught exception #6

Closed evenmark closed 7 years ago

evenmark commented 7 years ago

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);

Mevrael commented 7 years ago

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

Mevrael commented 7 years ago

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!