Skip to content

Commit c6faa55

Browse files
committed
Make sure the input cursor doesn’t disappear when moving the focus to a blank input field in IE8
Fixes mathiasbynens#67.
1 parent c548851 commit c6faa55

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

jquery.placeholder.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! http://mths.be/placeholder v2.0.5 by @mathias */
1+
/*! http://mths.be/placeholder v2.0.6 by @mathias */
22
;(function(window, document, $) {
33

44
var isInputSupported = 'placeholder' in document.createElement('input'),
@@ -99,8 +99,10 @@
9999

100100
function clearPlaceholder(event, value) {
101101
var input = this,
102-
$input = $(input);
102+
$input = $(input),
103+
hadFocus;
103104
if (input.value == $input.attr('placeholder') && $input.hasClass('placeholder')) {
105+
hadFocus = input == document.activeElement;
104106
if ($input.data('placeholder-password')) {
105107
$input = $input.hide().next().show().attr('id', $input.removeAttr('id').data('placeholder-id'));
106108
// If `clearPlaceholder` was called from `$.valHooks.input.set`
@@ -112,6 +114,7 @@
112114
input.value = '';
113115
$input.removeClass('placeholder');
114116
}
117+
hadFocus && input.select();
115118
}
116119
}
117120

jquery.placeholder.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)