mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-24 08:23:52 +00:00
Skip over empty inline templates (e.g. tracking templates)
Bug: T269036 Change-Id: I15e56041c1f1ecb85e9e368a9fbb07882438bf8d
This commit is contained in:
parent
a672cdb1b0
commit
fb0cc01ff8
|
@ -8,6 +8,7 @@ use DOMNode;
|
|||
use DOMXPath;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use Title;
|
||||
use Wikimedia\Parsoid\Utils\DOMCompat;
|
||||
|
||||
class CommentUtils {
|
||||
private function __construct() {
|
||||
|
@ -47,7 +48,13 @@ class CommentUtils {
|
|||
$node instanceof DOMComment ||
|
||||
$node instanceof DOMElement && (
|
||||
strtolower( $node->tagName ) === 'meta' ||
|
||||
strtolower( $node->tagName ) === 'link'
|
||||
strtolower( $node->tagName ) === 'link' ||
|
||||
// Empty inline templates, e.g. tracking templates
|
||||
(
|
||||
strtolower( $node->tagName ) === 'span' &&
|
||||
in_array( 'mw:Transclusion', explode( ' ', $node->getAttribute( 'typeof' ) ) ) &&
|
||||
!self::htmlTrim( DOMCompat::getInnerHTML( $node ) )
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,14 @@ function isRenderingTransparentNode( node ) {
|
|||
node.nodeType === Node.COMMENT_NODE ||
|
||||
node.nodeType === Node.ELEMENT_NODE && (
|
||||
node.tagName.toLowerCase() === 'meta' ||
|
||||
node.tagName.toLowerCase() === 'link'
|
||||
node.tagName.toLowerCase() === 'link' ||
|
||||
// Empty inline templates, e.g. tracking templates
|
||||
(
|
||||
node.tagName.toLowerCase() === 'span' &&
|
||||
node.getAttribute( 'typeof' ).split( ' ' ).indexOf( 'mw:Transclusion' ) !== -1 &&
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
!htmlTrim( node.innerHTML )
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -10,6 +10,10 @@
|
|||
<p>hello <a rel="mw:WikiLink" href="./User:Matma_Rex" title="User:Matma Rex">Matma Rex</a> (<a rel="mw:WikiLink" href="./User_talk:Matma_Rex" title="User talk:Matma Rex"><font color="green"><i>talk</i></font></a>) 18:44, 22 July 2020 (UTC) </p>
|
||||
<!-- Above comment added by announce-bot --><dl><dd data-parsoid="{}">Reply to c|Matma Rex|2020-07-22T18:44:00.000Z|comments_T257651</dd></dl>
|
||||
|
||||
<div class="user-block">Blocked!
|
||||
<ul><li>For this reason</li></ul>
|
||||
<a rel="mw:WikiLink" href="./User:Admin" title="User:Admin">Admin</a> (<a rel="mw:WikiLink" href="./User_talk:Admin" title="User talk:Admin">talk</a>) 21:33, 8 December 2020 (UTC)</div><link rel="mw:PageProp/Category" href="./Category:Blocked_users"/><span about="#mwt6" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"z13","href":"./Template:Z13"},"params":{},"i":0}}]}' id="mwMQ"></span><!-- Template:blockedusers --><dl><dd data-parsoid="{}">Reply to c|Admin|2020-12-08T21:33:00.000Z|comments_T257651</dd></dl>
|
||||
|
||||
<p>hello <a rel="mw:WikiLink" href="./User:Matma_Rex" title="User:Matma Rex">Matma Rex</a> (<a rel="mw:WikiLink" href="./User_talk:Matma_Rex" title="User talk:Matma Rex"><font color="green"><i>talk</i></font></a>) 18:45, 22 July 2020 (UTC) </p><link rel="mw:PageProp/Category" href="./Category:Test"/><dl><dd data-parsoid="{}">Reply to c|Matma Rex|2020-07-22T18:45:00.000Z|comments_T257651</dd></dl>
|
||||
|
||||
<p>hello <a rel="mw:WikiLink" href="./User:Matma_Rex" title="User:Matma Rex">Matma Rex</a> (<a rel="mw:WikiLink" href="./User_talk:Matma_Rex" title="User talk:Matma Rex"><font color="green"><i>talk</i></font></a>) 18:46, 22 July 2020 (UTC) </p><dl><dd data-parsoid="{}">Reply to c|Matma Rex|2020-07-22T18:46:00.000Z|comments_T257651</dd></dl>
|
||||
|
|
|
@ -10,6 +10,10 @@
|
|||
<p>hello <a rel="mw:WikiLink" href="./User:Matma_Rex" title="User:Matma Rex">Matma Rex</a> (<a rel="mw:WikiLink" href="./User_talk:Matma_Rex" title="User talk:Matma Rex"><font color="green"><i>talk</i></font></a>) 18:44, 22 July 2020 (UTC) </p>
|
||||
<!-- Above comment added by announce-bot -->
|
||||
|
||||
<div class="user-block">Blocked!
|
||||
<ul><li>For this reason</li></ul>
|
||||
<a rel="mw:WikiLink" href="./User:Admin" title="User:Admin">Admin</a> (<a rel="mw:WikiLink" href="./User_talk:Admin" title="User talk:Admin">talk</a>) 21:33, 8 December 2020 (UTC)</div><link rel="mw:PageProp/Category" href="./Category:Blocked_users"><span about="#mwt6" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"z13","href":"./Template:Z13"},"params":{},"i":0}}]}' id="mwMQ"></span><!-- Template:blockedusers -->
|
||||
|
||||
<p>hello <a rel="mw:WikiLink" href="./User:Matma_Rex" title="User:Matma Rex">Matma Rex</a> (<a rel="mw:WikiLink" href="./User_talk:Matma_Rex" title="User talk:Matma Rex"><font color="green"><i>talk</i></font></a>) 18:45, 22 July 2020 (UTC) </p><link rel="mw:PageProp/Category" href="./Category:Test">
|
||||
|
||||
<p>hello <a rel="mw:WikiLink" href="./User:Matma_Rex" title="User:Matma Rex">Matma Rex</a> (<a rel="mw:WikiLink" href="./User_talk:Matma_Rex" title="User talk:Matma Rex"><font color="green"><i>talk</i></font></a>) 18:46, 22 July 2020 (UTC) </p>
|
||||
|
|
Loading…
Reference in a new issue