{"action":"opened","issue":{"url":"https://api.github.com/repos/dyygtfx/EveryDayCode/issues/50","labels_url":"https://api.github.com/repos/dyygtfx/EveryDayCode/issues/50/labels{/name}","comments_url":"https://api.github.com/repos/dyygtfx/EveryDayCode/issues/50/comments","events_url":"https://api.github.com/repos/dyygtfx/EveryDayCode/issues/50/events","html_url":"https://github.com/dyygtfx/EveryDayCode/issues/50","id":93246877,"number":50,"title":"查找两个节点的最近的一个共同父节点，可以包括节点自身 ","user":{"login":"dyygtfx","id":3821390,"avatar_url":"https://avatars.githubusercontent.com/u/3821390?v=3","gravatar_id":"","url":"https://api.github.com/users/dyygtfx","html_url":"https://github.com/dyygtfx","followers_url":"https://api.github.com/users/dyygtfx/followers","following_url":"https://api.github.com/users/dyygtfx/following{/other_user}","gists_url":"https://api.github.com/users/dyygtfx/gists{/gist_id}","starred_url":"https://api.github.com/users/dyygtfx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dyygtfx/subscriptions","organizations_url":"https://api.github.com/users/dyygtfx/orgs","repos_url":"https://api.github.com/users/dyygtfx/repos","events_url":"https://api.github.com/users/dyygtfx/events{/privacy}","received_events_url":"https://api.github.com/users/dyygtfx/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-07-06T10:46:12Z","updated_at":"2015-07-06T10:46:12Z","closed_at":null,"body":"查找两个节点的最近的一个共同父节点，可以包括节点自身 \r\noNode1 和 oNode2 在同一文档中，且不会为相同的节点\r\n\r\n\r\n```\r\nfunction commonParentNode(oNode1, oNode2) {\r\n    if(oNode1.contains(oNode2)) {\r\n        return oNode1;\r\n    } else if (oNode2.contains(oNode1)) {\r\n        return oNode2;\r\n    } else {\r\n        return arguments.callee(oNode1.parentNode,oNode2);\r\n    }\r\n}\r\n```\r\nps:\r\nNode.contains()返回一个布尔值来表示是否传入的节点是，该节点的子节点。"}}