Explorar o código

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

Thibaut %!s(int64=12) %!d(string=hai) anos
pai
achega
76763e6667
Modificáronse 1 ficheiros con 3 adicións e 4 borrados
  1. 3 4
      assets/javascripts/lib/util.coffee

+ 3 - 4
assets/javascripts/lib/util.coffee

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