Unified · Split
| @@ -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 el | 15 | return unless parent |
| 16 | loop | 16 | while el |
| 17 | return true if el is parent | 17 | return true if el is parent |
| 18 | return if el is document.body | 18 | return if el is document.body |
| 19 | el = el.parentElement | 19 | el = el.parentElement |
| 20 | 20 | ||
| 21 | $.closestLink = (el, parent = document.body) -> | 21 | $.closestLink = (el, parent = document.body) -> |
| 22 | return unless el and parent | 22 | 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 parent | 24 | return if el is parent |
| 26 | el = el.parentElement | 25 | el = el.parentElement |