Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"name": "dom-create-element",
"version": "1.0.2",
"version": "1.0.3",
"description": "Create DOM elements.",
"main": "index.js",
"types": "./types.d.ts",
"license": "MIT",
"author": {
"name": "Baptiste Briel",
Expand Down
32 changes: 32 additions & 0 deletions types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
export = create;

type DomCreateElement = (CreateProperties) => HTMLElement;

type DomCreateElementBase = {
attr?: Array<[string, string]>;
};

type DomCreateElementCommon = DomCreateElementBase & {
children?: Array<HTMLElement|HTMLAnchorElement|HTMLImageElement>
html?: string;
};

type DomCreateElementOther = DomCreateElementCommon & {
selector: string;
};

type DomCreateElementImage = DomCreateElementBase & {
selector: 'img' | 'IMG';
src?: string;
lazyload?: boolean;
};

type DomCreateElementAnchor = DomCreateElementCommon & {
selector: 'a' | 'A';
link?: string;
target?: string;
};

declare function create(params:DomCreateElementImage): HTMLImageElement;
declare function create(params:DomCreateElementAnchor): HTMLAnchorElement;
declare function create(params:DomCreateElementOther): HTMLElement;