题解 | #dom 节点查找#
dom 节点查找
http://www.nowcoder.com/practice/74d74be449af4c66907fe2d6961c255c
function commonParentNode(oNode1, oNode2) { if (oNode1 === oNode2) { return oNode1; } const parent1 = oNode1.parentNode; const parent2 = oNode2.parentNode; if (parent1 === oNode2 || parent1 === parent2) { return parent1; } else if (parent2 === oNode1) { return parent2; } return commonParentNode(parent1, parent2); }