What is the best method and that is thorough to test if a string is html or an html element being passed in
this is what I'm using at the moment
make = function(a, b) {
let name = null;
let el = null;
if(/<[a-z][\s\S]*>/i.test(a)) { //<- Is this the best?
name = a.match(/(\w+)/i)[1];
el = document.createElement(name);
// get attributes and apply them
return el;
} else if(a == htmlelement) {
// do something here
}
}
createNode('<img id="1" data-name="test" src="image_01.jpg" />');