Skip to content

Commit

Permalink
Fix regression where password placeholders get displayed as text in F…
Browse files Browse the repository at this point in the history
…irefox 3.5

Closes mathiasbynens#72.
  • Loading branch information
mathiasbynens committed Apr 23, 2012
1 parent c6faa55 commit ae85bce
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ <h1>HTML5 Placeholder jQuery Plugin</h1>
<p><input type="submit" value="type=submit"></p>
</form>
<p><a href="http://mathiasbynens.be/" title="Mathias Bynens, front-end developer">Mathias</a></p>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.js"></script>
<script src="jquery.placeholder.js"></script>
<script>
// To test the @id toggling on password inputs in browsers that don’t support changing an input’s @type dynamically (e.g. Firefox 3.6 or IE), uncomment this:
Expand Down
8 changes: 3 additions & 5 deletions jquery.placeholder.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! http://mths.be/placeholder v2.0.6 by @mathias */
/*! http://mths.be/placeholder v2.0.7 by @mathias */
;(function(window, document, $) {

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

function clearPlaceholder(event, value) {
var input = this,
$input = $(input),
hadFocus;
$input = $(input);
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 @@ -113,8 +111,8 @@
} else {
input.value = '';
$input.removeClass('placeholder');
input == document.activeElement && input.select();
}
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 ae85bce

Please sign in to comment.