fix(aio): support multibyte character in heading (#21414)
PR Close #21414
This commit is contained in:
parent
0de219adcd
commit
f15ca6ce50
@ -136,6 +136,17 @@ describe('ScrollService', () => {
|
||||
expect(element.scrollIntoView).toHaveBeenCalled();
|
||||
expect(window.scrollBy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should scroll to the element whose id matches the hash with encoded characters', () => {
|
||||
const element = new MockElement();
|
||||
location.hash = '%F0%9F%91%8D'; // 👍
|
||||
document.getElementById.and.returnValue(element);
|
||||
|
||||
scrollService.scroll();
|
||||
expect(document.getElementById).toHaveBeenCalledWith('👍');
|
||||
expect(element.scrollIntoView).toHaveBeenCalled();
|
||||
expect(window.scrollBy).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('#scrollToElement', () => {
|
||||
|
@ -83,6 +83,6 @@ export class ScrollService {
|
||||
* Return the hash fragment from the `PlatformLocation`, minus the leading `#`.
|
||||
*/
|
||||
private getCurrentHash() {
|
||||
return this.location.hash.replace(/^#/, '');
|
||||
return decodeURIComponent(this.location.hash.replace(/^#/, ''));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user