Browse Source

Handle null arguments in $.hasChild and $.closestLink

Thibaut 12 years ago
parent
commit
2c56b4349a
1 changed files with 2 additions and 0 deletions
  1. 2 0
      assets/javascripts/lib/util.coffee

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

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