We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
introduced in #72
Essentially get rid of the any
any
The text was updated successfully, but these errors were encountered:
Add TODO(#73)
9599819
vars
Tag can extend the HTMLElement interface. Something like:
Tag
HTMLElement
interface Tag extends HTMLElement { att$: (name: string, value: string) => Tag onclick$: (callback: (this: GlobalEventHandlers, ev: MouseEvent) => Tag) => Tag }
A Tag can then be created with:
const result: Tag = Object.assign(document.createElement(name), { att$: function(name, value) { this.setAttribute(name, value); return this; } as Tag["att$"], onclick$: function(callback) { this.onclick = callback; return this; } as Tag["onclick$"] });
The Object.assign() stuff might not be as clean as one would like. Another way to assign att$ and onclick$ to result would be:
Object.assign()
att$
onclick$
result
const result = document.createElement(name); (result as Tag).att$ = function(name, value) { this.setAttribute(name, value); return this; }; (result as Tag).onclick$ = function(callback) { this.onclick = callback; return this; }; // ... return result as Tag;
And when Tag is no longer any we also need to properly cast the "mundane tags" to the appropriate element type:
function input(type: string) { return tag("input").att$("type", type) as Tag & HTMLInputElement; }
Sorry, something went wrong.
No branches or pull requests
introduced in #72
Essentially get rid of the
any
The text was updated successfully, but these errors were encountered: