diff --git a/common/content/browser.js b/common/content/browser.js index f854bcaa..d12b46b5 100644 --- a/common/content/browser.js +++ b/common/content/browser.js @@ -94,7 +94,7 @@ const Browser = Module("browser", { mappings.add([modes.NORMAL], ["~"], "Open home directory", - function () { dactyl.open("~/"); }); + function () { dactyl.open("~"); }); mappings.add([modes.NORMAL], ["gh"], "Open homepage", @@ -170,7 +170,7 @@ const Browser = Module("browser", { dactyl.open("about:blank"); }, { completer: function (context) completion.url(context), - domains: function (args) array.compact(dactyl.stringToURLArray(args[0] || "").map( + domains: function (args) array.compact(dactyl.parseURLs(args[0] || "").map( function (url) util.getHost(url))), literal: 0, privateData: true diff --git a/common/content/dactyl.js b/common/content/dactyl.js index 75d532e8..ae0a55b6 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -25,19 +25,24 @@ const FailedAssertion = Class("FailedAssertion", Error, { } }); -function deprecated(reason, fn, name) - let (func = (callable(fn) ? fn : function () this[fn].apply(this, arguments))) - update(function deprecatedMethod() { - let frame = Components.stack.caller; - if (!set.add(deprecatedMethod.seen, frame.filename)) - dactyl.echoerr( - frame.filename.replace(/^.*? -> /, "") + - ":" + frame.lineNumber + ": " + - (this.className || this.constructor.className) + "." + - (fn.name || name) + " is deprecated: " + reason); - return func.apply(this, arguments); - }, - { seen: { "chrome://dactyl/content/javascript.js": true } }); +function deprecated(reason, fn) { + let name, func = callable(fn) ? fn : function () this[fn].apply(this, arguments); + function deprecatedMethod() { + let frame = Components.stack.caller; + if (!set.add(deprecatedMethod.seen, frame.filename)) + dactyl.echoerr( + frame.filename.replace(/^.*? -> /, "") + + ":" + frame.lineNumber + ": " + + (this.className || this.constructor.className) + "." + + (fn.name || name) + " is deprecated: " + reason); + return func.apply(this, arguments); + } + deprecatedMethod.seen = { "chrome://dactyl/content/javascript.js": true }; + return callable(fn) ? deprecatedMethod : Class.Property({ + get: function () deprecatedMethod, + init: function (prop) { name = prop } + }); +} const Dactyl = Module("dactyl", { init: function () { @@ -746,7 +751,7 @@ const Dactyl = Module("dactyl", { * * @param {string|Array} urls A representation of the URLs to open. May be * either a string, which will be passed to - * {@see Dactyl#stringToURLArray}, or an array in the same format as + * {@see Dactyl#parseURLs}, or an array in the same format as * would be returned by the same. * @param {object} params A set of parameters specifying how to open the * URLs. The following properties are recognized: @@ -770,7 +775,7 @@ const Dactyl = Module("dactyl", { */ open: function (urls, params, force) { if (typeof urls == "string") - urls = dactyl.stringToURLArray(urls); + urls = dactyl.parseURLs(urls); if (urls.length > 20 && !force) return commandline.input("This will open " + urls.length + " new tabs. Would you like to continue? (yes/[no]) ", @@ -884,7 +889,8 @@ const Dactyl = Module("dactyl", { * @param {string} str * @returns {string[]} */ - stringToURLArray: function stringToURLArray(str) { + stringToURLArray: deprecated("Please use dactyl.parseURLs instead", "parseURLs"), + parseURLs: function parseURLs(str) { let urls; if (options["urlseparator"]) diff --git a/common/content/options.js b/common/content/options.js index 2bcbe4de..439b62ce 100644 --- a/common/content/options.js +++ b/common/content/options.js @@ -155,10 +155,10 @@ const Option = Class("Option", { dactyl.triggerObserver("options." + this.name, newValues); }, - getValues: deprecated("Please use Option#get instead", "get", "getValues"), - setValues: deprecated("Please use Option#set instead", "set", "setValues"), - joinValues: deprecated("Please use Option#stringify instead", "stringify", "joinValues"), - parseValues: deprecated("Please use Option#parse instead", "parse", "parseValues"), + getValues: deprecated("Please use Option#get instead", "get"), + setValues: deprecated("Please use Option#set instead", "set"), + joinValues: deprecated("Please use Option#stringify instead", "stringify"), + parseValues: deprecated("Please use Option#parse instead", "parse"), values: Class.Property({ get: deprecated("Please use Option#value instead", function values() this.value), set: deprecated("Please use Option#value instead", function values(val) this.value = val) diff --git a/common/content/quickmarks.js b/common/content/quickmarks.js index c2dfd3d9..e52c2afb 100644 --- a/common/content/quickmarks.js +++ b/common/content/quickmarks.js @@ -41,7 +41,7 @@ const QuickMarks = Module("quickmarks", { find: function find(url) { let res = []; for (let [k, v] in this._qmarks) - if (dactyl.stringToURLArray(v).some(function (u) String.replace(u, /#.*/, "") == url)) + if (dactyl.parseURLs(v).some(function (u) String.replace(u, /#.*/, "") == url)) res.push(k); return res; },