Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
A few spec compliance changes to pass the w3c tests
Browse files Browse the repository at this point in the history
- relatedTarget must be null if pointerevent is capturing
- `new PointerEvent(..) instanceof PointerEvent === true`
- Manual tests: http://github.com/w3c/web-platform-tests
  • Loading branch information
dfreedm committed Oct 21, 2013
1 parent ea4bec9 commit 8dc9be8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/PointerEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@
);
}

// make the event pass instanceof checks
e.__proto__ = PointerEvent.prototype;

// define the buttons property according to DOM Level 3 spec
if (!HAS_BUTTONS) {
// IE 10 has buttons on MouseEvent.prototype as a getter w/o any setting
Expand Down Expand Up @@ -148,6 +151,9 @@
return e;
}

// PointerEvent extends MouseEvent
PointerEvent.prototype = Object.create(MouseEvent.prototype);

// attach to window
if (!scope.PointerEvent) {
scope.PointerEvent = PointerEvent;
Expand Down
4 changes: 4 additions & 0 deletions src/dispatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,10 @@
* @return {Event} A PointerEvent of type `inType`
*/
makeEvent: function(inType, inEvent) {
// relatedTarget must be null if pointer is captured
if (this.captureInfo) {
inEvent.relatedTarget = null;
}
var e = new PointerEvent(inType, inEvent);
this.targets.set(e, this.targets.get(inEvent) || inEvent.target);
return e;
Expand Down

0 comments on commit 8dc9be8

Please sign in to comment.