Skip to content

Commit

Permalink
Make sure the input cursor doesn’t disappear when moving the focus to…
Browse files Browse the repository at this point in the history
… a blank input field in IE8

Fixes mathiasbynens#67.
  • Loading branch information
mathiasbynens committed Mar 21, 2012
1 parent c548851 commit c6faa55
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions jquery.placeholder.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! http://mths.be/placeholder v2.0.5 by @mathias */
/*! http://mths.be/placeholder v2.0.6 by @mathias */
;(function(window, document, $) {

var isInputSupported = 'placeholder' in document.createElement('input'),
Expand Down Expand Up @@ -99,8 +99,10 @@

function clearPlaceholder(event, value) {
var input = this,
$input = $(input);
$input = $(input),
hadFocus;
if (input.value == $input.attr('placeholder') && $input.hasClass('placeholder')) {
hadFocus = input == document.activeElement;
if ($input.data('placeholder-password')) {
$input = $input.hide().next().show().attr('id', $input.removeAttr('id').data('placeholder-id'));
// If `clearPlaceholder` was called from `$.valHooks.input.set`
Expand All @@ -112,6 +114,7 @@
input.value = '';
$input.removeClass('placeholder');
}
hadFocus && input.select();
}
}

Expand Down
4 changes: 2 additions & 2 deletions jquery.placeholder.min.js

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

0 comments on commit c6faa55

Please sign in to comment.