Find element by id
This commit is contained in:
parent
6c21d8c857
commit
fdd4c0e4d9
@ -594,3 +594,21 @@ extension Element {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension Element {
|
||||
|
||||
/**
|
||||
Find a page by its page ID within the tree of the element.
|
||||
*/
|
||||
func find(_ pageId: String) -> Element? {
|
||||
if self.id == pageId {
|
||||
return self
|
||||
}
|
||||
for child in elements {
|
||||
if let found = child.find(pageId) {
|
||||
return found
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user