From 61ca89ce04a9e8958755b69917b7e1e1f8e440a5 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Sun, 15 May 2016 14:58:28 -0400 Subject: [PATCH] Post-insertion configureNode() --- js/src/ui.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/js/src/ui.js b/js/src/ui.js index c83a845..dd23029 100644 --- a/js/src/ui.js +++ b/js/src/ui.js @@ -352,6 +352,17 @@ function htmlToNodes(parent, html) { return Array.prototype.slice.call(e.childNodes); } +function configureNode(n) { + // Runs post-insertion configuration of nodes. + // TODO: review this design. + selectorMatch(n, '.-syndicate-focus').forEach(function (n) { + if ('focus' in n && 'setSelectionRange' in n) { + n.focus(); + n.setSelectionRange(n.value.length, n.value.length); + } + }); +} + UIFragment.prototype.updateContent = function (newSelector, newHtml, newOrderBy) { var self = this; @@ -364,6 +375,7 @@ UIFragment.prototype.updateContent = function (newSelector, newHtml, newOrderBy) htmlToNodes(anchorNode, newHtml).forEach(function (newNode) { setSortKey(newNode, newOrderBy, self.fragmentId); anchorNode.insertBefore(newNode, insertionPoint); + configureNode(newNode); }); });