Fixed to previous JS adjustments

This commit is contained in:
Felix Krause 2017-03-30 17:58:53 +02:00
parent 7ba95845e0
commit f07cf173dc
2 changed files with 10 additions and 6 deletions

View File

@ -235,11 +235,12 @@ proc serializeNode(n: YamlNode, c: SerializationContext, a: AnchorStyle,
tagId: TagId
anchor: AnchorId
if a == asAlways:
val = c.nextAnchorId
when defined(JS):
{.emit: [c, ".refs.set(", n, ", ", c.nextAnchorId, ");"].}
{.emit: [c, ".refs.set(", n, ", ", val, ");"].}
else:
c.refs[p] = c.nextAnchorId
c.nextAnchorId = AnchorId(int(c.nextAnchorId) + 1)
c.nextAnchorId = AnchorId(int(val) + 1)
else:
when defined(JS):
{.emit: [c, ".refs.set(", n, ", ", yAnchorNone, ");"].}

View File

@ -1244,10 +1244,13 @@ proc representChild*[O](value: ref O, ts: TagStyle, c: SerializationContext) =
c.nextAnchorId = AnchorId(int(c.nextAnchorId) + 1)
c.put(aliasEvent(val))
return
if c.style == asAlways:
c.refs[p] = c.nextAnchorId
c.nextAnchorId = AnchorId(int(c.nextAnchorId) + 1)
else: c.refs[p] = yAnchorNone
if c.style == asAlways:
val = c.nextAnchorId
when defined(JS):
{.emit: [c, ".refs.set(", p, ", ", val, ");"].}
else: c.refs[p] = val
c.nextAnchorId = AnchorId(int(val) + 1)
else: c.refs[p] = yAnchorNone
let
a = if c.style == asAlways: val else: cast[AnchorId](p)
childTagStyle = if ts == tsAll: tsAll else: tsRootOnly