function matchesSomeSelectors(element, selectors) {
return selectors.some(function (selector) {
return Prototype.Selector.match(element, selector);
});
}
http://jsfiddle.net/4p4LJ/
我不确定是否
some
在IE或更旧的浏览器中可用,但如果需要,您可以自己轻松地复制它。
下面是Mozilla的实现,如果您需要的话:
if (!Array.prototype.some)
{
Array.prototype.some = function(fun, thisp)
{
var i = 0,
len = this.length >>> 0;
if (typeof fun != "function")
throw new TypeError();
var thisp = arguments[1];
for (; i < len; i++)
{
if (i in this &&
fun.call(thisp, this[i], i, this))
return true;
}
return false;
};
}