qualcentric-web-solutions / jquery-watermark

Automatically exported from code.google.com/p/jquery-watermark
0 stars 0 forks source link

Changing password watermark causes watermark to never hide #111

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Add a watermark to a password input.
2. Change the watermark on the password input above.
3. Click in the password field to hide the watermark, the watermark stays.

What is the expected output? What do you see instead?
Expects the watermark to be hidden when clicking into the password input.
Instead, watermark stays, doesn't hide.

What version of the product are you using? On what operating system?
3.1.4

Please provide any additional information below.
I created a the fix for this.
When checking if the watermark is being updated (already initialized), the 
$input is the password field and the data values are set correctly.  
The fix is to set the data properties on the password field's corresponding 
text field too.
(The bug is in the hide event where it checks the text value against the 
watermark value.)

Here's the updated code:

            // Watermark already initialized?
            if ( $input.data( dataFlag ) ) {

                // If re-defining text or class, first remove existing watermark, then make changes
                if ( hasText || hasClass ) {
                    $.watermark._hide( $input );

                    var $wm = $input.data( dataPassword );
                    if ( hasText ) {
                        $input.data( dataText, text );
                        $wm.data( dataText, $input.data( dataText ) );
                    }

                    if ( hasClass ) {
                        $input.data( dataClass, options.className );
                        $wm.data( dataClass, $input.data( dataClass ) );
                    }
                }
            } 

Original issue reported on code.google.com by jroc...@gmail.com on 26 Jun 2013 at 6:31

GoogleCodeExporter commented 8 years ago
It is noted in the Project Home page that programmatically changing a password 
watermark is tricky and not recommended.  Do at your own risk, and be prepared 
to dissect how the code works.

Original comment by t...@speednet.biz on 16 Aug 2014 at 4:57