diff --git a/src/Compiler.php b/src/Compiler.php
index 552543b..9691b38 100644
--- a/src/Compiler.php
+++ b/src/Compiler.php
@@ -150,7 +150,6 @@ public function convertNode(DOMNode $node, int $level = 0): DOMNode
$this->handleIf($node);
$this->handleFor($node);
$this->stripEventHandlers($node);
- //$this->handleRawHtml($node, $data);
$this->handleDefaultSlot($node);
$this->cleanupAttributes($node);
}
@@ -410,14 +409,20 @@ protected function handleTextNode(DOMText $node)
}
private function cleanupAttributes(DOMElement $node) {
- if ($node->hasAttribute('ref')) {
- $node->removeAttribute('ref');
+ $removeAttributes = [];
+ /** @var DOMAttr $attribute */
+ foreach ($node->attributes as $attribute) {
+ if (
+ (preg_match('/^v-([a-z]*)/', $attribute->name, $matches) === 1 && $matches[1] !== 'bind')
+ || preg_match('/^[:]?ref$/', $attribute->name) === 1
+ ) {
+ $removeAttributes[] = $attribute->name;
+ }
}
- if ($node->hasAttribute(':ref')) {
- $node->removeAttribute(':ref');
+ foreach ($removeAttributes as $removeAttribute) {
+ $node->removeAttribute($removeAttribute);
}
}
-
private function handleIf(DOMElement $node): void
{
if (!$node->hasAttribute('v-if') &&
diff --git a/tests/CleanupAttributesTest.php b/tests/CleanupAttributesTest.php
index 6165daa..bccdc1a 100644
--- a/tests/CleanupAttributesTest.php
+++ b/tests/CleanupAttributesTest.php
@@ -6,7 +6,7 @@ class CleanupAttributesTest extends AbstractTestCase
{
public function testCleanupAttributes()
{
- $vueTemplate = '