https://bugzilla.wikimedia.org/show_bug.cgi?id=40430
Web browser: ---
Bug #: 40430
Summary: jquery.placeholder.js should take the placeholder
value as first parameter
Product: MediaWiki
Version: unspecified
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: Unprioritized
Component: JavaScript
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected], [email protected]
Classification: Unclassified
Mobile Platform: ---
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' );
--
Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
You are on the CC list for the bug.
_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l