Element element
) Finds the first ancestor element with FnxRouterBehavior.
Initializes parent router element if hasn't been initialized yet.
Source
/// Finds the first ancestor element with [FnxRouterBehavior].
///
/// Initializes parent router element if hasn't been initialized yet.
FnxRouterBehavior findParentRouter(Element element) {
if (element is FnxRouterBehavior) {
FnxRouterBehavior p = element as FnxRouterBehavior;
if (!p._initialized) {
p._initRouting();
}
return p;
}
if (element is BodyElement) return null;
if (element is HtmlElement) return null;
Element parent = element.parent;
if (parent == null) return null;
return findParentRouter(parent);
}