windex

jQuery-like that's safe to use in a Firefox Extension
git clone https://wehaveforgeathome.hates.computer/windex.git
Log | Files | Refs | LICENSE

commit 0c46c249c9591b714a1b5fce7ef873abe27aa466
parent 64e66002ffdd28ff71c44a4c1ed882ce07e6eed0
Author: Ryan Wolf <rwolf@borderstylo.com>
Date:   Wed, 15 Dec 2010 11:02:13 -0800

added toArray, put the defaultContext where is belongs

Diffstat:
Mwindex.js | 8+++-----
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/windex.js b/windex.js @@ -18,10 +18,6 @@ var Windex = exports = function(selector, context) { throw new Error("$(" + selector + ", " + context + "): selector is not a Node or a String"); } - if (!Windex.defaultContext) { - throw new Error('You must define Windex.defaultContext() before calling Windex without a context.'); - } - // TODO: return documents, windows if (selector == "body") return Windex(defaultContext()); if (selector == "!document") { @@ -49,7 +45,7 @@ var Windex = exports = function(selector, context) { return new WindexNodes([context], selector, context).find(selector); }; -Windex.defaultContext = null; +Windex.prototype.defaultContext = null; // See: http://api.jquery.com/jQuery.extend/ Windex.extend = function () { @@ -124,6 +120,8 @@ WindexNodes.prototype.find = function (selector) { return new WindexNodes(nodes, selector, context); }; +WindexNodes.prototype.toArray = function () { return [].concat(this); } + WindexNodes.prototype.each = function (f) { return Windex.each(this, f); }; WindexNodes.prototype.filter = function (f) {