Skip to content

Commit

Permalink
rf
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishiv committed Oct 17, 2024
1 parent 7f21a45 commit 9bf65ce
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 33 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "alfama",
"version": "1.3.12",
"version": "1.3.13",
"author": "Abhishiv Saxena<abhishiv@gmail.com>",
"license": "MIT",
"description": "Fine-grained reactive library with no compiler, no magic, and no virtual DOM",
Expand Down
2 changes: 1 addition & 1 deletion src/core/state/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const createStoreSubscription = <T>(
const v = getValueUsingPath(manager.v as any, cursorPath);
return v;
} catch (e) {
console.log(wire, wire.stores, encodedCursor, manager.v);
// console.log(wire, wire.stores, encodedCursor, manager.v);
throw e;
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/dom/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ export const updateElement = (

export const getLiveFragmentChildNodes = (frag: LiveDocumentFragment) => {
const els: Node[] = [];
let node: Node | null = frag.startMarker;
let node: Node | null = frag.start;
while (node) {
els.push(node);
if (node === frag.endMarker) {
if (node === frag.end) {
break;
}
node = node.nextSibling;
Expand Down
19 changes: 10 additions & 9 deletions src/dom/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,25 @@ const createTextNode = (arg: string | number | boolean | null | undefined) =>

const createMarker = (text: string, owner: DocumentFragment) => {
const marker = document.createComment(text);
(marker as any).__owner__ = owner;
// (marker as any).__owner__ = owner;
return marker;
};

// important only use append/prepend
export class LiveDocumentFragment extends DocumentFragment {
startMarker: Comment;
endMarker: Comment;
start: Comment;
end: Comment;
constructor(t?: string) {
super();
this.startMarker = createMarker(`<${t}>`, this);
this.endMarker = createMarker(`</${t}>`, this);
super.append(this.startMarker, this.endMarker);
this.start = createMarker(`<${t}>`, this);
this.end = createMarker(`</${t}>`, this);
super.append(this.start, this.end);
}
append(...nodes: Node[]) {
this.endMarker.before(...nodes);
this.end.before(...nodes);
}
prepend(...nodes: Node[]) {
this.startMarker.after(...nodes);
this.start.after(...nodes);
}
}

Expand Down Expand Up @@ -125,7 +126,7 @@ const setAttributeValue = (
if (el.tagName === "INPUT" && attr === "value")
(el as HTMLInputElement).value = val;
} catch (e) {
console.error(el, attr, val);
// console.error(el, attr, val);
throw e;
}
};
36 changes: 17 additions & 19 deletions src/dom/index.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,36 @@
import { StoreManager, Wire, wireReset } from "../core/state";
import * as DOMConstants from "../dom/constants";
import {
Context,
ComponentUtils,
VElement,
Component,
ComponentVElement,
NativeVElement,
RenderContext,
TreeStep,
} from "./types";
import { getCursorProxyMeta } from "../utils";
import { getRenderContext, renderTreeStep, rmNodes } from "./api";
import { reifyTree } from "./traverser";
import type {
GenericEventAttrs,
HTMLAttrs,
SVGAttrs,
HTMLElements,
SVGAttrs,
SVGElements,
TargetedEvent,
} from "./jsx";
import { runWire, StoreManager, Wire, wireReset } from "../core/state";
import { getCursorProxyMeta } from "../utils";
import {
Component,
ComponentUtils,
ComponentVElement,
Context,
NativeVElement,
RenderContext,
TreeStep,
VElement,
} from "./types";

export * from "./types";
export * as DOMConstants from "./constants";
export {
addNode,
removeNode,
insertElement,
removeElement,
removeNode,
updateElement,
} from "./api";
export * as DOMConstants from "./constants";
export { reifyTree } from "./traverser";
export * from "./types";
export { h };

export function defineContext<T = any>(arg?: string): Context<T> {
return {
Expand Down Expand Up @@ -64,7 +63,6 @@ function h(
t: t,
} as ComponentVElement | NativeVElement;
}
export { h };

export function render(
element: VElement,
Expand Down
2 changes: 1 addition & 1 deletion src/dom/traverser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export const getTreeStep = (
onUnmount: [],
} as ComponentTreeStep;
} else {
console.error(el);
// console.error(el);
throw createError(110);
}
}
Expand Down

0 comments on commit 9bf65ce

Please sign in to comment.