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

Commit b8c0250

Browse files
committed
Capture: Assert target is connected
Closes gh-283 Ref gh-258
1 parent 04ae42f commit b8c0250

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

src/capture.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,21 @@ function assertActive(id) {
99
throw error;
1010
}
1111
}
12+
function assertConnected(elem) {
13+
if (!elem.ownerDocument.contains(elem)) {
14+
var error = new Error('InvalidStateError');
15+
error.name = 'InvalidStateError';
16+
throw error;
17+
}
18+
}
1219
function inActiveButtonState(id) {
1320
var p = dispatcher.pointermap.get(id);
1421
return p.buttons !== 0;
1522
}
1623
if (n.msPointerEnabled) {
1724
s = function(pointerId) {
1825
assertActive(pointerId);
26+
assertConnected(this);
1927
if (inActiveButtonState(pointerId)) {
2028
this.msSetPointerCapture(pointerId);
2129
}
@@ -27,6 +35,7 @@ if (n.msPointerEnabled) {
2735
} else {
2836
s = function setPointerCapture(pointerId) {
2937
assertActive(pointerId);
38+
assertConnected(this);
3039
if (inActiveButtonState(pointerId)) {
3140
dispatcher.setCapture(pointerId, this);
3241
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
define(function(require) {
2+
var registerSuite = require('intern!object');
3+
var w3cTest = require('../support/w3cTest');
4+
var name = 'pointerevent_setpointercapture_disconnected-manual';
5+
6+
registerSuite({
7+
name: name,
8+
9+
main: function() {
10+
return w3cTest(this.remote, name + '.html')
11+
.findById('target0')
12+
.moveMouseTo(50, 25)
13+
.clickMouseButton(0)
14+
.end()
15+
.checkResults();
16+
}
17+
});
18+
});

tests/intern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ define({
8686
// 'tests/functional/pointerevent_releasepointercapture_onpointercancel_touch-manual.js',
8787
'tests/functional/pointerevent_releasepointercapture_onpointerup_mouse-manual',
8888

89-
// 'tests/functional/pointerevent_setpointercapture_disconnected-manual.js',
89+
'tests/functional/pointerevent_setpointercapture_disconnected-manual.js',
9090
'tests/functional/pointerevent_setpointercapture_inactive_button_mouse-manual.js',
9191
'tests/functional/pointerevent_setpointercapture_invalid_pointerid-manual.js',
9292
'tests/functional/pointerevent_setpointercapture_relatedtarget-manual.js'

0 commit comments

Comments
 (0)