diff options
author | Sam Wilkins <samwilkins333@gmail.com> | 2019-07-29 13:21:41 -0400 |
---|---|---|
committer | Sam Wilkins <samwilkins333@gmail.com> | 2019-07-29 13:21:41 -0400 |
commit | 18663c72459d551d154a555194ecb88729af574f (patch) | |
tree | 416a98cd8fe34dfb7ad9827941c13f3d4892f2c8 /src/new_fields/Doc.ts | |
parent | 27cafb6eebd1c6229c3377187a5c0043db25ba0a (diff) | |
parent | e7ea2028f54787d6c92fb22b789f17b7268d3793 (diff) |
merged with master
Diffstat (limited to 'src/new_fields/Doc.ts')
-rw-r--r-- | src/new_fields/Doc.ts | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts index b5708e97b..da4f459e2 100644 --- a/src/new_fields/Doc.ts +++ b/src/new_fields/Doc.ts @@ -283,21 +283,28 @@ export namespace Doc { export function AddDocToList(target: Doc, key: string, doc: Doc, relativeTo?: Doc, before?: boolean, first?: boolean, allowDuplicates?: boolean) { if (target[key] === undefined) { + console.log("target key undefined"); Doc.GetProto(target)[key] = new List<Doc>(); } let list = Cast(target[key], listSpec(Doc)); if (list) { + console.log("has list"); if (allowDuplicates !== true) { let pind = list.reduce((l, d, i) => d instanceof Doc && Doc.AreProtosEqual(d, doc) ? i : l, -1); if (pind !== -1) { list.splice(pind, 1); } } - if (first) list.splice(0, 0, doc); + if (first) { + console.log("is first"); + list.splice(0, 0, doc); + } else { + console.log("not first"); let ind = relativeTo ? list.indexOf(relativeTo) : -1; if (ind === -1) list.push(doc); else list.splice(before ? ind : ind + 1, 0, doc); + console.log("index", ind); } } return true; |