From b43fa3b5af9f689d6bc4858df3b8f0cf543d8aae Mon Sep 17 00:00:00 2001 From: Filip Haglund Date: Tue, 5 Jun 2018 21:55:17 +0200 Subject: [PATCH] Disallow using setSelectionRange on number inputs. This fixes #555. --- lib/fastclick.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/fastclick.js b/lib/fastclick.js index 86bf83e0..ec52bc7a 100644 --- a/lib/fastclick.js +++ b/lib/fastclick.js @@ -326,7 +326,11 @@ 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') { + var disallowedTypes = ['time', 'month', 'email', 'number']; + if (deviceIsIOS && + targetElement.setSelectionRange && + targetElement.type.indexOf('date') !== 0 && + disallowedTypes.indexOf(targetElement.type) === -1) { length = targetElement.value.length; targetElement.setSelectionRange(length, length); } else {