7badb11ae872270d5b24f815617c772cc8287d7d
Usually, you create a new node with jQuery using the following syntax:
$('<elem>', map_of_methods_and_attributes);
Methods of $.prototype take preference over attributes. So, when using
$('<elem>', { paceholder: "text to be shown when empty" });
and the jQuery placeholder plugIn is loaded, it is called instead of setting the attribute.
Test case:
mw.loader.using('jquery.placeholder', function() {
// Prove that it is loaded console.log('placeholder> ', mw.loader.getState( 'jquery.placeholder' )); // Prove that the placeholder is not set $('<input>', { type: 'text', placeholder: 'Hello!' }) .prependTo('#content');
});
Result: Empty text box without placeholder.
Expected: Placeholder text "Hello!"
This can be easily circumvented if $.fn.placeholder would take one argument:
-$.fn.placeholder = function () {
+$.fn.placeholder = function (text) {
and using this argument later
+placeholder = text || this.getAttribute( 'placeholder' );
+-if ( this.placeholder && 'placeholder' in document.createElement( this.tagName ) ) {
+this.setAttribute( 'placeholder', placeholder );
+- return;
-placeholder = this.getAttribute( 'placeholder' );
Version: 1.21.x
Severity: normal