Krinkle <> changed:

           What    |Removed                     |Added
             Status|PATCH_TO_REVIEW             |RESOLVED
         Resolution|---                         |WONTFIX
            Summary|mediawiki.util: Deprecate   |mediawiki.util: Deprecate
                   |mw.util.$content            |mw.util.$content in favor
                   |                            |of mw.hook(
                   |                            |'wikipage.content' )

--- Comment #2 from Krinkle <> ---
Closing as won't fix per discussion between Daniel Friesen and myself at

Although the naming is unfortunate, these are different things for different
use cases.

mw.hook( 'wikipage.content' ) is to get a reference to #mw-content-text (the
true wiki page content, no skinning around it). It is different from $(
'#mw-content-text' ) in that:

* It can be asynchronous (you can register the hook without needing to
explicitly wait for document-ready).
* It is more semantically correct if your intent is "change content" because it
will re-fire when the content changes dynamically (e.g. after saving an edit
with VisualEditor, or when ajax live previewing wikitext, or in some
hypothetical "ajax navigation" feature).

mw.util.$content is to get a reference to the body content wrapper (the element
containing #mw-content-text, usually indicated by .mw-body). Because
mw.util.$content has been around since before mw.hook, it is likely that there
are existing uses out there that would benefit from using mw.hook instead.
However there remain uses for mw.util.$content where mw.hook is not a suitable

Having said that, I still think we should deprecate mw.util.$content because it
sucks (retrieving its value is tricky because it is asynchronously initialised
without a clear callback for when that happens). However until we have an
alternative for it, let's keep it.

Ideally we'd just mandate that all skins follow the convention to use mw-body
class and then just document that as an API (similar to how addPortletLink's
html structure has become more or less skin independent, though not quite there
yet) that people use by waiting for domready and querying mw-body or

You are receiving this mail because:
You are on the CC list for the bug.
Wikibugs-l mailing list

Reply via email to