Skip to content

Commit c9c9725

Browse files
committed
refactor: remove unused getter api from serializer
1 parent 280f4d3 commit c9c9725

File tree

3 files changed

+3
-47
lines changed

3 files changed

+3
-47
lines changed

packages/runtime-tags/src/__tests__/serializer.test.ts

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
import assert from "node:assert/strict";
22
import { inspect } from "node:util";
33

4-
import {
5-
register,
6-
registerGetter,
7-
Serializer,
8-
stringify,
9-
} from "../html/serializer";
4+
import { register, Serializer, stringify } from "../html/serializer";
105
import type { Boundary } from "../html/writer";
116

127
describe("serializer", () => {
@@ -889,15 +884,6 @@ describe("serializer", () => {
889884
},
890885
);
891886
});
892-
893-
it("getter", () => {
894-
const scope = { value: 1 } as any;
895-
const fn = () => scope.value;
896-
fn.toString = () => "()=>s.value";
897-
const obj = { a: 1, fn };
898-
registerGetter("value", fn, scope);
899-
assertStringify(obj, `{a:1,fn:(s=>()=>s.value)(_.a={value:1})}`);
900-
});
901887
});
902888

903889
describe("serializer", () => {

packages/runtime-tags/src/html/serializer.ts

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ interface Registered {
1111
id: string;
1212
access: string;
1313
scope: unknown;
14-
getter: boolean;
1514
}
1615

1716
enum MutationType {
@@ -398,21 +397,6 @@ export function register<T extends WeakKey>(
398397
id,
399398
scope,
400399
access: "_._" + toAccess(toObjectKey(id)),
401-
getter: false,
402-
});
403-
return val;
404-
}
405-
406-
export function registerGetter<T extends WeakKey>(
407-
accessor: string,
408-
val: T,
409-
scope?: unknown,
410-
) {
411-
REGISTRY.set(val, {
412-
id: "",
413-
scope,
414-
access: toAccess(accessor),
415-
getter: true,
416400
});
417401
return val;
418402
}
@@ -649,7 +633,7 @@ function writeRegistered(
649633
val: WeakKey,
650634
parent: Reference | null,
651635
accessor: string,
652-
{ access, scope, getter }: Registered,
636+
{ access, scope }: Registered,
653637
) {
654638
if (scope) {
655639
const scopeRef = state.refs.get(scope);
@@ -661,21 +645,6 @@ function writeRegistered(
661645
);
662646
state.refs.set(val, fnRef);
663647

664-
if (getter) {
665-
if (scopeRef) {
666-
state.buf.push("()=>" + ensureId(state, scopeRef) + access);
667-
return true;
668-
}
669-
670-
state.buf.push("(s=>()=>s" + access + ")(");
671-
writeProp(state, scope, parent, "");
672-
state.buf.push(")");
673-
674-
const newScopeRef = state.refs.get(scope);
675-
if (newScopeRef) ensureId(state, newScopeRef);
676-
return true;
677-
}
678-
679648
if (scopeRef) {
680649
if (
681650
parent &&

packages/runtime-tags/src/html/writer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ export function _var(
135135
registryId: string,
136136
) {
137137
_scope_with_id(parentScopeId)[scopeOffsetAccessor] = _scope_id();
138+
// TODO: if the return value is already registered, use that.
138139
_scope_with_id(childScopeId)[AccessorProp.TagVariable] = _resume(
139140
{},
140141
registryId,

0 commit comments

Comments
 (0)