Permalink
Browse files

bug fix for: ftlabs/fastclick#312

1 parent 75b0aa0 commit a5670f0f159d07a8e3499484bb84fb1b98c956a0 @itsjustcon itsjustcon committed Oct 16, 2014
Showing with 4 additions and 2 deletions.
  1. +2 −2 lib/fastclick.js
  2. +2 −0 tests/160-reduced.html
View
@@ -312,8 +312,8 @@
FastClick.prototype.focus = function(targetElement) {
var length;
- // Issue #160: on iOS 7, some input elements (e.g. date datetime) 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') {
+ // 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') {
length = targetElement.value.length;
targetElement.setSelectionRange(length, length);
} else {
@@ -56,6 +56,8 @@
<input type="date" class="test">
<p>Test (datetime):</p>
<input type="datetime" class="test">
+ <p>Test (month):</p>
+ <input type="month" class="test">
<p>Test (time):</p>
<input type="time" class="test">
<p>Control (text):</p>

0 comments on commit a5670f0

Please sign in to comment.