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. Remove href.
PASS document.activeElement is target
PASS document.activeElement is document.body PASS document.activeElement is document.body
Update href.
PASS document.activeElement is target
PASS successfullyParsed is true PASS successfullyParsed is true
TEST COMPLETE TEST COMPLETE
......
...@@ -5,12 +5,19 @@ ...@@ -5,12 +5,19 @@
<script> <script>
jsTestIsAsync = true; jsTestIsAsync = true;
var target = document.getElementById('target'); var target = document.getElementById('target');
target.focus();
shouldBe('document.activeElement', 'target');
debug('Remove href.');
window.onload = function() { window.onload = function() {
debug('Remove href.');
target.focus();
shouldBe('document.activeElement', 'target');
target.removeAttribute('href'); target.removeAttribute('href');
shouldBe('document.activeElement', 'document.body'); shouldBe('document.activeElement', 'document.body');
debug('Update href.');
target.href = 'javascript:';
target.focus();
target.href = 'javascript:undefined';
shouldBe('document.activeElement', 'target');
target.remove(); target.remove();
finishJSTest(); finishJSTest();
}; };
......
...@@ -256,10 +256,9 @@ void HTMLAnchorElement::attributeChanged( ...@@ -256,10 +256,9 @@ void HTMLAnchorElement::attributeChanged(
HTMLElement::attributeChanged(params); HTMLElement::attributeChanged(params);
if (params.reason != AttributeModificationReason::kDirectly) if (params.reason != AttributeModificationReason::kDirectly)
return; return;
if (params.name != hrefAttr && isLink()) if (params.name != hrefAttr)
return;
if (adjustedFocusedElementInTreeScope() != this)
return; return;
if (!isLink() && adjustedFocusedElementInTreeScope() == this)
blur(); 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