forked from mystiq/hydrogen-web
improve typing in utils
This commit is contained in:
parent
d9ddeaf107
commit
81ec8dca8c
1 changed files with 5 additions and 5 deletions
|
@ -14,10 +14,10 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {UIView, IMountArgs} from "./types";
|
import {UIView, IMountArgs, ViewNode} from "./types";
|
||||||
import {tag} from "./html";
|
import {tag} from "./html";
|
||||||
|
|
||||||
export function mountView(view: UIView, mountArgs?: IMountArgs): HTMLElement {
|
export function mountView(view: UIView, mountArgs?: IMountArgs): ViewNode {
|
||||||
let node;
|
let node;
|
||||||
try {
|
try {
|
||||||
node = view.mount(mountArgs);
|
node = view.mount(mountArgs);
|
||||||
|
@ -27,7 +27,7 @@ export function mountView(view: UIView, mountArgs?: IMountArgs): HTMLElement {
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function errorToDOM(error: Error): HTMLElement {
|
export function errorToDOM(error: Error): Element {
|
||||||
const stack = new Error().stack;
|
const stack = new Error().stack;
|
||||||
let callee: string | null = null;
|
let callee: string | null = null;
|
||||||
if (stack) {
|
if (stack) {
|
||||||
|
@ -38,10 +38,10 @@ export function errorToDOM(error: Error): HTMLElement {
|
||||||
tag.h3(error.message),
|
tag.h3(error.message),
|
||||||
tag.p(`This occurred while running ${callee}.`),
|
tag.p(`This occurred while running ${callee}.`),
|
||||||
tag.pre(error.stack),
|
tag.pre(error.stack),
|
||||||
]) as HTMLElement;
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function insertAt(parentNode: Element, idx: number, childNode: Element): void {
|
export function insertAt(parentNode: Element, idx: number, childNode: Node): void {
|
||||||
const isLast = idx === parentNode.childElementCount;
|
const isLast = idx === parentNode.childElementCount;
|
||||||
if (isLast) {
|
if (isLast) {
|
||||||
parentNode.appendChild(childNode);
|
parentNode.appendChild(childNode);
|
||||||
|
|
Loading…
Reference in a new issue