Tiny simplification to NavLink
This commit is contained in:
parent
d388cb6510
commit
f4e0d663fa
|
|
@ -56,19 +56,15 @@ namespace Microsoft.AspNetCore.Blazor.Browser.Routing
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
// To avoid leaking memory, it's important to detach any event handlers
|
// To avoid leaking memory, it's important to detach any event handlers in Dispose()
|
||||||
// in Dispose().
|
|
||||||
UriHelper.OnLocationChanged -= OnLocationChanged;
|
UriHelper.OnLocationChanged -= OnLocationChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnLocationChanged(object sender, string e)
|
private void OnLocationChanged(object sender, string newUri)
|
||||||
{
|
{
|
||||||
// We could just re-render always, but for this component we know the
|
// We could just re-render always, but for this component we know the
|
||||||
// only relevant state change is to the _isActive property.
|
// only relevant state change is to the _isActive property.
|
||||||
var shouldBeActiveNow = UriHelper.GetAbsoluteUri().Equals(
|
var shouldBeActiveNow = newUri.Equals(_hrefAbsolute, StringComparison.Ordinal);
|
||||||
_hrefAbsolute,
|
|
||||||
StringComparison.Ordinal);
|
|
||||||
|
|
||||||
if (shouldBeActiveNow != _isActive)
|
if (shouldBeActiveNow != _isActive)
|
||||||
{
|
{
|
||||||
_isActive = shouldBeActiveNow;
|
_isActive = shouldBeActiveNow;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue