From ef888771d6ed71e2921b1caf70501955e5efb2d7 Mon Sep 17 00:00:00 2001
From: Simon Chan <1330321+yume-chan@users.noreply.github.com>
Date: Thu, 24 Oct 2024 00:37:07 +0800
Subject: [PATCH 1/3] Fix removing one
renders all previous s
---
src/index.tsx | 1 +
test/index.spec.tsx | 31 ++++++++++++++++++++++++++++++-
2 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/src/index.tsx b/src/index.tsx
index b1ed144..ded9fb0 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -155,6 +155,7 @@ function initClientProvider() {
for (let i = index - 1; i >= 0; i--) {
if (t[i] != null) {
document.head.appendChild(t[i].ref);
+ break;
}
}
}
diff --git a/test/index.spec.tsx b/test/index.spec.tsx
index 8aa10ae..e9e0abb 100644
--- a/test/index.spec.tsx
+++ b/test/index.spec.tsx
@@ -89,6 +89,35 @@ test("unmount middle child, should show only the last title", () => {
dispose();
});
+test("unmount last child, should show only the second last title", () => {
+ let div = document.createElement("div");
+ const snapshot1 = "Title 3";
+ const snapshot2 = "Title 2";
+ const [visible, setVisible] = createSignal(true);
+ const dispose = render(
+ () => (
+
+
+
Title 1
+
+
+
Title 2
+
+
+
+
Title 3
+
+
+
+ ),
+ div
+ );
+ expect(document.head.innerHTML).toBe(snapshot1);
+ setVisible(false);
+ expect(document.head.innerHTML).toBe(snapshot2);
+ dispose();
+});
+
test("hydrates only the last title", () => {
hydrationScript();
let div = document.createElement("div");
@@ -361,4 +390,4 @@ test("Escaping the title meta", () => {
);
expect(document.head.innerHTML).toBe(snapshot);
dispose();
-});
\ No newline at end of file
+});
From 9934fa84657011cb1acce0aa3c4d4a29b7e505d7 Mon Sep 17 00:00:00 2001
From: Birk Skyum
Date: Tue, 15 Apr 2025 11:52:23 +0200
Subject: [PATCH 2/3] add changeset
---
.changeset/wide-clubs-serve.md | 5 +++++
1 file changed, 5 insertions(+)
create mode 100644 .changeset/wide-clubs-serve.md
diff --git a/.changeset/wide-clubs-serve.md b/.changeset/wide-clubs-serve.md
new file mode 100644
index 0000000..cde8071
--- /dev/null
+++ b/.changeset/wide-clubs-serve.md
@@ -0,0 +1,5 @@
+---
+"@solidjs/meta": patch
+---
+
+Fix removing one renders all previous s
From c82cacb204103dc38d28be21fed866bda8add8a6 Mon Sep 17 00:00:00 2001
From: Birk Skyum
Date: Tue, 15 Apr 2025 11:54:01 +0200
Subject: [PATCH 3/3] format with prettier
---
test/index.spec.tsx | 23 +++++++++--------------
1 file changed, 9 insertions(+), 14 deletions(-)
diff --git a/test/index.spec.tsx b/test/index.spec.tsx
index e9e0abb..6487447 100644
--- a/test/index.spec.tsx
+++ b/test/index.spec.tsx
@@ -247,7 +247,7 @@ test("renders only the last meta with the same name", () => {
const snapshot1 = '';
const snapshot2 = '';
const snapshot3 = '';
-
+
const [visible1, setVisible1] = createSignal(false);
const [visible2, setVisible2] = createSignal(false);
const dispose = render(
@@ -308,16 +308,8 @@ test("renders both meta with the same name/property but different other attribut
const dispose = render(
() => (
-
-
+
+
),
div
@@ -336,7 +328,7 @@ test("throws error if head tag is rendered without MetaProvider", () => {
test("doesn't create any effect on removal", () => {
let div = document.createElement("div");
- const [ show, setShow ] = createSignal(true);
+ const [show, setShow] = createSignal(true);
const showAndTest = () => {
expect(getOwner()?.owner).toBeTruthy();
return show();
@@ -346,7 +338,9 @@ test("doesn't create any effect on removal", () => {
() => (
- Something {showAndTest()} that forces the Solid compiler to create a memo here
+
+ Something {showAndTest()} that forces the Solid compiler to create a memo here
+
),
@@ -359,7 +353,8 @@ test("doesn't create any effect on removal", () => {
test("Escaping the title tag", () => {
let div = document.createElement("div");
- const snapshot = 'Hello</title><script>alert("inject");</script><title> World';
+ const snapshot =
+ 'Hello</title><script>alert("inject");</script><title> World';
const dispose = render(
() => (