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
( 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 );
}
return;
}
- placeholder = arguments.length ? text : this.getAttribute( 'placeholder' );
+ placeholder = hasArg ? text : this.getAttribute( 'placeholder' );
$input = $(this);
// Show initially, if empty