Browse Source

Generalize support for events in Dom element maker

main
Tissevert 4 months ago
parent
commit
0d7f180ce2
  1. 10
      src/UnitJS/Dom.js

10
src/UnitJS/Dom.js

@ -22,11 +22,13 @@ function make(tag, properties, children) {
case "maxlength":
e.setAttribute("maxlength", value);
break;
case "onClick":
e.addEventListener("click", value);
break;;
default:
e[key] = value;
var matched = key.match(/on([A-Z]\w+)/);
if(matched) {
e.addEventListener(matched[1].toLowerCase(), value);
} else {
e[key] = value;
}
}
}
for(var i = 0; i < children.length; i++) {

Loading…
Cancel
Save