about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2025-01-30 23:45:23 +0100
committerbptato <nincsnevem662@gmail.com>2025-01-30 23:54:08 +0100
commitbba9eda3f1d44b1839576ea7d1651ea23d5afc16 (patch)
tree37a11b21d041a7644b594af3295b605359e133ee
parent77acb5d5953fb585cd0ce5724ddad3190fbf46b6 (diff)
downloadchawan-bba9eda3f1d44b1839576ea7d1651ea23d5afc16.tar.gz
sheet: fix a hashing bug
-rw-r--r--src/css/sheet.nim2
-rw-r--r--test/layout/unhashed-selector-after-hashed-selector.color.expected1
-rw-r--r--test/layout/unhashed-selector-after-hashed-selector.html5
3 files changed, 7 insertions, 1 deletions
diff --git a/src/css/sheet.nim b/src/css/sheet.nim
index 0746268c..ed15fe76 100644
--- a/src/css/sheet.nim
+++ b/src/css/sheet.nim
@@ -131,8 +131,8 @@ proc getSelectorIds(hashes: var SelectorHashes; sel: Selector): bool =
       hashes.class != CAtomNull or hashes.attr != CAtomNull
 
 proc add(sheet: CSSStylesheet; rule: CSSRuleDef) =
-  var hashes = SelectorHashes()
   for cxsel in rule.sels:
+    var hashes = SelectorHashes()
     hashes.getSelectorIds(cxsel)
     if hashes.tags.len > 0:
       for tag in hashes.tags:
diff --git a/test/layout/unhashed-selector-after-hashed-selector.color.expected b/test/layout/unhashed-selector-after-hashed-selector.color.expected
new file mode 100644
index 00000000..6d83f3ab
--- /dev/null
+++ b/test/layout/unhashed-selector-after-hashed-selector.color.expected
@@ -0,0 +1 @@
+test
diff --git a/test/layout/unhashed-selector-after-hashed-selector.html b/test/layout/unhashed-selector-after-hashed-selector.html
new file mode 100644
index 00000000..c5691db2
--- /dev/null
+++ b/test/layout/unhashed-selector-after-hashed-selector.html
@@ -0,0 +1,5 @@
+<!DOCTYPE html>
+<style>
+div#a, * { color: red }
+</style>
+test