Skip to content

Commit db3103d

Browse files
committed
Added deep equality check for link url change
1 parent 08958c0 commit db3103d

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

package-lock.json

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@
2424
"ngPackage": {
2525
"lib": {
2626
"entryFile": "public_api.ts"
27-
}
27+
},
28+
"whitelistedNonPeerDependencies": [
29+
"fast-deep-equal"
30+
]
2831
},
2932
"repository": {
3033
"type": "git",
@@ -52,5 +55,8 @@
5255
"prettier": "^1.15.3",
5356
"rxjs": "^6.5.3",
5457
"typescript": "^4.1.0"
58+
},
59+
"dependencies": {
60+
"fast-deep-equal": "^3.1.3"
5561
}
5662
}

src/link.directive.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
SimpleChanges
1010
} from '@angular/core';
1111
import { RouterLink, RouterLinkWithHref } from '@angular/router';
12+
import * as isEqual from 'fast-deep-equal';
1213
import { LinkHandler } from './link-handler.service';
1314
import { LinkHandlerStrategy } from './link-handler-strategy';
1415

@@ -34,7 +35,7 @@ export class LinkDirective implements OnChanges, OnDestroy {
3435
}
3536

3637
ngOnChanges(c: SimpleChanges) {
37-
if (c.routerLink) {
38+
if (c.routerLink && !isEqual(c.routerLink.currentValue, c.routerLink.previousValue)) {
3839
this.linkHandler.unregister(this);
3940
this.linkHandler.register(this);
4041
}

0 commit comments

Comments
 (0)