diff options
author | Florian Dold <florian.dold@gmail.com> | 2016-11-08 15:07:07 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2016-11-08 15:19:39 +0100 |
commit | afb9fba64be1f15a3ce3ed31214a704e73e5e8bb (patch) | |
tree | 6f69712a8c976178c05144483ff0c8e9b09445c8 /thirdparty/preact/src/linked-state.js | |
parent | b37e7762bb5492cbd6788863232e7d2634ab5e5c (diff) | |
parent | 6e5fb04d3f3f9a6cd43ac20896d73321dd079f96 (diff) |
Update preact version
Diffstat (limited to 'thirdparty/preact/src/linked-state.js')
-rw-r--r-- | thirdparty/preact/src/linked-state.js | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/thirdparty/preact/src/linked-state.js b/thirdparty/preact/src/linked-state.js index ed72bd8bc..b6959df73 100644 --- a/thirdparty/preact/src/linked-state.js +++ b/thirdparty/preact/src/linked-state.js @@ -8,21 +8,17 @@ import { isString, delve } from './util'; * @private */ export function createLinkedState(component, key, eventPath) { - let path = key.split('.'), - p0 = path[0]; + let path = key.split('.'); return function(e) { - let t = e && e.currentTarget || this, - s = component.state, - obj = s, - v = isString(eventPath) ? delve(e, eventPath) : t.nodeName ? ((t.nodeName+t.type).match(/^input(che|rad)/i) ? t.checked : t.value) : e, - i; - if (path.length>1) { - for (i=0; i<path.length-1; i++) { - obj = obj[path[i]] || (obj[path[i]] = {}); - } - obj[path[i]] = v; - v = s[p0]; + let t = e && e.target || this, + state = {}, + obj = state, + v = isString(eventPath) ? delve(e, eventPath) : t.nodeName ? (t.type.match(/^che|rad/) ? t.checked : t.value) : e, + i = 0; + for ( ; i<path.length-1; i++) { + obj = obj[path[i]] || (obj[path[i]] = !i && component.state[path[i]] || {}); } - component.setState({ [p0]: v }); + obj[path[i]] = v; + component.setState(state); }; } |