# HG changeset patch # User cin # Date 2020-03-11 23:47:58 # Node ID 9e546fe36fdddc8324f1098ee950fa1a7ba19b93 # Parent 6c01fabe9ea9fb5e753fbeae8b0d2664e7072a66 Added placeAt() method to BuildContext diff --git a/src/main/ts/tsx/BuildContextBase.ts b/src/main/ts/tsx/BuildContextBase.ts --- a/src/main/ts/tsx/BuildContextBase.ts +++ b/src/main/ts/tsx/BuildContextBase.ts @@ -1,7 +1,9 @@ import { isNull, mixin, argumentNotNull } from "@implab/core-amd/safe"; -import { isPlainObject, isNode, isBuildContext } from "./traits"; +import { isPlainObject, isNode, isBuildContext, DojoNodePosition, BuildContext } from "./traits"; -export abstract class BuildContextBase { +import dom = require("dojo/dom-construct"); + +export abstract class BuildContextBase implements BuildContext { _attrs = {}; _children = new Array(); @@ -57,6 +59,10 @@ export abstract class BuildContextBase { return this._getDomElement(); } + placeAt(refNode: string | Node, position?: DojoNodePosition) { + dom.place(this.getDomElement(), refNode, position); + } + abstract _addChild(child: any): void; abstract _setAttrs(attrs: object): void; diff --git a/src/main/ts/tsx/traits.ts b/src/main/ts/tsx/traits.ts --- a/src/main/ts/tsx/traits.ts +++ b/src/main/ts/tsx/traits.ts @@ -2,9 +2,12 @@ import _WidgetBase = require("dijit/_Wid type _WidgetBaseConstructor = typeof _WidgetBase; +export type DojoNodePosition = "first" | "after" | "before" | "last" | "replace" | "only" | number; export interface BuildContext { getDomElement(): HTMLElement; + + placeAt(refNode: string | Node, position?: DojoNodePosition): void; } export function isNode(el: any): el is HTMLElement { diff --git a/src/test/tsconfig.json b/src/test/tsconfig.json --- a/src/test/tsconfig.json +++ b/src/test/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../tsconfig", "compilerOptions": { "baseUrl": ".", - "rootDir": "ts", + //"rootDir": "ts", "rootDirs": [ "ts", "typings",