diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2019-03-01 17:33:39 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-01 17:33:39 -0500 |
commit | 4d8d54fc00644204768886569959429dd67998a0 (patch) | |
tree | f6b5ed24dda700226067cf834ac76aa06119ee86 /components/script/dom | |
parent | 27f443fd009dcbcd85487e0cf538c8c11e944822 (diff) | |
parent | fcadff7bad42c3562a761e2ec6300a33c0fa7666 (diff) | |
download | servo-4d8d54fc00644204768886569959429dd67998a0.tar.gz servo-4d8d54fc00644204768886569959429dd67998a0.zip |
Auto merge of #22933 - pngai:implement-returnValue-attribute, r=jdm
Implement historical returnValue attribute for Event interface
<!-- Please describe your changes on the following line: -->
Implementation of `returnValue` attribute for Event interface.
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #22881 (GitHub issue number if applicable)
<!-- Either: -->
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because ___
<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22933)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom')
-rw-r--r-- | components/script/dom/event.rs | 12 | ||||
-rw-r--r-- | components/script/dom/webidls/Event.webidl | 1 |
2 files changed, 13 insertions, 0 deletions
diff --git a/components/script/dom/event.rs b/components/script/dom/event.rs index fc18036bfc7..914cf279278 100644 --- a/components/script/dom/event.rs +++ b/components/script/dom/event.rs @@ -297,6 +297,18 @@ impl EventMethods for Event { self.cancelable.get() } + // https://dom.spec.whatwg.org/#dom-event-returnvalue + fn ReturnValue(&self) -> bool { + self.canceled.get() == EventDefault::Allowed + } + + // https://dom.spec.whatwg.org/#dom-event-returnvalue + fn SetReturnValue(&self, val: bool) { + if !val { + self.PreventDefault(); + } + } + // https://dom.spec.whatwg.org/#dom-event-timestamp fn TimeStamp(&self) -> u64 { self.timestamp diff --git a/components/script/dom/webidls/Event.webidl b/components/script/dom/webidls/Event.webidl index 6c7861ecc6e..1a6fd8e4a5c 100644 --- a/components/script/dom/webidls/Event.webidl +++ b/components/script/dom/webidls/Event.webidl @@ -26,6 +26,7 @@ interface Event { readonly attribute boolean bubbles; [Pure] readonly attribute boolean cancelable; + attribute boolean returnValue; // historical void preventDefault(); [Pure] readonly attribute boolean defaultPrevented; |