fix(Page.select): synthesized events should bubble

This patch fixes `Page.select` to synthesize bubbling events.
This commit is contained in:
Christian Davis
2017-10-07 12:27:38 -05:00
committed by Andrey Lushnikov
parent 44cdf85b77
commit 3ecd98d634
3 changed files with 23 additions and 3 deletions

View File

@@ -25,6 +25,8 @@
window.result = {
onInput: null,
onChange: null,
onBubblingChange: null,
onBubblingInput: null,
};
let select = document.querySelector('select');
@@ -50,6 +52,18 @@
return option.value;
});
}, false);
document.body.addEventListener('input', () => {
result.onBubblingInput = Array.from(select.querySelectorAll('option:checked')).map((option) => {
return option.value;
});
}, false);
document.body.addEventListener('change', () => {
result.onBubblingChange = Array.from(select.querySelectorAll('option:checked')).map((option) => {
return option.value;
});
}, false);
</script>
</body>
</html>