作者:蓝瑟 | 来源:互联网 | 2023-10-12 15:39
我在阅读appframework.js中的源码时,下面这个函数中有些语句不明白
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| /**
* Given a set of nodes, it returns them as an array. Used to find
* siblings of an element
* @param {Nodelist} nodes Node list to search
* @param {Object=} element [optional] objects to find siblings off of
* @return {Array} array of siblings
* @api private
*/
var nundefined;
function siblings(nodes, element) {
var elems = [];
if (nodes == nundefined)
return elems;
for (; nodes; nodes = nodes.nextSibling) {
if (nodes.nodeType === 1 && nodes !== element) {
elems.push(nodes);
}
}
return elems;
} |
nodes应该是一个元素集合,nodes.nextSibling及nodes !== element不太理解