about summary refs log tree commit diff stats
path: root/src/css
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-10-25 14:04:39 +0200
committerbptato <nincsnevem662@gmail.com>2023-10-25 14:04:39 +0200
commit10bdd58bbe9f3736bbb3f73d2c500740724b696f (patch)
tree56aa0eb0ce5703b8c3adb12bb0e40892b738f154 /src/css
parentaa47707bec6caa024ae1ce8e17461409a3456964 (diff)
downloadchawan-10bdd58bbe9f3736bbb3f73d2c500740724b696f.tar.gz
dom: add some CSSStyleDeclaration functions
Diffstat (limited to 'src/css')
-rw-r--r--src/css/cssparser.nim7
-rw-r--r--src/css/values.nim3
2 files changed, 8 insertions, 2 deletions
diff --git a/src/css/cssparser.nim b/src/css/cssparser.nim
index ef167fb2..ea337ab1 100644
--- a/src/css/cssparser.nim
+++ b/src/css/cssparser.nim
@@ -116,10 +116,13 @@ proc `$`*(c: CSSParsedItem): string =
     else:
       result &= $c.tokenType & '\n'
   elif c of CSSDeclaration:
-    result &= CSSDeclaration(c).name
+    let decl = CSSDeclaration(c)
+    result &= decl.name
     result &= ": "
-    for s in CSSDeclaration(c).value:
+    for s in decl.value:
       result &= $s
+    if decl.important:
+      result &= " !important"
     result &= ";\n"
   elif c of CSSFunction:
     result &= CSSFunction(c).name & "("
diff --git a/src/css/values.nim b/src/css/values.nim
index 6fae4737..91911c09 100644
--- a/src/css/values.nim
+++ b/src/css/values.nim
@@ -354,6 +354,9 @@ func propertyType(s: string): CSSPropertyType =
 func valueType(prop: CSSPropertyType): CSSValueType =
   return ValueTypes[prop]
 
+func isSupportedProperty*(s: string): bool =
+  return s in PropertyNames
+
 func `$`*(length: CSSLength): string =
   if length.auto:
     return "auto"