From e93a17e13f31d770c9e8b3f5aa3e70d2cd4ba86a Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Wed, 10 Dec 2008 01:10:12 +1100 Subject: [PATCH] fix completion.alternateStylesheet --- common/content/completion.js | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/common/content/completion.js b/common/content/completion.js index dcc3de32..f79a42d8 100644 --- a/common/content/completion.js +++ b/common/content/completion.js @@ -1583,22 +1583,18 @@ function Completion() //{{{ alternateStylesheet: function alternateStylesheet(context) { context.title = ["Stylesheet", "Location"]; - context.keys = { text: "title", description: function (item) item.href }; // unify split style sheets - let completions = buffer.alternateStyleSheets; - completions.forEach(function (stylesheet) { - stylesheet.href = stylesheet.href || "inline"; - completions = completions.filter(function (sheet) { - if (stylesheet.title == sheet.title && stylesheet != sheet) - { - stylesheet.href += ", " + sheet.href; - return false; - } - return true; - }); + let styles = {}; + + buffer.alternateStyleSheets.forEach(function (style) { + if (style.title in styles) + styles[style.title].push(style.href); + else + styles[style.title] = [style.href]; }); - context.completions = completions; + + context.completions = [[s, styles[s].join(", ")] for (s in styles)]; }, // filter a list of urls