Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/funny-showers-hope.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@solidjs/meta": patch
---

fix: Don't read props of the Title component during cleanup
5 changes: 3 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ const metaTagProperties: string[] =
const getTagKey = (tag: TagDescription, properties: string[]) => {
// pick allowed properties and sort them
const tagProps = Object.fromEntries(
Object.entries(tag.props)
.filter(([k]) => properties.includes(k))
properties
.filter(k => k in tag.props)
.map(k => [k, tag.props[k]])
.sort()
);

Expand Down
26 changes: 25 additions & 1 deletion test/index.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* @jsxImportSource solid-js */
import { createSignal, lazy } from "solid-js";
import { createSignal, getOwner, lazy } from "solid-js";
import { hydrate, render, Show } from "solid-js/web";
import { MetaProvider, Title, Style, Meta, Link, Base } from "../src";
import { hydrationScript, removeScript } from "./hydration_script";
Expand Down Expand Up @@ -304,6 +304,30 @@ test("throws error if head tag is rendered without MetaProvider", () => {
}).toThrowError(/<MetaProvider \/> should be in the tree/);
});

test("doesn't create any effect on removal", () => {
let div = document.createElement("div");

const [ show, setShow ] = createSignal(true);
const showAndTest = () => {
expect(getOwner()?.owner).toBeTruthy();
return show();
};

const dispose = render(
() => (
<MetaProvider>
<Show when={show()}>
<Title>Something {showAndTest()} that forces the Solid compiler to create a memo here</Title>
</Show>
</MetaProvider>
),
div
);

setShow(false);
dispose();
});

test("Escaping the title tag", () => {
let div = document.createElement("div");
const snapshot = '<title>Hello&lt;/title&gt;&lt;script&gt;alert("inject");&lt;/script&gt;&lt;title&gt; World</title>';
Expand Down