Editors: Please review these uses, and remove or replace the CSS IDs, as needed:
- #mw-anon-edit-warning shown on the editor for anonymous users and used in McrUndoAction.php. Not used in JavaScript,
4223 usages across gadgets/user scripts - #mw-anon-preview-warning shown when anonymous user previewing their changes in McrUndoAction.php and EditPage.php. Unused in code,
53 global search results. - #mw-undelete-revision shown on Special:Undelete. Unused in code,
1312 global search results - #mw-preferences-success used on Special:Preferences and SpecialLUserrights and Extension:CentralAuth. Unused in code. 0 results in global search.
- #mw-userinvalidconfigtitle and #mw-previewconflict in EditPage.php. Both has no usage in code an globally (1, 2).
Original task:
The Html class has methods messageBox, warningBox and errorBox. Currently these support the creation of message boxes in a standardized way.
There are several instances where we create message boxes with ID attributes in our code.
[See list above]
The question is what should we do about these?
Options
- Allow message boxes to define an ID.
This would complicate the Html function API and also encourage bad behaviours such as shipping styles that are usually unused for most page views, changing the default styles for certain message boxes and using the warning to check state e.g. consider this code:
var isAnon = !!document.getElementById( 'mw-anon-edit-warning' );
- Retain the IDs but move them to container elements
e.g.
$out->addHTML( Html::rawElement( 'div', [ 'id' => 'mw-anon-edit-warning' ], Html::warningBox( $html ) ) );
- Drop the IDs.
Decision
Let’s go with 3), dropping the IDs.
Acceptance criteria
For the following drop the use of the ID attribute and use the HTML methods.
- Use HTML::warningBox inside includes/actions/McrUndoAction.php
- Use HTML::warningBox and HTML::errorBox inside EditPage.php
- Use HTML::warningBox includes/specials/SpecialUndelete.php
- Use HTML::successBox inside includes/specials/SpecialUserrights.php
- Use HTML::successBox inside includes/specials/SpecialPreferences.php
- When the code is merged, we should add the User-notice tag to make clear these IDs have been removed.