mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-27 17:51:09 +00:00
CommentUtils: Fix confusing types in getIndentLevel()
Change-Id: I548cf4ad54e92c22da64caf53ee028a906cd3b62
This commit is contained in:
parent
584f6a020c
commit
0e576216b2
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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++;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue