Skip to content

Commit ce4a89b

Browse files
committed
ifeat: hoist native tag refs
1 parent c74f145 commit ce4a89b

File tree

88 files changed

+2616
-231
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+2616
-231
lines changed

.sizes.json

+20-20
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
{
88
"name": "*",
99
"total": {
10-
"min": 17986,
11-
"brotli": 6770
10+
"min": 18455,
11+
"brotli": 6945
1212
}
1313
},
1414
{
@@ -18,12 +18,12 @@
1818
"brotli": 144
1919
},
2020
"runtime": {
21-
"min": 4137,
22-
"brotli": 1798
21+
"min": 4180,
22+
"brotli": 1829
2323
},
2424
"total": {
25-
"min": 4326,
26-
"brotli": 1942
25+
"min": 4369,
26+
"brotli": 1973
2727
}
2828
},
2929
{
@@ -33,42 +33,42 @@
3333
"brotli": 100
3434
},
3535
"runtime": {
36-
"min": 3456,
37-
"brotli": 1565
36+
"min": 3478,
37+
"brotli": 1571
3838
},
3939
"total": {
40-
"min": 3567,
41-
"brotli": 1665
40+
"min": 3589,
41+
"brotli": 1671
4242
}
4343
},
4444
{
4545
"name": "comments",
4646
"user": {
4747
"min": 1088,
48-
"brotli": 528
48+
"brotli": 529
4949
},
5050
"runtime": {
51-
"min": 7426,
52-
"brotli": 3121
51+
"min": 7469,
52+
"brotli": 3139
5353
},
5454
"total": {
55-
"min": 8514,
56-
"brotli": 3649
55+
"min": 8557,
56+
"brotli": 3668
5757
}
5858
},
5959
{
6060
"name": "comments 💧",
6161
"user": {
6262
"min": 145,
63-
"brotli": 119
63+
"brotli": 120
6464
},
6565
"runtime": {
66-
"min": 3658,
67-
"brotli": 1625
66+
"min": 3680,
67+
"brotli": 1643
6868
},
6969
"total": {
70-
"min": 3803,
71-
"brotli": 1745
70+
"min": 3825,
71+
"brotli": 1763
7272
}
7373
}
7474
]

