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

pull/62/merge
Thibaut 11 years ago
parent aa41562f5c
commit 76763e6667

@ -12,15 +12,14 @@ $.id = (id) ->
document.getElementById(id) document.getElementById(id)
$.hasChild = (parent, el) -> $.hasChild = (parent, el) ->
return unless parent and el return unless parent
loop while el
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 while el
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
el = el.parentElement el = el.parentElement

Loading…
Cancel
Save