Skip to content

Commit 7bc7630

Browse files
committed
Support embedding html using html attribute. Workaround for failed v-html directive.
1 parent 39e0bb4 commit 7bc7630

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/component.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ export default {
2222
name: {
2323
type: String,
2424
default: () => Math.floor(Date.now() * Math.random()).toString(16)
25+
},
26+
html: {
27+
type: String,
28+
default: null
2529
}
2630
},
2731

@@ -55,6 +59,16 @@ export default {
5559

5660
tpl.appendChild(tail)
5761

62+
// embed html
63+
if (this.html) {
64+
let template = document.createElement('template')
65+
template.innerHTML = this.html
66+
// copy elements over
67+
Array.from(template.content.childNodes).forEach(node => {
68+
tpl.appendChild(node)
69+
})
70+
}
71+
5872
let next = container.nextSibling
5973
parent.insertBefore(tpl, container, true)
6074
parent.removeChild(container)

0 commit comments

Comments
 (0)