mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Implement cannot navigate
This commit is contained in:
parent
9d70f51356
commit
cb86d451e6
4 changed files with 26 additions and 12 deletions
|
@ -3235,6 +3235,18 @@ impl Element {
|
||||||
let root = node.GetRootNode();
|
let root = node.GetRootNode();
|
||||||
root.is::<Document>()
|
root.is::<Document>()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/#cannot-navigate
|
||||||
|
pub fn cannot_navigate(&self) -> bool {
|
||||||
|
let document = document_from_node(self);
|
||||||
|
|
||||||
|
// Step 1.
|
||||||
|
!document.is_fully_active() ||
|
||||||
|
(
|
||||||
|
// Step 2.
|
||||||
|
!self.is::<HTMLAnchorElement>() && !self.is_connected()
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Element {
|
impl Element {
|
||||||
|
|
|
@ -317,7 +317,11 @@ impl HTMLFormElement {
|
||||||
|
|
||||||
/// [Form submission](https://html.spec.whatwg.org/multipage/#concept-form-submit)
|
/// [Form submission](https://html.spec.whatwg.org/multipage/#concept-form-submit)
|
||||||
pub fn submit(&self, submit_method_flag: SubmittedFrom, submitter: FormSubmitter) {
|
pub fn submit(&self, submit_method_flag: SubmittedFrom, submitter: FormSubmitter) {
|
||||||
// TODO: Step 1. If form cannot navigate , then return.
|
// Step 1
|
||||||
|
if self.upcast::<Element>().cannot_navigate() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Step 2
|
// Step 2
|
||||||
if self.constructing_entry_list.get() {
|
if self.constructing_entry_list.get() {
|
||||||
return;
|
return;
|
||||||
|
@ -342,6 +346,11 @@ impl HTMLFormElement {
|
||||||
if event.DefaultPrevented() {
|
if event.DefaultPrevented() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Step 7-3
|
||||||
|
if self.upcast::<Element>().cannot_navigate() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 8
|
// Step 8
|
||||||
|
@ -353,7 +362,10 @@ impl HTMLFormElement {
|
||||||
None => return,
|
None => return,
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: Step 10. If form cannot navigate, then return.
|
// Step 10
|
||||||
|
if self.upcast::<Element>().cannot_navigate() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Step 11
|
// Step 11
|
||||||
let mut action = submitter.action();
|
let mut action = submitter.action();
|
||||||
|
|
|
@ -18,7 +18,3 @@
|
||||||
|
|
||||||
[redispatch during post-click handling]
|
[redispatch during post-click handling]
|
||||||
expected: TIMEOUT
|
expected: TIMEOUT
|
||||||
|
|
||||||
[disconnected form should not submit]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,9 @@
|
||||||
[button-click-submits.html]
|
[button-click-submits.html]
|
||||||
type: testharness
|
type: testharness
|
||||||
expected: TIMEOUT
|
expected: TIMEOUT
|
||||||
[clicking a button with .click() should not trigger a submit (form disconnected)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[clicking a button by dispatching an event should trigger a submit (form connected)]
|
[clicking a button by dispatching an event should trigger a submit (form connected)]
|
||||||
expected: TIMEOUT
|
expected: TIMEOUT
|
||||||
|
|
||||||
[clicking a button that cancels the event should not trigger a submit]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[clicking the child of a button by dispatching a bubbling event should trigger a submit]
|
[clicking the child of a button by dispatching a bubbling event should trigger a submit]
|
||||||
expected: TIMEOUT
|
expected: TIMEOUT
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue