Last modified: 2013-04-03 18:25:48 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T33260, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 31260 - Add support for rawParams to mw.message
Add support for rawParams to mw.message
Status: NEW
Product: MediaWiki
Classification: Unclassified
JavaScript (Other open bugs)
1.17.x
All All
: Normal enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
: i18n, javascript, need-unittest
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-09-29 23:49 UTC by Krinkle
Modified: 2013-04-03 18:25 UTC (History)
5 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Krinkle 2011-09-29 23:49:39 UTC
Just like wfMessage('foo')->rawParams($x)->escaped() works, we also need this in javascript.

For example when wanting to replace $1 with a hyperlink, we currently have to do something like this:

mw.message( msgkey )
	.escaped()
	.replace( /\$1/,
		mw.html.element( 'a', { id: 'foo' }, mw.msg( 'bar' ) )
	);

Which should become:

mw.message( msgkey )
	.rawParams(
		mw.html.element( 'a', { id: 'foo' }, mw.msg( 'bar' ) )
	);
	.escaped();
Comment 1 Brion Vibber 2011-09-30 18:29:48 UTC
Yes, definitely makes sense to have closer interface parity, and it's an often handy thing. Added needs-unittest keyword as it'll want tests added to the qunit suite!

Main problem I see: if we return a *string* from .escaped() etc, then any parameters you've provided as DOM elements will need to be flattened back to HTML source on the output.

This is ok for simple cases, but if you want to do something like attach some data or behavior to an element (something that IIRC Neil's message parser for UploadWizard explicitly does) you could end up losing it.

(Event handlers etc would need to be re-added after the string gets turned back into DOM elements in the document, which is potentially awkward.)

It may be useful to have an output mode that produces a DOM element rather than HTML source.
Comment 2 Aude 2013-01-11 16:22:12 UTC
I was looking for a way to do this today for Wikidata and hope for a solution soonish.
Comment 3 Daniel Friesen 2013-04-03 18:25:48 UTC
Note that inside JavaScript we don't really need an actual rawParams method. We just support passing jQuery or DOM objects into params.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links