diff options
-rw-r--r-- | src/css/select.nim | 4 | ||||
-rw-r--r-- | src/css/stylednode.nim | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/css/select.nim b/src/css/select.nim index f1140d1e..f47df9af 100644 --- a/src/css/select.nim +++ b/src/css/select.nim @@ -29,7 +29,7 @@ func pseudoSelectorMatches[T: Element|StyledNode](elem: T, sel: Selector, felem: of PSEUDO_LAST_CHILD: return elem.parentNode.lastElementChild == elem of PSEUDO_ONLY_CHILD: return elem.parentNode.firstElementChild == elem and elem.parentNode.lastElementChild == elem of PSEUDO_HOVER: - when selem is StyledNode: felem.depends.nodes[DEPEND_HOVER].add(selem) + when selem is StyledNode: felem.addDependency(selem, DEPEND_HOVER) return elem.hover of PSEUDO_ROOT: return elem == elem.document.html of PSEUDO_NTH_CHILD: @@ -41,7 +41,7 @@ func pseudoSelectorMatches[T: Element|StyledNode](elem: T, sel: Selector, felem: inc i return false of PSEUDO_CHECKED: - when selem is StyledNode: felem.depends.nodes[DEPEND_CHECKED].add(selem) + when selem is StyledNode: felem.addDependency(selem, DEPEND_CHECKED) if elem.tagType == TAG_INPUT: return HTMLInputElement(elem).checked elif elem.tagType == TAG_OPTION: diff --git a/src/css/stylednode.nim b/src/css/stylednode.nim index 8586bee4..f575d99a 100644 --- a/src/css/stylednode.nim +++ b/src/css/stylednode.nim @@ -101,6 +101,10 @@ proc applyDependValues*(styledNode: StyledNode) = styledNode.depends.prev[DEPEND_CHECKED] = elem.checked elem.invalid = false +proc addDependency*(styledNode, dep: StyledNode, t: DependencyType) = + if dep notin styledNode.depends.nodes[t]: + styledNode.depends.nodes[t].add(dep) + func newStyledElement*(parent: StyledNode, element: Element, computed: CSSComputedValues, reg: sink DependencyInfo): StyledNode = result = StyledNode(t: STYLED_ELEMENT, computed: computed, node: element, parent: parent) result.depends = reg |