From a62550b6870d7865ad83092865d93b01168959f3 Mon Sep 17 00:00:00 2001 From: Fomafix Date: Sun, 3 Nov 2024 19:04:24 +0000 Subject: [PATCH] Get mode from data-ct-options instead of data-ct-mode The attribute data-ct-options already contains the mode and attribute data-ct-mode is just redundant. The attribute data-ct-mode is now not needed anymore and removed from the rendered HTML. Change-Id: If261f3cdab6c55243e80dc2ef3caa884538b02bc --- includes/CategoryTree.php | 1 - includes/CategoryTreePage.php | 1 - modules/ext.categoryTree/ext.categoryTree.js | 3 +-- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/includes/CategoryTree.php b/includes/CategoryTree.php index 077a938a..820e6f44 100644 --- a/includes/CategoryTree.php +++ b/includes/CategoryTree.php @@ -92,7 +92,6 @@ class CategoryTree { $attr['class'] = 'CategoryTreeTag'; } - $attr['data-ct-mode'] = $this->optionManager->getOption( 'mode' ); $attr['data-ct-options'] = $this->optionManager->getOptionsAsJsStructure(); if ( !$title->getArticleID() ) { diff --git a/includes/CategoryTreePage.php b/includes/CategoryTreePage.php index 8846a288..16708404 100644 --- a/includes/CategoryTreePage.php +++ b/includes/CategoryTreePage.php @@ -193,7 +193,6 @@ class CategoryTreePage extends SpecialPage { $output->addHTML( Html::rawElement( 'div', [ 'class' => 'CategoryTreeResult CategoryTreeTag', - 'data-ct-mode' => $this->tree->optionManager->getOption( 'mode' ), 'data-ct-options' => $this->tree->optionManager->getOptionsAsJsStructure(), ], $this->tree->renderNode( $title, 1 ) diff --git a/modules/ext.categoryTree/ext.categoryTree.js b/modules/ext.categoryTree/ext.categoryTree.js index 7a1b6b9e..1aace12f 100644 --- a/modules/ext.categoryTree/ext.categoryTree.js +++ b/modules/ext.categoryTree/ext.categoryTree.js @@ -143,9 +143,8 @@ function loadChildren( $link, $children ) { // Element may not have a .CategoryTreeTag parent, fallback to defauls // Probably a CategoryPage (@todo: based on what?) const ctTitle = $link.attr( 'data-ct-title' ); - const ctMode = $linkParentCTTag.data( 'ct-mode' ); - const mode = typeof ctMode === 'number' ? ctMode : undefined; const ctOptions = $linkParentCTTag.attr( 'data-ct-options' ) || config.defaultCtOptions; + const mode = JSON.parse( ctOptions ).mode; // Mode and options have defaults or fallbacks, title does not. // Don't make a request if there is no title.