links: fix JS error due to a missing non-null check

Causing a console error on a COBOL code block on
https://en.wikipedia.org/wiki/Visual_FoxPro.

The optional chaining operator should ideally be used here, too bad
it's ES2020.

Bug: T376958
Change-Id: Id4c604e4897d83cb51218e785db9f553b3f32fda
This commit is contained in:
Siddharth VP 2024-10-11 17:43:29 +05:30
parent 7dac7163cc
commit f455864c7b

View file

@ -27,7 +27,9 @@ $( () => {
.concat( Array.from( document.getElementsByClassName( classes.doubleQuoteString ) ) ); .concat( Array.from( document.getElementsByClassName( classes.doubleQuoteString ) ) );
stringNodes.forEach( ( node ) => { stringNodes.forEach( ( node ) => {
if ( !node.nextElementSibling || !node.nextElementSibling.firstChild || if ( !node.nextElementSibling ||
!node.nextElementSibling.firstChild ||
!node.nextElementSibling.firstChild.nodeValue ||
node.nextElementSibling.firstChild.nodeValue.indexOf( ')' ) !== 0 ) { node.nextElementSibling.firstChild.nodeValue.indexOf( ')' ) !== 0 ) {
return; return;
} }