Skip to content

Commit

Permalink
#55 / EDGE: Incorrect handling of non-text input fields Maximilian co…
Browse files Browse the repository at this point in the history
…mmitted

quick correction on the correct position of this condition within the source code, as it would elsewhere break IE10+ & EDGE
  • Loading branch information
Maximilian committed Jan 27, 2019
1 parent 4841810 commit c7c59de
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions datalist-polyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,15 @@
}

// Handling IE10+ & EDGE
// As only EDGE doesn't trigger the input event after selecting an item via mouse, we need to differentiate here
if (isGteIE10 || (isEDGE && input.type === 'text')) {
if (isGteIE10 || isEDGE) {
// On keypress check for value
if (
getInputValue(input) !== '' &&
!keyOpen &&
event.keyCode !== keyENTER &&
event.keyCode !== keyESC
event.keyCode !== keyESC &&
// As only EDGE doesn't trigger the input event after selecting an item via mouse, we need to differentiate here
(isGteIE10 || input.type === 'text')
) {
updateIEOptions(input, datalist);

Expand Down
7 changes: 4 additions & 3 deletions datalist-polyfill.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ var n=function(e){var t=e.target,a=t.list,i=e.keyCode===y||e.keyCode===f;
// Check for whether the events target was an input and still check for an existing instance of the datalist and polyfilling select
if("input"===t.tagName.toLowerCase()&&null!==a)
// Handling IE10+ & EDGE
// As only EDGE doesn't trigger the input event after selecting an item via mouse, we need to differentiate here
if(s||d&&"text"===t.type)
if(s||d)
// On keypress check for value
""===L(t)||i||e.keyCode===c||e.keyCode===v||(b(t,a),
""===L(t)||i||e.keyCode===c||e.keyCode===v||
// As only EDGE doesn't trigger the input event after selecting an item via mouse, we need to differentiate here
!s&&"text"!==t.type||(b(t,a),
// TODO: Check whether this update is necessary depending on the options values
t.focus());else{var n=!1,
// Creating the select if there's no instance so far (e.g. because of that it hasn't been handled or it has been dynamically inserted)
Expand Down

0 comments on commit c7c59de

Please sign in to comment.