Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

return boolean from $().is() via ender bridge

  • Loading branch information...
commit d75a4be9ef2be8b60a1f2e6c166da772d3e3daa2 1 parent 7f94ea9
@rvagg authored
View
12 ender_bridge.js
@@ -13,7 +13,13 @@
} catch (ex) { } // ignore exception, we may have an ender build with no selector engine
integrated = true
}
- fn = function (self, selector, index) { return $(t(self)[meth](selector, index)) }
+ fn = meth == 'is'
+ ? function (self, slfn) {
+ return t(self)[meth](slfn) // boolean
+ }
+ : function (self, selector, index) {
+ return $(t(self)[meth](selector, index)) // collection
+ }
return fn(self, selector, index)
}
return function (selector, index) { return fn(this, selector, index) }
@@ -21,6 +27,10 @@
, methods = 'up down next previous prev parents closest siblings children first last eq slice filter not is has'.split(' ')
, b = {}, i = methods.length
+ // does this build have an .is()? if so, shift it to _is() for traversty to use and
+ // allow us to integrate a new is(), wrapped around it
+ if ($.fn.is) $.fn._is = $.fn.is
while (--i >= 0) b[methods[i]] = integrate(methods[i])
$.ender(b, true)
+ $.fn.is.__ignore = true
}(ender))
View
6 test/engines-test.js
@@ -46,8 +46,8 @@ var own = Object.prototype.hasOwnProperty
// we also don't want to run native tests in older browsers that don't support it
if (__matchesSelector) engineTest(null, 'Native')
engineTest(Q, 'Qwery')
-engineTest(Sizzle, 'Sizzle')
-engineTest(NW.Dom, 'NW')
+//engineTest(Sizzle, 'Sizzle')
+//engineTest(NW.Dom, 'NW')
// Sel must be last because it requires es5-basic which extends natives and we don't
// want that impacting any other tests in unexpected ways
-engineTest(sel, 'Sel', function() { loadES5Basic() })
+//engineTest(sel, 'Sel', function() { loadES5Basic() })
View
22 test/filters.js
@@ -750,23 +750,23 @@ this.filterTests = {
, 'is()': {
'is() on empty collection': function () {
- refute(T([]).is())
+ assert(T([]).is() === false)
}
, 'is() on multi collection': function () {
- refute(T(Q('#fixtures > ul > li')).is())
+ assert(T(Q('#fixtures > ul > li')).is() === false)
}
, 'is(fn=false) on multi collection': function () {
- refute(T(Q('#fixtures > ul > li')).is(function () { return false }))
+ assert(T(Q('#fixtures > ul > li')).is(function () { return false }) === false)
}
, 'is(fn=true) on multi collection': function () {
- assert(T(Q('#fixtures > ul > li')).is(function () { return true }))
+ assert(T(Q('#fixtures > ul > li')).is(function () { return true }) === true)
}
, 'is(fn=true) on empty collection': function () {
- refute(T([]).is(function () { return true }))
+ assert(T([]).is(function () { return true }) === false)
}
, 'is(fn) `this` and arguments check': function () {
@@ -784,21 +784,21 @@ this.filterTests = {
}
, 'is(nonmatch selector) on multi collection': function () {
- refute(T(Q('#fixtures > ul > li')).is('ul'))
+ assert(T(Q('#fixtures > ul > li')).is('ul') === false)
}
, 'is(selector) on multi collection': function () {
- assert(T(Q('#fixtures > ul > li')).is('li'))
+ assert(T(Q('#fixtures > ul > li')).is('li') === true)
}
, 'is(nonmatch element) on multi collection': function () {
- refute(T(Q('#fixtures > ul > li')).is(Q('#fixtures')[0]))
+ assert(T(Q('#fixtures > ul > li')).is(Q('#fixtures')[0]) === false)
}
, 'is(element) on multi collection': function () {
- assert(T(Q('#fixtures > ul > li')).is(Q('#fixtures > ul > li')[0]))
- assert(T(Q('#fixtures > ul > li')).is(Q('#fixtures > ul > li')[2]))
- assert(T(Q('#fixtures > ul > li')).is(Q('#fixtures > ul > li')[6]))
+ assert(T(Q('#fixtures > ul > li')).is(Q('#fixtures > ul > li')[0]) === true)
+ assert(T(Q('#fixtures > ul > li')).is(Q('#fixtures > ul > li')[2]) === true)
+ assert(T(Q('#fixtures > ul > li')).is(Q('#fixtures > ul > li')[6]) === true)
}
}
}
View
2  test/integration/ender_noselector.html
@@ -20,7 +20,7 @@
.up('ul').eq(-1).css('borderLeft', 'solid 5px orange')
.closest('#fixtures').down('li').slice(-10,-9).css('fontSize', '25px')
- if ($('li').is('.c')) $.create('<div>INTEGRATION TEST ALL DONE!</div>').prependTo('#fixtures')
+ if ($('li').is('.c') === true) $.create('<div>INTEGRATION TEST ALL DONE!</div>').prependTo('#fixtures')
})
</script>
</head>
View
37 test/integration/ender_noselector.js
@@ -2,7 +2,7 @@
* =============================================================
* Ender: open module JavaScript framework (https://ender.no.de)
* Build: ender build domready bonzo ../.. --output ender_noselector
- * Packages: ender-js@0.4.4 domready@0.2.11 bonzo@1.2.3 traversty@0.0.7
+ * Packages: ender-js@0.4.4 domready@0.2.11 bonzo@1.2.4 traversty@0.0.7
* =============================================================
*/
@@ -1026,7 +1026,8 @@
, dim: function () {
if (!this.length) return { height: 0, width: 0 }
var el = this[0]
- , orig = !el.offsetWidth && !el.offsetHeight ?
+ , de = el.nodeType == 9 && el.documentElement // document
+ , orig = !de && !!el.style && !el.offsetWidth && !el.offsetHeight ?
// el isn't visible, can't be measured properly, so fix that
function (t) {
var s = {
@@ -1041,8 +1042,12 @@
})
return s
}(this) : null
- , width = el.offsetWidth
- , height = el.offsetHeight
+ , width = de
+ ? Math.max(el.body.scrollWidth, el.body.offsetWidth, de.scrollWidth, de.offsetWidth, de.clientWidth)
+ : el.offsetWidth
+ , height = de
+ ? Math.max(el.body.scrollHeight, el.body.offsetHeight, de.scrollWidth, de.offsetWidth, de.clientHeight)
+ : el.offsetHeight
orig && this.first().css(orig)
return {
@@ -1780,6 +1785,7 @@
))
}
}
+ T.prototype.prev = T.prototype.previous
function t(els) {
return new T(isString(els) ? selectorFind(els, doc) : els)
@@ -1805,10 +1811,11 @@
// perhaps it's an selector(x).is(y) type selector?
ss = s('a', e)
_selectorMatches =
- isFunction(ss.matching) ? function (selector, el) { return s(el).matching(selector).length > 0 } :
- isFunction(ss.is) ? function (selector, el) { return s(el).is(selector) } :
- isFunction(ss.matchesSelector) ? function (selector, el) { return s(el).matchesSelector(selector) } :
- isFunction(ss.match) ? function (selector, el) { return s(el).match(selector) } : null
+ isFunction(ss._is) ? function (selector, el) { return s(el)._is(selector) } : // original .is(), replaced by Enderbridge
+ isFunction(ss.matching) ? function (selector, el) { return s(el).matching(selector).length > 0 } :
+ isFunction(ss.is) && !ss.is.__ignore ? function (selector, el) { return s(el).is(selector) } :
+ isFunction(ss.matchesSelector) ? function (selector, el) { return s(el).matchesSelector(selector) } :
+ isFunction(ss.match) ? function (selector, el) { return s(el).match(selector) } : null
}
if (!_selectorMatches)
@@ -1864,15 +1871,25 @@
} catch (ex) { } // ignore exception, we may have an ender build with no selector engine
integrated = true
}
- fn = function (self, selector, index) { return $(t(self)[meth](selector, index)) }
+ fn = meth == 'is'
+ ? function (self, slfn) {
+ return t(self)[meth](slfn) // boolean
+ }
+ : function (self, selector, index) {
+ return $(t(self)[meth](selector, index)) // collection
+ }
return fn(self, selector, index)
}
return function (selector, index) { return fn(this, selector, index) }
}
- , methods = 'up down next previous parents closest siblings children first last eq slice filter not is has'.split(' ')
+ , methods = 'up down next previous prev parents closest siblings children first last eq slice filter not is has'.split(' ')
, b = {}, i = methods.length
+ // does this build have an .is()? if so, shift it to _is() for traversty to use and
+ // allow us to integrate a new is(), wrapped around it
+ if ($.fn.is) $.fn._is = $.fn.is
while (--i >= 0) b[methods[i]] = integrate(methods[i])
$.ender(b, true)
+ $.fn.is.__ignore = true
}(ender))
}());
View
2  test/integration/ender_nwmatcher.html
@@ -20,7 +20,7 @@
.up('ul').eq(-1).css('borderLeft', 'solid 5px orange')
.closest('#fixtures').down('li').slice(-10,-9).css('fontSize', '25px')
- if ($('li').is('.c')) $('<div>INTEGRATION TEST ALL DONE!</div>').prependTo('#fixtures')
+ if ($('li').is('.c') === true) $('<div>INTEGRATION TEST ALL DONE!</div>').prependTo('#fixtures')
})
</script>
</head>
View
37 test/integration/ender_nwmatcher.js
@@ -2,7 +2,7 @@
* =============================================================
* Ender: open module JavaScript framework (https://ender.no.de)
* Build: ender build domready nwmatcher bonzo ../.. --output ender_nwmatcher
- * Packages: ender-js@0.4.4 domready@0.2.11 nwmatcher@1.2.5 bonzo@1.2.3 traversty@0.0.7
+ * Packages: ender-js@0.4.4 domready@0.2.11 nwmatcher@1.2.5 bonzo@1.2.4 traversty@0.0.7
* =============================================================
*/
@@ -1141,7 +1141,8 @@
, dim: function () {
if (!this.length) return { height: 0, width: 0 }
var el = this[0]
- , orig = !el.offsetWidth && !el.offsetHeight ?
+ , de = el.nodeType == 9 && el.documentElement // document
+ , orig = !de && !!el.style && !el.offsetWidth && !el.offsetHeight ?
// el isn't visible, can't be measured properly, so fix that
function (t) {
var s = {
@@ -1156,8 +1157,12 @@
})
return s
}(this) : null
- , width = el.offsetWidth
- , height = el.offsetHeight
+ , width = de
+ ? Math.max(el.body.scrollWidth, el.body.offsetWidth, de.scrollWidth, de.offsetWidth, de.clientWidth)
+ : el.offsetWidth
+ , height = de
+ ? Math.max(el.body.scrollHeight, el.body.offsetHeight, de.scrollWidth, de.offsetWidth, de.clientHeight)
+ : el.offsetHeight
orig && this.first().css(orig)
return {
@@ -1895,6 +1900,7 @@
))
}
}
+ T.prototype.prev = T.prototype.previous
function t(els) {
return new T(isString(els) ? selectorFind(els, doc) : els)
@@ -1920,10 +1926,11 @@
// perhaps it's an selector(x).is(y) type selector?
ss = s('a', e)
_selectorMatches =
- isFunction(ss.matching) ? function (selector, el) { return s(el).matching(selector).length > 0 } :
- isFunction(ss.is) ? function (selector, el) { return s(el).is(selector) } :
- isFunction(ss.matchesSelector) ? function (selector, el) { return s(el).matchesSelector(selector) } :
- isFunction(ss.match) ? function (selector, el) { return s(el).match(selector) } : null
+ isFunction(ss._is) ? function (selector, el) { return s(el)._is(selector) } : // original .is(), replaced by Enderbridge
+ isFunction(ss.matching) ? function (selector, el) { return s(el).matching(selector).length > 0 } :
+ isFunction(ss.is) && !ss.is.__ignore ? function (selector, el) { return s(el).is(selector) } :
+ isFunction(ss.matchesSelector) ? function (selector, el) { return s(el).matchesSelector(selector) } :
+ isFunction(ss.match) ? function (selector, el) { return s(el).match(selector) } : null
}
if (!_selectorMatches)
@@ -1979,15 +1986,25 @@
} catch (ex) { } // ignore exception, we may have an ender build with no selector engine
integrated = true
}
- fn = function (self, selector, index) { return $(t(self)[meth](selector, index)) }
+ fn = meth == 'is'
+ ? function (self, slfn) {
+ return t(self)[meth](slfn) // boolean
+ }
+ : function (self, selector, index) {
+ return $(t(self)[meth](selector, index)) // collection
+ }
return fn(self, selector, index)
}
return function (selector, index) { return fn(this, selector, index) }
}
- , methods = 'up down next previous parents closest siblings children first last eq slice filter not is has'.split(' ')
+ , methods = 'up down next previous prev parents closest siblings children first last eq slice filter not is has'.split(' ')
, b = {}, i = methods.length
+ // does this build have an .is()? if so, shift it to _is() for traversty to use and
+ // allow us to integrate a new is(), wrapped around it
+ if ($.fn.is) $.fn._is = $.fn.is
while (--i >= 0) b[methods[i]] = integrate(methods[i])
$.ender(b, true)
+ $.fn.is.__ignore = true
}(ender))
}());
View
2  test/integration/ender_qwery.html
@@ -20,7 +20,7 @@
.up('ul').eq(-1).css('borderLeft', 'solid 5px orange')
.closest('#fixtures').down('li').slice(-10,-9).css('fontSize', '25px')
- if ($('li').is('.c')) $('<div>INTEGRATION TEST ALL DONE!</div>').prependTo('#fixtures')
+ if ($('li').is('.c') === true) $('<div>INTEGRATION TEST ALL DONE!</div>').prependTo('#fixtures')
})
</script>
</head>
View
37 test/integration/ender_qwery.js
@@ -2,7 +2,7 @@
* =============================================================
* Ender: open module JavaScript framework (https://ender.no.de)
* Build: ender build domready qwery bonzo ../.. --output ender_qwery
- * Packages: ender-js@0.4.4 domready@0.2.11 qwery@3.3.11 bonzo@1.2.3 traversty@0.0.7
+ * Packages: ender-js@0.4.4 domready@0.2.11 qwery@3.3.11 bonzo@1.2.4 traversty@0.0.7
* =============================================================
*/
@@ -1465,7 +1465,8 @@
, dim: function () {
if (!this.length) return { height: 0, width: 0 }
var el = this[0]
- , orig = !el.offsetWidth && !el.offsetHeight ?
+ , de = el.nodeType == 9 && el.documentElement // document
+ , orig = !de && !!el.style && !el.offsetWidth && !el.offsetHeight ?
// el isn't visible, can't be measured properly, so fix that
function (t) {
var s = {
@@ -1480,8 +1481,12 @@
})
return s
}(this) : null
- , width = el.offsetWidth
- , height = el.offsetHeight
+ , width = de
+ ? Math.max(el.body.scrollWidth, el.body.offsetWidth, de.scrollWidth, de.offsetWidth, de.clientWidth)
+ : el.offsetWidth
+ , height = de
+ ? Math.max(el.body.scrollHeight, el.body.offsetHeight, de.scrollWidth, de.offsetWidth, de.clientHeight)
+ : el.offsetHeight
orig && this.first().css(orig)
return {
@@ -2219,6 +2224,7 @@
))
}
}
+ T.prototype.prev = T.prototype.previous
function t(els) {
return new T(isString(els) ? selectorFind(els, doc) : els)
@@ -2244,10 +2250,11 @@
// perhaps it's an selector(x).is(y) type selector?
ss = s('a', e)
_selectorMatches =
- isFunction(ss.matching) ? function (selector, el) { return s(el).matching(selector).length > 0 } :
- isFunction(ss.is) ? function (selector, el) { return s(el).is(selector) } :
- isFunction(ss.matchesSelector) ? function (selector, el) { return s(el).matchesSelector(selector) } :
- isFunction(ss.match) ? function (selector, el) { return s(el).match(selector) } : null
+ isFunction(ss._is) ? function (selector, el) { return s(el)._is(selector) } : // original .is(), replaced by Enderbridge
+ isFunction(ss.matching) ? function (selector, el) { return s(el).matching(selector).length > 0 } :
+ isFunction(ss.is) && !ss.is.__ignore ? function (selector, el) { return s(el).is(selector) } :
+ isFunction(ss.matchesSelector) ? function (selector, el) { return s(el).matchesSelector(selector) } :
+ isFunction(ss.match) ? function (selector, el) { return s(el).match(selector) } : null
}
if (!_selectorMatches)
@@ -2303,15 +2310,25 @@
} catch (ex) { } // ignore exception, we may have an ender build with no selector engine
integrated = true
}
- fn = function (self, selector, index) { return $(t(self)[meth](selector, index)) }
+ fn = meth == 'is'
+ ? function (self, slfn) {
+ return t(self)[meth](slfn) // boolean
+ }
+ : function (self, selector, index) {
+ return $(t(self)[meth](selector, index)) // collection
+ }
return fn(self, selector, index)
}
return function (selector, index) { return fn(this, selector, index) }
}
- , methods = 'up down next previous parents closest siblings children first last eq slice filter not is has'.split(' ')
+ , methods = 'up down next previous prev parents closest siblings children first last eq slice filter not is has'.split(' ')
, b = {}, i = methods.length
+ // does this build have an .is()? if so, shift it to _is() for traversty to use and
+ // allow us to integrate a new is(), wrapped around it
+ if ($.fn.is) $.fn._is = $.fn.is
while (--i >= 0) b[methods[i]] = integrate(methods[i])
$.ender(b, true)
+ $.fn.is.__ignore = true
}(ender))
}());
View
2  test/integration/ender_sel.html
@@ -20,7 +20,7 @@
.up('ul').eq(-1).css('borderLeft', 'solid 5px orange')
.closest('#fixtures').down('li').slice(-10,-9).css('fontSize', '25px')
- if ($('li').is('.c')) $('<div>INTEGRATION TEST ALL DONE!</div>').prependTo('#fixtures')
+ if ($('li').is('.c') === true) $('<div>INTEGRATION TEST ALL DONE!</div>').prependTo('#fixtures')
})
</script>
</head>
View
37 test/integration/ender_sel.js
@@ -2,7 +2,7 @@
* =============================================================
* Ender: open module JavaScript framework (https://ender.no.de)
* Build: ender build domready sel bonzo ../../ --output ender_sel
- * Packages: ender-js@0.4.4 domready@0.2.11 es5-basic@0.2.1 sel@0.7.5 bonzo@1.2.3 traversty@0.0.7
+ * Packages: ender-js@0.4.4 domready@0.2.11 es5-basic@0.2.1 sel@0.7.5 bonzo@1.2.4 traversty@0.0.7
* =============================================================
*/
@@ -2150,7 +2150,8 @@
, dim: function () {
if (!this.length) return { height: 0, width: 0 }
var el = this[0]
- , orig = !el.offsetWidth && !el.offsetHeight ?
+ , de = el.nodeType == 9 && el.documentElement // document
+ , orig = !de && !!el.style && !el.offsetWidth && !el.offsetHeight ?
// el isn't visible, can't be measured properly, so fix that
function (t) {
var s = {
@@ -2165,8 +2166,12 @@
})
return s
}(this) : null
- , width = el.offsetWidth
- , height = el.offsetHeight
+ , width = de
+ ? Math.max(el.body.scrollWidth, el.body.offsetWidth, de.scrollWidth, de.offsetWidth, de.clientWidth)
+ : el.offsetWidth
+ , height = de
+ ? Math.max(el.body.scrollHeight, el.body.offsetHeight, de.scrollWidth, de.offsetWidth, de.clientHeight)
+ : el.offsetHeight
orig && this.first().css(orig)
return {
@@ -2904,6 +2909,7 @@
))
}
}
+ T.prototype.prev = T.prototype.previous
function t(els) {
return new T(isString(els) ? selectorFind(els, doc) : els)
@@ -2929,10 +2935,11 @@
// perhaps it's an selector(x).is(y) type selector?
ss = s('a', e)
_selectorMatches =
- isFunction(ss.matching) ? function (selector, el) { return s(el).matching(selector).length > 0 } :
- isFunction(ss.is) ? function (selector, el) { return s(el).is(selector) } :
- isFunction(ss.matchesSelector) ? function (selector, el) { return s(el).matchesSelector(selector) } :
- isFunction(ss.match) ? function (selector, el) { return s(el).match(selector) } : null
+ isFunction(ss._is) ? function (selector, el) { return s(el)._is(selector) } : // original .is(), replaced by Enderbridge
+ isFunction(ss.matching) ? function (selector, el) { return s(el).matching(selector).length > 0 } :
+ isFunction(ss.is) && !ss.is.__ignore ? function (selector, el) { return s(el).is(selector) } :
+ isFunction(ss.matchesSelector) ? function (selector, el) { return s(el).matchesSelector(selector) } :
+ isFunction(ss.match) ? function (selector, el) { return s(el).match(selector) } : null
}
if (!_selectorMatches)
@@ -2988,15 +2995,25 @@
} catch (ex) { } // ignore exception, we may have an ender build with no selector engine
integrated = true
}
- fn = function (self, selector, index) { return $(t(self)[meth](selector, index)) }
+ fn = meth == 'is'
+ ? function (self, slfn) {
+ return t(self)[meth](slfn) // boolean
+ }
+ : function (self, selector, index) {
+ return $(t(self)[meth](selector, index)) // collection
+ }
return fn(self, selector, index)
}
return function (selector, index) { return fn(this, selector, index) }
}
- , methods = 'up down next previous parents closest siblings children first last eq slice filter not is has'.split(' ')
+ , methods = 'up down next previous prev parents closest siblings children first last eq slice filter not is has'.split(' ')
, b = {}, i = methods.length
+ // does this build have an .is()? if so, shift it to _is() for traversty to use and
+ // allow us to integrate a new is(), wrapped around it
+ if ($.fn.is) $.fn._is = $.fn.is
while (--i >= 0) b[methods[i]] = integrate(methods[i])
$.ender(b, true)
+ $.fn.is.__ignore = true
}(ender))
}());
View
2  test/integration/ender_sizzle.html
@@ -20,7 +20,7 @@
.up('ul').eq(-1).css('borderLeft', 'solid 5px orange')
.closest('#fixtures').down('li').slice(-10,-9).css('fontSize', '25px')
- if ($('li').is('.c')) $('<div>INTEGRATION TEST ALL DONE!</div>').prependTo('#fixtures')
+ if ($('li').is('.c') === true) $('<div>INTEGRATION TEST ALL DONE!</div>').prependTo('#fixtures')
})
</script>
</head>
View
37 test/integration/ender_sizzle.js
@@ -2,7 +2,7 @@
* =============================================================
* Ender: open module JavaScript framework (https://ender.no.de)
* Build: ender build domready sizzle bonzo ../.. --output ender_sizzle
- * Packages: ender-js@0.4.4 domready@0.2.11 sizzle@1.1.0 bonzo@1.2.3 traversty@0.0.7
+ * Packages: ender-js@0.4.4 domready@0.2.11 sizzle@1.1.0 bonzo@1.2.4 traversty@0.0.7
* =============================================================
*/
@@ -2584,7 +2584,8 @@
, dim: function () {
if (!this.length) return { height: 0, width: 0 }
var el = this[0]
- , orig = !el.offsetWidth && !el.offsetHeight ?
+ , de = el.nodeType == 9 && el.documentElement // document
+ , orig = !de && !!el.style && !el.offsetWidth && !el.offsetHeight ?
// el isn't visible, can't be measured properly, so fix that
function (t) {
var s = {
@@ -2599,8 +2600,12 @@
})
return s
}(this) : null
- , width = el.offsetWidth
- , height = el.offsetHeight
+ , width = de
+ ? Math.max(el.body.scrollWidth, el.body.offsetWidth, de.scrollWidth, de.offsetWidth, de.clientWidth)
+ : el.offsetWidth
+ , height = de
+ ? Math.max(el.body.scrollHeight, el.body.offsetHeight, de.scrollWidth, de.offsetWidth, de.clientHeight)
+ : el.offsetHeight
orig && this.first().css(orig)
return {
@@ -3338,6 +3343,7 @@
))
}
}
+ T.prototype.prev = T.prototype.previous
function t(els) {
return new T(isString(els) ? selectorFind(els, doc) : els)
@@ -3363,10 +3369,11 @@
// perhaps it's an selector(x).is(y) type selector?
ss = s('a', e)
_selectorMatches =
- isFunction(ss.matching) ? function (selector, el) { return s(el).matching(selector).length > 0 } :
- isFunction(ss.is) ? function (selector, el) { return s(el).is(selector) } :
- isFunction(ss.matchesSelector) ? function (selector, el) { return s(el).matchesSelector(selector) } :
- isFunction(ss.match) ? function (selector, el) { return s(el).match(selector) } : null
+ isFunction(ss._is) ? function (selector, el) { return s(el)._is(selector) } : // original .is(), replaced by Enderbridge
+ isFunction(ss.matching) ? function (selector, el) { return s(el).matching(selector).length > 0 } :
+ isFunction(ss.is) && !ss.is.__ignore ? function (selector, el) { return s(el).is(selector) } :
+ isFunction(ss.matchesSelector) ? function (selector, el) { return s(el).matchesSelector(selector) } :
+ isFunction(ss.match) ? function (selector, el) { return s(el).match(selector) } : null
}
if (!_selectorMatches)
@@ -3422,15 +3429,25 @@
} catch (ex) { } // ignore exception, we may have an ender build with no selector engine
integrated = true
}
- fn = function (self, selector, index) { return $(t(self)[meth](selector, index)) }
+ fn = meth == 'is'
+ ? function (self, slfn) {
+ return t(self)[meth](slfn) // boolean
+ }
+ : function (self, selector, index) {
+ return $(t(self)[meth](selector, index)) // collection
+ }
return fn(self, selector, index)
}
return function (selector, index) { return fn(this, selector, index) }
}
- , methods = 'up down next previous parents closest siblings children first last eq slice filter not is has'.split(' ')
+ , methods = 'up down next previous prev parents closest siblings children first last eq slice filter not is has'.split(' ')
, b = {}, i = methods.length
+ // does this build have an .is()? if so, shift it to _is() for traversty to use and
+ // allow us to integrate a new is(), wrapped around it
+ if ($.fn.is) $.fn._is = $.fn.is
while (--i >= 0) b[methods[i]] = integrate(methods[i])
$.ender(b, true)
+ $.fn.is.__ignore = true
}(ender))
}());
View
2  test/traversal.js
@@ -781,7 +781,7 @@ this.traversalTests = {
assert.hasExactElements(
T(Q('#fixtures > ul')).children()
- , '#fixtures > ul > li,'
+ , '#fixtures > ul > li'
, 'sublings() with no-arg returns all children (multi collection, firstChildren)'
)
}
View
11 traversty.js
@@ -137,7 +137,7 @@
// ignore non-elements, only consider selector-matching elements
// handle both the index and no-index (selector-only) cases
if (isElement(el)
- && (!filterFn || (filterFn === true || filterFn(el, elind)))
+ && (!filterFn || filterFn === true || filterFn(el, elind))
&& selectorMatches(selector, el)
&& (index === null || i-- === 0)) {
// this concat vs push is to make sure we add elements to the result array
@@ -334,10 +334,11 @@
// perhaps it's an selector(x).is(y) type selector?
ss = s('a', e)
_selectorMatches =
- isFunction(ss.matching) ? function (selector, el) { return s(el).matching(selector).length > 0 } :
- isFunction(ss.is) ? function (selector, el) { return s(el).is(selector) } :
- isFunction(ss.matchesSelector) ? function (selector, el) { return s(el).matchesSelector(selector) } :
- isFunction(ss.match) ? function (selector, el) { return s(el).match(selector) } : null
+ isFunction(ss._is) ? function (selector, el) { return s(el)._is(selector) } : // original .is(), replaced by Enderbridge
+ isFunction(ss.matching) ? function (selector, el) { return s(el).matching(selector).length > 0 } :
+ isFunction(ss.is) && !ss.is.__ignore ? function (selector, el) { return s(el).is(selector) } :
+ isFunction(ss.matchesSelector) ? function (selector, el) { return s(el).matchesSelector(selector) } :
+ isFunction(ss.match) ? function (selector, el) { return s(el).match(selector) } : null
}
if (!_selectorMatches)
Please sign in to comment.
Something went wrong with that request. Please try again.