Skip to content

Commit

Permalink
fixes issue artch#15
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffreyPalmer committed Oct 17, 2013
1 parent 985f1ec commit 852f8b0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/route-segment.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,10 @@ angular.module( 'route-segment', [] ).provider( '$routeSegment',

var newSegment = getSegmentInChain( i, segmentNameChain );

if(resolvingSemaphoreChain[i] != newSegment.name || isDependenciesChanged(newSegment)) {
if(resolvingSemaphoreChain[i] != newSegment.name || updates.length > 0 || isDependenciesChanged(newSegment)) {

if($routeSegment.chain[i] && $routeSegment.chain[i].name == newSegment.name &&
!isDependenciesChanged(newSegment))
updates.length == 0 && !isDependenciesChanged(newSegment))
// if we went back to the same state as we were before resolving new segment
resolvingSemaphoreChain[i] = newSegment.name;
else
Expand Down
24 changes: 24 additions & 0 deletions test/unit/view-segment.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,30 @@ describe('view-segment', function() {
expect(elm.find('> div > div > h4').text()).toBe('Details item 2');
}))

it('should recreate when parent segment is changed and sub-segment name is the same', inject(function() {

$routeSegmentProvider.when('/1/details', 'section1.details');
$routeSegmentProvider.when('/2/details', 'section2.details');
$routeSegmentProvider.segment('section1', {
template: '<div app:view-segment="1"></div>'})
$routeSegmentProvider.segment('section1', {
template: '<div app:view-segment="1"></div>'})
$routeSegmentProvider.within('section1').segment('details', {
template: '<h4>Detail 1</h4>'})
$routeSegmentProvider.within('section2').segment('details', {
template: '<h4>Detail 2</h4>'})

$location.path('/1/details');
$rootScope.$digest();

expect(elm.find('> div >div > h4').text()).toBe('Detail 1');

$location.path('/2/details');
$rootScope.$digest();

expect(elm.find('> div > div > h4').text()).toBe('Detail 2');
}))

it('should populate a view initially, when location is already set before compiling', function() {
$location.path('/1');
$rootScope.$digest();
Expand Down

0 comments on commit 852f8b0

Please sign in to comment.