https://bugzilla.wikimedia.org/show_bug.cgi?id=63466

Krinkle <krinklem...@gmail.com> 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 <krinklem...@gmail.com> ---
Closing as won't fix per discussion between Daniel Friesen and myself at
https://gerrit.wikimedia.org/r/123559.

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
alternative.

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
mw-body-primary.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
Wikibugs-l mailing list
Wikibugs-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to