Skip to content

Commit

Permalink
Fix miltiple text children in param
Browse files Browse the repository at this point in the history
  • Loading branch information
richardDobron committed Jun 16, 2024
1 parent 52bd461 commit bcadc2e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/fbt/Transform/FbtTransform/FbtAutoWrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public static function createDescriptionsWithStack(string $moduleName, Node $nod
{
$stack[] = $node;

if ($node->children()) {
if ($node->nodes) {
$filteredChildren = FbtUtils::filterEmptyNodes($node->nodes);
foreach ($filteredChildren as $child) {
if ($child->isElement() && FbtUtils::validateNamespacedFbtElement($moduleName, $node) === 'implicitParamMarker') {
Expand Down
4 changes: 1 addition & 3 deletions src/fbt/Transform/FbtTransform/Utils/GetNamespacedArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ public function param(Node $node): array
$node = NodeParser::parse('<html>' . $node->innertext() . '</html>', false, true, DEFAULT_TARGET_CHARSET, false)
->find('html', 0);

$value = FbtUtils::makeFbtElementArrayFromNode($node->children() ?: $node->nodes)[0] ?? '';

$value = (string)$value;
$value = implode('', FbtUtils::makeFbtElementArrayFromNode($node->nodes));

$paramArgs = [$nameAttr, $value];

Expand Down
8 changes: 8 additions & 0 deletions tests/fbt/fbtTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,14 @@ public function testHtmlBreak()
FBT;

$this->assertSame('Bar<br/> Bar<br/> Bar', self::transform($fbt));

$fbt = <<<FBT
<fbt desc="Bar">
Foo<br/><fbt:param name="lineBreakk">Bar<br>Baz</fbt:param>
</fbt>
FBT;

$this->assertSame('Foo<br/>Bar<br/>Baz', self::transform($fbt));
}

public function testCheckAlreadyStoredHashes()
Expand Down

0 comments on commit bcadc2e

Please sign in to comment.