Skip to content

Commit

Permalink
OptimizeChoose: reorganized code
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshyPHP committed Dec 17, 2023
1 parent 80c61e5 commit 31ae9ab
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions src/Configurator/TemplateNormalizations/OptimizeChoose.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,6 @@

class OptimizeChoose extends AbstractChooseOptimization
{
/**
* Adopt the children of given element's only child
*
* @param Element $branch
* @return void
*/
protected function adoptChildren(Element $branch)
{
$branch->append(...$branch->firstChild->childNodes);
$branch->firstChild->remove();
}

/**
* Test whether all branches of current xsl:choose element share a common firstChild/lastChild
*
Expand Down Expand Up @@ -241,13 +229,13 @@ protected function optimizeSingleBranch()
protected function reparentChild()
{
$branches = $this->getBranches();
$childNode = $branches[0]->firstChild->cloneNode();
$this->choose->replaceWith($childNode);
$childNode->appendChild($this->choose);

$outerNode = $branches[0]->firstChild->cloneNode();
foreach ($branches as $branch)
{
$this->adoptChildren($branch);
$branch->append(...$branch->firstChild->childNodes);
$branch->firstChild->remove();
}
$this->choose->replaceWith($outerNode);
$outerNode->appendChild($this->choose);
}
}

0 comments on commit 31ae9ab

Please sign in to comment.