The MDN docs and most browsers document functions such as getElementsByClassName and getElementsByTagName returning HTMLCollections rather than node lists. Unfortunately this doesn't pass the current validation which only checks for [object NodeList]. Something like:
function _validateArguments (elements, callback) {
var nodes = Object.prototype.toString.call(elements),
validObject = nodes === '[object NodeList]' || nodes === '[object HTMLCollection]',
elementsValid = elements && ((validObject && elements.length) || (elements.nodeType === 1)),
callbackValid = callback && typeof callback === 'function'
if ('console' in window && 'warn' in console) {
if (!elementsValid) console.warn('Countable: No valid elements were found')
if (!callbackValid) console.warn('Countable: "' + callback + '" is not a valid callback function')
}
return elementsValid && callbackValid
}
But I'm not sure how the tests would work since they seem to be designed for single elements.
The MDN docs and most browsers document functions such as
getElementsByClassName
andgetElementsByTagName
returning HTMLCollections rather than node lists. Unfortunately this doesn't pass the current validation which only checks for[object NodeList]
. Something like:But I'm not sure how the tests would work since they seem to be designed for single elements.