diff --git a/includes/CommentUtils.php b/includes/CommentUtils.php index d22d53d20..f49457581 100644 --- a/includes/CommentUtils.php +++ b/includes/CommentUtils.php @@ -327,17 +327,17 @@ class CommentUtils { * The indent level is the number of lists inside of which it is nested. * * @param Node $node - * @param Node $rootNode + * @param Element $rootNode * @return int */ - public static function getIndentLevel( Node $node, Node $rootNode ): int { + public static function getIndentLevel( Node $node, Element $rootNode ): int { $indent = 0; while ( $node ) { if ( $node === $rootNode ) { break; } - $nodeName = strtolower( $node->nodeName ); - if ( $nodeName === 'li' || $nodeName === 'dd' ) { + $tagName = $node instanceof Element ? strtolower( $node->tagName ) : null; + if ( $tagName === 'li' || $tagName === 'dd' ) { $indent++; } $node = $node->parentNode; diff --git a/includes/ThreadItem.php b/includes/ThreadItem.php index 8ac47de9e..7f7035f5f 100644 --- a/includes/ThreadItem.php +++ b/includes/ThreadItem.php @@ -7,7 +7,6 @@ use LogicException; use Title; use Wikimedia\Assert\Assert; use Wikimedia\Parsoid\DOM\Element; -use Wikimedia\Parsoid\DOM\Node; use Wikimedia\Parsoid\Utils\DOMUtils; /** @@ -337,9 +336,9 @@ abstract class ThreadItem implements JsonSerializable { } /** - * @return Node Root node (level is relative to this node) + * @return Element Root node (level is relative to this node) */ - public function getRootNode(): Node { + public function getRootNode(): Element { return $this->rootNode; } @@ -400,9 +399,9 @@ abstract class ThreadItem implements JsonSerializable { } /** - * @param Node $rootNode Root node (level is relative to this node) + * @param Element $rootNode Root node (level is relative to this node) */ - public function setRootNode( Node $rootNode ): void { + public function setRootNode( Element $rootNode ): void { $this->rootNode = $rootNode; } diff --git a/modules/utils.js b/modules/utils.js index d5c61a6a0..d910a8d7c 100644 --- a/modules/utils.js +++ b/modules/utils.js @@ -280,7 +280,7 @@ function htmlTrim( str ) { * * @private * @param {Node} node - * @param {Node} rootNode + * @param {Element} rootNode * @return {number} */ function getIndentLevel( node, rootNode ) { @@ -289,7 +289,7 @@ function getIndentLevel( node, rootNode ) { if ( node === rootNode ) { break; } - var tagName = node.tagName && node.tagName.toLowerCase(); + var tagName = node instanceof HTMLElement ? node.tagName.toLowerCase() : null; if ( tagName === 'li' || tagName === 'dd' ) { indent++; }