feat: migrate Slider with native range semantics and strict ESM declarations

This commit is contained in:
maoyingjie
2026-10-23 13:12:26 +08:00
parent b1cb00deba
commit 4da45b109e
40 changed files with 2239 additions and 3 deletions
+37
View File
@@ -0,0 +1,37 @@
// @vitest-environment node
import { expect, it } from "vitest";
import { createSSRApp, h } from "vue";
import { renderToString } from "@vue/server-renderer";
import {
Slider,
SliderTrack,
SliderFill,
SliderThumb,
SliderOutput,
Label,
} from "../packages/vue/src";
it("renders explicit native range values, positions and composed label on the server", async () => {
expect(typeof window).toBe("undefined");
const html = await renderToString(
createSSRApp({
render: () =>
h(Slider, { defaultValue: [20, 80] }, () => [
h(Label, {}, () => "Price"),
h(SliderOutput),
h(SliderTrack, {}, () => [
h(SliderFill),
h(SliderThumb, { name: "min" }),
h(SliderThumb, { index: 1, name: "max" }),
]),
]),
}),
);
expect(html).toContain('aria-valuenow="20"');
expect(html).toContain('aria-valuenow="80"');
expect(html).toContain("left:20%");
expect(html).toContain("left:80%");
expect(html).not.toContain("display:none");
const labelId = html.match(/<span[^>]*id="([^"]+)"/)?.[1];
expect(labelId).toBeDefined();
expect(html).toContain(`aria-labelledby="${labelId}"`);
});