Skip to content

Commit d49ad7c

Browse files
Relax blur conditions when removing href attribute
Removing the href attribute from an anchor element was almost always causing it to be blurred, even if it is still focusable. This patch changes the logic to consult focusability before blurring. Fixed: 443585794 Change-Id: Id9bef50d4d5db8b266464c595e8b2e56dc75cc61 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6944690 Commit-Queue: Mason Freed <[email protected]> Auto-Submit: Joey Arhar <[email protected]> Reviewed-by: Mason Freed <[email protected]> Cr-Commit-Position: refs/heads/main@{#1520081}
1 parent 8f2316d commit d49ad7c

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

focus/anchor-remove-href.html

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!DOCTYPE html>
2+
<link rel=author href="mailto:[email protected]">
3+
<link rel=help href="https://issues.chromium.org/issues/443585794">
4+
<script src="/resources/testharness.js"></script>
5+
<script src="/resources/testharnessreport.js"></script>
6+
7+
<a href="#">anchor tag</a>
8+
9+
<script>
10+
promise_test(async () => {
11+
const anchor = document.querySelector('a');
12+
anchor.focus();
13+
assert_equals(document.activeElement, anchor,
14+
'anchor should be focused at the start of the test.');
15+
16+
anchor.removeAttribute('href');
17+
anchor.setAttribute('tabindex', '0');
18+
assert_equals(document.activeElement, anchor,
19+
'anchor should be focused after removing href.');
20+
21+
await new Promise(requestAnimationFrame);
22+
await new Promise(requestAnimationFrame);
23+
24+
assert_equals(document.activeElement, anchor,
25+
'anchor should still be focused after a double rAF.');
26+
}, 'anchor element should remain focused after removing href attribute.');
27+
</script>

0 commit comments

Comments
 (0)