From 76763e66671e37090d45bf5db4e99f4823495bca Mon Sep 17 00:00:00 2001 From: Thibaut Date: Sat, 8 Feb 2014 11:48:24 -0500 Subject: [PATCH] Fix $.hasChild and $.closestLink when el becomes null --- assets/javascripts/lib/util.coffee | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/assets/javascripts/lib/util.coffee b/assets/javascripts/lib/util.coffee index c4321e15..7d5ff6d2 100644 --- a/assets/javascripts/lib/util.coffee +++ b/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