Comparing version 2.0.2 to 2.0.3
@@ -12,4 +12,4 @@ import { OptionalObject, NodeInterface } from './interfaces/index'; | ||
convertObjectToCss(style: OptionalObject): string; | ||
parser(node: NodeInterface, data: OptionalObject): string; | ||
parseChildren(child: NodeInterface, data: OptionalObject): string; | ||
parser(node: NodeInterface, data: OptionalObject): any; | ||
parseChildren(child: NodeInterface, data: OptionalObject): any; | ||
parseAttributes(props: OptionalObject): { | ||
@@ -16,0 +16,0 @@ attributes: OptionalObject; |
@@ -80,3 +80,3 @@ "use strict"; | ||
} | ||
else if (typeof node === "object" && node.type) { | ||
else if (typeof node === "object" && typeof node.type === "string") { | ||
let type = node.type; | ||
@@ -88,3 +88,4 @@ let props = node.props; | ||
let parsedChildren = children.map((child) => { | ||
let parsedChild = this.parseChildren(child, data); | ||
// console.log(child); | ||
let parsedChild = this.parseChildren(child, Object.assign(Object.assign(Object.assign({}, data), props), { children })); | ||
if (parsedChild) { | ||
@@ -107,2 +108,7 @@ if (typeof parsedChild === "string") { | ||
} | ||
else if (typeof node === "object" && typeof node.type === "function") { | ||
let component = node.type(Object.assign(Object.assign({}, node.props), { children: node.children })); | ||
let result = this.parser(component, node.props); | ||
return result; | ||
} | ||
} | ||
@@ -113,5 +119,5 @@ parseChildren(child, data) { | ||
} | ||
else if (child.type && typeof child.type === "function") { | ||
else if (child && child.type && typeof child.type === "function") { | ||
let component = child.type; | ||
let node = component(child.props); | ||
let node = component(Object.assign(Object.assign({}, child.props), { children: child.children || [] })); | ||
return this.parser(node, child.props); | ||
@@ -118,0 +124,0 @@ } |
{ | ||
"name": "grandjs", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"description": "A backend framework for solid web apps based on node.js", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -74,3 +74,3 @@ /** | ||
} | ||
parser(node:NodeInterface, data:OptionalObject) { | ||
parser(node:NodeInterface, data:OptionalObject):any { | ||
let str = ""; | ||
@@ -83,3 +83,3 @@ if(Array.isArray(node)) { | ||
return str; | ||
} else if (typeof node === "object" && node.type) { | ||
} else if (typeof node === "object" && typeof node.type === "string") { | ||
let type = node.type; | ||
@@ -91,3 +91,4 @@ let props = node.props; | ||
let parsedChildren = children.map((child) => { | ||
let parsedChild = this.parseChildren(child, data) | ||
// console.log(child); | ||
let parsedChild = this.parseChildren(child, {...data, ...props, children}) | ||
if(parsedChild) { | ||
@@ -107,2 +108,6 @@ if(typeof parsedChild === "string") { | ||
return str; | ||
} else if(typeof node === "object" && typeof node.type === "function") { | ||
let component = node.type({...node.props, children: node.children}); | ||
let result = this.parser(component, node.props); | ||
return result; | ||
} | ||
@@ -113,5 +118,5 @@ } | ||
return child; | ||
} else if(child.type && typeof child.type === "function") { | ||
} else if(child && child.type && typeof child.type === "function") { | ||
let component = child.type; | ||
let node = component(child.props); | ||
let node = component({...child.props, children: child.children || []}); | ||
return this.parser(node, child.props); | ||
@@ -118,0 +123,0 @@ } else { |
Sorry, the diff of this file is not supported yet
203383
4191