buildElement method
T
buildElement(
- DOMElement? domParent,
- T? parent,
- DOMElement domElement,
- DOMTreeMap<
T> treeMap, - DOMContext<
T> ? context,
Implementation
T buildElement(DOMElement? domParent, T? parent, DOMElement domElement,
DOMTreeMap<T> treeMap, DOMContext<T>? context) {
if (domParent != null) {
domElement.parent = domParent;
}
var element = createWithRegisteredElementGenerator(
domParent, parent, domElement, treeMap, context);
if (element == null) {
final domContext = _domContext;
if (domContext != null) {
element = domContext.resolveNamedElement(
domParent, parent, domElement, treeMap);
element ??= createElement(domElement.tag, domElement);
} else {
element = createElement(domElement.tag, domElement);
}
if (element == null) {
throw StateError("Can't create element for tag: ${domElement.tag}");
}
setAttributes(domElement, element, treeMap,
preserveClass: true, preserveStyle: true);
if (parent != null) {
addChildToElement(parent, element);
}
treeMap.map(domElement, element);
_callOnElementCreated(treeMap, domElement, element, context);
var length = domElement.length;
for (var i = 0; i < length; i++) {
var node = domElement.nodeByIndex(i)!;
build(domElement, element, node, treeMap, context);
}
} else if (parent != null) {
addChildToElement(parent, element);
}
domElement.notifyElementGenerated(element);
return element;
}