Skip to content
This repository has been archived by the owner on Jun 9, 2022. It is now read-only.

Issue #160: Added targetElement type number to check #585

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/fastclick.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,12 +326,13 @@
var length;

// Issue #160: on iOS 7, some input elements (e.g. date datetime month) throw a vague TypeError on setSelectionRange. These elements don't have an integer value for the selectionStart and selectionEnd properties, but unfortunately that can't be used for detection because accessing the properties also throws a TypeError. Just check the type instead. Filed as Apple bug #15122724.
if (deviceIsIOS && targetElement.setSelectionRange && targetElement.type.indexOf('date') !== 0 && targetElement.type !== 'time' && targetElement.type !== 'month' && targetElement.type !== 'email') {
if (deviceIsIOS && targetElement.setSelectionRange && !['date', 'time', 'month', 'email', 'number'].includes(targetElement.type)) {
length = targetElement.value.length;
targetElement.setSelectionRange(length, length);
} else {
targetElement.focus();
}
targetElement.focus();
};


Expand Down