Home Reference Source

Function

Static Public Summary
public

el(element: Object | Component | string | function, attrs: Object, children: Array): Object

JSX factory function to create an object representing a dom node.

public

predicate(cond: boolean | function(): boolean, element: *, elseElement: *): *

Can be used as a simple if/else statement info your jsx :

 SimpleDom.renderTo('container',
     <div>
         SimpleDom.predicate(myCondition,
             <h1>myCondition is true</h1>,
             <h1>myCondition is false</h1>
         )
     </div>
 );
public

renderTo(node: string | Node, elements: Array)

Render some elements into a node.

public

renderToDom(node: string | Node, component: Component, store: Store)

Render a component to the dom.

public

Render some elements into a string.

Static Public

public el(element: Object | Component | string | function, attrs: Object, children: Array): Object source

import {el} from 'simpledom-component'

JSX factory function to create an object representing a dom node. Designed to be used with a JSX transpiler.

Params:

NameTypeAttributeDescription
element Object | Component | string | function

the name of the tag, or a Component.

attrs Object

properties of the node, a plain old JS object. Not optional, if no value, put empty object.

children Array

the children of the node, a vararg

Return:

Object

an object representing a dom node.

public predicate(cond: boolean | function(): boolean, element: *, elseElement: *): * source

import {predicate} from 'simpledom-component'

Can be used as a simple if/else statement info your jsx :

 SimpleDom.renderTo('container',
     <div>
         SimpleDom.predicate(myCondition,
             <h1>myCondition is true</h1>,
             <h1>myCondition is false</h1>
         )
     </div>
 );

Params:

NameTypeAttributeDescription
cond boolean | function(): boolean

condition to evaluate

element *

element to return if cond is true (if it's a function, the result of the function is returned).

elseElement *

element to return if cond is false (if it's a function, the result of the function is returned).

Return:

*

element or elseElement depending of cond value.

public renderTo(node: string | Node, elements: Array) source

import {renderTo} from 'simpledom-component'

Render some elements into a node.

Params:

NameTypeAttributeDescription
node string | Node

the id or the node where the component must be rendered.

elements Array

elements returned by el or primitive like string.

public renderToDom(node: string | Node, component: Component, store: Store) source

import {renderToDom} from 'simpledom-component'

Render a component to the dom.

Params:

NameTypeAttributeDescription
node string | Node

the id or the node where the component must be rendered.

component Component

the component to render.

store Store

the store

public renderToString(elements: Array): string source

import {renderToString} from 'simpledom-component'

Render some elements into a string.

Params:

NameTypeAttributeDescription
elements Array

elements returned by el or primitive like string.

Return:

string

html as a string.