-
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathcheckbox_patch.js
More file actions
16 lines (16 loc) · 706 Bytes
/
Copy pathcheckbox_patch.js
File metadata and controls
16 lines (16 loc) · 706 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function checkbox_patch(checkbox) {
const { get, set } = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'checked');
Object.defineProperty(checkbox, 'checked', {
get() {
// If you want to monitor the retrieval of the `checked` property, uncomment the line below and do whatever you like...
// console.log('Getting "checked" property...');
return get.call(this);
},
set(newVal) {
// console.log(`Setting "checked" property to "${newVal}"...`); // Debug
let ret = set.call(this, newVal);
this.dispatchEvent(new Event("change", { bubbles: true }));
return ret;
}
});
}