Skip to content

Commit

Permalink
Update conditional logic to maintain activeElement check, ref #38
Browse files Browse the repository at this point in the history
  • Loading branch information
ten1seven committed May 29, 2019
1 parent 5566379 commit a73ddba
Show file tree
Hide file tree
Showing 6 changed files with 519 additions and 410 deletions.
2 changes: 1 addition & 1 deletion dist/maps/what-input.min.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/what-input.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* what-input - A global utility for tracking the current input method (mouse, keyboard or touch).
* @version v5.2.1
* @version v5.2.2
* @link https://github.com/ten1seven/what-input
* @license MIT
*/
Expand Down Expand Up @@ -270,7 +270,7 @@ return /******/ (function(modules) { // webpackBootstrap
if (shouldUpdate && currentIntent !== value) {
// preserve intent for keyboard interaction with form fields
var activeElem = document.activeElement;
var notFormInput = activeElem && activeElem.nodeName && formInputs.indexOf(activeElem.nodeName.toLowerCase()) === -1 || activeElem.nodeName.toLowerCase() === 'button' && !checkClosest(activeElem, 'form');
var notFormInput = activeElem && activeElem.nodeName && (formInputs.indexOf(activeElem.nodeName.toLowerCase()) === -1 || activeElem.nodeName.toLowerCase() === 'button' && !checkClosest(activeElem, 'form'));

if (notFormInput) {
currentIntent = value;
Expand Down
4 changes: 2 additions & 2 deletions dist/what-input.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "what-input",
"version": "5.2.1",
"version": "5.2.2",
"description": "A global utility for tracking the current input method (mouse, keyboard or touch).",
"main": "dist/what-input.js",
"repository": {
Expand Down
19 changes: 10 additions & 9 deletions src/scripts/what-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ module.exports = (() => {
17, // control
18, // alt
91, // Windows key / left Apple cmd
93 // Windows menu / right Apple cmd
93 // Windows menu / right Apple cmd
]

let specificMap = []
Expand Down Expand Up @@ -182,8 +182,7 @@ module.exports = (() => {
value = pointerType(event)
}

let ignoreMatch =
!specificMap.length && ignoreMap.indexOf(eventKey) === -1
let ignoreMatch = !specificMap.length && ignoreMap.indexOf(eventKey) === -1

let specificMatch =
specificMap.length && specificMap.indexOf(eventKey) !== -1
Expand Down Expand Up @@ -212,11 +211,11 @@ module.exports = (() => {
// preserve intent for keyboard interaction with form fields
let activeElem = document.activeElement
let notFormInput =
(activeElem &&
activeElem.nodeName &&
formInputs.indexOf(activeElem.nodeName.toLowerCase()) === -1) ||
(activeElem.nodeName.toLowerCase() === 'button' &&
!checkClosest(activeElem, 'form'))
activeElem &&
activeElem.nodeName &&
(formInputs.indexOf(activeElem.nodeName.toLowerCase()) === -1 ||
(activeElem.nodeName.toLowerCase() === 'button' &&
!checkClosest(activeElem, 'form')))

if (notFormInput) {
currentIntent = value
Expand Down Expand Up @@ -371,7 +370,9 @@ module.exports = (() => {
const ElementPrototype = window.Element.prototype

if (!ElementPrototype.matches) {
ElementPrototype.matches = ElementPrototype.msMatchesSelector || ElementPrototype.webkitMatchesSelector
ElementPrototype.matches =
ElementPrototype.msMatchesSelector ||
ElementPrototype.webkitMatchesSelector
}

if (!ElementPrototype.closest) {
Expand Down
Loading

0 comments on commit a73ddba

Please sign in to comment.