Commit ef80b9a6 authored by tkent's avatar tkent Committed by Commit bot

Updating href attribute should not blur.

In HTMLAnchorElement::attributeChanged,

    params.name != hrefAttr && isLink()

should have been

    params.name != hrefAttr || isLink()

This CL fixes it, and improves code readability.

BUG=679669

Review-Url: https://codereview.chromium.org/2623163002
Cr-Commit-Position: refs/heads/master@{#442855}
parent cb36c493
PASS document.activeElement is target
Remove href.
PASS document.activeElement is target
PASS document.activeElement is document.body
Update href.
PASS document.activeElement is target
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -5,12 +5,19 @@
<script>
jsTestIsAsync = true;
var target = document.getElementById('target');
target.focus();
shouldBe('document.activeElement', 'target');
debug('Remove href.');
window.onload = function() {
debug('Remove href.');
target.focus();
shouldBe('document.activeElement', 'target');
target.removeAttribute('href');
shouldBe('document.activeElement', 'document.body');
debug('Update href.');
target.href = 'javascript:';
target.focus();
target.href = 'javascript:undefined';
shouldBe('document.activeElement', 'target');
target.remove();
finishJSTest();
};
......
......@@ -256,10 +256,9 @@ void HTMLAnchorElement::attributeChanged(
HTMLElement::attributeChanged(params);
if (params.reason != AttributeModificationReason::kDirectly)
return;
if (params.name != hrefAttr && isLink())
return;
if (adjustedFocusedElementInTreeScope() != this)
if (params.name != hrefAttr)
return;
if (!isLink() && adjustedFocusedElementInTreeScope() == this)
blur();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment