1 | /*
|
2 | * @Author: zhongjiahao
|
3 | * @Date: 2016-11-01 18:35:52
|
4 | * @Last Modified by: zhongjiahao
|
5 | * @Last Modified time: 2016-11-01 18:36:20
|
6 | */
|
7 | // 判断n 元素是否是 root中的子元素
|
8 | export default function contains(root, n) {
|
9 | var node = n;
|
10 |
|
11 | while (node) {
|
12 | if (node === root) {
|
13 | return true;
|
14 | }
|
15 |
|
16 | node = node.parentNode;
|
17 | }
|
18 |
|
19 | return false;
|
20 | } |
\ | No newline at end of file |