aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2025-03-27 18:33:23 +0100
committerbptato <nincsnevem662@gmail.com>2025-03-27 18:33:23 +0100
commitb2d954b96f227597b62cfae1ac64785bd8f0fb37 (patch)
treefabbdccc81ab1b5cc52fb7a87994dde669545277 /src
parent0611a6b84a3c45ee65d90b48a7a40fd6e05571cd (diff)
downloadchawan-b2d954b96f227597b62cfae1ac64785bd8f0fb37.tar.gz
dom: fix a style invalidation bug
Clearing the entire dependedBy array in applyStyleDependencies is wrong.
Diffstat (limited to 'src')
-rw-r--r--src/html/dom.nim13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/html/dom.nim b/src/html/dom.nim
index 32cab101..7f51adae 100644
--- a/src/html/dom.nim
+++ b/src/html/dom.nim
@@ -2839,8 +2839,8 @@ func hover*(element: Element): bool =
return element.internalHover
proc setHover*(element: Element; hover: bool) =
- element.invalidate(dtHover)
element.internalHover = hover
+ element.invalidate(dtHover)
func findAutoFocus*(document: Document): Element =
for child in document.elements:
@@ -3974,20 +3974,23 @@ proc invalidate*(element: Element; dep: DependencyType) =
for it in p[]:
it.invalidate()
+proc findAndDelete(map: var seq[Element]; element: Element) =
+ map.del(map.find(element))
+
proc applyStyleDependencies*(element: Element; depends: DependencyInfo) =
let document = element.document
element.selfDepends = {}
for t, map in document.styleDependencies.mpairs:
map.dependsOn.withValue(element, p):
for it in p[]:
- map.dependedBy.del(it)
- document.styleDependencies[t].dependsOn.del(element)
+ map.dependedBy[it].findAndDelete(element)
+ map.dependsOn.del(element)
for el in depends[t]:
if el == element:
element.selfDepends.incl(t)
continue
- document.styleDependencies[t].dependedBy.mgetOrPut(el, @[]).add(element)
- document.styleDependencies[t].dependsOn.mgetOrPut(element, @[]).add(el)
+ map.dependedBy.mgetOrPut(el, @[]).add(element)
+ map.dependsOn.mgetOrPut(element, @[]).add(el)
proc add*(depends: var DependencyInfo; element: Element; t: DependencyType) =
depends[t].add(element)