Skip to content

Commit

Permalink
Tag::replaceNAttribute() replaces $attrNode too
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Nov 13, 2023
1 parent 81a5541 commit 01641ca
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Latte/Compiler/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ public function expectArguments(string $what = 'arguments'): void
}


public function replaceNAttribute(Node $node): void
public function replaceNAttribute(AreaNode $node): void
{
$index = array_search($this->attrNode, $this->htmlElement->attributes->children, true);
$this->htmlElement->attributes->children[$index] = $node;
$this->htmlElement->attributes->children[$index] = $this->attrNode = $node;
}
}
2 changes: 1 addition & 1 deletion src/Latte/Compiler/TemplateParserHtml.php
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ private function openNAttrNodes(array $toOpen): array
if ($res instanceof \Generator && $res->valid()) {
$toClose[] = [$res, $tag];

} elseif ($res instanceof Node) {
} elseif ($res instanceof AreaNode) {
$this->parser->ensureIsConsumed($tag);
$res->position = $tag->position;
$tag->replaceNAttribute($res);
Expand Down

0 comments on commit 01641ca

Please sign in to comment.