createElement function
Creates a HTML Element. Returns 1st node form parsed HTML.
Implementation
Element createElement({String? html, bool unsafe = false}) {
if (html == null || html.isEmpty) return HTMLSpanElement();
var dependentTagMatch = _regexpDependentTag.firstMatch(html);
if (dependentTagMatch != null) {
return _createDependentTagElement(dependentTagMatch, html, unsafe);
} else {
var div = createDiv(inline: true, html: html, unsafe: unsafe);
var childNodes = div.childNodes;
if (childNodes.isEmpty) return div;
var childNode = childNodes.whereElement().firstOrNull;
var element = childNode.asElementChecked;
if (element != null) {
return element;
}
var span = HTMLSpanElement();
span.appendNodes(div.childNodes.toList());
return span;
}
}