Hi. I have some questions about modularization. If I want to get my own name, I can either type mw.config.values.wgUserName or mw.user.getName(), but if I want to get the page name, the only option seems to be mw.config.values.wgPageName. The only thing I can find in mw.page is watch. So, my question is, will more stuff be added to mw.page in the future? Will it be something like mw.page.getPageName() in the future? Is the work with modularization abandoned or ongoing? Will the values in mw.config.values eventually be deprecated once they've been in a module long enough? Is there a Phabricator task about this? I did find phab:T133277 which is called "Modularization of JS code", but that appears to be something much more specific than what I'm talking about.
Topic on User talk:Roan Kattouw (WMF)/Flow
Side note: you should use mw.config.get( 'wgFoo' )
instead of mw.config.values.wgFoo
.
I don't think there's a specific task about this (perhaps @Timo Tijhof (WMF) would know) but an idea I've proposed before is to expose config variables per module instead of globally. This could change mw.config.get()
to something else, but we'd probably keep the old one around for backwards compatibility. As for mw.page
, I'm not aware of any immediate plans to move more stuff into there.
I wouldn't say the modularization work is abandoned, but it's not particularly active either. Perhaps a better way to describe its status would be "dormant" or "moving slowly". The task you found is specific to one extension (RevisionSlider).
Is there a reason I should use mw.config.get( 'wgFoo' ) over mw.config.values.wgFoo? mw.config.get( 'wgFoo' ) fails silently with trailing spaces, even though it is unambiguous, see this edit for instance. mw.config.values.wgFoo is much more robust and fails loudly.
The main reason is that mw.config.values.foo
is using an internal implementation detail, not the public API. The public API is mw.config.get( 'foo' )
. So the latter is considered cleaner, but both work. You're right though that louder failures for misspelled config variables would be good.
@Nirmos Ideas for a more complete Page interface exist at phab:T41813. For now, mw.config.get
is the supported way to get this information. See also Manual:Interface/JavaScript#mw.config.
(phab:T133277 is actually about the RevisionSlider project, not MediaWiki.)