-// Copyright (c) 2008-2013 Kris Maglione <maglione.k at Gmail>
+// Copyright (c) 2008-2014 Kris Maglione <maglione.k at Gmail>
//
// This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file.
},
cleanup: function cleanup() {
- for (let sheet in values(this.sheets))
- sheet.enabled = false;
+ for (let sheet of this.sheets)
+ util.trapErrors(() => {
+ sheet.enabled = false;
+ });
},
__iterator__: function () Iterator(this.sheets),
*/
add: function add(name, filter, css, agent, lazy) {
- if (!isArray(filter))
+ if (isArray(filter))
+ // Need an array from the same compartment.
+ filter = Array.slice(filter);
+ else
filter = filter.split(",");
+
if (name && name in this.names) {
var sheet = this.names[name];
sheet.agent = agent;
name = null;
}
- if (filter && filter.indexOf(",") > -1)
+ if (filter && filter.contains(","))
return filter.split(",").reduce(
(n, f) => n + this.removeSheet(name, f, index), 0);
update(services["dactyl:"].providers, {
"style": function styleProvider(uri, path) {
let id = parseInt(path);
- if (Set.has(styles.allSheets, id))
+ if (hasOwnProperty(styles.allSheets, id))
return ["text/css", styles.allSheets[id].fullCSS];
return null;
}
},
cleanup: function cleanup() {
- for each (let hive in this.hives)
+ for (let hive of this.hives || [])
util.trapErrors("cleanup", hive);
this.hives = [];
this.user = this.addHive("user", this, true);
},
addHive: function addHive(name, ref, persist) {
- let hive = array.nth(this.hives, h => h.name === name,
- 0);
+ let hive = this.hives.find(h => h.name === name);
if (!hive) {
hive = Hive(name, persist);
this.hives.push(hive);
}, {
append: function (dest, src, sort) {
let props = {};
- for each (let str in [dest, src])
+ for (let str of [dest, src])
for (let prop in Styles.propertyIter(str))
props[prop.name] = prop.value;
return val;
},
- completeSite: function (context, content, group = styles.user) {
+ completeSite: function (context, content, group=styles.user) {
context.anchored = false;
try {
context.fork("current", 0, this, function (context) {
let uris = util.visibleURIs(window.content);
context.compare = modules.CompletionContext.Sort.number;
context.generate = () => args["-group"].sheets;
- context.keys.active = sheet => uris.some(sheet.closure.match);
+ context.keys.active = sheet => uris.some(sheet.bound.match);
context.keys.description = sheet => [sheet.formatSites(uris), ": ", sheet.css.replace("\n", "\\n")];
if (filter)
context.filters.push(({ item }) => filter(item));