Skip to content

Commit 7f2ca4b

Browse files
committed
feat: value-dispatch attribute to dispatch event even if value is null or undefined
1 parent cd9aa55 commit 7f2ca4b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/setValue.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ HTMLHeadingElement.prototype.setValue = function (value, dispatch) {
1414

1515
// TODO: check if using a a switch case will provide better performance
1616
const setValue = (el, value, dispatch) => {
17-
if (value === '$false') {
17+
let valueDispatch = el.getAttribute('value-dispatch')
18+
if ((valueDispatch || valueDispatch === '') && (value === '$false' || value === undefined || value === null)) {
1819
return dispatchEvents(el, dispatch)
1920
};
2021

@@ -72,7 +73,7 @@ const setValue = (el, value, dispatch) => {
7273
} else if (el.tagName == "SELECT" && el.hasAttribute('multiple') && Array.isArray(value)) {
7374
let options = el.options;
7475
for (let i = 0; i < options.length; i++) {
75-
if (value.includes(options[i].value)) {
76+
if (value.includes && value.includes(options[i].value)) {
7677
options[i].selected = "selected";
7778
} else {
7879
options[i].selected = "";

0 commit comments

Comments
 (0)