@@ -4550,16 +4550,19 @@ function journalText(node: Text, previous: string | null): void {
45504550}
45514551
45524552/**
4553- * True while a spread commit's write loop runs under a journaled transaction:
4554- * the element's own replay entry supersedes per-attribute snapshots, so the
4555- * writers below skip their getAttribute reads. Replaying writes (a rollback
4556- * re-running a writer) never journal either — they only append dead entries
4557- * to a log the rollback discards after replay.
4553+ * Host whose in-flight spread/planned write owns the journal window: that
4554+ * element's replay entry supersedes per-attribute snapshots, so its writers
4555+ * skip getAttribute reads. Other hosts keep snapshotting — a nested
4556+ * custom-element callback or flushSync can write them, and those writes are
4557+ * not covered by the outer undo. Nested dispatches save/restore this slot so
4558+ * an inner finally cannot unmute the outer write. Replaying writes never
4559+ * journal either — they only append dead entries to a log the rollback
4560+ * discards after replay.
45584561 */
4559- let JOURNAL_ATTR_SUPPRESS = false ;
4562+ let JOURNAL_ATTR_SUPPRESS_EL: Element | null = null ;
45604563
45614564function journalAttr(el: Element, name: string): void {
4562- if (JOURNAL_ATTR_SUPPRESS || TRANSITION_JOURNAL_REPLAYING) return;
4565+ if (el === JOURNAL_ATTR_SUPPRESS_EL || TRANSITION_JOURNAL_REPLAYING) return;
45634566 TRANSITION_JOURNAL!.push(JOURNAL_ATTR, el, name, (STAGED_DOM?.view(el) ?? el).getAttribute(name));
45644567 journalBag();
45654568}
@@ -23807,9 +23810,9 @@ const SOURCES_PLAN = /* @__PURE__ */ Symbol('octane.host-prop-sources-plan');
2380723810 * attachSourcesPlan's per-commit allocations — a source shape that never
2380823811 * stabilizes reverts to the full path for good. ponytail: poisoned is
2380923812 * permanent; a shape that stabilizes later keeps the full path (reviving it
23810- * would take a decay or per-shape plans).
23813+ * would take a decay or per-shape plans). Count lives on the plan (`misses`),
23814+ * not on the host.
2381123815 */
23812- const SOURCES_PLAN_MISSES = /* @__PURE__ */ Symbol('octane.host-prop-sources-plan-misses');
2381323816const SOURCES_PLAN_MISS_LIMIT = 3;
2381423817
2381523818/**
@@ -23840,6 +23843,12 @@ interface ResolvedSourcesPlan {
2384023843 readonly diffIdx: number[];
2384123844 readonly diffVal: unknown[];
2384223845 diffLen: number;
23846+ /**
23847+ * Consecutive failed verifications. Lives on the plan, not the host: a DOM
23848+ * expando on the committed write path is banned, and the plan is already
23849+ * the per-element planning record.
23850+ */
23851+ misses: number;
2384323852}
2384423853
2384523854/**
@@ -23898,6 +23907,7 @@ function attachSourcesPlan(
2389823907 resolved: Record<string, unknown>,
2389923908 sources: readonly HostPropSource[],
2390023909 winners: HostPropWriter[],
23910+ misses = 0,
2390123911): void {
2390223912 let spreadIndex = -1;
2390323913 let spreadKeys: readonly string[] | null = null;
@@ -23953,6 +23963,7 @@ function attachSourcesPlan(
2395323963 diffIdx: new Array<number>(winners.length),
2395423964 diffVal: new Array<unknown>(winners.length),
2395523965 diffLen: 0,
23966+ misses,
2395623967 } satisfies ResolvedSourcesPlan,
2395723968 });
2395823969}
@@ -24101,10 +24112,11 @@ function writePlannedDiff(
2410124112 TRANSITION_JOURNAL !== null &&
2410224113 !TRANSITION_JOURNAL_REPLAYING &&
2410324114 activeHydration() === null;
24115+ const prevSuppress = JOURNAL_ATTR_SUPPRESS_EL;
2410424116 if (journalReplay) {
2410524117 journalUndo(() => writePlannedDiff(el, prev, next, plan, scope, true));
2410624118 journalBag();
24107- JOURNAL_ATTR_SUPPRESS = true ;
24119+ JOURNAL_ATTR_SUPPRESS_EL = el ;
2410824120 }
2410924121 try {
2411024122 if (!replay) stampSpreadPropFlags(el, next);
@@ -24165,7 +24177,7 @@ function writePlannedDiff(
2416524177 }
2416624178 if (process.env.NODE_ENV !== 'production' && !replay) queueDevFormDiagnostic(el, scope);
2416724179 } finally {
24168- if (journalReplay) JOURNAL_ATTR_SUPPRESS = false ;
24180+ if (journalReplay) JOURNAL_ATTR_SUPPRESS_EL = prevSuppress ;
2416924181 }
2417024182}
2417124183
@@ -24190,11 +24202,10 @@ function replaySourcesPlan(
2419024202 const plan = (prev as Record<symbol, unknown>)[SOURCES_PLAN] as ResolvedSourcesPlan | undefined;
2419124203 if (plan === undefined) return null;
2419224204 if (!scanSourcesForPlan(sources, plan, prev, readStyle)) {
24193- const tagged = el as any;
24194- tagged[SOURCES_PLAN_MISSES] = ((tagged[SOURCES_PLAN_MISSES] as number | undefined) ?? 0) + 1;
24205+ plan.misses++;
2419524206 return null;
2419624207 }
24197- (el as any)[SOURCES_PLAN_MISSES] = 0;
24208+ if (plan.misses !== 0) plan.misses = 0;
2419824209 const next = buildFromSourcesPlan(plan, prev);
2419924210 if (
2420024211 next === prev &&
@@ -24424,14 +24435,15 @@ export function setHostPropSources(
2442424435 // allocations. The plan stamps the record actually retained — on an
2442524436 // unchanged commit resolvedHostPropsEqual just proved `prev` carries the
2442624437 // identical keys, so the plan replays correctly against it — rather than
24427- // dying with a discarded `resolved`. Elements whose scans keep failing stop
24428- // paying the attach once SOURCES_PLAN_MISS_LIMIT trips.
24429- if (
24430- !formHost &&
24431- prev !== undefined &&
24432- (((el as any)[SOURCES_PLAN_MISSES] as number | undefined) ?? 0) < SOURCES_PLAN_MISS_LIMIT
24433- )
24434- attachSourcesPlan(el, out!, sources, winners);
24438+ // dying with a discarded `resolved`. Consecutive scan misses live on the
24439+ // previous plan; once SOURCES_PLAN_MISS_LIMIT trips, attach stops.
24440+ const prevPlan =
24441+ prev === undefined
24442+ ? undefined
24443+ : ((prev as Record<symbol, unknown>)[SOURCES_PLAN] as ResolvedSourcesPlan | undefined);
24444+ const planMisses = prevPlan?.misses ?? 0;
24445+ if (!formHost && prev !== undefined && planMisses < SOURCES_PLAN_MISS_LIMIT)
24446+ attachSourcesPlan(el, out!, sources, winners, planMisses);
2443524447 return out;
2443624448}
2443724449
@@ -25099,7 +25111,8 @@ export function setSpread(
2509925111 setSpread(el, prev, value, mountScope, skipDangerouslySetInnerHTML, skipFormControls, true),
2510025112 );
2510125113 journalBag();
25102- JOURNAL_ATTR_SUPPRESS = true;
25114+ const prevSuppress = JOURNAL_ATTR_SUPPRESS_EL;
25115+ JOURNAL_ATTR_SUPPRESS_EL = el;
2510325116 try {
2510425117 setSpreadBody(
2510525118 el,
@@ -25111,7 +25124,7 @@ export function setSpread(
2511125124 false,
2511225125 );
2511325126 } finally {
25114- JOURNAL_ATTR_SUPPRESS = false ;
25127+ JOURNAL_ATTR_SUPPRESS_EL = prevSuppress ;
2511525128 }
2511625129}
2511725130
0 commit comments