From 2c56b4349ade174277002a7d449f9ab2b719396d Mon Sep 17 00:00:00 2001 From: Thibaut Date: Sat, 25 Jan 2014 10:25:42 -0500 Subject: [PATCH] Handle null arguments in $.hasChild and $.closestLink --- assets/javascripts/lib/util.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/assets/javascripts/lib/util.coffee b/assets/javascripts/lib/util.coffee index 2fb102b1..c4321e15 100644 --- a/assets/javascripts/lib/util.coffee +++ b/assets/javascripts/lib/util.coffee @@ -12,12 +12,14 @@ $.id = (id) -> document.getElementById(id) $.hasChild = (parent, el) -> + return unless parent and el loop 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 return el if el.tagName is 'A' return if el is parent