Change the current document.createElement()
method to do this:
var div = document.createElement("div", {
"id": "id",
"class": "this that and so on",
"data-whatever": "whatever data",
});
As of right now document.createElement second paremeter takes a string for the “is” attribute.
The above eliminates the reuse of the div variable like in the following:
var div = document.createElement('div');
div.id = "id";
div.className = "this that and so on"; //Also see how I have to use className instead of what I use in markup. Which obviously is fine we have had className for a while that's not going to change. (Not the point)
div.dataset.whatever = "whatever data"; //Having to access dataset
Also I’m not sure if there’s a reason why HTMLDivElement and all of the rest of HTML"Whatever"Element are not constructors. If there’s a good reason for that disregard the following:
If HTML"Whatever"Element can be constructors allow the following:
var div = new HTMLDivElement({
"id": "id",
...//you get the point
});
This will also get rid of having a random window.Option constructor. Which to me is really weird.