diff options
author | bob <bcz@cs.brown.edu> | 2020-02-03 20:53:19 -0500 |
---|---|---|
committer | bob <bcz@cs.brown.edu> | 2020-02-03 20:53:19 -0500 |
commit | 11b4645ce52df01f071a9a4a2582cae10a0140ba (patch) | |
tree | c976ed900e85143bffab4c665d47ffa1d05f4526 /src/new_fields/Doc.ts | |
parent | a66d1cbe0110b6495cc597b31bd39c4b14540958 (diff) |
template fixes for nesting documents.
Diffstat (limited to 'src/new_fields/Doc.ts')
-rw-r--r-- | src/new_fields/Doc.ts | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts index 2b700863e..4dcdc6581 100644 --- a/src/new_fields/Doc.ts +++ b/src/new_fields/Doc.ts @@ -421,8 +421,8 @@ export namespace Doc { doc.title = title; return doc; } - export function MakeAlias(doc: Doc) { - const alias = !GetT(doc, "isPrototype", "boolean", true) ? Doc.MakeCopy(doc) : Doc.MakeDelegate(doc); + export function MakeAlias(doc: Doc, id?: string) { + const alias = !GetT(doc, "isPrototype", "boolean", true) ? Doc.MakeCopy(doc, undefined, id) : Doc.MakeDelegate(doc, id); const layout = Doc.LayoutField(alias); if (layout instanceof Doc && layout !== alias && layout === Doc.Layout(alias)) { Doc.SetLayout(alias, Doc.MakeAlias(layout)); @@ -574,7 +574,7 @@ export namespace Doc { } return undefined; } - export function ApplyTemplateTo(templateDoc: Doc, target: Doc, targetKey: string, titleTarget: string | undefined = undefined) { + export function ApplyTemplateTo(templateDoc: Doc, target: Doc, targetKey: string, titleTarget: string | undefined) { if (!templateDoc) { target.layout = undefined; target._nativeWidth = undefined; @@ -584,14 +584,9 @@ export namespace Doc { return; } - if ((target[targetKey] as Doc)?.proto !== templateDoc) { - const layoutCustomLayout = Doc.MakeDelegate(templateDoc); - + if (!Doc.AreProtosEqual(target[targetKey] as Doc, templateDoc)) { titleTarget && (Doc.GetProto(target).title = titleTarget); - Doc.GetProto(target).type = DocumentType.TEMPLATE; - target.onClick = templateDoc.onClick instanceof ObjectField && templateDoc.onClick[Copy](); - - Doc.GetProto(target)[targetKey] = new PrefetchProxy(layoutCustomLayout); + Doc.GetProto(target)[targetKey] = new PrefetchProxy(templateDoc); } target.layoutKey = targetKey; return target; |