fixup! Fixed issue #11651 (Do not fire a blur event when calling .focus() on a focused element)

This commit is contained in:
Davide Giovannini 2016-06-10 11:36:08 +02:00
parent 35aa24eb4c
commit 01c3640e5f
2 changed files with 20 additions and 22 deletions

View file

@ -598,7 +598,9 @@ impl Document {
/// Reassign the focus context to the element that last requested focus during this
/// transaction, or none if no elements requested it.
pub fn commit_focus_transaction(&self, focus_type: FocusType) {
if self.focused != self.possibly_focused.get().r() {
if self.focused == self.possibly_focused.get().r() {
return
}
if let Some(ref elem) = self.focused.get() {
let node = elem.upcast::<Node>();
elem.set_focus_state(false);
@ -621,7 +623,6 @@ impl Document {
}
}
}
}
/// Handles any updates when the document's title has changed.
pub fn title_changed(&self) {

View file

@ -251,9 +251,6 @@ impl HTMLElementMethods for HTMLElement {
fn Focus(&self) {
// TODO: Mark the element as locked for focus and run the focusing steps.
// https://html.spec.whatwg.org/multipage/#focusing-steps
if self.upcast::<Element>().focus_state() {
return;
}
let document = document_from_node(self);
document.begin_focus_transaction();
document.request_focus(self.upcast());