Ai
1 Star 0 Fork 12

NextZero/dom.js

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
getSiblings.js 798 Bytes
一键复制 编辑 原始数据 按行查看 历史
import isElement from './isElement'
import getPreviousSiblings from './getPreviousSiblings'
import getNextSiblings from './getNextSiblings'
/**
* 获取 DOM 元素的前面或后面所有邻居元素节点。
* ========================================================================
* @method getSiblings
* @param {HTMLElement} el
* @param {Boolean} [includeSelf]
* @return {Array}
*/
const getSiblings = (el, includeSelf = false) => {
let list = []
let prev = []
let next = []
if (!isElement(el)) {
return list
}
prev = getPreviousSiblings(el)
list.push(...prev)
/* istanbul ignore else */
if (includeSelf) {
list.push(el)
}
next = getNextSiblings(el)
list.push(...next)
return list
}
export default getSiblings
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/nextzero/dom.js.git
git@gitee.com:nextzero/dom.js.git
nextzero
dom.js
dom.js
main

搜索帮助