From 3da4194f98fa0c1ad1e5ab159719e4b25799e6d4 Mon Sep 17 00:00:00 2001 From: Vojta Jina Date: Sat, 16 Jun 2012 13:04:40 -0700 Subject: fix($location): url rewriting if element was removed When user clicks a link, $location needs to intercept this event. The doesn't have to be target element of the DOM event, so it needs to traverse the DOM, to find first parent. If the target element was removed from DOM, during the same event, it would throw an exception. This fixes the issue. Closes #1058--- src/ng/location.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/ng/location.js') diff --git a/src/ng/location.js b/src/ng/location.js index 727a0c2b..cf50952d 100644 --- a/src/ng/location.js +++ b/src/ng/location.js @@ -550,8 +550,8 @@ function $LocationProvider(){ // traverse the DOM up to find first A tag while (lowercase(elm[0].nodeName) !== 'a') { - if (elm[0] === $rootElement[0]) return; - elm = elm.parent(); + // ignore rewriting if no A tag (reached root element, or no parent - removed from document) + if (elm[0] === $rootElement[0] || !(elm = elm.parent())[0]) return; } var absHref = elm.prop('href'), -- cgit v1.2.3