Skip to content

Commit c3a5483

Browse files
authored
Merge pull request #4 from ara-framework/fix/mount-ignoring-comments
fix: mount ignoring comments
2 parents b37c143 + e77805a commit c3a5483

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hypernova-vue",
3-
"version": "3.0.0-alpha.0",
3+
"version": "3.0.2",
44
"description": "Vue bindings for Hypernova",
55
"main": "lib/index.js",
66
"types": "lib/index.d.ts",

src/__test__/index.spec.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,23 @@ describe('mountComponent', () => {
5656

5757
expect(node.innerHTML).toEqual('<h1>Ara Framework</h1>');
5858
});
59+
60+
test('should mount component correctly ignoring html comments', () => {
61+
document.body.innerHTML = '<div id="app"><!-- Comment --><div>';
62+
63+
const app = Vue.extend({
64+
props: ['title'],
65+
render(h): VNode {
66+
return h('h1', {}, this.title);
67+
},
68+
});
69+
70+
const node = document.getElementById('app');
71+
72+
mountComponent(app, node, { title: 'Ara Framework' });
73+
74+
expect(node.innerHTML).toEqual('<!-- Comment --><h1>Ara Framework</h1>');
75+
});
5976
});
6077

6178
describe('renderInPlaceholder', () => {

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const mountComponent = (
2626
propsData: data,
2727
});
2828

29-
if (!node.firstChild) {
29+
if (!node.childElementCount) {
3030
node.appendChild(document.createElement('div'));
3131
}
3232

0 commit comments

Comments
 (0)