map method
Maps in this instance the pair domNode
and element
.
Implementation
void map(DOMNode domNode, T element,
{DOMContext<T>? context, bool allowOverwrite = false}) {
if (element == null) return;
var prevElement = _domNodeToElementMap[domNode];
var prevDomNode = _elementToDOMNodeMap[element];
if (prevElement != null || prevDomNode != null) {
var samePrevElement = identical(prevElement, element);
var samePrevDomNode = identical(prevDomNode, domNode);
if (samePrevElement && samePrevDomNode) {
return;
} else {
if (!allowOverwrite) {
print(
'WARNING> Mapping to different instances: $prevElement ; $prevDomNode');
}
}
}
_domNodeToElementMap[domNode] = element;
_elementToDOMNodeMap[element] = domNode;
domNode.treeMap = this;
_elementsDOMTreeMap[element] = this;
if (domNode is DOMElement) {
domGenerator.resolveActionAttribute(this, domNode, element, context);
domGenerator.registerEventListeners(this, domNode, element, context);
}
}