Skip to content

Commit

Permalink
Don't setPlaceholder if the element has focus. Fixes mathiasbynens#56.
Browse files Browse the repository at this point in the history
  • Loading branch information
sbull committed Feb 23, 2012
1 parent 5148335 commit cb53e48
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions jquery.placeholder.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@
}
if (value == '') {
element.value = value;
// We can’t use `triggerHandler` here because of dummy text/password inputs :(
setPlaceholder.call(element);
// Issue #56: Setting the placeholder causes problems if the element continues to have focus.
if (!$element.is(':focus')) {
// We can’t use `triggerHandler` here because of dummy text/password inputs :(
setPlaceholder.call(element);
}
} else if ($element.hasClass('placeholder')) {
clearPlaceholder.call(element, true, value) || (element.value = value);
} else {
Expand Down

0 comments on commit cb53e48

Please sign in to comment.