parent
5a2ea1eef9
commit
bd18fc980c
2 changed files with 11 additions and 2 deletions
|
|
@ -303,6 +303,12 @@ proc sameAttrs*(a, b: VNode): bool =
|
||||||
proc addEventListener*(n: VNode; event: EventKind; handler: EventHandler) =
|
proc addEventListener*(n: VNode; event: EventKind; handler: EventHandler) =
|
||||||
n.events.add((event, handler, nil))
|
n.events.add((event, handler, nil))
|
||||||
|
|
||||||
|
when kstring is cstring:
|
||||||
|
proc len(a: kstring): int =
|
||||||
|
# xxx: maybe move where kstring is defined
|
||||||
|
# without this, `n.field.len` fails on js (non web) platform
|
||||||
|
if a == nil: 0 else: a.len
|
||||||
|
|
||||||
template toStringAttr(field) =
|
template toStringAttr(field) =
|
||||||
if n.field.len > 0:
|
if n.field.len > 0:
|
||||||
result.add " " & astToStr(field) & " = " & $n.field
|
result.add " " & astToStr(field) & " = " & $n.field
|
||||||
|
|
|
||||||
|
|
@ -235,6 +235,9 @@ proc eq*(a, b: VStyle): bool =
|
||||||
return true
|
return true
|
||||||
|
|
||||||
proc setAttr*(s: VStyle; a, value: kstring) {.noSideEffect.} =
|
proc setAttr*(s: VStyle; a, value: kstring) {.noSideEffect.} =
|
||||||
|
## inserts (a, value) in sorted order of key `a`
|
||||||
|
# worst case quadratic complexity (if given styles in reverse order), hopefully
|
||||||
|
# not a concern assuming small cardinal
|
||||||
var i = 0
|
var i = 0
|
||||||
while i < s.len:
|
while i < s.len:
|
||||||
if s[i] == a:
|
if s[i] == a:
|
||||||
|
|
@ -243,8 +246,8 @@ proc setAttr*(s: VStyle; a, value: kstring) {.noSideEffect.} =
|
||||||
elif s[i] > a:
|
elif s[i] > a:
|
||||||
s.add ""
|
s.add ""
|
||||||
s.add ""
|
s.add ""
|
||||||
# insertion point here:
|
# insertion point here, shift all remaining pairs by 2 indexes
|
||||||
for j in countdown(s.len-1, i, 2):
|
for j in countdown(s.len-1, i+3, 2):
|
||||||
s[j] = s[j-2]
|
s[j] = s[j-2]
|
||||||
s[j-1] = s[j-3]
|
s[j-1] = s[j-3]
|
||||||
s[i] = a
|
s[i] = a
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue