Skip to content

Commit 25deaab

Browse files
committed
Create a new component instance for every usage of a component
1 parent f591ece commit 25deaab

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/Compiler.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ public function convertNode(DOMNode $node): DOMNode
106106
//$this->handleRawHtml($node, $data);
107107

108108
if (in_array($node->nodeName, array_keys($this->components))) {
109-
$currentComponent = $this->components[$node->nodeName];
109+
$matchedComponent = $this->components[$node->nodeName];
110+
$usedComponent = new Component($matchedComponent->getName(), $matchedComponent->getPath());
110111

111112
if ($node->hasAttributes()) {
112113
/** @var DOMAttr $attribute */
@@ -115,17 +116,17 @@ public function convertNode(DOMNode $node): DOMNode
115116
$name = substr($attribute->name, strpos($attribute->name, ':') + 1);
116117
$value = $this->refactorTemplateString($attribute->value);
117118

118-
$currentComponent->addProperty($name, $value, true);
119+
$usedComponent->addProperty($name, $value, true);
119120
} else {
120-
$currentComponent->addProperty($attribute->name, '"'.$attribute->value.'"', false);
121+
$usedComponent->addProperty($attribute->name, '"'.$attribute->value.'"', false);
121122
}
122123
}
123124
}
124125

125126
$include = $this->document->createTextNode(
126127
$this->builder->createIncludePartial(
127-
$currentComponent->getPath(),
128-
$currentComponent->getProperties()
128+
$usedComponent->getPath(),
129+
$usedComponent->getProperties()
129130
)
130131
);
131132

0 commit comments

Comments
 (0)