Skip to content

Commit cd71df9

Browse files
committed
Merge branch 'dev-3.0'
2 parents fd1df7a + 37ae4f4 commit cd71df9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+721
-569
lines changed

.circleci/config.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,22 @@ version: 2.1
1919
jobs:
2020
test-node-20: # Maintenance LTS, EOL 2026.04.30
2121
docker:
22-
- image: cimg/node:20.19
22+
- image: cimg/node:20.20
2323
steps:
2424
*install-and-test
2525
test-node-22: # Maintenance LTS, EOL 2027.04.30
2626
docker:
27-
- image: cimg/node:22.21
27+
- image: cimg/node:22.22
2828
steps:
2929
*install-and-test
3030
test-node-24: # Active LTS, EOL 2028.04.30
3131
docker:
32-
- image: cimg/node:24.12
32+
- image: cimg/node:24.13
3333
steps:
3434
*install-and-test
3535
test-node-25: # Current, EOL 2026.06.01
3636
docker:
37-
- image: cimg/node:25.2
37+
- image: cimg/node:25.5
3838
steps:
3939
*install-and-test
4040
build-and-test:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ __coverage__
22
*.tgz
33
build
44
node_modules
5+
/.eslintcache

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
24.12.0
1+
24.13.0

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ successor of now unmaintained and stale
1919
[<img width=36 src="https://avatars.githubusercontent.com/u/17030877?v=4&s=36" />](https://github.com/RigoOnRails)
2020

2121
### [Contributors](https://github.com/birdofpreyru/react-helmet/graphs/contributors)
22+
[<img width=36 src="https://avatars.githubusercontent.com/u/5297725?v=4&s=36" />](https://github.com/vegerot)
2223
[<img width=36 src="https://avatars.githubusercontent.com/u/20144632?s=36" />](https://github.com/birdofpreyru)
2324

2425
## Table of Contents

__tests__/__snapshots__/misc.test.tsx.snap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,7 @@ exports[`misc Declarative API only adds new tags and preserves tags when renderi
2727
exports[`misc Declarative API only adds new tags and preserves tags when rendering additional Helmet instances 5`] = `"<meta content="Test description" name="description" data-rh="true">"`;
2828
2929
exports[`misc Declarative API recognizes valid tags regardless of attribute ordering 1`] = `"<meta content="Test Description" name="description" data-rh="true">"`;
30+
31+
exports[`misc Declarative API throws on invalid elements 1`] = `"Only elements types base, body, Symbol(react.fragment), head, html, link, meta, noscript, script, style, title are allowed. Helmet does not support rendering <div> elements. Refer to our API for more information."`;
32+
33+
exports[`misc Declarative API throws on invalid self-closing elements 1`] = `"Only elements types base, body, Symbol(react.fragment), head, html, link, meta, noscript, script, style, title are allowed. Helmet does not support rendering <div> elements. Refer to our API for more information."`;

__tests__/api/base.test.tsx

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/** @jest-environment jsdom */
22

3+
import { renderClient } from '../../jest/browser-utils';
34
import { Helmet } from '../../src';
45
import { HELMET_ATTRIBUTE } from '../../src/constants';
5-
import { renderClient } from '../../jest/browser-utils';
66

77
describe('base tag', () => {
88
describe('API', () => {
@@ -30,8 +30,21 @@ describe('base tag', () => {
3030
expect(existingTags).toHaveLength(0);
3131
});
3232

33-
it('tags without \'href\' are not accepted', () => {
34-
renderClient(<Helmet base={{ property: 'won\'t work' }} />);
33+
it("tags with only 'target' are accepted", () => {
34+
renderClient(<Helmet base={{ target: '_blank' }} />);
35+
const existingTags = [...document.head.querySelectorAll(`base[${HELMET_ATTRIBUTE}]`)];
36+
37+
expect(existingTags).toBeDefined();
38+
expect(existingTags).toHaveLength(1);
39+
const firstTag = existingTags[0]!;
40+
expect(firstTag).toBeInstanceOf(Element);
41+
expect(firstTag.getAttribute).toBeDefined();
42+
expect(firstTag).toHaveAttribute('target', '_blank');
43+
expect(firstTag).not.toHaveAttribute('href');
44+
});
45+
46+
it("tags without 'href' or 'target' are not accepted", () => {
47+
renderClient(<Helmet base={{ property: "won't work" }} />);
3548
const existingTags = document.head.querySelectorAll(`base[${HELMET_ATTRIBUTE}]`);
3649

3750
expect(existingTags).toBeDefined();
@@ -97,7 +110,25 @@ describe('base tag', () => {
97110
expect(existingTags).toHaveLength(0);
98111
});
99112

100-
it('tags without \'href\' are not accepted', () => {
113+
it("tags with only 'target' are accepted", () => {
114+
renderClient(
115+
<Helmet>
116+
<base target="_blank" />
117+
</Helmet>,
118+
);
119+
120+
const existingTags = [...document.head.querySelectorAll(`base[${HELMET_ATTRIBUTE}]`)];
121+
122+
expect(existingTags).toBeDefined();
123+
expect(existingTags).toHaveLength(1);
124+
const firstTag = existingTags[0]!;
125+
expect(firstTag).toBeInstanceOf(Element);
126+
expect(firstTag.getAttribute).toBeDefined();
127+
expect(firstTag).toHaveAttribute('target', '_blank');
128+
expect(firstTag).not.toHaveAttribute('href');
129+
});
130+
131+
it("tags without 'href' or 'target' are not accepted", () => {
101132
/* eslint-disable react/no-unknown-property */
102133
renderClient(
103134
<Helmet>

__tests__/api/bodyAttributes.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/** @jest-environment jsdom */
22

3+
import { renderClient } from '../../jest/browser-utils';
34
import { type BodyProps, Helmet } from '../../src';
45
import { HELMET_ATTRIBUTE, HTML_TAG_MAP } from '../../src/constants';
5-
import { renderClient } from '../../jest/browser-utils';
66

77
describe('body attributes', () => {
88
describe('valid attributes', () => {

__tests__/api/client.test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/** @jest-environment jsdom */
22

3-
import { type OnChangeClientState, Helmet } from '../../src';
4-
53
import { renderClient } from '../../jest/browser-utils';
64

5+
import { Helmet, type OnChangeClientState } from '../../src';
6+
77
describe('onChangeClientState', () => {
88
describe('API', () => {
99
// eslint-disable-next-line complexity
1010
it('when handling client state change, calls the function with new state, addedTags and removedTags', () => {
11-
const onChange = jest.fn<unknown, Parameters<OnChangeClientState>>();
11+
const onChange = jest.fn<undefined, Parameters<OnChangeClientState>>();
1212
renderClient(
1313
<div>
1414
<Helmet
@@ -105,7 +105,7 @@ describe('onChangeClientState', () => {
105105
describe('Declarative API', () => {
106106
// eslint-disable-next-line complexity
107107
it('when handling client state change, calls the function with new state, addedTags and removedTags', () => {
108-
const onChange = jest.fn<unknown, Parameters<OnChangeClientState>>();
108+
const onChange = jest.fn<undefined, Parameters<OnChangeClientState>>();
109109
renderClient(
110110
<div>
111111
<Helmet onChangeClientState={onChange}>

__tests__/api/htmlAttributes.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/** @jest-environment jsdom */
22

3+
import { renderClient } from '../../jest/browser-utils';
34
import { Helmet } from '../../src';
45
import { HELMET_ATTRIBUTE } from '../../src/constants';
5-
import { renderClient } from '../../jest/browser-utils';
66

77
describe('html attributes', () => {
88
describe('API', () => {

__tests__/api/link.test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/** @jest-environment jsdom */
22

3+
import { renderClient } from '../../jest/browser-utils';
34
import { Helmet } from '../../src';
45
import { HELMET_ATTRIBUTE } from '../../src/constants';
5-
import { renderClient } from '../../jest/browser-utils';
66

77
describe('link tags', () => {
88
describe('API', () => {
@@ -359,10 +359,10 @@ describe('link tags', () => {
359359
// them is treated as the actual primary attribute. Does not look as
360360
// a good, intuitive behavior to me... perhaps to be reworked.
361361
// @ts-expect-error "pre-existing"
362-
{ rel: 'icon', sizes: '192x192', href: null }, // eslint-disable-line sort-keys
362+
{ rel: 'icon', sizes: '192x192', href: null }, // eslint-disable-line perfectionist/sort-objects
363363
{
364364
rel: 'canonical',
365-
href: 'http://localhost/helmet/component', // eslint-disable-line sort-keys
365+
href: 'http://localhost/helmet/component', // eslint-disable-line perfectionist/sort-objects
366366
},
367367
]}
368368
/>,
@@ -647,7 +647,7 @@ describe('link tags', () => {
647647
// them is treated as the actual primary attribute. Does not look as
648648
// a good, intuitive behavior to me... perhaps to be reworked.
649649
// @ts-expect-error "pre-existing"
650-
href={null} // eslint-disable-line react/jsx-sort-props, @stylistic/jsx-sort-props
650+
href={null} // eslint-disable-line perfectionist/sort-jsx-props
651651
/>
652652
<link href="http://localhost/helmet/component" rel="canonical" />
653653
</Helmet>,

0 commit comments

Comments
 (0)