Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Password placeholder breaks when element is added between it and its clone text field #229

Closed
amerikan opened this issue Dec 16, 2014 · 0 comments

Comments

@amerikan
Copy link
Collaborator

It seems that the plugin for password fields assumes that the next element will be an <input> element that it generated; this is assumption is incorrect.

I know for password fields, this placeholder plugin simply clones a text field out of it, so it'll end up generating something like this:

<input type="password" placeholder="your placeholder text" style="display:none"> <!-- visible when password is filled -->
<input type="text" value="your placeholder text"> <!-- visible when password is empty ->

In line 126 we see the use of next() to select the input field it has generated:

$input = $input.hide().next().show().attr('id', $input.removeAttr('id').data('placeholder-id'));

Here's where the problem arises
I'm using parsley.js for my client-side validation. Parsley programmatically adds <ul> right after the password field where it will show any errors if any exists. So it actually modifies the markup to be something like:

<input type="password" placeholder="your placeholder text" style="display:none"> <!-- visible when password is filled -->
<ul class="parsley-error-list"></ul> <!-- added by parsley.js -->
<input type="text" value="your placeholder text"> <!-- visible when password is empty ->

So as you can see above, assuming that next() is an input field is wrong and will result in problems. The solution would be to make the selection more specific than just a plain next(). Maybe like nextAll('input:first') or something better.

Some screenshots showing the issues

Initial state:
screen shot 2014-12-16 at 1 39 49 pm

After clicking in the password input field it disappears:
screen shot 2014-12-16 at 1 39 57 pm

@amerikan amerikan changed the title placeholder assumes next() element its input field Password placeholder breaks when element is added between it and its clone text field Dec 16, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant