Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add zepto binding, refactor others.

  • Loading branch information...
commit 7c800e827ab98fe25fabd0409f15032e797c7ada 1 parent 4b6becf
@chjj authored
View
18 Makefile
@@ -2,8 +2,24 @@ all:
@cp lib/zest.js .
@uglifyjs -o zest.min.js zest.js
+ender:
+ @cat lib/zest.js ext/zest.ender.js > zest.js
+ @uglifyjs -o zest.min.js zest.js
+
+jquery:
+ @cat lib/zest.js ext/zest.jquery.js > zest.js
+ @uglifyjs -o zest.min.js zest.js
+
+prototype:
+ @cat lib/zest.js ext/zest.prototype.js > zest.js
+ @uglifyjs -o zest.min.js zest.js
+
+zepto:
+ @cat lib/zest.js ext/zest.zepto.js > zest.js
+ @uglifyjs -o zest.min.js zest.js
+
clean:
@rm zest.js
@rm zest.min.js
-.PHONY: clean all
+.PHONY: all clean ender jquery prototype zepto
View
25 ext/zest.ender.js
@@ -1,23 +1,28 @@
/**
- * Zest support for ender.js
- * https://github.com/ender-js/Ender
+ * zest.js support for ender.js
+ *
+ * zest.js
+ * Copyright (c) 2011-2012, Christopher Jeffrey
+ * https://github.com/chjj/zest
+ *
+ * ender.js
+ * copyright @ded and @fat
+ * https://github.com/ender-js
*/
-// i try not to change the expected functionality here, however,
+// I try not to change the expected functionality here, however,
// these functions seem like they should belong in a dom library,
// not as part of the selector engine binding.
-(function() {
+
+;(function() {
var window = this
, document = this.document
- , zest = this.zest;
-
- // remove zest
- delete this.zest;
+ , zest = this.zest.noConflict();
$._select = function(str, context) {
context = context || document;
if (/^\s*</.test(str)) {
- context = context.nodeType === 9
+ context = context.nodeType === 9
? context : context.ownerDocument;
var out = []
@@ -60,4 +65,4 @@
}
};
}());
-}).call(this);
+}).call(this);
View
56 ext/zest.jquery.js
@@ -1,36 +1,39 @@
/**
- * Zest support for jQuery
+ * zest.js support for jQuery
+ *
+ * zest.js
+ * Copyright (c) 2011-2012, Christopher Jeffrey
+ * https://github.com/chjj/zest
+ *
+ * jQuery
+ * Copyright (c) 2009 John Resig
* https://github.com/jquery/jquery
*/
+;(function() {
+
// Using this, jQuery can be built with Zest as its selector engine.
+// Unfortunately, Sizzle exposes a lot of functions to jQuery. These functions
+// are necessary in order for jQuery to run properly. jQuery wasn't made to
+// work with any selector engine but Sizzle. They're incredibly tightly
+// coupled.
+
// The functions you see here were taken directly from Sizzle to ensure jQuery
// remains working properly.
-// To be honest, this is absolutely horrible: *none* of this should be the
-// selector engine's job. These functions belong in jQuery core as they are
-// ubiquitous and used everywhere internally. jQuery doesn't even use these
-// methods for anything selector-related (it uses them for non-selector dom
-// traversal), among other things. But alas, jQuery was only designed to work
-// with sizzle and it undeniably assumes its use, so I had to grab a number of
-// sizzle methods to keep jQuery working correctly.
-(function() {
-var engine = window.zest;
-delete window.zest;
+var engine = this.zest.noConflict();
engine.matchesSelector = engine.matches;
engine.matches = function(sel, set) {
- var res = engine(sel)
- , i = set.length
- , l;
-
- s: while (i--) {
- l = res.length;
- while (l--) if (res[l] === set[i]) continue s;
- set.splice(i, 1);
+ var test = engine.compile(sel)
+ , i = set.length;
+
+ while (i--) {
+ if (!test(set[i])) set.splice(i, 1);
}
+
return set;
};
@@ -84,7 +87,7 @@ engine.getText = function( elems ) {
return ret;
};
-var hasDuplicate = false,
+var hasDuplicate = false,
baseHasDuplicate = true;
[0, 0].sort(function() {
@@ -113,11 +116,11 @@ if ( document.documentElement.compareDocumentPosition ) {
return a.sourceIndex - b.sourceIndex;
}
- var al, bl,
- ap = [],
- bp = [],
- aup = a.parentNode,
- bup = b.parentNode,
+ var al, bl,
+ ap = [],
+ bp = [],
+ aup = a.parentNode,
+ bup = b.parentNode,
cur = aup;
if ( aup === bup ) {
@@ -217,4 +220,5 @@ jQuery.isXMLDoc = engine.isXML;
jQuery.contains = engine.contains;
jQuery.zest = engine;
-})();
+
+}).call(this);
View
9 ext/zest.prototype.js
@@ -1,5 +1,12 @@
/**
- * Zest support for Prototype
+ * zest.js support for Prototype
+ *
+ * zest.js
+ * Copyright (c) 2011-2012, Christopher Jeffrey
+ * https://github.com/chjj/zest
+ *
+ * Prototype
+ * Copyright (c) 2005-2010 Sam Stephenson
* https://github.com/sstephenson/prototype
*/
View
38 ext/zest.zepto.js
@@ -0,0 +1,38 @@
+/**
+ * zest.js support for Zepto.js
+ *
+ * zest.js
+ * Copyright (c) 2011-2012, Christopher Jeffrey
+ * https://github.com/chjj/zest
+ *
+ * Zepto.js
+ * (c) 2010-2012 Thomas Fuchs
+ * https://github.com/madrobby/zepto
+ */
+
+;(function() {
+ var Zepto = this.Zepto
+ , zest = this.zest.noConflict()
+ , key;
+
+ var Zepto_ = function(selector, context) {
+ if (typeof selector === 'string' && !/^\s*</.test(selector)) {
+ var results = zest(selector, context);
+ results.__proto__ = Zepto.fn;
+ results.selector = selector;
+ return results;
+ }
+ return Zepto(selector, context);
+ };
+
+ Zepto_.qsa = zest;
+
+ for (key in Zepto) {
+ if (Object.prototype.hasOwnProperty.call(Zepto, key)) {
+ Zepto_[key] = Zepto[key];
+ }
+ }
+
+ if (this.$ === Zepto) this.$ = Zepto_;
+ this.Zepto = Zepto_;
+}).call(this);
Please sign in to comment.
Something went wrong with that request. Please try again.