On 2019-12-10 04:20, Paul Galbraith wrote:
Can anybody help me understand why this template displays different values
in Firefox than it does in Chrome?

https://ddowiki.com/page/Template:Item

You can see quite clearly in the two examples that are on the template
page, if you check in different browsers.  In Firefox the results are what
I would expect, the link labels are "Carnifex" and "mirror".  However, in
Chrome (and Edge) the labels are "I:Carnifex" and "I:mirror", which based
on the template code I would not expect at all.  Does anyone know why this
is happening?

This is caused by the code here: https://ddowiki.com/page/MediaWiki:Gadget-nsShortener.js

$( 'a.item' ).each( function() {
        $( this ).html( 'I:' + $( this ).html() );
} );

This adds the "I:" before the links.

I think the differences between different browsers are not because of the browsers, but because of the basically random loading order. This piece of code relies on the "item" CSS class, which is added by JS code here: https://ddowiki.com/page/MediaWiki:Common.js

$( 'a[href^="/page/Item:"]' ).each( function() {
    $( this ).addClass( 'item' );
    $( this ).html( $( this ).html().replace( 'Item:', '' ) );
} );

However there is nothing to enforce that it runs before that one. If they run in the wrong order, the "I:" won't be added.

Try adding "|dependencies=site" to the entry for "nsShortener" on https://ddowiki.com/page/MediaWiki:Gadgets-definition , I think that's the right way to fix this.

--
Bartosz Dziewoński

_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l

Reply via email to