Render Modal as real markup; drain scripts via CaptureScript (#2742)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
This commit is contained in:
Paweł Kuna
2026-08-03 00:55:32 +02:00
committed by GitHub
co-authored by StarDev
parent 66dc336726
commit 575d68572f
200 changed files with 10670 additions and 10096 deletions
+19 -19
View File
@@ -1,6 +1,6 @@
---
// Port of ui/range.html. With an id → a noUiSlider div + init script, rendered
// directly here; without an id → a native <input type=range>.
// With an id → a noUiSlider div + init script; without an id → a native <input type=range>.
import CaptureScript from '../components/CaptureScript.astro';
interface Props {
min?: number;
max?: number;
@@ -18,7 +18,7 @@ const size = values.length;
const numericValues = values.map(Number);
const startValue = size > 1 ? numericValues : numericValues[0];
// connect array: {% for i in (2..size) %}cycle false,true{% endfor %} then true, false
// Connect array: alternate false/true for mid segments, then true, false.
let connectValue;
if (size > 1 || connect) {
const parts: boolean[] = [];
@@ -38,22 +38,22 @@ const rangeId = `range-${id}`;
}
{
id && (
<Fragment>
<Fragment set:html={'<!-- BEGIN RANGE -->'} />
<script define:vars={{ rangeId, startValue, connectValue, step, min, max }}>
function initRange() {
window.noUiSlider &&
noUiSlider.create(document.getElementById(rangeId), {
start: startValue,
...(connectValue ? { connect: connectValue } : {}),
step,
range: { min, max },
});
}
<CaptureScript>
<!-- BEGIN RANGE -->
<script define:vars={{ rangeId, startValue, connectValue, step, min, max }}>
function initRange() {
window.noUiSlider &&
noUiSlider.create(document.getElementById(rangeId), {
start: startValue,
...(connectValue ? { connect: connectValue } : {}),
step,
range: { min, max },
});
}
document.readyState !== 'loading' ? initRange() : document.addEventListener('DOMContentLoaded', initRange, { once: true });
</script>
<Fragment set:html={'<!-- END RANGE -->'} />
</Fragment>
document.readyState !== 'loading' ? initRange() : document.addEventListener('DOMContentLoaded', initRange, { once: true });
</script>
<!-- END RANGE -->
</CaptureScript>
)
}