shadow-component
Advanced tools
Comparing version 0.1.7 to 0.1.8
@@ -28,19 +28,29 @@ import Builder from './builder' | ||
return { | ||
render () { | ||
let result = view.bind(this)() | ||
if (typeof result === 'function') { | ||
result.bind(this)() | ||
render: function render(reRender) { | ||
if (!reRender) { | ||
renderElement(view, this) | ||
} else { | ||
patch(this, function(scope) { | ||
renderElement(view, scope) | ||
}, this) | ||
} | ||
} | ||
}; | ||
} | ||
function renderElement (view, scope) { | ||
var result = view.bind(scope)(); | ||
if (typeof result === 'function') { | ||
result.bind(scope)(); | ||
} | ||
} | ||
function setStateFactory () { | ||
function setStateFactory() { | ||
return { | ||
setState (newState) { | ||
this.state = Object.assign({}, this.state, newState) | ||
this.render() | ||
return this.state | ||
setState: function setState(newState, force = false) { | ||
this.state = Object.assign({}, this.state, newState); | ||
this.render(force); | ||
return this.state; | ||
} | ||
} | ||
}; | ||
} | ||
@@ -47,0 +57,0 @@ |
{ | ||
"name": "shadow-component", | ||
"version": "0.1.7", | ||
"version": "0.1.8", | ||
"description": "This is a test implementation of components with shadow dom and full template rendering of changes of state", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -42,6 +42,9 @@ 'use strict'; | ||
return { | ||
render: function render() { | ||
var result = view.bind(this)(); | ||
if (typeof result === 'function') { | ||
result.bind(this)(); | ||
render: function render(reRender) { | ||
if (!reRender) { | ||
renderElement(view, this); | ||
} else { | ||
(0, _incrementalDom.patch)(this, function (scope) { | ||
renderElement(view, scope); | ||
}, this); | ||
} | ||
@@ -52,7 +55,16 @@ } | ||
function renderElement(view, scope) { | ||
var result = view.bind(scope)(); | ||
if (typeof result === 'function') { | ||
result.bind(scope)(); | ||
} | ||
} | ||
function setStateFactory() { | ||
return { | ||
setState: function setState(newState) { | ||
var force = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1]; | ||
this.state = Object.assign({}, this.state, newState); | ||
this.render(); | ||
this.render(force); | ||
return this.state; | ||
@@ -59,0 +71,0 @@ } |
89745
819