remove h useless hack

This commit is contained in:
CoolElectronics 2024-01-19 17:41:40 -05:00
parent 6cd1e1f304
commit eb6ee2cb8c
No known key found for this signature in database
GPG key ID: F63593D168636C50
3 changed files with 5 additions and 20 deletions

2
.gitignore vendored
View file

@ -1,3 +1,5 @@
examples/lib/
node_modules
index.js
a.js
index.html

View file

@ -127,25 +127,8 @@ export function useValue(references) {
return reference.proxy[reference.property];
}
// Hack to skip use() when there's only one possible property
Object.defineProperty(window, "h", {
get: () => {
__reference_stack = [];
return (type, props, ...children) => {
let references = __reference_stack;
references[ALICEJS_REFERENCES_MARKER] = true;
if (references.length == 1 && children.length == 1) {
__reference_stack = [];
return h(type, props, references);
} else {
return h(type, props, ...children);
}
};
}
});
// Actual JSX factory. Responsible for creating the HTML elements and all of the *reactive* syntactic sugar
function h(type, props, ...children) {
export function h(type, props, ...children) {
if (typeof type === "function") {
let newthis = stateful({});

View file

@ -13,7 +13,7 @@ function App() {
<div>
<button on:click={() => this.counter++} >Click me!</button>
<p>
{this.counter}
{use(this.counter)}
</p>
</div>
);
@ -39,7 +39,7 @@ function App() {
<div>
<button onClick={increase}>Click me!</button>
<p>
Value: {use(this.counter)}
Value: {counter}
</p>
</div>
);