Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "araz", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.ts", |
@@ -32,6 +32,8 @@ import { Element } from './types'; | ||
const createElement = <P extends { [key: string]: any }>({ | ||
const h = <P extends { [key: string]: any }>({ | ||
name, | ||
props = {} as P, | ||
children = null, | ||
setup, | ||
onMounted, | ||
}: Element<P>): HTMLElement => { | ||
@@ -43,6 +45,14 @@ const element: HTMLElement = document.createElement(name); | ||
addChildren(element, children); | ||
if (setup) { | ||
setup(element); // Call the setup function with the created element | ||
} | ||
if (onMounted) { | ||
element.addEventListener('DOMContentLoaded', () => { | ||
onMounted(element); // Call the onMounted function when the element is mounted | ||
}); | ||
} | ||
return element; | ||
}; | ||
export default createElement; | ||
export default h; |
// types.ts | ||
export interface Element<P extends { [key: string]: any } = {}> { | ||
name: string; | ||
props?: P; | ||
children?: Node | string | (Node | string)[] | null; | ||
} | ||
name: string; | ||
props?: P; | ||
children?: Node | string | (Node | string)[] | null; | ||
setup :any | ||
onMounted: any | ||
} | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3836
58