generateWithRoot method
T?
generateWithRoot(
- DOMElement? domRoot,
- T? rootElement,
- List<
DOMNode> nodes, { - DOMTreeMap<
T> ? treeMap, - T? rootParent,
- DOMContext<
T> ? context, - bool finalizeTree = true,
- bool setTreeMapRoot = true,
Same as generate, but generates nodes
inside a preexistent rootElement
.
Implementation
T? generateWithRoot(DOMElement? domRoot, T? rootElement, List<DOMNode> nodes,
{DOMTreeMap<T>? treeMap,
T? rootParent,
DOMContext<T>? context,
bool finalizeTree = true,
bool setTreeMapRoot = true}) {
treeMap ??= createGenericDOMTreeMap();
context ??= _domContext;
if (rootElement == null && domRoot != null) {
rootElement = treeMap.getMappedElement(domRoot);
rootElement ??= build(null, null, domRoot, treeMap, context);
}
if (rootElement == null) throw StateError("Null `rootElement`.");
domRoot ??= treeMap.getMappedDOMNode(rootElement) as DOMElement?;
if (rootParent != null) {
addChildToElement(rootParent, rootElement);
}
treeMap.map(domRoot!, rootElement);
for (var node in nodes) {
if (!domRoot.containsNode(node)) {
domRoot.add(node);
}
build(domRoot, rootElement, node, treeMap, context);
}
if (setTreeMapRoot) {
treeMap.setRoot(domRoot, rootElement);
}
_callFinalizeGeneratedTree(treeMap, context, finalizeTree);
return rootElement;
}