diff --git a/.changeset/funny-showers-hope.md b/.changeset/funny-showers-hope.md new file mode 100644 index 0000000..8f7260b --- /dev/null +++ b/.changeset/funny-showers-hope.md @@ -0,0 +1,5 @@ +--- +"@solidjs/meta": patch +--- + +fix: Don't read props of the Title component during cleanup diff --git a/src/index.tsx b/src/index.tsx index bba8268..b1ed144 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -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() ); diff --git a/test/index.spec.tsx b/test/index.spec.tsx index 13266ae..8aa10ae 100644 --- a/test/index.spec.tsx +++ b/test/index.spec.tsx @@ -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"; @@ -304,6 +304,30 @@ test("throws error if head tag is rendered without MetaProvider", () => { }).toThrowError(/ 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( + () => ( + + + Something {showAndTest()} that forces the Solid compiler to create a memo here + + + ), + div + ); + + setShow(false); + dispose(); +}); + test("Escaping the title tag", () => { let div = document.createElement("div"); const snapshot = 'Hello</title><script>alert("inject");</script><title> World';