The wikipage.content hook is often assumed to only be fired for #mw-content-text. In practice, especially with gadgets and user scripts, the passed $content can be anything, sometimes even outside of #mw-content-text.
Any client that assumes #mw-content-text can then break depending on its logic. Recent examples:
- T394705: wikipage.content handler does not check if it's the correct content
- T385297: [Regression 1.44.0-wmf.14] MediaViewer breaks with XTools page info
- T360781: [MinervaNeue/MobileFrontend] Guard against undefined in initMediaViewer()
Changing clients who fire the hook is probably beyond our means, given the hook has been around for ages and is commonly used for any content, both in MediaWiki extensions as well as community-authored gadgets and scripts. See Codesearch and Global Search.
At minimum, I think we need a warning added to the docs for wikipage.content that hook handlers are expected to check if it's the intended content or an element therein.
Another idea is to introduce a new hook specifically for #mw-content-text.