(arr: T[]): T[][] {
return arr.map((_, i) => arr.slice(0, i));
}
+function weird_slices
(arr: T[]): T[][] {
+ return arr.map(item => [...arr.filter(t => t != item), item]);
+}
+
const MultiWheel: Component = ({ items }, _) => (
- {slices(items).map(items => (
-
+ {...weird_slices(items).map(items => (
+
))}
+
);
diff --git a/html/html.ts b/html/html.ts
index d8130dc..a93c129 100644
--- a/html/html.ts
+++ b/html/html.ts
@@ -42,7 +42,7 @@ function expand_fragments(elem: Html): Html {
if (is_string(elem)) {
return elem;
} else {
- const children = expand_fragments_in_list(elem.children);
+ const children = expand_fragments_in_list(elem.children ?? []);
return { ...elem, children };
}
}
@@ -56,14 +56,13 @@ const attr = (attrs: Attributes) => (elem: Html): Html => {
}
};
-const escape = (unsafe: string): string => {
- return unsafe
+const escape = (unsafe: string): string =>
+ unsafe
.replaceAll("&", "&")
.replaceAll("<", "<")
.replaceAll(">", ">")
.replaceAll('"', """)
.replaceAll("'", "'");
-};
function render_attributes(attrs: Attributes): string {
return (
@@ -76,14 +75,14 @@ function render_attributes(attrs: Attributes): string {
}
function indent(str: string, amount = 4, char = " "): string {
- const ind = char.repeat(4);
+ const ind = char.repeat(amount);
return str
.split("\n")
.map((l) => ind + l)
.join("\n");
}
-// incomplete, obviously.
+// incomplete, obviously
const NON_SELF_CLOSING = ["div", "p", "a"];
function render_elem(