diff options
author | bptato <nincsnevem662@gmail.com> | 2022-12-12 16:03:46 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2022-12-12 16:03:46 +0100 |
commit | 96824ecd8f66eeedcf8bd954b44ddb32c50c9256 (patch) | |
tree | afe96a81628d554dc920cac7b50fb42587d0e470 /src/css | |
parent | 1672b79734ca5c37d5609b5d44ac63a60c5f2dae (diff) | |
download | chawan-96824ecd8f66eeedcf8bd954b44ddb32c50c9256.tar.gz |
Make background-color non-inherited; fix {}= for CSSComputedValues
Diffstat (limited to 'src/css')
-rw-r--r-- | src/css/values.nim | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/css/values.nim b/src/css/values.nim index 2c9ef97d..f57917a6 100644 --- a/src/css/values.nim +++ b/src/css/values.nim @@ -287,9 +287,8 @@ const InheritedProperties = { PROPERTY_COLOR, PROPERTY_FONT_STYLE, PROPERTY_WHITE_SPACE, PROPERTY_FONT_WEIGHT, PROPERTY_TEXT_DECORATION, PROPERTY_WORD_BREAK, PROPERTY_LIST_STYLE_TYPE, PROPERTY_WORD_SPACING, PROPERTY_LINE_HEIGHT, - PROPERTY_TEXT_ALIGN, PROPERTY_LIST_STYLE_POSITION, PROPERTY_BACKGROUND_COLOR, - PROPERTY_CAPTION_SIDE, PROPERTY_BORDER_SPACING, PROPERTY_BORDER_COLLAPSE, - PROPERTY_QUOTES + PROPERTY_TEXT_ALIGN, PROPERTY_LIST_STYLE_POSITION, PROPERTY_CAPTION_SIDE, + PROPERTY_BORDER_SPACING, PROPERTY_BORDER_COLLAPSE, PROPERTY_QUOTES } func getPropInheritedArray(): array[CSSPropertyType, bool] = @@ -316,13 +315,15 @@ macro `{}`*(vals: CSSComputedValues, s: string): untyped = let s = vs.split('_')[1..^1].join("_").tolower() result = newDotExpr(newTree(nnkBracketExpr, vals, newLit(t)), newIdentNode(s)) -macro `{}=`*(vals: CSSComputedValues, s: string, v: typed): untyped = +macro `{}=`*(vals: CSSComputedValues, s: string, val: typed) = let t = propertyType($s) - let vs = $valueType(t) + let v = valueType(t) + let vs = $v let s = vs.split('_')[1..^1].join("_").tolower() - let expr = newDotExpr(newTree(nnkBracketExpr, vals, newLit(t)), newIdentNode(s)) + let id = ident(s) + let expr = newTree(nnkBracketExpr, vals, newLit(t)) result = quote do: - `expr` = `v` + `expr` = CSSComputedValue(t: CSSPropertyType(`t`), v: CSSValueType(`v`), `id`: `val`) func inherited(t: CSSPropertyType): bool = return InheritedArray[t] |