Bug 298892 Use instanceof loop instead of findParentNode r=timeless sr+a=dveditz

This commit is contained in:
neil%parkwaycc.co.uk 2005-07-06 11:14:02 +00:00
Родитель f0a9c8b3fb
Коммит bde71783c0
2 изменённых файлов: 2 добавлений и 25 удалений

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

@ -134,7 +134,8 @@
prefillTextBox(target); // prefill the empty text field if possible prefillTextBox(target); // prefill the empty text field if possible
} }
else { else {
linkNode = findParentNode(event.originalTarget, "a"); while (linkNode && !(linkNode instanceof HTMLAnchorElement))
linkNode = linkNode.parentNode;
// <a> cannot be nested. So if we find an anchor without an // <a> cannot be nested. So if we find an anchor without an
// href, there is no useful <a> around the target // href, there is no useful <a> around the target
if (linkNode && !linkNode.hasAttribute("href")) if (linkNode && !linkNode.hasAttribute("href"))
@ -186,7 +187,6 @@
if (pref && !isKeyPress && event.button == 1 && if (pref && !isKeyPress && event.button == 1 &&
!event.getPreventDefault() && !event.getPreventDefault() &&
!findParentNode(event.originalTarget, "scrollbar") &&
pref.getBoolPref("middlemouse.contentLoadURL")) { pref.getBoolPref("middlemouse.contentLoadURL")) {
if (middleMousePaste(event)) { if (middleMousePaste(event)) {
event.preventBubble(); event.preventBubble();

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

@ -178,29 +178,6 @@ function openNewTabWith(url, sendReferrer, reverseBackgroundPref)
} }
} }
function findParentNode(node, parentNode)
{
if (node && node.nodeType == Node.TEXT_NODE) {
node = node.parentNode;
}
while (node) {
if (node.nodeType == Node.DOCUMENT_NODE) {
return null;
}
var nodeName = node.localName;
if (!nodeName)
return null;
nodeName = nodeName.toLowerCase();
if (nodeName == "body" || nodeName == "html") {
return null;
}
if (nodeName == parentNode)
return node;
node = node.parentNode;
}
return null;
}
// Clientelle: (Make sure you don't break any of these) // Clientelle: (Make sure you don't break any of these)
// - File -> Save Page/Frame As... // - File -> Save Page/Frame As...
// - Context -> Save Page/Frame As... // - Context -> Save Page/Frame As...