Skip to content

Commit cdea299

Browse files
committed
not to use global.ssr
1 parent 0d1c96e commit cdea299

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Diff for: viewEngine.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ function toProps(props) {
1212
}
1313

1414
function toHTML(vdom) {
15+
if (!vdom) return '';
1516
if (Array.isArray(vdom)) return toHTMLArray(vdom)
1617
if (vdom.tag) {
1718
const props = vdom.props ? toProps(vdom.props) : '';
@@ -38,15 +39,16 @@ function clean(obj) {
3839
}
3940
}
4041
}
42+
4143
function engine(name, options, callback) {
4244
const fn = require(name).default;
4345
const rendered = fn(options);
4446
clean(rendered);
45-
return global.ssr ?
47+
return options.ssr ?
4648
callback(null, toHTML(rendered)) :
4749
callback(null, rendered);
4850
}
4951

50-
module.exports = function(mode) {
51-
return mode === 'html' ? toHTML: engine
52+
module.exports = function (mode) {
53+
return mode === 'html' ? toHTML : engine
5254
}

0 commit comments

Comments
 (0)