Post-insertion configureNode()

This commit is contained in:
Tony Garnock-Jones 2016-05-15 14:58:28 -04:00
parent 152a76af5e
commit 61ca89ce04
1 changed files with 12 additions and 0 deletions

View File

@ -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);
});
});