Skip to content
Permalink
Browse files

Implement cannot navigate

  • Loading branch information...
CYBAI committed Jan 10, 2019
1 parent 9d70f51 commit cb86d451e663646c496e6bece8b456f5196afca7
@@ -3235,6 +3235,18 @@ impl Element {
let root = node.GetRootNode();
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 {
@@ -317,7 +317,11 @@ impl HTMLFormElement {

/// [Form submission](https://html.spec.whatwg.org/multipage/#concept-form-submit)
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
if self.constructing_entry_list.get() {
return;
@@ -342,6 +346,11 @@ impl HTMLFormElement {
if event.DefaultPrevented() {
return;
}

// Step 7-3
if self.upcast::<Element>().cannot_navigate() {
return;
}
}

// Step 8
@@ -353,7 +362,10 @@ impl HTMLFormElement {
None => return,
};

// TODO: Step 10. If form cannot navigate, then return.
// Step 10
if self.upcast::<Element>().cannot_navigate() {
return;
}

// Step 11
let mut action = submitter.action();
@@ -18,7 +18,3 @@

[redispatch during post-click handling]
expected: TIMEOUT

[disconnected form should not submit]
expected: FAIL

@@ -1,15 +1,9 @@
[button-click-submits.html]
type: testharness
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)]
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]
expected: TIMEOUT

0 comments on commit cb86d45

Please sign in to comment.
You can’t perform that action at this time.