Skip to content

Commit 295c338

Browse files
committed
Update babel and add render in placeholder
1 parent ed92300 commit 295c338

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

package.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hypernova-vue",
3-
"version": "2.0.0",
3+
"version": "2.1.0",
44
"description": "Vue bindings for Hypernova",
55
"main": "lib/index.js",
66
"author": "Felipe Guizar Diaz <[email protected]>",
@@ -21,14 +21,17 @@
2121
"url": "[email protected]:marconi1992/hypernova-vue.git"
2222
},
2323
"devDependencies": {
24-
"babel-cli": "^6.26.0",
25-
"babel-preset-airbnb": "^2.5.3",
24+
"@babel/cli": "^7.5.5",
25+
"@babel/core": "^7.5.5",
26+
"@babel/runtime": "^7.5.5",
27+
"babel-preset-airbnb": "^4.0.1",
2628
"eslint": "^5.14.1",
2729
"eslint-config-airbnb-base": "^13.1.0",
2830
"eslint-plugin-import": "^2.16.0"
2931
},
30-
"peerDependencies": {
32+
"dependencies": {
3133
"hypernova": "^2.5.0",
34+
"nova-helpers": "^1.0.1-alpha.0",
3235
"vue": "^2.6.6",
3336
"vue-server-renderer": "^2.6.6"
3437
}

src/index.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,33 @@
11
import vue from 'vue';
22
import { createRenderer } from 'vue-server-renderer';
33
import hypernova, { serialize, load } from 'hypernova';
4+
import { findNode, getData } from 'nova-helpers';
5+
6+
const { document } = global;
7+
8+
const mountComponent = (Component, node, data) => {
9+
const vm = new Component({
10+
propsData: data,
11+
});
12+
13+
if (!node.firstChild) {
14+
node.appendChild(document.createElement('div'));
15+
}
16+
17+
vm.$mount(node.children[0]);
18+
};
419

520
export const Vue = vue;
621

22+
export const renderInPlaceholder = (name, Component, id) => {
23+
const node = findNode(name, id);
24+
const data = getData(name, id);
25+
26+
if (node && data) {
27+
mountComponent(Component, node, data);
28+
}
29+
};
30+
731
export const renderVue = (name, Component) => hypernova({
832
server() {
933
return async (propsData) => {

0 commit comments

Comments
 (0)