ContextUtils: Prevented setSelection() fail (Error: prefix not bound to a namespace) happens when focusedElement is xul:textbox and options.text isn't provided. Filled in a missing line that should have been there on 79c4becfe1a1.

This commit is contained in:
satyr 2010-05-18 05:35:07 +09:00
Родитель 1dbe81f78c
Коммит a7602cc058
1 изменённых файлов: 5 добавлений и 6 удалений

Просмотреть файл

@ -110,12 +110,10 @@ function setSelection(context, content, options) {
}
if (Utils.isTextBox(focusedElement)) {
let plainText = options && options.text;
if (!plainText) {
let rng = focusedElement.ownerDocument.createRange();
rng.selectNode(focusedElement);
plainText = rng.createContextualFragment(content).textContent;
}
let plainText = String(
options && options.text ||
(focusedElement.ownerDocument.createRange()
.createContextualFragment("<_>" + content + "</_>").textContent));
focusedElement.QueryInterface(Ci.nsIDOMNSEditableElement)
.editor.QueryInterface(Ci.nsIPlaintextEditor).insertText(plainText);
focusedElement.selectionStart -= plainText.length;
@ -176,6 +174,7 @@ function getSelectedNodes(context, selector) {
}
} while (node.nodeType === TEXT || range.isPointInRange(node, 0));
}
var flm = context.focusedElement;
if (flm) (function run(rs, ns) {
for (var n, i = -1; n = ns[++i];) {
~rs.indexOf(n) || rs.push(n);