Skip to content

Commit a61aef0

Browse files
committed
Fix bug where "element" was required input.
1 parent 2f32185 commit a61aef0

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "simple-tsx",
3-
"version": "1.2.0",
3+
"version": "1.2.1",
44
"description": "A simple way to write tsx files. No babel required!",
55
"main": "dist/index.js",
66
"type": "commonjs",

src/element.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
import { AttributeValueType, AttributesType } from "./types";
22

33
export default class Element {
4-
element: HTMLElement;
4+
private privElement?: HTMLElement;
55

66
// This will allow you to use this class for IntrinsicElements. I know this is a hacky way to do things but I don't have anything better.
7-
[name: string]: AttributeValueType | HTMLElement;
7+
[name: string]: AttributeValueType | HTMLElement | undefined;
8+
9+
public get element(): HTMLElement {
10+
return this.privElement!
11+
}
812

913
constructor(
1014
tagName: string,
1115
attributes: AttributesType | null,
1216
...children: (Element | string | number | null | undefined)[]
1317
) {
14-
this.element = document.createElement(tagName);
18+
this.privElement = document.createElement(tagName);
1519
const trueAttributes = attributes || {};
1620
Object.entries(trueAttributes).forEach(([key, value]) => {
1721
if (key.startsWith("on") && key.toLowerCase() in window) {

0 commit comments

Comments
 (0)