From 6450cea848d4254eec2c760c6776b1a4b17d4ea9 Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Thu, 29 Oct 2020 15:41:26 +0000 Subject: [PATCH] Fix fetching of headline node with new HTML This code path needs to work with new and old HTML markup around headings. Change-Id: I2291e407e68423b34fca4d53362680d97ab44a71 --- modules/dt.ui.ReplyWidget.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/dt.ui.ReplyWidget.js b/modules/dt.ui.ReplyWidget.js index 7b0b9ebd8..d3ed7b7b4 100644 --- a/modules/dt.ui.ReplyWidget.js +++ b/modules/dt.ui.ReplyWidget.js @@ -1,7 +1,8 @@ var controller = require( 'ext.discussionTools.init' ).controller, modifier = require( 'ext.discussionTools.init' ).modifier, utils = require( 'ext.discussionTools.init' ).utils, - logger = require( 'ext.discussionTools.init' ).logger; + logger = require( 'ext.discussionTools.init' ).logger, + Parser = require( 'ext.discussionTools.init' ).Parser; /** * @external CommentController @@ -393,7 +394,7 @@ ReplyWidget.prototype.setup = function ( data ) { // This comment is in 0th section, there's no section title for the edit summary summary = ''; } else { - headingNode = heading.range.startContainer.querySelector( '.mw-headline' ).cloneNode( true ); + headingNode = ( new Parser() ).getHeadlineNodeAndOffset( heading.range.startContainer ).node; // Remove mw-headline-number. T264561 $( headingNode ).find( '.mw-headline-number' ).remove(); summary = '/* ' + headingNode.innerText.trim() + ' */ ';