diff --git a/extension.json b/extension.json index f44f0e346..992f6de17 100644 --- a/extension.json +++ b/extension.json @@ -151,6 +151,7 @@ "cases/en-big-parsoid/en-big-parsoid.json", "cases/en-big-parsoid/en-big-parsoid-transcludedFrom.json", "cases/en-bigafd-parsoid/en-bigafd-parsoid-transcludedFrom.json", + "cases/transclusions/transclusions-transcludedFrom.json", "cases/pl-big-oldparser/pl-big-oldparser.json", "cases/pl-big-parsoid/pl-big-parsoid.json", "cases/no-heading/no-heading.json", @@ -166,6 +167,7 @@ "cases/en-big-parsoid/en-big-parsoid.html", "cases/en-big-parsoid/en-big-parsoid-modified.html", "cases/en-bigafd-parsoid/en-bigafd-parsoid.html", + "cases/transclusions/transclusions.html", "cases/pl-big-oldparser/pl-big-oldparser.html", "cases/pl-big-oldparser/pl-big-oldparser-modified.html", "cases/pl-big-oldparser/pl-big-oldparser-reply.html", diff --git a/modules/controller.js b/modules/controller.js index d6091e6fe..485ae73a4 100644 --- a/modules/controller.js +++ b/modules/controller.js @@ -335,6 +335,8 @@ function getParsoidCommentData( pageName, oldId, commentId ) { data = response.visualeditor; parsoidDoc = ve.parseXhtml( data.content ); + // Remove section wrappers, they interfere with transclusion handling + mw.libs.ve.unwrapParsoidSections( parsoidDoc.body ); // Mirror VE's ve.init.mw.Target.prototype.fixBase behavior: ve.fixBase( parsoidDoc, document, ve.resolveUrl( // Don't replace $1 with the page name, because that'll break if diff --git a/tests/qunit/cases/transclusions/transclusions-transcludedFrom.json b/tests/qunit/cases/transclusions/transclusions-transcludedFrom.json new file mode 100644 index 000000000..8704091f0 --- /dev/null +++ b/tests/qunit/cases/transclusions/transclusions-transcludedFrom.json @@ -0,0 +1,12 @@ +{ + "Matma Rex|2020-03-04T20:11:00.000Z|0": false, + "Matma Rex|2020-03-04T20:12:00.000Z|0": false, + "Matma Rex|2020-03-04T20:13:00.000Z|0": false, + "Matma Rex|2020-03-04T20:21:00.000Z|0": "Talk:Transcluded subpage", + "Matma Rex|2020-03-04T20:22:00.000Z|0": "Talk:Transcluded subpage", + "Matma Rex|2020-03-04T20:23:00.000Z|0": "Talk:Transcluded subpage", + "Matma Rex|2020-03-04T20:30:00.000Z|0": true, + "Matma Rex|2020-03-04T20:31:00.000Z|0": true, + "Matma Rex|2020-03-04T20:32:00.000Z|0": true, + "Matma Rex|2020-03-04T20:33:00.000Z|0": true +} diff --git a/tests/qunit/cases/transclusions/transclusions.html b/tests/qunit/cases/transclusions/transclusions.html new file mode 100644 index 000000000..1516e9cc5 --- /dev/null +++ b/tests/qunit/cases/transclusions/transclusions.html @@ -0,0 +1,23 @@ + +Talk:Transcluded

Not transcluded

+

Normal comment. Matma Rex (talk) 20:11, 4 March 2020 (UTC)

+
Normal comment 2. Matma Rex (talk) 20:12, 4 March 2020 (UTC)
+
Ping-like template. Matma Rex (talk) 20:13, 4 March 2020 (UTC)
+ + +

On a subpage

+

Normal comment. Matma Rex (talk) 20:21, 4 March 2020 (UTC)

+
Normal comment 2. Matma Rex (talk) 20:22, 4 March 2020 (UTC)
+
Ping-like template. Matma Rex (talk) 20:23, 4 March 2020 (UTC)
+ +

Archived

+
+
The following discussion is closed. Please do not modify it. Subsequent comments should be made in a new section. A summary of the conclusions reached follows. +
Archived discussion. Matma Rex (talk) 20:30, 4 March 2020 (UTC)
+
+ +

Normal comment. Matma Rex (talk) 20:31, 4 March 2020 (UTC)

+
Normal comment 2. Matma Rex (talk) 20:32, 4 March 2020 (UTC)
+
Ping-like template. Matma Rex (talk) 20:33, 4 March 2020 (UTC)
+
+
The above discussion is closed. Please do not modify it. Subsequent comments should be made in a new section.
diff --git a/tests/qunit/parser.test.js b/tests/qunit/parser.test.js index bbe5c61f9..3b93d46d6 100644 --- a/tests/qunit/parser.test.js +++ b/tests/qunit/parser.test.js @@ -231,6 +231,13 @@ QUnit.test( '#getTranscludedFrom', function ( assert ) { var i, j, cases, comments, transcludedFrom, fixture; cases = [ + { + name: 'transclusions', + dom: mw.template.get( 'test.DiscussionTools', 'cases/transclusions/transclusions.html' ).render(), + expected: require( './cases/transclusions/transclusions-transcludedFrom.json' ), + config: require( './data/enwiki-config.json' ), + data: require( './data/enwiki-data.json' ) + }, { name: 'enwiki parsoid', dom: mw.template.get( 'test.DiscussionTools', 'cases/en-big-parsoid/en-big-parsoid.html' ).render(), @@ -251,6 +258,8 @@ QUnit.test( '#getTranscludedFrom', function ( assert ) { for ( i = 0; i < cases.length; i++ ) { $( fixture ).empty().append( cases[ i ].dom ); + mw.libs.ve.unwrapParsoidSections( fixture ); + testUtils.overrideMwConfig( cases[ i ].config ); testUtils.overrideParserData( cases[ i ].data );