1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-03-01 13:35:47 +01:00

Deprecate liberator alias.

This commit is contained in:
Kris Maglione
2010-11-12 21:36:10 -05:00
parent fd2f40837d
commit 6425fbd2dd

View File

@@ -23,12 +23,12 @@ function deprecated(reason, fn) {
let name, func = callable(fn) ? fn : function () this[fn].apply(this, arguments); let name, func = callable(fn) ? fn : function () this[fn].apply(this, arguments);
function deprecatedMethod() { function deprecatedMethod() {
let frame = Components.stack.caller; let frame = Components.stack.caller;
let obj = this.className || this.constructor.className;
if (!set.add(deprecatedMethod.seen, frame.filename)) if (!set.add(deprecatedMethod.seen, frame.filename))
dactyl.echoerr( dactyl.echoerr(
frame.filename.replace(/^.*? -> /, "") + (frame.filename || "unknown").replace(/^.*? -> /, "") +
":" + frame.lineNumber + ": " + ":" + frame.lineNumber + ": " +
(this.className || this.constructor.className) + "." + (obj ? obj + "." : "") + (fn.name || name) + " is deprecated: " + reason);
(fn.name || name) + " is deprecated: " + reason);
return func.apply(this, arguments); return func.apply(this, arguments);
} }
deprecatedMethod.seen = { "chrome://dactyl/content/javascript.js": true }; deprecatedMethod.seen = { "chrome://dactyl/content/javascript.js": true };
@@ -42,8 +42,9 @@ const Dactyl = Module("dactyl", {
init: function () { init: function () {
window.dactyl = this; window.dactyl = this;
// cheap attempt at compatibility // cheap attempt at compatibility
window.liberator = this; let prop = { get: deprecated("Please use dactyl instead", function liberator() dactyl) };
modules.liberator = this; Object.defineProperty(window, "liberator", prop);
Object.defineProperty(modules, "liberator", prop);
this.commands = {}; this.commands = {};
this.modules = modules; this.modules = modules;
this.observers = {}; this.observers = {};