浏览代码

Handle null arguments in $.hasChild and $.closestLink

Thibaut 12 年之前
父节点
当前提交
2c56b4349a
共有 1 个文件被更改,包括 2 次插入0 次删除
  1. 2 0
      assets/javascripts/lib/util.coffee

+ 2 - 0
assets/javascripts/lib/util.coffee

@@ -12,12 +12,14 @@ $.id = (id) ->
   document.getElementById(id)
 
 $.hasChild = (parent, el) ->
+  return unless parent and el
   loop
     return true if el is parent
     return if el is document.body
     el = el.parentElement
 
 $.closestLink = (el, parent = document.body) ->
+  return unless el and parent
   loop
     return el if el.tagName is 'A'
     return if el is parent