mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-09-23 18:38:18 +00:00
Use tagName
rather than nodeName
when we know the node is an element
`tagName` is only defined on Element, and it returns its tag name. `nodeName` is defined on Node, and it returns the tag name for Elements, and a string like '#text' or '#document-fragment' for other types. We were using both, which made it harder to reason about what types we're dealing with. Change-Id: I8e621e5872bdf78c84ec553cfbfcdbf0192f0589
This commit is contained in:
parent
063174e71c
commit
584f6a020c
|
@ -291,7 +291,7 @@ class CommentModifier {
|
|||
$hasElements = false;
|
||||
foreach ( $nodes as $node ) {
|
||||
if ( $node instanceof Element ) {
|
||||
if ( strtolower( $node->nodeName ) !== strtolower( $type ) ) {
|
||||
if ( strtolower( $node->tagName ) !== strtolower( $type ) ) {
|
||||
return false;
|
||||
}
|
||||
$hasElements = true;
|
||||
|
|
|
@ -598,7 +598,7 @@ class CommentParser {
|
|||
// if the timestamp node is the only child of a link node, use the link node instead
|
||||
//
|
||||
// Handle links nested in formatting elements.
|
||||
if ( $event === 'leave' && $node instanceof Element && strtolower( $node->nodeName ) === 'a' ) {
|
||||
if ( $event === 'leave' && $node instanceof Element && strtolower( $node->tagName ) === 'a' ) {
|
||||
$username = $this->getUsernameFromLink( $node );
|
||||
if ( $username ) {
|
||||
// Accept the first link to the user namespace, then only accept links to that user
|
||||
|
|
|
@ -148,9 +148,9 @@ class CommentUtils {
|
|||
public static function isCommentSeparator( Node $node ): bool {
|
||||
return $node instanceof Element && (
|
||||
// Empty paragraphs (`<p><br></p>`) between indented comments mess up indentation detection
|
||||
strtolower( $node->nodeName ) === 'br' ||
|
||||
strtolower( $node->tagName ) === 'br' ||
|
||||
// Horizontal line
|
||||
strtolower( $node->nodeName ) === 'hr' ||
|
||||
strtolower( $node->tagName ) === 'hr' ||
|
||||
// {{outdent}} templates
|
||||
DOMCompat::getClassList( $node )->contains( 'outdent-template' )
|
||||
);
|
||||
|
@ -213,7 +213,7 @@ class CommentUtils {
|
|||
do {
|
||||
if (
|
||||
$node instanceof Element &&
|
||||
in_array( strtolower( $node->nodeName ), $tagNames )
|
||||
in_array( strtolower( $node->tagName ), $tagNames )
|
||||
) {
|
||||
return $node;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ function ReplyWidget( commentController, commentDetails, config ) {
|
|||
// don't need to worry about transcluded replies.
|
||||
this.pageExists = mw.config.get( 'wgRelevantArticleId', 0 ) !== 0;
|
||||
var contextNode = utils.closestElement( threadItem.range.endContainer, [ 'dl', 'ul', 'ol' ] );
|
||||
this.context = contextNode ? contextNode.nodeName.toLowerCase() : 'dl';
|
||||
this.context = contextNode ? contextNode.tagName.toLowerCase() : 'dl';
|
||||
// TODO: Should storagePrefix include pageName?
|
||||
this.storagePrefix = 'reply/' + threadItem.id;
|
||||
this.storage = controller.storage;
|
||||
|
|
|
@ -113,9 +113,9 @@ function cantHaveElementChildren( node ) {
|
|||
function isCommentSeparator( node ) {
|
||||
return node.nodeType === Node.ELEMENT_NODE && (
|
||||
// Empty paragraphs (`<p><br></p>`) between indented comments mess up indentation detection
|
||||
node.nodeName.toLowerCase() === 'br' ||
|
||||
node.tagName.toLowerCase() === 'br' ||
|
||||
// Horizontal line
|
||||
node.nodeName.toLowerCase() === 'hr' ||
|
||||
node.tagName.toLowerCase() === 'hr' ||
|
||||
// {{outdent}} templates
|
||||
node.classList.contains( 'outdent-template' )
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue