jquery.placeholder: Fixup for a8145d6fa2
authorMarius Hoch <hoo@online.de>
Fri, 26 Jul 2013 17:23:52 +0000 (19:23 +0200)
committerKrinkle <krinklemail@gmail.com>
Fri, 26 Jul 2013 18:09:37 +0000 (18:09 +0000)
* add release notes
* fix minor bug where wrong value is used

Change-Id: Iaab38cc041d143228332e00092f8521f6f3de596

RELEASE-NOTES-1.22
resources/jquery/jquery.placeholder.js

index 0d4bee7..2658193 100644 (file)
@@ -163,6 +163,8 @@ production.
   The special page form received a new checkbox matching that option.
 * (bug 23580) Implement javascript callback interface "mw.hook".
 * (bug 30713) New mw.hook "wikipage.content".
+* (bug 40430) jquery.placeholder gets a new parameter to set the attribute value
+  to be used.
 
 === Bug fixes in 1.22 ===
 * Disable Special:PasswordReset when $wgEnableEmail is false. Previously one
index 73f701b..f7c9ae0 100644 (file)
 ( function ( $ ) {
 
        $.fn.placeholder = function ( text ) {
-               // Check whether supplied argument is a string
-               var textIsValid = ( typeof text === 'string' );
 
                return this.each( function () {
                        var placeholder, $input;
 
+                       if ( arguments.length ) {
+                               this.setAttribute( 'placeholder', text );
+                       }
 
                        // If the HTML5 placeholder attribute is supported, use it
                        if ( this.placeholder && 'placeholder' in document.createElement( this.tagName ) ) {
-                               if ( textIsValid ) {
-                                       this.setAttribute( 'placeholder', text );
-                               }
                                return;
                        }
 
-                       placeholder = textIsValid ? text : this.getAttribute( 'placeholder' );
+                       placeholder = arguments.length ? text : this.getAttribute( 'placeholder' );
                        $input = $(this);
 
                        // Show initially, if empty