Dedicated task for a comment I posted on T13555:
In T13555#10603383, @Od1n wrote:While doing some code browsing about an unrelated task, I noticed that, in MobileFrontend, some update may be needed in PageHTMLParser.js.
First, see line 3:
HEADING_SELECTOR = mw.config.get( 'wgMFMobileFormatterHeadings', [ 'h1', 'h2', 'h3', 'h4', 'h5' ] ).join( ',' ),(At the time of writing, wgMFMobileFormatterHeadings is [ 'h1', 'h2', 'h3', 'h4', 'h5', 'h6' ].)
Then, see in findSectionHeadingByIndex() method, line 45:
return this.$headings // Headings must strictly be a child element of a section element // or the parser-output. // Not an ancestor! .filter( '.mw-parser-output > *, [class^="mf-section-"] > *' ).eq( sectionIndex - 1 );That filter() no longer matches the headings, because of the new markup.
(By the way, note that find( 'h1, h2, h3, h4, h5, h6' ), which uses querySelectorAll() underneath, is extremely slow, as elaborated in T220751. A more efficient code would be to loop over h1, then h2, etc. as it would make use of getElementsByTagName().)
Subsequently, I also posted a comment on T220751:
In T220751#10605294, @Od1n wrote:It seems that this code needs to be updated, please have a look at T13555#10603383.
I don't remember if "raw headings" are counted in the §ion=N indexes. If they are not counted, that's good news for the case at hand: provided we are fine with targetting h1 ... h6 levels, we could replace everything with just .find( '.mw-heading' ) (and it wouldn't even need the subsequent .filter()).
Also, refs this page: Heading HTML changes.