Skip to content

Commit 9535181

Browse files
authored
perf: revert back to recursiveTagParse() (#27)
* fix unnecessary whitespace trim on tab content * use recursiveTagParse() to lessen unstrip size
1 parent 122df77 commit 9535181

3 files changed

Lines changed: 10 additions & 11 deletions

File tree

includes/Tabber.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,15 @@ public static function render( $input, Parser $parser, PPFrame $frame ) {
8080
* @return string HTML
8181
*/
8282
private static function buildTab( $tab, Parser $parser, PPFrame $frame ) {
83-
$tab = trim( $tab );
84-
if ( empty( $tab ) ) {
85-
return $tab;
83+
if ( empty( trim( $tab ) ) ) {
84+
return '';
8685
}
8786

8887
// Use array_pad to make sure at least 2 array values are always returned
89-
list( $tabName, $tabBody ) = array_pad( array_map( 'trim', explode( '=', $tab, 2 ) ), 2, '' );
88+
list( $tabName, $tabBody ) = array_pad( explode( '=', $tab, 2 ), 2, '' );
9089

91-
$tabBody = $parser->recursiveTagParseFully( $tabBody, $frame );
90+
$tabName = trim( $tabName );
91+
$tabBody = $parser->recursiveTagParse( $tabBody, $frame );
9292

9393
$tab = '<article class="tabber__panel" title="' . htmlspecialchars( $tabName ) .
9494
'">' . $tabBody . '</article>';

includes/TabberParsoid.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ public static function render( ParsoidExtensionAPI $extApi, string $src ) {
5555
* @return string HTML
5656
*/
5757
private static function buildTab( ParsoidExtensionAPI $extApi, string $tab ) {
58-
$tab = trim( $tab );
59-
if ( empty( $tab ) ) {
60-
return $tab;
58+
if ( empty( trim( $tab ) ) ) {
59+
return '';
6160
}
6261

6362
// Use array_pad to make sure at least 2 array values are always returned
64-
list( $tabName, $tabBody ) = array_pad( array_map( 'trim', explode( '=', $tab, 2 ) ), 2, '' );
63+
list( $tabName, $tabBody ) = array_pad( explode( '=', $tab, 2 ), 2, '' );
6564

65+
$tabName = trim( $tabName );
6666
$tabBody = $extApi->domToHTML(
6767
$extApi->wikitextToDOM(
6868
$tabBody,

includes/TabberTransclude.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ public static function render( $input, Parser $parser, PPFrame $frame ) {
8585
* @return string HTML
8686
*/
8787
private static function buildTabTransclude( $tab, Parser $parser, PPFrame $frame, &$selected ) {
88-
$tab = trim( $tab );
89-
if ( empty( $tab ) ) {
88+
if ( empty( trim( $tab ) ) ) {
9089
return '';
9190
}
9291

0 commit comments

Comments
 (0)