Skip to content

Commit ae85bce

Browse files
committed
Fix regression where password placeholders get displayed as text in Firefox 3.5
Closes mathiasbynens#72.
1 parent c6faa55 commit ae85bce

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

demo.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ <h1>HTML5 Placeholder jQuery Plugin</h1>
2929
<p><input type="submit" value="type=submit"></p>
3030
</form>
3131
<p><a href="http://mathiasbynens.be/" title="Mathias Bynens, front-end developer">Mathias</a></p>
32-
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js"></script>
32+
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.js"></script>
3333
<script src="jquery.placeholder.js"></script>
3434
<script>
3535
// 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:

jquery.placeholder.js

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

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

100100
function clearPlaceholder(event, value) {
101101
var input = this,
102-
$input = $(input),
103-
hadFocus;
102+
$input = $(input);
104103
if (input.value == $input.attr('placeholder') && $input.hasClass('placeholder')) {
105-
hadFocus = input == document.activeElement;
106104
if ($input.data('placeholder-password')) {
107105
$input = $input.hide().next().show().attr('id', $input.removeAttr('id').data('placeholder-id'));
108106
// If `clearPlaceholder` was called from `$.valHooks.input.set`
@@ -113,8 +111,8 @@
113111
} else {
114112
input.value = '';
115113
$input.removeClass('placeholder');
114+
input == document.activeElement && input.select();
116115
}
117-
hadFocus && input.select();
118116
}
119117
}
120118

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)