From bdc9cdc85d137e167c10d28a0364c4ad258f4196 Mon Sep 17 00:00:00 2001 From: Dean Sofer Date: Tue, 22 Jan 2013 01:13:46 -0800 Subject: [PATCH 1/9] feat(route) prototyping a new route checking directive --- modules/directives/route/route.js | 25 ++++++++++++++++++++++ modules/directives/route/test/routeSpec.js | 24 +++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 modules/directives/route/route.js create mode 100644 modules/directives/route/test/routeSpec.js diff --git a/modules/directives/route/route.js b/modules/directives/route/route.js new file mode 100644 index 0000000..cd9d635 --- /dev/null +++ b/modules/directives/route/route.js @@ -0,0 +1,25 @@ +/** + * Add a clear button to form inputs to reset their value + */ +angular.module('ui.directives').directive('uiRoute', ['ui.config', '$location', function (uiConfig, $location) { + if (uiConfig.route !== undefined) + routeClass = uiConfig.route; + else + routeClass = 'ui-active'; + return { + link: function ($scope, elm, attrs) { + var watcher; + function checkRoute() { + var regexp = new RegExp('^' + watcher + '$', ["i"]); + elm.toggleClass(routeClass, regexp.test($location.path())); + } + attrs.$observe('uiRoute', function(newVal) { + watcher = newVal; + checkRoute(); + }); + $scope.$on('$routeChangeSuccess', function(){ + checkRoute(); + }); + } + }; +}]); diff --git a/modules/directives/route/test/routeSpec.js b/modules/directives/route/test/routeSpec.js new file mode 100644 index 0000000..7432888 --- /dev/null +++ b/modules/directives/route/test/routeSpec.js @@ -0,0 +1,24 @@ +/*global describe, beforeEach, module, inject, it, spyOn, expect, $ */ +describe('uiReset', function () { + 'use strict'; + + var scope, $compile; + beforeEach(module('ui.directives')); + beforeEach(inject(function (_$rootScope_, _$compile_, _$window_) { + scope = _$rootScope_.$new(); + $compile = _$compile_; + })); + + describe('class toggle', function () { + it('should be triggered by changing interpolation value', function () { + }); + it('should be triggered by changing routes', function () { + }); + }); + describe('element class', function () { + it('should be "ui-active" by default', function () { + }); + it('should value set in uiConfig', function () { + }); + }); +}); \ No newline at end of file From 1e89e6987aa4943c97a8d91a8481aea169148d57 Mon Sep 17 00:00:00 2001 From: Dean Sofer Date: Thu, 24 Jan 2013 15:26:33 -0800 Subject: [PATCH 2/9] fix(route) working on fleshing out tests and refactoring structure --- modules/directives/route/route.js | 45 +++++++++----- modules/directives/route/test/routeSpec.js | 71 +++++++++++++++++++--- 2 files changed, 93 insertions(+), 23 deletions(-) diff --git a/modules/directives/route/route.js b/modules/directives/route/route.js index cd9d635..286c9cc 100644 --- a/modules/directives/route/route.js +++ b/modules/directives/route/route.js @@ -1,24 +1,41 @@ /** - * Add a clear button to form inputs to reset their value + * Set a $activeRoute boolean to see if the current route matches */ angular.module('ui.directives').directive('uiRoute', ['ui.config', '$location', function (uiConfig, $location) { - if (uiConfig.route !== undefined) - routeClass = uiConfig.route; - else - routeClass = 'ui-active'; return { + restrict: 'AC', + priority: 9999, link: function ($scope, elm, attrs) { - var watcher; - function checkRoute() { - var regexp = new RegExp('^' + watcher + '$', ["i"]); - elm.toggleClass(routeClass, regexp.test($location.path())); + var watcher = angular.noop; + + // Used by href and ngHref + function observeHref(newVal) { + watcher = function watchHref() { + $scope.$routeActive = ($location.path().indexOf(newVal) > -1); + }; + watcher(); } - attrs.$observe('uiRoute', function(newVal) { - watcher = newVal; - checkRoute(); - }); + + if (attrs.uiRoute) { + attrs.$observe('uiRoute', function(newVal) { + watcher = function watchRegex() { + var regexp = new RegExp('^' + watcher + '$', ["i"]); + $scope.$routeActive = regexp.test($location.path()); + }; + watcher(); + }); + } else if (attrs.ngHref) { + // Setup watcher() every time ngHref changes + attrs.$observe('ngHref', observeHref); + } else if (attrs.href) { + // Setup watcher() + observeHref(attrs.href); + } else { + throw new Error('uiRoute missing a route or href property on ' + elm[0]); + } + $scope.$on('$routeChangeSuccess', function(){ - checkRoute(); + watcher(); }); } }; diff --git a/modules/directives/route/test/routeSpec.js b/modules/directives/route/test/routeSpec.js index 7432888..a04e750 100644 --- a/modules/directives/route/test/routeSpec.js +++ b/modules/directives/route/test/routeSpec.js @@ -1,24 +1,77 @@ /*global describe, beforeEach, module, inject, it, spyOn, expect, $ */ -describe('uiReset', function () { +describe('uiRoute', function () { 'use strict'; - var scope, $compile; + var scope, $compile, $location; beforeEach(module('ui.directives')); - beforeEach(inject(function (_$rootScope_, _$compile_, _$window_) { + beforeEach(inject(function (_$rootScope_, _$compile_, _$window_, _$location_) { scope = _$rootScope_.$new(); $compile = _$compile_; + $location = _$location_; })); - describe('class toggle', function () { - it('should be triggered by changing interpolation value', function () { + describe('with uiRoute defined', function(){ + it('should use the uiRoute property', function(){ + $compile('
')(scope); }); - it('should be triggered by changing routes', function () { + it('should update $activeRoute on $observe', function(){ + $location.path('/bar'); + scope.$apply('foobar = "foo"'); + $compile('
')(scope); + expect(scope.$activeRoute).toBeFalsy(); + scope.$apply('foobar = "bar"'); + expect(scope.$activeRoute).toBe(true); + scope.$apply('foobar = "foo"'); + expect(scope.$activeRoute).toBe(false); + }); + it('should support regular expression', function(){ + $location.path('/foo/123'); + $compile('
')(scope); + expect(scope.$activeRoute).toBe(true); }); }); - describe('element class', function () { - it('should be "ui-active" by default', function () { + + describe('with ngHref defined', function(){ + + it('should use the ngHref property', function(){ + $location.path('/foo'); + $compile('')(scope); + expect(scope.$activeRoute).toBe(true); }); - it('should value set in uiConfig', function () { + it('should update $activeRoute on $observe', function(){ + $location.path('/bar'); + scope.$apply('foobar = "foo"'); + $compile('')(scope); + expect(scope.$activeRoute).toBeFalsy(); + scope.$apply('foobar = "bar"'); + expect(scope.$activeRoute).toBe(true); + scope.$apply('foobar = "foo"'); + expect(scope.$activeRoute).toBe(false); }); }); + + describe('with href defined', function(){ + + it('should use the href property', function(){ + $location.path('/foo'); + $compile('')(scope); + expect(scope.$activeRoute).toBe(true); + }); + }); + + it('should throw an error if no route property available', function(){ + expect(function(){ + $compile('
')(scope); + }).toThrow(); + }); + + it('should update $activeRoute on route change', function(){ + $location.path('/bar'); + $compile('
')(scope); + expect(scope.$activeRoute).toBeFalsy(); + $location.path('/foo'); + expect(scope.$activeRoute).toBe(true); + $location.path('/bar'); + expect(scope.$activeRoute).toBe(false); + }); }); \ No newline at end of file From 834557e1cbaa954900c53b02dfd795158dc17019 Mon Sep 17 00:00:00 2001 From: Dean Sofer Date: Thu, 24 Jan 2013 15:46:36 -0800 Subject: [PATCH 3/9] fix(route) adjusted priority and added comment --- modules/directives/route/route.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/directives/route/route.js b/modules/directives/route/route.js index 286c9cc..df670e3 100644 --- a/modules/directives/route/route.js +++ b/modules/directives/route/route.js @@ -4,7 +4,7 @@ angular.module('ui.directives').directive('uiRoute', ['ui.config', '$location', function (uiConfig, $location) { return { restrict: 'AC', - priority: 9999, + priority: 100, // must occur before attrs.ngHref is removed link: function ($scope, elm, attrs) { var watcher = angular.noop; From f0ea1a4cc2c53e0b1f1ba3cb90fa740e5d5b446c Mon Sep 17 00:00:00 2001 From: Dean Sofer Date: Thu, 24 Jan 2013 16:58:24 -0800 Subject: [PATCH 4/9] Corrected uiRoute regex --- modules/directives/route/route.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/directives/route/route.js b/modules/directives/route/route.js index df670e3..7bdd155 100644 --- a/modules/directives/route/route.js +++ b/modules/directives/route/route.js @@ -1,7 +1,7 @@ /** * Set a $activeRoute boolean to see if the current route matches */ -angular.module('ui.directives').directive('uiRoute', ['ui.config', '$location', function (uiConfig, $location) { +angular.module('ui.directives').directive('uiRoute', ['$location', function ($location) { return { restrict: 'AC', priority: 100, // must occur before attrs.ngHref is removed @@ -19,7 +19,7 @@ angular.module('ui.directives').directive('uiRoute', ['ui.config', '$location', if (attrs.uiRoute) { attrs.$observe('uiRoute', function(newVal) { watcher = function watchRegex() { - var regexp = new RegExp('^' + watcher + '$', ["i"]); + var regexp = new RegExp('^' + newVal + '$', ['i']); $scope.$routeActive = regexp.test($location.path()); }; watcher(); From ad322e517a86eaa6e88f68eee0579029aec3ae4d Mon Sep 17 00:00:00 2001 From: Dean Sofer Date: Thu, 24 Jan 2013 17:18:45 -0800 Subject: [PATCH 5/9] fix(route) added support for # and changed flag to $uiRoute --- modules/directives/route/route.js | 13 +++++++--- modules/directives/route/test/routeSpec.js | 30 +++++++++++----------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/modules/directives/route/route.js b/modules/directives/route/route.js index 7bdd155..0f5db7a 100644 --- a/modules/directives/route/route.js +++ b/modules/directives/route/route.js @@ -1,26 +1,31 @@ /** - * Set a $activeRoute boolean to see if the current route matches + * Set a $uiRoute boolean to see if the current route matches */ angular.module('ui.directives').directive('uiRoute', ['$location', function ($location) { return { restrict: 'AC', priority: 100, // must occur before attrs.ngHref is removed + scope: false, link: function ($scope, elm, attrs) { var watcher = angular.noop; // Used by href and ngHref function observeHref(newVal) { + if ((hash = newVal.indexOf('#')) > -1) + newVal = newVal.substr(hash + 1); watcher = function watchHref() { - $scope.$routeActive = ($location.path().indexOf(newVal) > -1); + $scope.$uiRoute = ($location.path().indexOf(newVal) > -1); }; watcher(); } if (attrs.uiRoute) { attrs.$observe('uiRoute', function(newVal) { + if ((hash = newVal.indexOf('#')) > -1) + newVal = newVal.substr(hash + 1); watcher = function watchRegex() { var regexp = new RegExp('^' + newVal + '$', ['i']); - $scope.$routeActive = regexp.test($location.path()); + $scope.$uiRoute = regexp.test($location.path()); }; watcher(); }); @@ -39,4 +44,4 @@ angular.module('ui.directives').directive('uiRoute', ['$location', function ($lo }); } }; -}]); +}]); \ No newline at end of file diff --git a/modules/directives/route/test/routeSpec.js b/modules/directives/route/test/routeSpec.js index a04e750..c962771 100644 --- a/modules/directives/route/test/routeSpec.js +++ b/modules/directives/route/test/routeSpec.js @@ -14,20 +14,20 @@ describe('uiRoute', function () { it('should use the uiRoute property', function(){ $compile('
')(scope); }); - it('should update $activeRoute on $observe', function(){ + it('should update $uiRoute on $observe', function(){ $location.path('/bar'); scope.$apply('foobar = "foo"'); $compile('
')(scope); - expect(scope.$activeRoute).toBeFalsy(); + expect(scope.$uiRoute).toBeFalsy(); scope.$apply('foobar = "bar"'); - expect(scope.$activeRoute).toBe(true); + expect(scope.$uiRoute).toBe(true); scope.$apply('foobar = "foo"'); - expect(scope.$activeRoute).toBe(false); + expect(scope.$uiRoute).toBe(false); }); it('should support regular expression', function(){ $location.path('/foo/123'); $compile('
')(scope); - expect(scope.$activeRoute).toBe(true); + expect(scope.$uiRoute).toBe(true); }); }); @@ -36,17 +36,17 @@ describe('uiRoute', function () { it('should use the ngHref property', function(){ $location.path('/foo'); $compile('')(scope); - expect(scope.$activeRoute).toBe(true); + expect(scope.$uiRoute).toBe(true); }); - it('should update $activeRoute on $observe', function(){ + it('should update $uiRoute on $observe', function(){ $location.path('/bar'); scope.$apply('foobar = "foo"'); $compile('')(scope); - expect(scope.$activeRoute).toBeFalsy(); + expect(scope.$uiRoute).toBeFalsy(); scope.$apply('foobar = "bar"'); - expect(scope.$activeRoute).toBe(true); + expect(scope.$uiRoute).toBe(true); scope.$apply('foobar = "foo"'); - expect(scope.$activeRoute).toBe(false); + expect(scope.$uiRoute).toBe(false); }); }); @@ -55,7 +55,7 @@ describe('uiRoute', function () { it('should use the href property', function(){ $location.path('/foo'); $compile('')(scope); - expect(scope.$activeRoute).toBe(true); + expect(scope.$uiRoute).toBe(true); }); }); @@ -65,13 +65,13 @@ describe('uiRoute', function () { }).toThrow(); }); - it('should update $activeRoute on route change', function(){ + it('should update $uiRoute on route change', function(){ $location.path('/bar'); $compile('
')(scope); - expect(scope.$activeRoute).toBeFalsy(); + expect(scope.$uiRoute).toBeFalsy(); $location.path('/foo'); - expect(scope.$activeRoute).toBe(true); + expect(scope.$uiRoute).toBe(true); $location.path('/bar'); - expect(scope.$activeRoute).toBe(false); + expect(scope.$uiRoute).toBe(false); }); }); \ No newline at end of file From f932ee9d75fc0f4f715bda89a3241f3ab428492c Mon Sep 17 00:00:00 2001 From: Dean Sofer Date: Thu, 24 Jan 2013 17:30:54 -0800 Subject: [PATCH 6/9] fix(route) Hack to work around attrs.uiRoute being undefined (YOU LYING BASTARD) --- modules/directives/route/route.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/directives/route/route.js b/modules/directives/route/route.js index 0f5db7a..d222be6 100644 --- a/modules/directives/route/route.js +++ b/modules/directives/route/route.js @@ -5,7 +5,6 @@ angular.module('ui.directives').directive('uiRoute', ['$location', function ($lo return { restrict: 'AC', priority: 100, // must occur before attrs.ngHref is removed - scope: false, link: function ($scope, elm, attrs) { var watcher = angular.noop; @@ -19,7 +18,7 @@ angular.module('ui.directives').directive('uiRoute', ['$location', function ($lo watcher(); } - if (attrs.uiRoute) { + if (elm.attr(attrs.$attr.uiRoute)) { attrs.$observe('uiRoute', function(newVal) { if ((hash = newVal.indexOf('#')) > -1) newVal = newVal.substr(hash + 1); From 8438919c18693ed9b7e9e9400a753aec3b81580f Mon Sep 17 00:00:00 2001 From: Dean Sofer Date: Thu, 24 Jan 2013 18:21:47 -0800 Subject: [PATCH 7/9] Checking properties at compile time instead of link time --- modules/directives/route/route.js | 70 ++++++++++++++++++------------- 1 file changed, 41 insertions(+), 29 deletions(-) diff --git a/modules/directives/route/route.js b/modules/directives/route/route.js index d222be6..01b0fb5 100644 --- a/modules/directives/route/route.js +++ b/modules/directives/route/route.js @@ -4,43 +4,55 @@ angular.module('ui.directives').directive('uiRoute', ['$location', function ($location) { return { restrict: 'AC', - priority: 100, // must occur before attrs.ngHref is removed - link: function ($scope, elm, attrs) { - var watcher = angular.noop; - - // Used by href and ngHref - function observeHref(newVal) { - if ((hash = newVal.indexOf('#')) > -1) - newVal = newVal.substr(hash + 1); - watcher = function watchHref() { - $scope.$uiRoute = ($location.path().indexOf(newVal) > -1); - }; - watcher(); + compile: function(tElement, tAttrs) { + var useProperty; + if (tAttrs.uiRoute) { + useProperty = 'uiRoute'; + } else if (tAttrs.ngHref) { + useProperty = 'ngHref'; + } else if (tAttrs.href) { + useProperty = 'href'; + } else { + throw new Error('uiRoute missing a route or href property on ' + elm[0]); } + return function ($scope, elm, attrs) { + var watcher = angular.noop; - if (elm.attr(attrs.$attr.uiRoute)) { - attrs.$observe('uiRoute', function(newVal) { + // Used by href and ngHref + function observeHref(newVal) { if ((hash = newVal.indexOf('#')) > -1) newVal = newVal.substr(hash + 1); - watcher = function watchRegex() { - var regexp = new RegExp('^' + newVal + '$', ['i']); - $scope.$uiRoute = regexp.test($location.path()); + watcher = function watchHref() { + $scope.$uiRoute = ($location.path().indexOf(newVal) > -1); }; watcher(); + } + + switch (useProperty) { + case 'uiRoute': + attrs.$observe('uiRoute', function(newVal) { + if ((hash = newVal.indexOf('#')) > -1) + newVal = newVal.substr(hash + 1); + watcher = function watchRegex() { + var regexp = new RegExp('^' + newVal + '$', ['i']); + $scope.$uiRoute = regexp.test($location.path()); + }; + watcher(); + }); + break; + case 'ngHref': + // Setup watcher() every time ngHref changes + attrs.$observe('ngHref', observeHref); + break; + case 'href': + // Setup watcher() + observeHref(attrs.href); + } + + $scope.$on('$routeChangeSuccess', function(){ + watcher(); }); - } else if (attrs.ngHref) { - // Setup watcher() every time ngHref changes - attrs.$observe('ngHref', observeHref); - } else if (attrs.href) { - // Setup watcher() - observeHref(attrs.href); - } else { - throw new Error('uiRoute missing a route or href property on ' + elm[0]); } - - $scope.$on('$routeChangeSuccess', function(){ - watcher(); - }); } }; }]); \ No newline at end of file From 54f89c1d8bfc4c99004abd61fa8703fbc82ed2b1 Mon Sep 17 00:00:00 2001 From: Dean Sofer Date: Thu, 24 Jan 2013 18:45:26 -0800 Subject: [PATCH 8/9] fix(route) slowly working towards success! --- modules/directives/route/route.js | 31 +++++++++++++--------- modules/directives/route/test/routeSpec.js | 22 +++++++++------ 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/modules/directives/route/route.js b/modules/directives/route/route.js index 01b0fb5..fd312b9 100644 --- a/modules/directives/route/route.js +++ b/modules/directives/route/route.js @@ -19,7 +19,7 @@ angular.module('ui.directives').directive('uiRoute', ['$location', function ($lo var watcher = angular.noop; // Used by href and ngHref - function observeHref(newVal) { + function staticWatcher(newVal) { if ((hash = newVal.indexOf('#')) > -1) newVal = newVal.substr(hash + 1); watcher = function watchHref() { @@ -27,26 +27,33 @@ angular.module('ui.directives').directive('uiRoute', ['$location', function ($lo }; watcher(); } + // Used by uiRoute + function regexWatcher(newVal) { + if ((hash = newVal.indexOf('#')) > -1) + newVal = newVal.substr(hash + 1); + watcher = function watchRegex() { + var regexp = new RegExp('^' + newVal + '$', ['i']); + $scope.$uiRoute = regexp.test($location.path()); + }; + watcher(); + } switch (useProperty) { case 'uiRoute': - attrs.$observe('uiRoute', function(newVal) { - if ((hash = newVal.indexOf('#')) > -1) - newVal = newVal.substr(hash + 1); - watcher = function watchRegex() { - var regexp = new RegExp('^' + newVal + '$', ['i']); - $scope.$uiRoute = regexp.test($location.path()); - }; - watcher(); - }); + // if uiRoute={{}} this will be undefined, otherwise it will have a value and $observe() never gets triggered + if (attrs.uiRoute) { + regexWatcher(attrs.uiRoute); + } else { + attrs.$observe('uiRoute', regexWatcher); + } break; case 'ngHref': // Setup watcher() every time ngHref changes - attrs.$observe('ngHref', observeHref); + attrs.$observe('ngHref', staticWatcher); break; case 'href': // Setup watcher() - observeHref(attrs.href); + staticWatcher(attrs.href); } $scope.$on('$routeChangeSuccess', function(){ diff --git a/modules/directives/route/test/routeSpec.js b/modules/directives/route/test/routeSpec.js index c962771..8a1e299 100644 --- a/modules/directives/route/test/routeSpec.js +++ b/modules/directives/route/test/routeSpec.js @@ -10,12 +10,17 @@ describe('uiRoute', function () { $location = _$location_; })); + function setPath(path) { + $location.path(path); + scope.$apply(); + } + describe('with uiRoute defined', function(){ it('should use the uiRoute property', function(){ $compile('
')(scope); }); it('should update $uiRoute on $observe', function(){ - $location.path('/bar'); + setPath('/bar'); scope.$apply('foobar = "foo"'); $compile('
')(scope); expect(scope.$uiRoute).toBeFalsy(); @@ -25,7 +30,7 @@ describe('uiRoute', function () { expect(scope.$uiRoute).toBe(false); }); it('should support regular expression', function(){ - $location.path('/foo/123'); + setPath('/foo/123'); $compile('
')(scope); expect(scope.$uiRoute).toBe(true); }); @@ -34,12 +39,13 @@ describe('uiRoute', function () { describe('with ngHref defined', function(){ it('should use the ngHref property', function(){ - $location.path('/foo'); + setPath('/foo'); + scope.$apply(); $compile('')(scope); expect(scope.$uiRoute).toBe(true); }); it('should update $uiRoute on $observe', function(){ - $location.path('/bar'); + setPath('/bar'); scope.$apply('foobar = "foo"'); $compile('')(scope); expect(scope.$uiRoute).toBeFalsy(); @@ -53,7 +59,7 @@ describe('uiRoute', function () { describe('with href defined', function(){ it('should use the href property', function(){ - $location.path('/foo'); + setPath('/foo'); $compile('')(scope); expect(scope.$uiRoute).toBe(true); }); @@ -66,12 +72,12 @@ describe('uiRoute', function () { }); it('should update $uiRoute on route change', function(){ - $location.path('/bar'); + setPath('/bar'); $compile('
')(scope); expect(scope.$uiRoute).toBeFalsy(); - $location.path('/foo'); + setPath('/foo'); expect(scope.$uiRoute).toBe(true); - $location.path('/bar'); + setPath('/bar'); expect(scope.$uiRoute).toBe(false); }); }); \ No newline at end of file From 6771078c878268ad15a382f06da8954f3a1b6168 Mon Sep 17 00:00:00 2001 From: Dean Sofer Date: Thu, 24 Jan 2013 18:55:13 -0800 Subject: [PATCH 9/9] fix(route) FINALLY completed ui-route directive --- modules/directives/route/route.js | 10 ++++++---- modules/directives/route/test/routeSpec.js | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/modules/directives/route/route.js b/modules/directives/route/route.js index fd312b9..19029cb 100644 --- a/modules/directives/route/route.js +++ b/modules/directives/route/route.js @@ -41,15 +41,17 @@ angular.module('ui.directives').directive('uiRoute', ['$location', function ($lo switch (useProperty) { case 'uiRoute': // if uiRoute={{}} this will be undefined, otherwise it will have a value and $observe() never gets triggered - if (attrs.uiRoute) { + if (attrs.uiRoute) regexWatcher(attrs.uiRoute); - } else { + else attrs.$observe('uiRoute', regexWatcher); - } break; case 'ngHref': // Setup watcher() every time ngHref changes - attrs.$observe('ngHref', staticWatcher); + if (attrs.ngHref) + staticWatcher(attrs.ngHref); + else + attrs.$observe('ngHref', staticWatcher); break; case 'href': // Setup watcher() diff --git a/modules/directives/route/test/routeSpec.js b/modules/directives/route/test/routeSpec.js index 8a1e299..cdc7511 100644 --- a/modules/directives/route/test/routeSpec.js +++ b/modules/directives/route/test/routeSpec.js @@ -12,6 +12,7 @@ describe('uiRoute', function () { function setPath(path) { $location.path(path); + scope.$broadcast('$routeChangeSuccess'); scope.$apply(); } @@ -38,9 +39,8 @@ describe('uiRoute', function () { describe('with ngHref defined', function(){ - it('should use the ngHref property', function(){ + iit('should use the ngHref property', function(){ setPath('/foo'); - scope.$apply(); $compile('')(scope); expect(scope.$uiRoute).toBe(true); });