diff --git a/registry/components/caption-editorial-emphasis/caption-editorial-emphasis.html b/registry/components/caption-editorial-emphasis/caption-editorial-emphasis.html index 83f808425..3790946ee 100644 --- a/registry/components/caption-editorial-emphasis/caption-editorial-emphasis.html +++ b/registry/components/caption-editorial-emphasis/caption-editorial-emphasis.html @@ -205,8 +205,13 @@ function hfValidate(data) { if (!data || typeof data !== "object") return { ok: false, reason: "not-an-object" }; - if (data.version != null && Math.floor(Number(data.version)) > HF_CONTRACT_VERSION) { - return { ok: false, reason: "unsupported-version" }; + if (data.version != null) { + // Number("v2") is NaN and NaN > x is always false — an explicit + // finite check keeps malformed versions from slipping past the gate. + var hfVersion = Number(data.version); + if (!Number.isFinite(hfVersion) || Math.floor(hfVersion) > HF_CONTRACT_VERSION) { + return { ok: false, reason: "unsupported-version" }; + } } if (!Array.isArray(data.segments) || data.segments.length === 0) { return { ok: false, reason: "no-segments" }; @@ -679,6 +684,10 @@ var ready = document.fonts && document.fonts.ready ? document.fonts.ready : Promise.resolve(); ready.then(function () { + // A manual window.__HF_CAPTION_ATTACH__ call that lands while the + // sibling fetch / fonts.ready are still pending must win — never + // clobber it with the late-arriving boot payload. + if (hfCurrentTimeline) return; hfAttach(data); }); } diff --git a/registry/components/caption-emoji-pop/caption-emoji-pop.html b/registry/components/caption-emoji-pop/caption-emoji-pop.html index 6d6f15c69..7c982e278 100644 --- a/registry/components/caption-emoji-pop/caption-emoji-pop.html +++ b/registry/components/caption-emoji-pop/caption-emoji-pop.html @@ -208,8 +208,13 @@ function hfValidate(data) { if (!data || typeof data !== "object") return { ok: false, reason: "not-an-object" }; - if (data.version != null && Math.floor(Number(data.version)) > HF_CONTRACT_VERSION) { - return { ok: false, reason: "unsupported-version" }; + if (data.version != null) { + // Number("v2") is NaN and NaN > x is always false — an explicit + // finite check keeps malformed versions from slipping past the gate. + var hfVersion = Number(data.version); + if (!Number.isFinite(hfVersion) || Math.floor(hfVersion) > HF_CONTRACT_VERSION) { + return { ok: false, reason: "unsupported-version" }; + } } if (!Array.isArray(data.segments) || data.segments.length === 0) { return { ok: false, reason: "no-segments" }; @@ -790,6 +795,10 @@ var ready = document.fonts && document.fonts.ready ? document.fonts.ready : Promise.resolve(); ready.then(function () { + // A manual window.__HF_CAPTION_ATTACH__ call that lands while the + // sibling fetch / fonts.ready are still pending must win — never + // clobber it with the late-arriving boot payload. + if (hfCurrentTimeline) return; hfAttach(data); }); } diff --git a/registry/components/caption-highlight/caption-highlight.html b/registry/components/caption-highlight/caption-highlight.html index b87f407e8..a1d1b8be9 100644 --- a/registry/components/caption-highlight/caption-highlight.html +++ b/registry/components/caption-highlight/caption-highlight.html @@ -214,8 +214,13 @@ function hfValidate(data) { if (!data || typeof data !== "object") return { ok: false, reason: "not-an-object" }; - if (data.version != null && Math.floor(Number(data.version)) > HF_CONTRACT_VERSION) { - return { ok: false, reason: "unsupported-version" }; + if (data.version != null) { + // Number("v2") is NaN and NaN > x is always false — an explicit + // finite check keeps malformed versions from slipping past the gate. + var hfVersion = Number(data.version); + if (!Number.isFinite(hfVersion) || Math.floor(hfVersion) > HF_CONTRACT_VERSION) { + return { ok: false, reason: "unsupported-version" }; + } } if (!Array.isArray(data.segments) || data.segments.length === 0) { return { ok: false, reason: "no-segments" }; @@ -491,6 +496,10 @@ var ready = document.fonts && document.fonts.ready ? document.fonts.ready : Promise.resolve(); ready.then(function () { + // A manual window.__HF_CAPTION_ATTACH__ call that lands while the + // sibling fetch / fonts.ready are still pending must win — never + // clobber it with the late-arriving boot payload. + if (hfCurrentTimeline) return; hfAttach(data); }); } diff --git a/registry/components/caption-pill-karaoke/caption-pill-karaoke.html b/registry/components/caption-pill-karaoke/caption-pill-karaoke.html index 341400fb8..c0025e262 100644 --- a/registry/components/caption-pill-karaoke/caption-pill-karaoke.html +++ b/registry/components/caption-pill-karaoke/caption-pill-karaoke.html @@ -214,8 +214,13 @@ function hfValidate(data) { if (!data || typeof data !== "object") return { ok: false, reason: "not-an-object" }; - if (data.version != null && Math.floor(Number(data.version)) > HF_CONTRACT_VERSION) { - return { ok: false, reason: "unsupported-version" }; + if (data.version != null) { + // Number("v2") is NaN and NaN > x is always false — an explicit + // finite check keeps malformed versions from slipping past the gate. + var hfVersion = Number(data.version); + if (!Number.isFinite(hfVersion) || Math.floor(hfVersion) > HF_CONTRACT_VERSION) { + return { ok: false, reason: "unsupported-version" }; + } } if (!Array.isArray(data.segments) || data.segments.length === 0) { return { ok: false, reason: "no-segments" }; @@ -599,6 +604,10 @@ var ready = document.fonts && document.fonts.ready ? document.fonts.ready : Promise.resolve(); ready.then(function () { + // A manual window.__HF_CAPTION_ATTACH__ call that lands while the + // sibling fetch / fonts.ready are still pending must win — never + // clobber it with the late-arriving boot payload. + if (hfCurrentTimeline) return; hfAttach(data); }); } diff --git a/registry/components/caption-weight-shift/caption-weight-shift.html b/registry/components/caption-weight-shift/caption-weight-shift.html index f2c42f10f..d6340fd6a 100644 --- a/registry/components/caption-weight-shift/caption-weight-shift.html +++ b/registry/components/caption-weight-shift/caption-weight-shift.html @@ -200,8 +200,13 @@ function hfValidate(data) { if (!data || typeof data !== "object") return { ok: false, reason: "not-an-object" }; - if (data.version != null && Math.floor(Number(data.version)) > HF_CONTRACT_VERSION) { - return { ok: false, reason: "unsupported-version" }; + if (data.version != null) { + // Number("v2") is NaN and NaN > x is always false — an explicit + // finite check keeps malformed versions from slipping past the gate. + var hfVersion = Number(data.version); + if (!Number.isFinite(hfVersion) || Math.floor(hfVersion) > HF_CONTRACT_VERSION) { + return { ok: false, reason: "unsupported-version" }; + } } if (!Array.isArray(data.segments) || data.segments.length === 0) { return { ok: false, reason: "no-segments" }; @@ -616,6 +621,10 @@ var ready = document.fonts && document.fonts.ready ? document.fonts.ready : Promise.resolve(); ready.then(function () { + // A manual window.__HF_CAPTION_ATTACH__ call that lands while the + // sibling fetch / fonts.ready are still pending must win — never + // clobber it with the late-arriving boot payload. + if (hfCurrentTimeline) return; hfAttach(data); }); }