代码拉取完成,页面将自动刷新
import isString from './utils/types/isString'
import isFunction from './utils/types/isFunction'
import isCollection from './isCollection'
import isElement from './isElement'
import getEl from './getEl'
import filter from './filter'
/**
* 将匹配的元素集减少为具有与选择器或过滤函数匹配的子体的元素集。
* ========================================================================
* @method has
* @since 1.2.0
* @param {HTMLElement|NodeList} el
* @param {String|Function} selector
* @return {Array}
*/
const has = (el, selector) => {
if (
(!isElement(el) && !isCollection(el)) ||
(!isString(selector) && !isFunction(selector))
) {
return []
}
if (isElement(el)) {
/* istanbul ignore else */
if (isString(selector)) {
return [...getEl(selector, el, true)]
}
} else {
return filter(el, selector)
}
}
export default has
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。