History

Fix $.hasChild and $.closestLink when el becomes null

Thibaut committed 12 years ago

Commit 76763e61 parent aa415621 file · +3 −4Browse files

Unified · Split

assets/javascripts/lib/util.coffee+3−4
@@ -12,15 +12,14 @@ $.id = (id) -> · 11 unmodified lines
1212 document.getElementById(id)
1313
1414 $.hasChild = (parent, el) ->
15− return unless parent and el
16− loop
15+ return unless parent
16+ while el
1717 return true if el is parent
1818 return if el is document.body
1919 el = el.parentElement
2020
2121 $.closestLink = (el, parent = document.body) ->
22− return unless el and parent
23− loop
22+ while el
2423 return el if el.tagName is 'A'
2524 return if el is parent
2625 el = el.parentElement