remove $nonce parameter from ::getLoad(), access
the option directly in that method; unhoist variables
and reduce duplication.
Change-Id: If0aef56fa123105e5c98568cb95c09368d55b68e
Minor clean up:
* Fix broken `@see` in MainConfigSchema.
* Add missing `@since`.
* Doc experimental nature, as per the Ic3b6eec1995393 msg.
* Doc anonymous scope, and mention general strategy for elsewhere.
* Dependency inject, to separate concerns and keep ClientHtml
decoupled from MediaWiki settings like wgCookiePrefix, which
otherwise break testing this class with only RL-specific config.
* Apply JS conventions. Made easier by using "JS" as the heredoc
identifier, which IDEs recognise as for highlighting.
* Move code together with the other documentElement.className
statement. This helps both with understanding the PHP side in terms
of related logic and how it interacts, as well as the frontend as
it literally brings <html script>, client-js, and clientpref all
next to each other.
HTML weight of default Main_Page on localhost, logged-out:
* vector : 23.21 kB / 140.48 kB
* vector-2022 : 24.17 kB / 146.43 kB +6.0 kB
* vector-2022 ClientPref=true before : 24.28 kB / 146.70 kB +6.3 kB
* vector-2022 ClientPref=true after : 24.27 kB / 146.68 kB +6.2 kB
Given:
* $wgResourceLoaderClientPreferences = true;
Test plan:
1. View /wiki/Main_Page?useskin=vector-2022 while logged-out,
confirm the inline script is there, and
"vector-feature-limited-width-content" is set on <html class>,
layout width appears fixed.
2. Run mw.cookie.set('mwclientprefs', 'vector-feature-limited-width-content');
3. Refresh and confirm the class is changed at runtime and layout
width is fluid.
Use mw.cookie.set('mwclientprefs', null) to undo.
Bug: T321498
Change-Id: I07f471b815ffadfca9eb4f7bd228cb72dfd1ec9b
This allows the body classes of skins to be customized for anonymous
users. Enable using $wgResourceLoaderClientPreferences = true;
* Only classes of the form <prefix>-(disabled|enabled)
can be toggled.
* For now no client side API is provided as this should not be
considered stable.
* Storage mechanism is cookie, stored under "mwclientprefs"
* Preferences apply to all skins. This means setting a preference
in Vector 2022 would also lead to class manipulation in Minerva.
This is by design to allow for skin-agnostic preferences. Up to
caller to make sure the class being manipulated is limited to the
skin if required ie. don't use generic classes.
* Avoids try/catch and JSON parsing by storaging as a string
* Places inline script before body tag before first stylesheet to
avoid breaking the article's ability to parse the article
concurrently with stylesheet download.
Usage:
Given a document with classes
"client-js vector-feature-limited-width-enabled ext-feature-enabled"
Set:
document.cookie = 'mwclientprefs=vector-feature-limited-width'
Will result in toggling off the limited width.
Bug: T321498
Change-Id: Ic3b6eec19953932c697ab5bf48c33a4ac1841b07
Move ResourceLoader classes to their own namespace. Strip the
"ResourceLoader" prefix from all except ResourceLoader itself.
Move the tests by analogy.
I used a namespace alias "RL" in some callers since RL\Module is less
ambiguous at the call site than just "Module".
I did not address DependencyStore which continues to have a non-standard
location and namespace.
Revert of a241d83e0a.
Bug: T308718
Change-Id: Id08a220e1d6085e2b33f3f6c9d0e3935a4204659
This reverts commit e08ea8ccb9.
Reason for revert: Breaks Phan in extensions, and as far as I’m aware,
this change isn’t urgently needed for anything, so the simplest fix is
to revert it again for now. After PHP 7.4 it should be safer to try this
again (we hopefully won’t need the two “hack” classes by then).
Bug: T308443
Change-Id: Iff3318cbf97a67f821f78e60da62a583f63e389e
Move ResourceLoader classes to their own namespace. Strip the
"ResourceLoader" prefix from all except ResourceLoader and
ResourceLoaderContext.
Move the tests by analogy.
I used a namespace alias "RL" in some callers since RL\Module is less
ambiguous at the call site than just "Module".
I did not address DependencyStore which continues to have a non-standard
location and namespace.
Change-Id: I92998ae6a82e0b935c13e02a183e7c324fa410a3
2022-05-16 14:41:27 +10:00
Renamed from includes/resourceloader/ResourceLoaderClientHtml.php (Browse further)