Skip to content

Commit

Permalink
Add a test for touches on labels causing clicks on the labelled element.
Browse files Browse the repository at this point in the history
  • Loading branch information
bicknellr committed Jun 11, 2018
1 parent cb40bb4 commit 6ac4813
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/unit/gestures.html
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,36 @@
document.body.removeChild(el);
});
});

suite('Clicks on the labelled elements from label touches do not throw.', function() {
let container;

setup(function() {
container = document.createElement('div');
container.innerHTML = `
<input type="text" id="anInput">
<label for="anInput">The label</label>
`;
document.body.appendChild(container);
})

teardown(function() {
document.body.removeChild(container);
});

test('test name', function() {
const input = container.querySelector('input#anInput');
const label = container.querySelector('label[for=anInput]');

const makeEvent =
(type) => new CustomEvent(type, {bubbles: true, composed: true});

label.dispatchEvent(makeEvent('touchstart'));
label.dispatchEvent(makeEvent('touchend'));
label.dispatchEvent(makeEvent('click'));
input.dispatchEvent(makeEvent('click'));
});
});
});
</script>

Expand Down

0 comments on commit 6ac4813

Please sign in to comment.