History

Handle null arguments in $.hasChild and $.closestLink

Thibaut committed 12 years ago

Commit 2c56b431 parent ce31de51 file · +2 −0Browse files

Unified · Split

assets/javascripts/lib/util.coffee+2−0
@@ -12,12 +12,14 @@ $.id = (id) -> · 11 unmodified lines
1212 document.getElementById(id)
1313
1414 $.hasChild = (parent, el) ->
15+ return unless parent and el
1516 loop
1617 return true if el is parent
1718 return if el is document.body
1819 el = el.parentElement
1920
2021 $.closestLink = (el, parent = document.body) ->
22+ return unless el and parent
2123 loop
2224 return el if el.tagName is 'A'
2325 return if el is parent