From a05c860c6e169cf2eb19258a9b75b04542ed5d68 Mon Sep 17 00:00:00 2001 From: navi Date: Mon, 28 Sep 2026 14:29:37 +0200 Subject: [PATCH] fix: bind :thisSlide per style block instead of per compile pass Every slide's :thisSlide rules leaked into every other slide: the whole joined source was recompiled once per slide with all occurrences rebound, so each pass attached every slide's scoped rules to that pass's slide and the concatenated output applied them all to everyone. Bind the token while each block still belongs to one slide (global block -> any slide) and compile the project once - also drops the O(n) duplicated CSS output. --- src/slides/compile.ts | 69 +++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 39 deletions(-) diff --git a/src/slides/compile.ts b/src/slides/compile.ts index 4720d4c..37f51a1 100644 --- a/src/slides/compile.ts +++ b/src/slides/compile.ts @@ -109,6 +109,9 @@ function slideSelector(id: string): string { return `[data-ps-slide="${id}"]` } +/** What `:thisSlide` means inside the global slide's styles: any slide. */ +const ANY_SLIDE_SELECTOR = '[data-ps-slide]' + const THIS_SLIDE = ':thisSlide' // `` is a bogus comment to the HTML parser, so a placeholder would not @@ -206,52 +209,40 @@ function isGlobalTemplate(global: string): boolean { * Compile a project into runtime-ready data. * * Every `