.sizes/comments.csr/entry.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// size: 1088 (min) 528 (brotli)
1+
// size: 1088 (min) 529 (brotli)
22
const _expr_comment_comments_id$if_content = intersection(
33
2,
44
(_scope) => {

.sizes/comments.ssr/entry.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// size: 145 (min) 119 (brotli)
1+
// size: 145 (min) 120 (brotli)
22
const _open$for_content_effect = effect("a0", (_scope, { 11: open }) =>
33
on(_scope[2], "click", function () {
44
_open$for_content(_scope, !open);

.sizes/dom.js

+81-60
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// size: 17986 (min) 6770 (brotli)
1+
// size: 18455 (min) 6945 (brotli)
22
var empty = [],
33
rest = Symbol();
44
function attrTag(attrs2) {
@@ -160,15 +160,15 @@ var registeredValues = {},
160160
else if ("[" === token)
161161
this.d &&
162162
(dataIndex && branchEnd(this.d, visit, visit),
163-
this.l.push(this.d)),
163+
this.n.push(this.d)),
164164
(this.d = scopeId),
165165
(scope.a = visit);
166166
else if ("]" === token) {
167167
scope[data3] = visit;
168168
let curParent = visit.parentNode,
169169
startNode = branchEnd(this.d, visit, visit).a;
170170
curParent !== startNode.parentNode && curParent.prepend(startNode),
171-
(this.d = this.l.pop());
171+
(this.d = this.n.pop());
172172
} else if ("|" === token || "=" === token) {
173173
let next = data3.indexOf(" "),
174174
curNode = visit;
@@ -935,15 +935,12 @@ function dynamicClosure(valueAccessor, fn, getIntersection, getOwnerScope) {
935935
for (let subscriber of subscribers)
936936
subscriber.g || queueSource(subscriber, childSignal);
937937
},
938-
subscribe = (scope) => {
939-
let owner = getOwnerScope ? getOwnerScope(scope) : scope._,
940-
subscribers = (owner[subscribersAccessor] ||= new Set());
941-
subscribers.has(scope) ||
942-
(subscribers.add(scope),
943-
getAbortSignal(scope, -1).addEventListener("abort", () =>
944-
subscribers.delete(scope),
945-
));
946-
};
938+
subscribe = (ownerSignal.I = (scope) =>
939+
subscribeToScopeSet(
940+
getOwnerScope ? getOwnerScope(scope) : scope._,
941+
subscribersAccessor,
942+
scope,
943+
));
947944
return (
948945
(ownerSignal._ = (scope) => {
949946
childSignal(scope), subscribe(scope);
@@ -1046,7 +1043,7 @@ function queueSource(scope, signal, value2) {
10461043
}
10471044
function queueRender(scope, signal, value2) {
10481045
let i = pendingRenders.length,
1049-
render = { s: scope, I: signal, J: value2, t: scope.c?.f || 0, u: i };
1046+
render = { u: scope, J: signal, K: value2, x: scope.c?.f || 0, y: i };
10501047
for (pendingRenders.push(render); i; ) {
10511048
let parentIndex = (i - 1) >> 1,
10521049
parent = pendingRenders[parentIndex];
@@ -1112,15 +1109,15 @@ function runRenders() {
11121109
}
11131110
pendingRenders[i] = item;
11141111
}
1115-
render.s.c?.F || render.I(render.s, render.J);
1112+
render.u.c?.G || render.J(render.u, render.K);
11161113
}
11171114
!(function () {
11181115
for (let scope of pendingScopes) scope.g = 0;
11191116
pendingScopes = [];
11201117
})();
11211118
}
11221119
function comparePendingRenders(a, b) {
1123-
return a.t - b.t || a.u - b.u;
1120+
return a.x - b.x || a.y - b.y;
11241121
}
11251122
function resetAbortSignal(scope, id) {
11261123
let ctrl = scope.h?.[id];
@@ -1155,9 +1152,11 @@ function walkInternal(currentWalkIndex, walkCodes, scope) {
11551152
(currentMultiplier = storedMultiplier),
11561153
(storedMultiplier = 0),
11571154
32 === value2)
1158-
)
1159-
scope[currentScopeIndex++] = walker.currentNode;
1160-
else if (37 === value2)
1155+
) {
1156+
let node = walker.currentNode;
1157+
(scope[currentScopeIndex] = node),
1158+
(scope[currentScopeIndex++ + ">"] = () => node);
1159+
} else if (37 === value2)
11611160
walker.currentNode.replaceWith(
11621161
(walker.currentNode = scope[currentScopeIndex++] = new Text()),
11631162
);
@@ -1188,7 +1187,7 @@ function createBranchScopeWithRenderer(
11881187
parentScope,
11891188
parentNode,
11901189
) {
1191-
let branch = createBranch($global, renderer.x || parentScope, parentScope);
1190+
let branch = createBranch($global, renderer.j || parentScope, parentScope);
11921191
return initBranch(renderer, branch, parentNode), branch;
11931192
}
11941193
function createBranchScopeWithTagNameOrRenderer(
@@ -1204,9 +1203,9 @@ function createBranchScopeWithTagNameOrRenderer(
12041203
parentScope,
12051204
parentNode,
12061205
);
1207-
let branch = createBranch($global, parentScope, parentScope);
1208-
return (
1209-
(branch[0] =
1206+
let branch = createBranch($global, parentScope, parentScope),
1207+
node =
1208+
(branch[0] =
12101209
branch.a =
12111210
branch.b =
12121211
document.createElementNS(
@@ -1216,9 +1215,8 @@ function createBranchScopeWithTagNameOrRenderer(
12161215
? "http://www.w3.org/1998/Math/MathML"
12171216
: parentNode.namespaceURI,
12181217
tagNameOrRenderer,
1219-
)),
1220-
branch
1221-
);
1218+
));
1219+
return (branch["0>"] = () => node), branch;
12221220
}
12231221
function createBranch($global, ownerScope, parentScope) {
12241222
let branch = createScope($global),
@@ -1228,43 +1226,50 @@ function createBranch($global, ownerScope, parentScope) {
12281226
(branch.c = branch),
12291227
parentBranch
12301228
? ((branch.f = parentBranch.f + 1),
1231-
(branch.q = parentBranch),
1232-
(parentBranch.j ||= new Set()).add(branch))
1229+
(branch.t = parentBranch),
1230+
(parentBranch.l ||= new Set()).add(branch))
12331231
: (branch.f = 1),
12341232
branch
12351233
);
12361234
}
12371235
function initBranch(renderer, branch, parentNode) {
1238-
let clone = renderer.k(parentNode.namespaceURI),
1236+
let clone = renderer.m(parentNode.namespaceURI),
12391237
cloneParent = clone.parentNode;
12401238
cloneParent
1241-
? (walk(cloneParent.firstChild, renderer.y, branch),
1239+
? (walk(cloneParent.firstChild, renderer.z, branch),
12421240
(branch.a = cloneParent.firstChild),
12431241
(branch.b = cloneParent.lastChild))
1244-
: (walk(clone, renderer.y, branch), (branch.a = branch.b = clone)),
1245-
renderer.z && queueRender(branch, renderer.z);
1246-
}
1247-
function createRendererWithOwner(template, rawWalks, setup, getArgs) {
1242+
: (walk(clone, renderer.z, branch), (branch.a = branch.b = clone)),
1243+
renderer.A && queueRender(branch, renderer.A);
1244+
}
1245+
function createRendererWithOwner(
1246+
template,
1247+
rawWalks,
1248+
setup,
1249+
getArgs,
1250+
dynamicScopesAccessor,
1251+
) {
12481252
let args,
12491253
id = {},
12501254
walks = rawWalks ? trimWalkString(rawWalks) : " ";
12511255
return (owner) => ({
1252-
A: id,
1253-
B: template,
1254-
y: walks,
1255-
z: setup,
1256-
k: _clone,
1257-
x: owner,
1256+
B: id,
1257+
C: template,
1258+
z: walks,
1259+
A: setup,
1260+
k: dynamicScopesAccessor,
1261+
m: _clone,
1262+
j: owner,
12581263
get e() {
1259-
return (args ||= getArgs?.());
1264+
return (args ||= getArgs ? getArgs() : void 0);
12601265
},
12611266
});
12621267
}
12631268
function createRenderer(template, walks, setup, getArgs) {
12641269
return createRendererWithOwner(template, walks, setup, getArgs)();
12651270
}
12661271
function _clone(ns) {
1267-
return ((cloneCache[ns] ||= {})[this.B] ||= (function (html2, ns) {
1272+
return ((cloneCache[ns] ||= {})[this.C] ||= (function (html2, ns) {
12681273
let { firstChild: firstChild, lastChild: lastChild } = parseHTML(html2, ns),
12691274
parent = document.createElementNS(ns, "t");
12701275
return (
@@ -1273,7 +1278,7 @@ function _clone(ns) {
12731278
? () => firstChild.cloneNode(!0)
12741279
: () => parent.cloneNode(!0).firstChild
12751280
);
1276-
})(this.B, ns))();
1281+
})(this.C, ns))();
12771282
}
12781283
var cloneCache = {};
12791284
function conditional(nodeAccessor, ...branches) {
@@ -1306,27 +1311,43 @@ var dynamicTag = function (nodeAccessor, getContent, getTagVar, inputIsArgs) {
13061311
if (value2) return value2.content || value2.default || value2;
13071312
})(newRendererOrOp);
13081313
if (
1309-
((!(rendererAccessor in scope) ||
1314+
(!(rendererAccessor in scope) ||
13101315
((a = scope[rendererAccessor]) !== (b = newRenderer) &&
1311-
(a?.A || 0) !== b?.A)) &&
1312-
((scope[rendererAccessor] = newRenderer),
1313-
setConditionalRenderer(
1314-
scope,
1315-
nodeAccessor,
1316-
newRenderer || (getContent ? getContent(scope) : void 0),
1317-
createBranchScopeWithTagNameOrRenderer,
1318-
),
1319-
getTagVar && setTagVar(scope, childScopeAccessor, getTagVar()),
1320-
getContent &&
1321-
"string" == typeof newRenderer &&
1316+
(a?.B || 0) !== b?.B)) &&
1317+
((scope[rendererAccessor] = newRenderer),
1318+
setConditionalRenderer(
1319+
scope,
1320+
nodeAccessor,
1321+
newRenderer || (getContent ? getContent(scope) : void 0),
1322+
createBranchScopeWithTagNameOrRenderer,
1323+
),
1324+
getTagVar && setTagVar(scope, childScopeAccessor, getTagVar()),
1325+
newRenderer)
1326+
)
1327+
if ("string" == typeof newRenderer) {
1328+
if (getContent) {
1329+
let content = getContent(scope);
13221330
setConditionalRenderer(
13231331
scope[childScopeAccessor],
13241332
0,
1325-
getContent(scope),
1333+
content,
13261334
createBranchScopeWithRenderer,
1327-
)),
1328-
newRenderer)
1329-
) {
1335+
),
1336+
content.k &&
1337+
subscribeToScopeSet(
1338+
content.j,
1339+
content.k,
1340+
scope[childScopeAccessor]["0!"],
1341+
);
1342+
}
1343+
} else
1344+
newRenderer.k &&
1345+
subscribeToScopeSet(
1346+
newRenderer.j,
1347+
newRenderer.k,
1348+
scope[childScopeAccessor],
1349+
);
1350+
if (newRenderer) {
13301351
let input = getInput?.();
13311352
"string" == typeof newRenderer
13321353
? attrs(
@@ -1630,7 +1651,7 @@ var classIdToBranch = new Map(),
16301651
: value2,
16311652
createRenderer(args, clone) {
16321653
let renderer = createRenderer("", 0, 0, () => args);
1633-
return (renderer.k = clone), renderer;
1654+
return (renderer.m = clone), renderer;
16341655
},
16351656
render(out, component, renderer, args) {
16361657
let branch = component.scope;
@@ -1651,7 +1672,7 @@ var classIdToBranch = new Map(),
16511672
branch
16521673
? (applyArgs(branch, MARK), (existing = !0))
16531674
: ((branch = component.scope = createScope(out.global)),
1654-
(branch._ = renderer.x),
1675+
(branch._ = renderer.j),
16551676
initBranch(renderer, branch, document.body)),
16561677
applyArgs(branch, args);
16571678
})),

0 commit comments

Comments
 (0)