mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Fixed issue #11651 (Do not fire a blur event when calling .focus() on a focused element)
This commit is contained in:
parent
f56848a0e8
commit
35aa24eb4c
2 changed files with 22 additions and 17 deletions
|
@ -598,6 +598,7 @@ impl Document {
|
||||||
/// Reassign the focus context to the element that last requested focus during this
|
/// Reassign the focus context to the element that last requested focus during this
|
||||||
/// transaction, or none if no elements requested it.
|
/// transaction, or none if no elements requested it.
|
||||||
pub fn commit_focus_transaction(&self, focus_type: FocusType) {
|
pub fn commit_focus_transaction(&self, focus_type: FocusType) {
|
||||||
|
if self.focused != self.possibly_focused.get().r() {
|
||||||
if let Some(ref elem) = self.focused.get() {
|
if let Some(ref elem) = self.focused.get() {
|
||||||
let node = elem.upcast::<Node>();
|
let node = elem.upcast::<Node>();
|
||||||
elem.set_focus_state(false);
|
elem.set_focus_state(false);
|
||||||
|
@ -620,6 +621,7 @@ impl Document {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Handles any updates when the document's title has changed.
|
/// Handles any updates when the document's title has changed.
|
||||||
pub fn title_changed(&self) {
|
pub fn title_changed(&self) {
|
||||||
|
|
|
@ -251,6 +251,9 @@ impl HTMLElementMethods for HTMLElement {
|
||||||
fn Focus(&self) {
|
fn Focus(&self) {
|
||||||
// TODO: Mark the element as locked for focus and run the focusing steps.
|
// TODO: Mark the element as locked for focus and run the focusing steps.
|
||||||
// https://html.spec.whatwg.org/multipage/#focusing-steps
|
// https://html.spec.whatwg.org/multipage/#focusing-steps
|
||||||
|
if self.upcast::<Element>().focus_state() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
let document = document_from_node(self);
|
let document = document_from_node(self);
|
||||||
document.begin_focus_transaction();
|
document.begin_focus_transaction();
|
||||||
document.request_focus(self.upcast());
|
document.request_focus(self.upcast());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue