@tanstack/redact 0.0.19 → 0.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/attributes.d.ts +1 -0
- package/dist/core/attributes.js +6 -0
- package/dist/core/attributes.js.map +2 -2
- package/dist/dom/dom.js +7 -5
- package/dist/dom/dom.js.map +2 -2
- package/dist/dom/features/class/full.js +8 -2
- package/dist/dom/features/class/full.js.map +2 -2
- package/dist/dom/features/hydration/full.js +6 -3
- package/dist/dom/features/hydration/full.js.map +2 -2
- package/dist/dom/features/suspense/full.js +9 -9
- package/dist/dom/features/suspense/full.js.map +2 -2
- package/dist/dom/reconcile.d.ts +3 -3
- package/dist/dom/reconcile.js +14 -18
- package/dist/dom/reconcile.js.map +2 -2
- package/dist/server/escape.js +2 -2
- package/dist/server/escape.js.map +2 -2
- package/package.json +10 -5
- package/src/core/attributes.ts +6 -0
- package/src/dom/dom.ts +7 -4
- package/src/dom/features/class/full.ts +9 -2
- package/src/dom/features/hydration/full.ts +10 -3
- package/src/dom/features/suspense/full.ts +9 -9
- package/src/dom/reconcile.ts +13 -19
- package/src/server/escape.ts +7 -6
|
@@ -147,7 +147,7 @@ function renderSuspense(fiber: Fiber, domParent: Node, anchor: Node | null): voi
|
|
|
147
147
|
renderFiber(state.f, domParent, anchor)
|
|
148
148
|
} else {
|
|
149
149
|
// First-mount suspension — nothing to preserve.
|
|
150
|
-
unmountAllChildren(fiber
|
|
150
|
+
unmountAllChildren(fiber)
|
|
151
151
|
reconcileChildren(fiber, childrenToArray(props.fallback), domParent, anchor)
|
|
152
152
|
}
|
|
153
153
|
} else {
|
|
@@ -160,7 +160,7 @@ function renderSuspense(fiber: Fiber, domParent: Node, anchor: Node | null): voi
|
|
|
160
160
|
state.d = null
|
|
161
161
|
}
|
|
162
162
|
if (state.f) {
|
|
163
|
-
unmountFiber(state.f
|
|
163
|
+
unmountFiber(state.f)
|
|
164
164
|
state.f = null
|
|
165
165
|
}
|
|
166
166
|
}
|
|
@@ -210,7 +210,7 @@ function hydrateSuspenseBoundary(
|
|
|
210
210
|
} catch (e) {
|
|
211
211
|
if (!isHydrationBailout(e)) {
|
|
212
212
|
clearBoundaryRange(startMark, endMark)
|
|
213
|
-
unmountAllChildren(fiber
|
|
213
|
+
unmountAllChildren(fiber)
|
|
214
214
|
throw e
|
|
215
215
|
}
|
|
216
216
|
recoverBoundaryHydration(fiber, props.children, parent, startMark, endMark)
|
|
@@ -258,14 +258,14 @@ function recoverBoundaryHydration(
|
|
|
258
258
|
const prevHydrating = root.h
|
|
259
259
|
discardPendingWork(root)
|
|
260
260
|
clearBoundaryRange(startMark, endMark)
|
|
261
|
-
unmountAllChildren(fiber
|
|
261
|
+
unmountAllChildren(fiber)
|
|
262
262
|
root.h = false
|
|
263
263
|
try {
|
|
264
264
|
reconcileChildren(fiber, childrenToArray(children), parent, endMark)
|
|
265
265
|
advanceCursorPast(fiber.parent!, endMark)
|
|
266
266
|
} catch (clientError) {
|
|
267
267
|
clearBoundaryRange(startMark, endMark)
|
|
268
|
-
unmountAllChildren(fiber
|
|
268
|
+
unmountAllChildren(fiber)
|
|
269
269
|
throw clientError
|
|
270
270
|
} finally {
|
|
271
271
|
root.h = prevHydrating
|
|
@@ -277,13 +277,13 @@ function recoverFallbackHydration(fiber: Fiber, fallback: any, parent: HTMLEleme
|
|
|
277
277
|
const prevHydrating = root.h
|
|
278
278
|
discardPendingWork(root)
|
|
279
279
|
parent.textContent = ''
|
|
280
|
-
unmountAllChildren(fiber
|
|
280
|
+
unmountAllChildren(fiber)
|
|
281
281
|
root.h = false
|
|
282
282
|
try {
|
|
283
283
|
reconcileChildren(fiber, childrenToArray(fallback), parent, null)
|
|
284
284
|
} catch (clientError) {
|
|
285
285
|
parent.textContent = ''
|
|
286
|
-
unmountAllChildren(fiber
|
|
286
|
+
unmountAllChildren(fiber)
|
|
287
287
|
throw clientError
|
|
288
288
|
} finally {
|
|
289
289
|
root.h = prevHydrating
|
|
@@ -303,7 +303,7 @@ function rehydrateBoundary(fiber: Fiber): void {
|
|
|
303
303
|
withCurrentRoot(root, () => {
|
|
304
304
|
const prevHydrating = root.h
|
|
305
305
|
try {
|
|
306
|
-
unmountAllChildren(fiber
|
|
306
|
+
unmountAllChildren(fiber)
|
|
307
307
|
|
|
308
308
|
// Re-hydrate with real children against the now-real DOM range.
|
|
309
309
|
root.h = true
|
|
@@ -312,7 +312,7 @@ function rehydrateBoundary(fiber: Fiber): void {
|
|
|
312
312
|
} catch (e) {
|
|
313
313
|
if (!isHydrationBailout(e)) {
|
|
314
314
|
clearBoundaryRange(state.b, state.e)
|
|
315
|
-
unmountAllChildren(fiber
|
|
315
|
+
unmountAllChildren(fiber)
|
|
316
316
|
throw e
|
|
317
317
|
}
|
|
318
318
|
|
package/src/dom/reconcile.ts
CHANGED
|
@@ -531,14 +531,14 @@ export function reconcileChildren(
|
|
|
531
531
|
// Unmount unclaimed
|
|
532
532
|
for (const f of existing) {
|
|
533
533
|
if (!claimed.has(f)) {
|
|
534
|
-
unmountFiber(f
|
|
534
|
+
unmountFiber(f)
|
|
535
535
|
structurallyChanged = true
|
|
536
536
|
}
|
|
537
537
|
}
|
|
538
538
|
// Leftover keyed
|
|
539
539
|
for (const f of keyed.values()) {
|
|
540
540
|
if (!claimed.has(f)) {
|
|
541
|
-
unmountFiber(f
|
|
541
|
+
unmountFiber(f)
|
|
542
542
|
structurallyChanged = true
|
|
543
543
|
}
|
|
544
544
|
}
|
|
@@ -1017,13 +1017,13 @@ export function isThenable(x: any): x is Promise<any> {
|
|
|
1017
1017
|
// Unmount
|
|
1018
1018
|
// ---------------------------------------------------------------------------
|
|
1019
1019
|
|
|
1020
|
-
export function unmountFiber(fiber: Fiber,
|
|
1020
|
+
export function unmountFiber(fiber: Fiber, removeDom = true): void {
|
|
1021
1021
|
fiber.um = true
|
|
1022
1022
|
// Recurse first
|
|
1023
1023
|
let c = fiber.child
|
|
1024
1024
|
while (c) {
|
|
1025
1025
|
const next = c.sibling
|
|
1026
|
-
unmountFiber(c, fiber.tag === FiberTag.
|
|
1026
|
+
unmountFiber(c, removeDom || fiber.tag === FiberTag.Portal)
|
|
1027
1027
|
c = next
|
|
1028
1028
|
}
|
|
1029
1029
|
fiber.child = null
|
|
@@ -1040,12 +1040,7 @@ export function unmountFiber(fiber: Fiber, domParent: Node): void {
|
|
|
1040
1040
|
fiber.cu = null
|
|
1041
1041
|
}
|
|
1042
1042
|
|
|
1043
|
-
if (fiber.tag === FiberTag.Class && fiber.sn
|
|
1044
|
-
try {
|
|
1045
|
-
fiber.sn.componentWillUnmount()
|
|
1046
|
-
} catch (e) {
|
|
1047
|
-
if (currentRoot?.re) currentRoot.re(e)
|
|
1048
|
-
}
|
|
1043
|
+
if (fiber.tag === FiberTag.Class && fiber.sn) {
|
|
1049
1044
|
fiber.sn._fiber = null
|
|
1050
1045
|
fiber.sn._enqueueUpdate = null
|
|
1051
1046
|
fiber.sn._forceUpdate = null
|
|
@@ -1054,19 +1049,17 @@ export function unmountFiber(fiber: Fiber, domParent: Node): void {
|
|
|
1054
1049
|
// Detach ref
|
|
1055
1050
|
if (fiber.ref) detachRef(fiber.ref)
|
|
1056
1051
|
|
|
1057
|
-
//
|
|
1058
|
-
if (
|
|
1059
|
-
fiber.dom
|
|
1060
|
-
} else if (fiber.tag === FiberTag.Text && fiber.dom && fiber.dom.parentNode) {
|
|
1061
|
-
fiber.dom.parentNode.removeChild(fiber.dom)
|
|
1052
|
+
// Only host and text fibers own DOM nodes.
|
|
1053
|
+
if (removeDom) {
|
|
1054
|
+
fiber.dom?.parentNode?.removeChild(fiber.dom)
|
|
1062
1055
|
}
|
|
1063
1056
|
}
|
|
1064
1057
|
|
|
1065
|
-
export function unmountAllChildren(parent: Fiber
|
|
1058
|
+
export function unmountAllChildren(parent: Fiber): void {
|
|
1066
1059
|
let c = parent.child
|
|
1067
1060
|
while (c) {
|
|
1068
1061
|
const next = c.sibling
|
|
1069
|
-
unmountFiber(c
|
|
1062
|
+
unmountFiber(c)
|
|
1070
1063
|
c = next
|
|
1071
1064
|
}
|
|
1072
1065
|
parent.child = null
|
|
@@ -1228,8 +1221,8 @@ export function enqueueEffect(fiber: Fiber, effect: Effect): void {
|
|
|
1228
1221
|
}
|
|
1229
1222
|
}
|
|
1230
1223
|
|
|
1231
|
-
export function scheduleLifecycle(
|
|
1232
|
-
pendingLifecycles.push(fn)
|
|
1224
|
+
export function scheduleLifecycle(fiber: Fiber, fn: () => void): void {
|
|
1225
|
+
pendingLifecycles.push(() => { if (!fiber.um) fn() })
|
|
1233
1226
|
}
|
|
1234
1227
|
|
|
1235
1228
|
export function runEffects(root: FiberRoot): void {
|
|
@@ -1257,6 +1250,7 @@ export function runEffects(root: FiberRoot): void {
|
|
|
1257
1250
|
}
|
|
1258
1251
|
|
|
1259
1252
|
function runEffect(fiber: Fiber, effect: Effect, root: FiberRoot): void {
|
|
1253
|
+
if (fiber.um) return
|
|
1260
1254
|
try {
|
|
1261
1255
|
const cleanup = effect.c()
|
|
1262
1256
|
if (typeof cleanup == 'function') {
|
package/src/server/escape.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { attributeName } from '../core/attributes'
|
|
1
|
+
import { attributeName, STRING_BOOLEAN_ATTRS } from '../core/attributes'
|
|
2
2
|
|
|
3
3
|
const ATTR_MAP: Record<string, string> = {
|
|
4
4
|
'&': '&',
|
|
@@ -96,11 +96,12 @@ export function attrToHtml(name: string, value: unknown, isSvg = false): string
|
|
|
96
96
|
|
|
97
97
|
const htmlName = attributeName(name, isSvg)
|
|
98
98
|
|
|
99
|
-
//
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
99
|
+
// These attributes need explicit "false", not boolean-attribute absence.
|
|
100
|
+
if (
|
|
101
|
+
STRING_BOOLEAN_ATTRS.has(htmlName) ||
|
|
102
|
+
name.startsWith('aria-') ||
|
|
103
|
+
name.startsWith('data-')
|
|
104
|
+
) {
|
|
104
105
|
return ` ${htmlName}="${escapeAttr(String(value))}"`
|
|
105
106
|
}
|
|
106
107
|
|