Skip to content

Commit 5b6318a

Browse files
authored
Merge pull request #47 from wmde/vHtmlAndBind
Don’t clone node in `handleRawHtml()`
2 parents 4d3000d + 4ccc086 commit 5b6318a

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/Component.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -319,11 +319,7 @@ private function handleRawHtml( DOMNode $node, array $data ) {
319319
$variableName = $node->getAttribute( 'v-html' );
320320
$node->removeAttribute( 'v-html' );
321321

322-
$newNode = $node->cloneNode( true );
323-
324-
$this->appendHTML( $newNode, $data[$variableName] );
325-
326-
$node->parentNode->replaceChild( $newNode, $node );
322+
$this->appendHTML( $node, $data[$variableName] );
327323
}
328324
}
329325

tests/php/TemplatingTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,15 @@ public function testTemplateWithVhtmlVariable_ReplacesVariableWithGivenValue() {
102102
$this->assertSame( '<div><div><p>some value</p></div></div>', $result );
103103
}
104104

105+
public function testTemplateWithVhtmlVariableAndAttributeBinding_ReplacesBoth(): void {
106+
$result = $this->createAndRender(
107+
'<div><div :data-a="a" v-html="html"></div></div>',
108+
[ 'a' => 'A', 'html' => '<p>HTML</p>' ]
109+
);
110+
111+
$this->assertSame( '<div><div data-a="A"><p>HTML</p></div></div>', $result );
112+
}
113+
105114
public function testTemplateWithVhtmlAndDiacritcsInValue_ReplacesVariableWithEncodedValue() {
106115
$result = $this->createAndRender(
107116
'<div><div v-html="value"></div></div>',

0 commit comments

Comments
 (0)