mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-03-16 18:53:31 +01:00
Make 'doc' available to group initializer.
This commit is contained in:
@@ -119,9 +119,12 @@ var Map = Class("Map", {
|
|||||||
.map(function ([i, prop]) [prop, this[i]], arguments)
|
.map(function ([i, prop]) [prop, this[i]], arguments)
|
||||||
.toObject();
|
.toObject();
|
||||||
|
|
||||||
args = update({ context: contexts.context },
|
let orig = args;
|
||||||
this.hive.argsExtra(args),
|
args = update({
|
||||||
args);
|
context: contexts.context,
|
||||||
|
doc: this.hive.group.lastDocument
|
||||||
|
}, args);
|
||||||
|
update(args, this.hive.argsExtra(args), orig);
|
||||||
|
|
||||||
let self = this;
|
let self = this;
|
||||||
function repeat() self.action(args)
|
function repeat() self.action(args)
|
||||||
|
|||||||
@@ -611,12 +611,13 @@ function call(fn) {
|
|||||||
*/
|
*/
|
||||||
function memoize(obj, key, getter) {
|
function memoize(obj, key, getter) {
|
||||||
if (arguments.length == 1) {
|
if (arguments.length == 1) {
|
||||||
|
let res = Object.create(obj);
|
||||||
for each (let prop in Object.getOwnPropertyNames(obj)) {
|
for each (let prop in Object.getOwnPropertyNames(obj)) {
|
||||||
let get = __lookupGetter__.call(obj, prop);
|
let get = __lookupGetter__.call(obj, prop);
|
||||||
if (get)
|
if (get)
|
||||||
memoize(obj, prop, get);
|
memoize(res, prop, get);
|
||||||
}
|
}
|
||||||
return obj;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -25,6 +25,9 @@ var Group = Class("Group", {
|
|||||||
this.hives = [];
|
this.hives = [];
|
||||||
},
|
},
|
||||||
|
|
||||||
|
set lastDocument(val) { this._lastDocument = val && Cu.getWeakReference(val); },
|
||||||
|
get lastDocument() this._lastDocument && this._lastDocument.get(),
|
||||||
|
|
||||||
modifiable: true,
|
modifiable: true,
|
||||||
|
|
||||||
cleanup: function cleanup() {
|
cleanup: function cleanup() {
|
||||||
@@ -271,7 +274,7 @@ var Contexts = Module("contexts", {
|
|||||||
return frame;
|
return frame;
|
||||||
},
|
},
|
||||||
|
|
||||||
groups: Class.memoize(function () this.matchingGroups(this.modules.buffer.uri)),
|
groups: Class.memoize(function () this.matchingGroups()),
|
||||||
|
|
||||||
allGroups: Class.memoize(function () Object.create(this.groupsProto, {
|
allGroups: Class.memoize(function () Object.create(this.groupsProto, {
|
||||||
groups: { value: this.initializedGroups() }
|
groups: { value: this.initializedGroups() }
|
||||||
@@ -283,8 +286,14 @@ var Contexts = Module("contexts", {
|
|||||||
|
|
||||||
activeGroups: function (uri, doc) {
|
activeGroups: function (uri, doc) {
|
||||||
if (!uri)
|
if (!uri)
|
||||||
({ uri, doc }) = this.modules.buffer;
|
var { uri, doc } = this.modules.buffer;
|
||||||
return this.initializedGroups().filter(function (g) uri && g.filter(uri, doc));
|
|
||||||
|
return this.initializedGroups().filter(function (g) {
|
||||||
|
let res = uri && g.filter(uri, doc);
|
||||||
|
if (doc)
|
||||||
|
g.lastDocument = res && doc;
|
||||||
|
return res;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
flush: function flush() {
|
flush: function flush() {
|
||||||
|
|||||||
Reference in New Issue
Block a user