From 4f2e5fe2a096c64cbaa23b0bed3d9c9655bf2dd4 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Sat, 27 Jul 2013 07:59:48 +0200 Subject: [PATCH] jquery.placeholder: Fixup for 7ec7d879ee Check for 'arguments.length' was done in the wrong scope. It checked for arguments to .each() which is always 2 (i, el). This caused a regression where any call to .placeholder() without arguments resulted in the string 'undefined' to be displayed as placeholder (since it was doing setAttribute and passing it `text` which is undefined, and then further using that undefined variable). Until 7ec7d879ee / a8145d6fa2 this was the only way .placeholder could be called, so this is a major regression affecting all use of it. Change-Id: I862b0f72548ec2122dad9c5d013149ac57688dab --- resources/jquery/jquery.placeholder.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/resources/jquery/jquery.placeholder.js b/resources/jquery/jquery.placeholder.js index f7c9ae0f29..8044d88038 100644 --- a/resources/jquery/jquery.placeholder.js +++ b/resources/jquery/jquery.placeholder.js @@ -11,11 +11,12 @@ ( function ( $ ) { $.fn.placeholder = function ( text ) { + var hasArg = arguments.length; return this.each( function () { var placeholder, $input; - if ( arguments.length ) { + if ( hasArg ) { this.setAttribute( 'placeholder', text ); } @@ -24,7 +25,7 @@ return; } - placeholder = arguments.length ? text : this.getAttribute( 'placeholder' ); + placeholder = hasArg ? text : this.getAttribute( 'placeholder' ); $input = $(this); // Show initially, if empty -- 2.20.1