From f01ab323fb4381ad56f8599e9340743ac2dc7afc Mon Sep 17 00:00:00 2001 From: davidmarkclements Date: Thu, 24 Dec 2015 01:46:01 +0000 Subject: [PATCH] support "selected" prop --- src/update.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/update.js b/src/update.js index 9f36dd2..16b0553 100644 --- a/src/update.js +++ b/src/update.js @@ -65,11 +65,19 @@ export default function update(node, options) { // TODO: enforce some kind of shallow equality? // TODO: handle position + const selectQue = [] + for (let key in options) { let value = options[key]; + if (key === 'selected' && node.select) + selectQue.push({ + node, + value: (typeof value === 'string' ? +value : value) + }) + // Setting label - if (key === 'label') + else if (key === 'label') node.setLabel(value); // Setting content @@ -112,4 +120,6 @@ export default function update(node, options) { } } } + + selectQue.forEach(({node, value}) => node.select(value)) }