Make a more specific CSS selector in getLangsWithBadges

This should avoid problems with elements that are not real
interlanguage links, which may be added by other code,
for example user scripts.

Bug: T267887
Change-Id: I3f9c618b417363f667a31e9dad335c1aec15b055
This commit is contained in:
Amir Aharoni
2020-11-17 10:25:43 +02:00
parent 4387bb9d61
commit 077a3ac844

View File

@@ -329,11 +329,9 @@
*/ */
CompactInterlanguageList.prototype.getLangsWithBadges = function () { CompactInterlanguageList.prototype.getLangsWithBadges = function () {
return Array.prototype.map.call( return Array.prototype.map.call(
document.querySelectorAll( '#p-lang [class*="badge"]' ), document.querySelectorAll( '#p-lang [class*="badge"] a.interlanguage-link-target' ),
function ( el ) { function ( el ) {
return mw.uls.convertMediaWikiLanguageCodeToULS( return mw.uls.convertMediaWikiLanguageCodeToULS( el.lang );
el.querySelector( '.interlanguage-link-target' ).lang
);
} }
); );
}; };