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
12 document.getElementById(id)12 document.getElementById(id)
13 13
14$.hasChild = (parent, el) ->14$.hasChild = (parent, el) ->
15 return unless parent and el15 return unless parent
16 loop16 while el
17 return true if el is parent17 return true if el is parent
18 return if el is document.body18 return if el is document.body
19 el = el.parentElement19 el = el.parentElement
20 20
21$.closestLink = (el, parent = document.body) ->21$.closestLink = (el, parent = document.body) ->
22 return unless el and parent22 while el
23 loop
24 return el if el.tagName is 'A'23 return el if el.tagName is 'A'
25 return if el is parent24 return if el is parent
26 el = el.parentElement25 el = el.parentElement