<li th:fragment="submenu(submenu, parent, pos)"
                 th:each="entry : ${submenu}"
                 th:with="
-                    childs=${entry == parent ? null : _childs.get(entry)},
-                    leaf=${pos >= (len - 1)},
                     child=${pos == len},
                     selected=${!child and crumbs.get(pos) == entry},
+                    leaf=${pos >= (len - 1) and not selected},
                     active=${entry == uri},
-                    sibling=${pos + 1 == len and (_childs.get(uri) == null or uri == parent)}
+                    sibling=${pos + 1 == len and (_childs.get(uri) == null or uri == parent)},
+                    childs=${entry == parent ? null : _childs.get(entry)}
                     "
                 class="s sub"
                 th:class="'s' + (${childs} ? ' sub' : '') + (${selected or sibling or child} ? '' : ' off')">