Skip to content

Commit

Permalink
Implement srcElement and returnValue for Event
Browse files Browse the repository at this point in the history
These were added to the spec in whatwg/dom#626.
  • Loading branch information
Zirro authored and domenic committed Apr 26, 2018
1 parent ea0f5cf commit 571cd9f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/jsdom/living/events/Event-impl.js
Expand Up @@ -35,6 +35,20 @@ class EventImpl {
this.timeStamp = Date.now();
}

get srcElement() {
return this.target;
}

get returnValue() {
return !this._canceledFlag;
}

set returnValue(v) {
if (this.cancelable && v === false) {
this._canceledFlag = true;
}
}

get defaultPrevented() {
return this._canceledFlag;
}
Expand Down
2 changes: 2 additions & 0 deletions lib/jsdom/living/events/Event.webidl
Expand Up @@ -3,6 +3,7 @@
interface Event {
readonly attribute DOMString type;
readonly attribute EventTarget? target;
readonly attribute EventTarget? srcElement; // historical
readonly attribute EventTarget? currentTarget;
// sequence<EventTarget> composedPath();

Expand All @@ -18,6 +19,7 @@ interface Event {

readonly attribute boolean bubbles;
readonly attribute boolean cancelable;
attribute boolean returnValue; // historical
void preventDefault();
readonly attribute boolean defaultPrevented;
// readonly attribute boolean composed;
Expand Down

0 comments on commit 571cd9f

Please sign in to comment.