3 Star 54 Fork 14

Yaohaixiao / dom.js

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
isMatched.js 690 Bytes
一键复制 编辑 原始数据 按行查看 历史
import isFunction from './utils/types/isFunction'
import isString from './utils/types/isString'
import isElement from './isElement'
import matches from './matches'
/**
* 检测 DOM 节点是否为符合检测条件的节点
* ========================================================================
* @method isMatched
* @param {HTMLElement} el
* @param {Function|String} filter
* @return {Boolean}
*/
const isMatched = (el, filter) => {
if (!isElement(el) || (!isFunction(filter) && !isString(filter))) {
return false
}
if (isFunction(filter)) {
return filter(el)
} else {
return !!matches(el, filter)
}
}
export default isMatched
JavaScript
1
https://gitee.com/yaohaixiao/dom.js.git
git@gitee.com:yaohaixiao/dom.js.git
yaohaixiao
dom.js
dom.js
main

搜索帮助