Permalink
Browse files

Merge pull request #57 from sbull/empty-string-val-issue-56

Don’t `setPlaceholder` if the element has focus

Fixes #56.
  • Loading branch information...
2 parents 5148335 + cb53e48 commit a9fd43dbaac1fdb9af6bec00d1f1fa929c90db7f @mathiasbynens mathiasbynens committed Feb 23, 2012
Showing with 5 additions and 2 deletions.
  1. +5 −2 jquery.placeholder.js
View
@@ -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 {

0 comments on commit a9fd43d

Please sign in to comment.