From bcadc2e9a0f370a5ed56efdb7b09a64a31e39a52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20Dobro=C5=88?= Date: Sun, 16 Jun 2024 14:13:50 +0200 Subject: [PATCH] Fix miltiple text children in param --- src/fbt/Transform/FbtTransform/FbtAutoWrap.php | 2 +- .../Transform/FbtTransform/Utils/GetNamespacedArgs.php | 4 +--- tests/fbt/fbtTest.php | 8 ++++++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/fbt/Transform/FbtTransform/FbtAutoWrap.php b/src/fbt/Transform/FbtTransform/FbtAutoWrap.php index cdad110..d36c5d5 100644 --- a/src/fbt/Transform/FbtTransform/FbtAutoWrap.php +++ b/src/fbt/Transform/FbtTransform/FbtAutoWrap.php @@ -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') { diff --git a/src/fbt/Transform/FbtTransform/Utils/GetNamespacedArgs.php b/src/fbt/Transform/FbtTransform/Utils/GetNamespacedArgs.php index 197c9e6..3d5f4bd 100644 --- a/src/fbt/Transform/FbtTransform/Utils/GetNamespacedArgs.php +++ b/src/fbt/Transform/FbtTransform/Utils/GetNamespacedArgs.php @@ -58,9 +58,7 @@ public function param(Node $node): array $node = NodeParser::parse('' . $node->innertext() . '', 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]; diff --git a/tests/fbt/fbtTest.php b/tests/fbt/fbtTest.php index 5779dc6..063a5f7 100644 --- a/tests/fbt/fbtTest.php +++ b/tests/fbt/fbtTest.php @@ -632,6 +632,14 @@ public function testHtmlBreak() FBT; $this->assertSame('Bar
Bar
Bar', self::transform($fbt)); + + $fbt = << + Foo
Bar
Baz
+
+FBT; + + $this->assertSame('Foo
Bar
Baz', self::transform($fbt)); } public function testCheckAlreadyStoredHashes()