From a7cda7ca4d26dc5a0f6e1351bf909db37f05d259 Mon Sep 17 00:00:00 2001 From: "heikki%netscape.com" Date: Thu, 20 Dec 2001 02:08:50 +0000 Subject: [PATCH] Bug 92172, bookmarking image map links should get something for name. r=timeless@mac.com, sr=blakeross@telocity.com. git-svn-id: svn://10.0.0.236/trunk@110839 18797224-902f-48f8-a5cc-f745e15eee43 --- .../resources/content/nsContextMenu.js | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/mozilla/xpfe/communicator/resources/content/nsContextMenu.js b/mozilla/xpfe/communicator/resources/content/nsContextMenu.js index 1716ae10915..f67067b5b79 100644 --- a/mozilla/xpfe/communicator/resources/content/nsContextMenu.js +++ b/mozilla/xpfe/communicator/resources/content/nsContextMenu.js @@ -570,15 +570,32 @@ nsContextMenu.prototype = { return this.link.href; } var href = this.link.getAttributeNS("http://www.w3.org/1999/xlink","href"); - if (href == "") { + if (!href || !href.match(/\S/)) { throw "Empty href"; // Without this we try to save as the current doc, for example, HTML case also throws if empty } href = this.makeURLAbsolute(this.link.baseURI,href); return href; }, - // Get text of link (if possible). + // Get text of link. linkText : function () { var text = gatherTextUnder( this.link ); + if (!text || !text.match(/\S/)) { + text = this.link.getAttribute("title"); + if (!text || !text.match(/\S/)) { + text = this.link.getAttribute("alt"); + if (!text || !text.match(/\S/)) { + if (this.link.href) { + text = this.link.href; + } else { + text = getAttributeNS("http://www.w3.org/1999/xlink", "href"); + if (text && text.match(/\S/)) { + text = this.makeURLAbsolute(this.link.baseURI, text); + } + } + } + } + } + return text; }, // Returns "true" if there's no text selected, null otherwise.