diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/html/dom.nim | 9 | ||||
-rw-r--r-- | src/server/buffer.nim | 6 |
2 files changed, 12 insertions, 3 deletions
diff --git a/src/html/dom.nim b/src/html/dom.nim index 4fcc6c51..67f0c666 100644 --- a/src/html/dom.nim +++ b/src/html/dom.nim @@ -1840,6 +1840,15 @@ func formmethod*(element: Element): FormMethod = return FORM_METHOD_GET +func findAnchor*(document: Document, id: string): Element = + if id.len == 0: + return nil + for child in document.elements: + if child.id == id: + return child + if child.tagType == TAG_A and child.attr("name") == id: + return child + # Forward declaration hack isDefaultPassive = func (eventTarget: EventTarget): bool = if eventTarget of Window: diff --git a/src/server/buffer.nim b/src/server/buffer.nim index 349a5d8d..49cd9140 100644 --- a/src/server/buffer.nim +++ b/src/server/buffer.nim @@ -510,8 +510,8 @@ proc findNextMatch*(buffer: Buffer, regex: Regex, cursorx, cursory: int, wrap: b proc gotoAnchor*(buffer: Buffer): tuple[x, y: int] {.proxy.} = if buffer.document == nil: return (-1, -1) - let anchor = buffer.document.getElementById(buffer.url.anchor) - if anchor == nil: return + let anchor = buffer.document.findAnchor(buffer.url.anchor) + if anchor == nil: return (-1, -1) for y in 0 ..< buffer.lines.len: let line = buffer.lines[y] for i in 0 ..< line.formats.len: @@ -1297,7 +1297,7 @@ proc readCanceled*(buffer: Buffer): bool {.proxy.} = return buffer.restoreFocus() proc findAnchor*(buffer: Buffer, anchor: string): bool {.proxy.} = - return buffer.document != nil and buffer.document.getElementById(anchor) != nil + return buffer.document != nil and buffer.document.findAnchor(anchor) != nil type GetLinesResult* = tuple[ numLines: int, |