mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
synced 2024-11-27 17:50:06 +00:00
Use class
instead of id
for scribunto errors
This avoids having multiple HTML elements with the same `id` attribute when certain Scribunto errors reoccur more than once on the same page. Bug: T375539 Change-Id: I123a0f0046a616f63506f096651ae917bbc65cc5
This commit is contained in:
parent
7c1ea4284e
commit
7a9ac93e8d
|
@ -223,7 +223,7 @@ class Hooks implements
|
|||
$parserError = htmlspecialchars( $e->getMessage() );
|
||||
|
||||
// #iferror-compatible error element
|
||||
return "<strong class=\"error\"><span class=\"scribunto-error\" id=\"$id\">" .
|
||||
return "<strong class=\"error\"><span class=\"scribunto-error $id\">" .
|
||||
$parserError . "</span></strong>";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
( () => {
|
||||
|
||||
mw.hook( 'wikipage.content' ).add( () => {
|
||||
const regex = /^mw-scribunto-error-(\w+)/;
|
||||
const regex = /\bmw-scribunto-error-(\w+)\b/;
|
||||
let popup;
|
||||
|
||||
$( '.scribunto-error' ).each( ( index, span ) => {
|
||||
const matches = regex.exec( span.id );
|
||||
let matches = regex.exec( span.className );
|
||||
if ( matches === null ) {
|
||||
// T375539: backward-compatibility with old cached HTML
|
||||
matches = regex.exec( span.id );
|
||||
}
|
||||
if ( matches === null ) {
|
||||
mw.log( 'mw.scribunto.errors: regex mismatch!' );
|
||||
return;
|
||||
|
|
|
@ -272,10 +272,10 @@ extension=ScribuntoErrors-5e10d413
|
|||
cat=Pages_with_script_errors sort=
|
||||
extension[ScribuntoErrors-5e10d413]="<p>Script error: No such module \"foo\".</p><p>No further details are available.</p>"
|
||||
!! html/php
|
||||
<p><strong class="error"><span class="scribunto-error" id="mw-scribunto-error-5e10d413">Script error: No such module "foo".</span></strong>
|
||||
<p><strong class="error"><span class="scribunto-error mw-scribunto-error-5e10d413">Script error: No such module "foo".</span></strong>
|
||||
</p>
|
||||
!! html/parsoid
|
||||
<p><strong class="error" about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"#invoke:foo","function":"invoke"},"params":{"1":{"wt":"bar"}},"i":0}}]}'><span class="scribunto-error" id="mw-scribunto-error-5e10d413">Script error: No such module <span typeof="mw:Entity">"</span>foo<span typeof="mw:Entity">"</span>.</span></strong></p>
|
||||
<p><strong class="error" about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"#invoke:foo","function":"invoke"},"params":{"1":{"wt":"bar"}},"i":0}}]}'><span class="scribunto-error mw-scribunto-error-5e10d413">Script error: No such module <span typeof="mw:Entity">"</span>foo<span typeof="mw:Entity">"</span>.</span></strong></p>
|
||||
!! end
|
||||
|
||||
!! test
|
||||
|
@ -290,10 +290,10 @@ extension=ScribuntoErrors-d64a22ba
|
|||
cat=Pages_with_script_errors sort=
|
||||
extension[ScribuntoErrors-d64a22ba]="<p>Script error: The function \"blah\" does not exist.</p><p>No further details are available.</p>"
|
||||
!! html/php
|
||||
<p><strong class="error"><span class="scribunto-error" id="mw-scribunto-error-d64a22ba">Script error: The function "blah" does not exist.</span></strong>
|
||||
<p><strong class="error"><span class="scribunto-error mw-scribunto-error-d64a22ba">Script error: The function "blah" does not exist.</span></strong>
|
||||
</p>
|
||||
!! html/parsoid
|
||||
<p><strong class="error" about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"#invoke:test","function":"invoke"},"params":{"1":{"wt":"blah"}},"i":0}}]}'><span class="scribunto-error" id="mw-scribunto-error-d64a22ba">Script error: The function <span typeof="mw:Entity">"</span>blah<span typeof="mw:Entity">"</span> does not exist.</span></strong></p>
|
||||
<p><strong class="error" about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"#invoke:test","function":"invoke"},"params":{"1":{"wt":"blah"}},"i":0}}]}'><span class="scribunto-error mw-scribunto-error-d64a22ba">Script error: The function <span typeof="mw:Entity">"</span>blah<span typeof="mw:Entity">"</span> does not exist.</span></strong></p>
|
||||
!! end
|
||||
|
||||
!! test
|
||||
|
|
Loading…
Reference in a new issue