Skip to content

Remove support for name attribute when hash routing #47954

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/Components/Web.JS/src/Services/NavigationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ function setHasLocationChangingListeners(hasListeners: boolean) {
}

export function scrollToElement(identifier: string): boolean {
const element = document.getElementById(identifier)
|| document.getElementsByName(identifier)[0];
const element = document.getElementById(identifier);

if (element) {
element.scrollIntoView();
Expand Down
8 changes: 4 additions & 4 deletions src/Components/test/E2ETest/Tests/RoutingTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1547,7 +1547,7 @@ public void CanNavigateBetweenPagesWithQueryStrings()
}

[Fact]
public void AnchorWithHrefContainingHashSamePage_ScrollsToElementWithIdOnTheSamePage()
public void AnchorWithHrefContainingHashSamePage_ScrollsToElementOnTheSamePage()
{
SetUrlViaPushState("/");
var app = Browser.MountTestComponent<TestRouter>();
Expand All @@ -1563,7 +1563,7 @@ public void AnchorWithHrefContainingHashSamePage_ScrollsToElementWithIdOnTheSame
}

[Fact]
public void AnchorWithHrefContainingHashAnotherPage_NavigatesToPageAndScrollsToElementWithName()
public void AnchorWithHrefContainingHashAnotherPage_NavigatesToPageAndScrollsToElement()
{
SetUrlViaPushState("/");
var app = Browser.MountTestComponent<TestRouter>();
Expand All @@ -1579,7 +1579,7 @@ public void AnchorWithHrefContainingHashAnotherPage_NavigatesToPageAndScrollsToE
}

[Fact]
public void NavigatationManagerNavigateToSameUrlWithHash_ScrollsToElementWithIdOnTheSamePage()
public void NavigatationManagerNavigateToSameUrlWithHash_ScrollsToElementOnTheSamePage()
{
SetUrlViaPushState("/");
var app = Browser.MountTestComponent<TestRouter>();
Expand All @@ -1595,7 +1595,7 @@ public void NavigatationManagerNavigateToSameUrlWithHash_ScrollsToElementWithIdO
}

[Fact]
public void NavigatationManagerNavigateToAnotherUrlWithHash_NavigatesToPageAndScrollsToElementWithName()
public void NavigatationManagerNavigateToAnotherUrlWithHash_NavigatesToPageAndScrollsToElement()
{
SetUrlViaPushState("/");
var app = Browser.MountTestComponent<TestRouter>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Scroll past me to find the links
</div>

<p name="test2">Test2</p>
<p id="test2">Test2</p>

<div style="border: 2px dashed blue; margin: 1rem; padding: 1rem; height: 1500px;">
Scroll past me to find the links
Expand Down