Bug 1245751 - Part 12: Retrieve href from both None & XLink namespace in Browser & Android.
MozReview-Commit-ID: dSyuTRh5MY
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -5393,17 +5393,19 @@ function hrefAndLinkNodeForClickEvent(ev
// If there is no linkNode, try simple XLink.
let href, baseURI;
node = event.target;
while (node && !href) {
if (node.nodeType == Node.ELEMENT_NODE &&
(node.localName == "a" ||
node.namespaceURI == "http://www.w3.org/1998/Math/MathML")) {
- href = node.getAttributeNS("http://www.w3.org/1999/xlink", "href");
+ href = node.getAttribute("href") ||
+ node.getAttributeNS("http://www.w3.org/1999/xlink", "href");
+
if (href) {
baseURI = node.baseURI;
break;
}
}
node = node.parentNode;
}
--- a/browser/base/content/content.js
+++ b/browser/base/content/content.js
@@ -588,17 +588,18 @@ var ClickEventHandler = {
// If there is no linkNode, try simple XLink.
let href, baseURI;
node = event.target;
while (node && !href) {
if (node.nodeType == content.Node.ELEMENT_NODE &&
(node.localName == "a" ||
node.namespaceURI == "http://www.w3.org/1998/Math/MathML")) {
- href = node.getAttributeNS("http://www.w3.org/1999/xlink", "href");
+ href = node.getAttribute("href") ||
+ node.getAttributeNS("http://www.w3.org/1999/xlink", "href");
if (href) {
baseURI = node.ownerDocument.baseURIObject;
break;
}
}
node = node.parentNode;
}
--- a/browser/base/content/nsContextMenu.js
+++ b/browser/base/content/nsContextMenu.js
@@ -1561,18 +1561,18 @@ nsContextMenu.prototype = {
},
// Generate fully qualified URL for clicked-on link.
getLinkURL: function() {
var href = this.link.href;
if (href)
return href;
- href = this.link.getAttributeNS("http://www.w3.org/1999/xlink",
- "href");
+ href = this.link.getAttribute("href") ||
+ this.link.getAttributeNS("http://www.w3.org/1999/xlink", "href");
if (!href || !href.match(/\S/)) {
// Without this we try to save as the current doc,
// for example, HTML case also throws if empty
throw "Empty href";
}
return makeURLAbsolute(this.link.baseURI, href);
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -2993,17 +2993,18 @@ var NativeWindow = {
};
},
_getLinkURL: function ch_getLinkURL(aLink) {
let href = aLink.href;
if (href)
return href;
- href = aLink.getAttributeNS(kXLinkNamespace, "href");
+ href = aLink.getAttribute("href") ||
+ aLink.getAttributeNS(kXLinkNamespace, "href");
if (!href || !href.match(/\S/)) {
// Without this we try to save as the current doc,
// for example, HTML case also throws if empty
throw "Empty href";
}
return this.makeURLAbsolute(aLink.baseURI, href);
},