Skip to content

Commit 1e39822

Browse files
authored
Remove support for name attribute when hash routing (#47954)
* remove support for name attribute for hash routing
1 parent 64e4c50 commit 1e39822

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

src/Components/Web.JS/src/Services/NavigationManager.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ function setHasLocationChangingListeners(hasListeners: boolean) {
5555
}
5656

5757
export function scrollToElement(identifier: string): boolean {
58-
const element = document.getElementById(identifier)
59-
|| document.getElementsByName(identifier)[0];
58+
const element = document.getElementById(identifier);
6059

6160
if (element) {
6261
element.scrollIntoView();

src/Components/test/E2ETest/Tests/RoutingTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,7 +1547,7 @@ public void CanNavigateBetweenPagesWithQueryStrings()
15471547
}
15481548

15491549
[Fact]
1550-
public void AnchorWithHrefContainingHashSamePage_ScrollsToElementWithIdOnTheSamePage()
1550+
public void AnchorWithHrefContainingHashSamePage_ScrollsToElementOnTheSamePage()
15511551
{
15521552
SetUrlViaPushState("/");
15531553
var app = Browser.MountTestComponent<TestRouter>();
@@ -1563,7 +1563,7 @@ public void AnchorWithHrefContainingHashSamePage_ScrollsToElementWithIdOnTheSame
15631563
}
15641564

15651565
[Fact]
1566-
public void AnchorWithHrefContainingHashAnotherPage_NavigatesToPageAndScrollsToElementWithName()
1566+
public void AnchorWithHrefContainingHashAnotherPage_NavigatesToPageAndScrollsToElement()
15671567
{
15681568
SetUrlViaPushState("/");
15691569
var app = Browser.MountTestComponent<TestRouter>();
@@ -1579,7 +1579,7 @@ public void AnchorWithHrefContainingHashAnotherPage_NavigatesToPageAndScrollsToE
15791579
}
15801580

15811581
[Fact]
1582-
public void NavigatationManagerNavigateToSameUrlWithHash_ScrollsToElementWithIdOnTheSamePage()
1582+
public void NavigatationManagerNavigateToSameUrlWithHash_ScrollsToElementOnTheSamePage()
15831583
{
15841584
SetUrlViaPushState("/");
15851585
var app = Browser.MountTestComponent<TestRouter>();
@@ -1595,7 +1595,7 @@ public void NavigatationManagerNavigateToSameUrlWithHash_ScrollsToElementWithIdO
15951595
}
15961596

15971597
[Fact]
1598-
public void NavigatationManagerNavigateToAnotherUrlWithHash_NavigatesToPageAndScrollsToElementWithName()
1598+
public void NavigatationManagerNavigateToAnotherUrlWithHash_NavigatesToPageAndScrollsToElement()
15991599
{
16001600
SetUrlViaPushState("/");
16011601
var app = Browser.MountTestComponent<TestRouter>();

src/Components/test/testassets/BasicTestApp/RouterTest/LongPageWithHash2.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Scroll past me to find the links
66
</div>
77

8-
<p name="test2">Test2</p>
8+
<p id="test2">Test2</p>
99

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

0 commit comments

Comments
 (0)