mirror of
https://github.com/StarCitizenTools/mediawiki-skins-Citizen.git
synced 2024-11-13 17:49:25 +00:00
perf(core): ⚡️ replace getElementsByTagName() with DOMCompat::querySelectorAll()
Should help with performance quite a bit Bug: T317070
This commit is contained in:
parent
b182872ea7
commit
81eadf9c8d
|
@ -31,6 +31,7 @@ use DOMXpath;
|
||||||
use Html;
|
use Html;
|
||||||
use HtmlFormatter\HtmlFormatter;
|
use HtmlFormatter\HtmlFormatter;
|
||||||
use MediaWiki\MediaWikiServices;
|
use MediaWiki\MediaWikiServices;
|
||||||
|
use Wikimedia\Parsoid\Utils\DOMCompat;
|
||||||
use Wikimedia\Services\NoSuchServiceException;
|
use Wikimedia\Services\NoSuchServiceException;
|
||||||
|
|
||||||
final class BodyContent extends Partial {
|
final class BodyContent extends Partial {
|
||||||
|
@ -206,7 +207,7 @@ final class BodyContent extends Partial {
|
||||||
$headings = [];
|
$headings = [];
|
||||||
|
|
||||||
foreach ( $this->topHeadingTags as $tagName ) {
|
foreach ( $this->topHeadingTags as $tagName ) {
|
||||||
$allTags = $doc->getElementsByTagName( $tagName );
|
$allTags = DOMCompat::querySelectorAll( $doc, $tagName );
|
||||||
|
|
||||||
foreach ( $allTags as $el ) {
|
foreach ( $allTags as $el ) {
|
||||||
if ( $el->parentNode->getAttribute( 'class' ) !== 'toctitle' ) {
|
if ( $el->parentNode->getAttribute( 'class' ) !== 'toctitle' ) {
|
||||||
|
@ -251,7 +252,7 @@ final class BodyContent extends Partial {
|
||||||
$found = false;
|
$found = false;
|
||||||
$subheadings = [];
|
$subheadings = [];
|
||||||
foreach ( $this->topHeadingTags as $tagName ) {
|
foreach ( $this->topHeadingTags as $tagName ) {
|
||||||
$allTags = $doc->getElementsByTagName( $tagName );
|
$allTags = DOMCompat::querySelectorAll( $doc, $tagName );
|
||||||
$elements = [];
|
$elements = [];
|
||||||
foreach ( $allTags as $el ) {
|
foreach ( $allTags as $el ) {
|
||||||
if ( $el->parentNode->getAttribute( 'class' ) !== 'toctitle' ) {
|
if ( $el->parentNode->getAttribute( 'class' ) !== 'toctitle' ) {
|
||||||
|
|
Loading…
Reference in a new issue