nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: chalk/chalk
Pull request #364 (2019-09-22 11:59:05)

Fix const enum for TypeScript
Fix https://github.com/chalk/chalk/issues/363


Patch:
diff --git a/source/index.js b/source/index.js
index 686758b..6fee0f8 100644
--- a/source/index.js
+++ b/source/index.js
@@ -223,4 +223,16 @@ chalk.supportsColor = stdoutColor;
 chalk.stderr = Chalk({level: stderrColor ? stderrColor.level : 0}); // eslint-disable-line new-cap
 chalk.stderr.supportsColor = stderrColor;
 
+// For TypeScript
+chalk.Level = {
+	None: 0,
+	Basic: 1,
+	Ansi256: 2,
+	TrueColor: 3,
+	0: 'None',
+	1: 'Basic',
+	2: 'Ansi256',
+	3: 'TrueColor'
+};
+
 module.exports = chalk;


Test patch:
diff --git a/test/level.js b/test/level.js
index 65d4720..4fe8fae 100644
--- a/test/level.js
+++ b/test/level.js
@@ -43,3 +43,15 @@ test('disable colors if they are not supported', async t => {
 	const {stdout} = await execa.node(path.join(__dirname, '_fixture'));
 	t.is(stdout, 'testout testerr');
 });
+
+test('chalk.Level enum object', t => {
+	const {Level} = chalk;
+	t.is(Level.None, 0);
+	t.is(Level.Basic, 1);
+	t.is(Level.Ansi256, 2);
+	t.is(Level.TrueColor, 3);
+	t.is(Level[Level.None], 'None');
+	t.is(Level[Level.Basic], 'Basic');
+	t.is(Level[Level.Ansi256], 'Ansi256');
+	t.is(Level[Level.TrueColor], 'TrueColor');
+});
Repository: chalk/chalk
Pull request #434 (2021-04-19 23:54:02)

Keep function prototype methods
Based on https://github.com/chalk/chalk/pull/389#issuecomment-608435186

Fixes: #388

Richienb: @Qix- Could you also review https://github.com/chalk/ansi-styles/pull/71?

Patch:
diff --git a/source/index.js b/source/index.js
index 0f159d4..8db69d2 100644
--- a/source/index.js
+++ b/source/index.js
@@ -54,6 +54,8 @@ function createChalk(options) {
 	return chalkFactory(options);
 }
 
+Object.setPrototypeOf(createChalk.prototype, Function.prototype);
+
 for (const [styleName, style] of Object.entries(ansiStyles)) {
 	styles[styleName] = {
 		get() {


Test patch:
diff --git a/test/chalk.js b/test/chalk.js
index adc1aed..af43558 100644
--- a/test/chalk.js
+++ b/test/chalk.js
@@ -117,3 +117,9 @@ test('sets correct level for chalkStderr and respects it', t => {
 	t.is(chalkStderr.level, 3);
 	t.is(chalkStderr.red.bold('foo'), '\u001B[31m\u001B[1mfoo\u001B[22m\u001B[39m');
 });
+
+test('keeps function prototype methods', t => {
+	t.is(chalk.apply(chalk, ['foo']), 'foo');
+	t.is(chalk.bind(chalk, 'foo')(), 'foo');
+	t.is(chalk.call(chalk, 'foo'), 'foo');
+});
Repository: preactjs/preact-render-to-string
Pull request #172 (2020-10-21 18:49:11)

Invoke _diff hook
As otherwise `preact/debug` throws errors when using hooks as `hooksAllowed` is never set to `true`.

I could not yet come up with a test repro for this though!


Patch:
diff --git a/package.json b/package.json
index aa0af17..4abfe40 100644
--- a/package.json
+++ b/package.json
@@ -27,7 +27,8 @@
 		"transpile": "microbundle src/index.js -f es,umd --target web --external preact",
 		"transpile:jsx": "microbundle src/jsx.js -o dist/jsx.js --target web --external none && microbundle dist/jsx.js -o dist/jsx.js -f cjs",
 		"copy-typescript-definition": "copyfiles -f src/*.d.ts dist",
-		"test": "eslint src test && tsc && mocha -r babel-core/register test/**/*.js",
+		"test": "eslint src test && tsc && npm run test:mocha",
+		"test:mocha": "mocha -r babel-core/register test/**/*.js",
 		"format": "prettier src/**/*.{d.ts,js} test/**/*.js --write",
 		"prepublishOnly": "npm run build",
 		"release": "npm run build && git commit -am $npm_package_version && git tag $npm_package_version && git push && git push --tags && npm publish"
diff --git a/src/index.js b/src/index.js
index 1aeae89..71f5b7d 100644
--- a/src/index.js
+++ b/src/index.js
@@ -101,7 +101,10 @@ function renderToString(vnode, context, opts, inner, isSvgMode, selectValue) {
 				__h: []
 			});
 
-			// options.render
+			// options._diff
+			if (options.__b) options.__b(vnode);
+
+			// options._render
 			if (options.__r) options.__r(vnode);
 
 			if (


Test patch:
diff --git a/test/render.js b/test/render.js
index b1c3cac..254fb1b 100644
--- a/test/render.js
+++ b/test/render.js
@@ -1,5 +1,5 @@
 import { render, shallowRender } from '../src';
-import { h, Component, createContext, Fragment } from 'preact';
+import { h, Component, createContext, Fragment, options } from 'preact';
 import { useState, useContext, useEffect, useLayoutEffect } from 'preact/hooks';
 import chai, { expect } from 'chai';
 import { spy, stub, match } from 'sinon';
@@ -1049,6 +1049,47 @@ describe('render', () => {
 		});
 	});
 
+	it('should invoke options._render and options._diff', () => {
+		const calls = [];
+		// _diff
+		const oldDiff = options.__b;
+		options.__b = (...args) => {
+			calls.push(['_diff', args]);
+			if (oldDiff) oldDiff(...args);
+		};
+		// _render
+		const oldRender = options.__r;
+		options.__r = (...args) => {
+			calls.push(['_render', args]);
+			if (oldRender) oldRender(...args);
+		};
+
+		function Component1({ children }) {
+			return children;
+		}
+
+		function Component2() {
+			return <div />;
+		}
+
+		const vnode2 = <Component2>1</Component2>;
+		const vnode1 = <Component1>{vnode2}</Component1>;
+
+		render(vnode1);
+
+		expect(calls).to.deep.equal([
+			['_diff', [vnode1]],
+			['_render', [vnode1]],
+			['_diff', [vnode2]],
+			['_render', [vnode2]]
+		]);
+
+		expect(calls.length).to.equal(4);
+
+		options.__b = oldDiff;
+		options.__r = oldRender;
+	});
+
 	it('should render select value on option', () => {
 		let res = render(
 			<select value="B">
Repository: preactjs/preact-render-to-string
Pull request #174 (2020-10-31 11:27:35)

Prevent to self-close if dangerouslySetInnerHTML set
This change prevents to self-close if the element has `dangerouslySetInnerHTML` prop. This is required for better xml support.

Currently behavior:
```
import { h } from 'preact'
import renderToString from 'preact-render-to-string'

console.log(renderToString(<a dangerouslySetInnerHTML={{ __html: '<b />' }}></a>, undefined, { xml: true }))
// <a><b / />

console.log(renderToString(<link dangerouslySetInnerHTML={{ __html: '<foo />' }}></link>))
// <link><foo / />
```


Patch:
diff --git a/src/index.js b/src/index.js
index 71f5b7d..27abd16 100644
--- a/src/index.js
+++ b/src/index.js
@@ -351,13 +351,13 @@ function renderToString(vnode, context, opts, inner, isSvgMode, selectValue) {
 		}
 	}
 
-	if (pieces.length) {
+	if (pieces.length || html) {
 		s += pieces.join('');
 	} else if (opts && opts.xml) {
 		return s.substring(0, s.length - 1) + ' />';
 	}
 
-	if (isVoid && !children) {
+	if (isVoid && !children && !html) {
 		s = s.replace(/>$/, ' />');
 	} else {
 		if (pretty && ~s.indexOf('\n')) s += '\n';


Test patch:
diff --git a/test/render.js b/test/render.js
index 254fb1b..e2e61fa 100644
--- a/test/render.js
+++ b/test/render.js
@@ -228,6 +228,15 @@ describe('render', () => {
 			expect(rendered).to.equal(expected);
 		});
 
+		it('should not self-close void elements if it has dangerouslySetInnerHTML prop', () => {
+			let rendered = render(
+					<link dangerouslySetInnerHTML={{ __html: '<foo>' }} />
+				),
+				expected = `<link><foo></link>`;
+
+			expect(rendered).to.equal(expected);
+		});
+
 		it('should serialize object styles', () => {
 			let rendered = render(<div style={{ color: 'red', border: 'none' }} />),
 				expected = `<div style="color: red; border: none;"></div>`;
@@ -814,6 +823,15 @@ describe('render', () => {
 			expect(renderXml(<a>b</a>)).to.equal(`<a>b</a>`);
 		});
 
+		it('should not self-close if it has dangerouslySetInnerHTML prop', () => {
+			expect(
+				renderXml(<a dangerouslySetInnerHTML={{ __html: 'b' }} />)
+			).to.equal(`<a>b</a>`);
+			expect(
+				renderXml(<a dangerouslySetInnerHTML={{ __html: '<b />' }} />)
+			).to.equal(`<a><b /></a>`);
+		});
+
 		it('should render boolean attributes with named values', () => {
 			expect(renderXml(<div foo bar />)).to.equal(
 				`<div foo="foo" bar="bar" />`
Repository: preactjs/preact-render-to-string
Pull request #203 (2021-11-10 21:14:09)

Fix: serialize defaultValue as value attribute
h/t @washingtonsteven who found this

This is sortof a follow-up to the patch from #163 - we shouldn't serialize `defaultValue` as `defaultValue`, but instead omitting it we should serialize to the `value` attribute (which is effectively the same as the `defaultValue` property).


Patch:
diff --git a/src/index.js b/src/index.js
index e506d05..fa973a0 100644
--- a/src/index.js
+++ b/src/index.js
@@ -240,12 +240,13 @@ function _renderToString(vnode, context, opts, inner, isSvgMode, selectValue) {
 				(name === 'key' ||
 					name === 'ref' ||
 					name === '__self' ||
-					name === '__source' ||
-					name === 'defaultValue')
+					name === '__source')
 			)
 				continue;
 
-			if (name === 'className') {
+			if (name === 'defaultValue') {
+				name = 'value';
+			} else if (name === 'className') {
 				if (props.class) continue;
 				name = 'class';
 			} else if (isSvgMode && name.match(/^xlink:?./)) {


Test patch:
diff --git a/test/render.test.js b/test/render.test.js
index 9327d49..27a08f6 100644
--- a/test/render.test.js
+++ b/test/render.test.js
@@ -82,9 +82,9 @@ describe('render', () => {
 			expect(rendered).to.equal(expected);
 		});
 
-		it('should omit defaultValue attribute', () => {
+		it('should serialize defaultValue props to the value attribute', () => {
 			let rendered = render(<div defaultValue="test" />),
-				expected = `<div></div>`;
+				expected = `<div value="test"></div>`;
 
 			expect(rendered).to.equal(expected);
 		});
Repository: preactjs/preact-render-to-string
Pull request #289 (2023-03-26 17:15:46)

support data attribute
Fixes https://github.com/preactjs/preact-render-to-string/issues/271

changeset-bot[bot]: ###  🦋  Changeset detected

Latest commit: 678588c523c9bb9bd4ecb9297fc7772bf1bc8900

**The changes in this PR will be included in the next version bump.**

<details><summary>This PR includes changesets to release 1 package</summary>

  | Name                    | Type  |
| ----------------------- | ----- |
| preact-render-to-string | Patch |

</details>

Not sure what this means? [Click here  to learn what changesets are](https://github.com/changesets/changesets/blob/master/docs/adding-a-changeset.md).

[Click here if you're a maintainer who wants to add another changeset to this PR](https://github.com/preactjs/preact-render-to-string/new/support-data?filename=.changeset/poor-buttons-drop.md&value=---%0A%22preact-render-to-string%22%3A%20patch%0A---%0A%0Asupport%20data%20attribute%0A)



Patch:
diff --git a/.changeset/perfect-ducks-rule.md b/.changeset/perfect-ducks-rule.md
new file mode 100644
index 0000000..2270e36
--- /dev/null
+++ b/.changeset/perfect-ducks-rule.md
@@ -0,0 +1,5 @@
+---
+'preact-render-to-string': patch
+---
+
+Support `data` attribute
diff --git a/src/index.js b/src/index.js
index 7e8f5dc..d610ca9 100644
--- a/src/index.js
+++ b/src/index.js
@@ -311,10 +311,7 @@ function _renderToString(vnode, context, isSvgMode, selectValue, parent) {
 					name = name.toLowerCase().replace(XLINK_REPLACE_REGEX, 'xlink:');
 				} else if (UNSAFE_NAME.test(name)) {
 					continue;
-				} else if (
-					((name[0] === 'a' && name[1] === 'r') || name === 'draggable') &&
-					v != null
-				) {
+				} else if ((name[4] === '-' || name === 'draggable') && v != null) {
 					// serialize boolean aria-xyz or draggable attribute values as strings
 					// `draggable` is an enumerated attribute and not Boolean. A value of `true` or `false` is mandatory
 					// https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/draggable


Test patch:
diff --git a/test/render.test.js b/test/render.test.js
index 82e0a73..17213b5 100644
--- a/test/render.test.js
+++ b/test/render.test.js
@@ -142,6 +142,16 @@ describe('render', () => {
 			expect(rendered).to.equal(expected);
 		});
 
+		it('should support false aria-* attributes', () => {
+			let rendered = render(<div aria-checked={false} />);
+			expect(rendered).to.equal(`<div aria-checked="false"></div>`);
+		});
+
+		it('should support false data-* attributes', () => {
+			let rendered = render(<div data-checked={false} />);
+			expect(rendered).to.equal(`<div data-checked="false"></div>`);
+		});
+
 		describe('attribute name sanitization', () => {
 			it('should omit attributes with invalid names', () => {
 				let rendered = render(
Repository: preactjs/preact-render-to-string
Pull request #301 (2023-06-06 13:30:09)

Add support for rendering HTML comments
This PR adds support for rendering HTML comments via `preact-render-to-string`. Instead of adding a new vnode type this leverages `Fragments`. This has the benefit that branching cost is minimal as `Fragments` are the least frequently used components and they sorta represent "nothing" in terms of client code.

`<Fragment UNSTABLE_comment="foobar" />` renders `<!--foobar-->`. When the prop is present, all other children are ignored.

This solves an issue with fresh which currently renders invalid HTML comments. Browsers happily parse over that, but it's annoying if you're testing with HTML validators on CI. See https://github.com/denoland/fresh/issues/838


Patch:
diff --git a/.changeset/shy-hotels-impress.md b/.changeset/shy-hotels-impress.md
new file mode 100644
index 0000000..418a2ed
--- /dev/null
+++ b/.changeset/shy-hotels-impress.md
@@ -0,0 +1,5 @@
+---
+'preact-render-to-string': minor
+---
+
+Add experimental ability to render HTML comments via `<Fragment UNSTABLE_comment="my-comment" />`. When the `UNSTABLE_comment` prop is present all children of that `Fragment` will be ignored and a HTML comment will be rendered instead. This feature is added to allow framework authors to experiment with marking DOM for hydration in the client. Note that it's marked as unstable and might change in the future.
diff --git a/src/index.js b/src/index.js
index 249266d..a0fa9ca 100644
--- a/src/index.js
+++ b/src/index.js
@@ -165,6 +165,12 @@ function _renderToString(vnode, context, isSvgMode, selectValue, parent) {
 	// Invoke rendering on Components
 	if (typeof type === 'function') {
 		if (type === Fragment) {
+			// Fragments are the least used components of core that's why
+			// branching here for comments has the least effect on perf.
+			if (props.UNSTABLE_comment) {
+				return '<!--' + encodeEntities(props.UNSTABLE_comment || '') + '-->';
+			}
+
 			rendered = props.children;
 		} else {
 			contextType = type.contextType;


Test patch:
diff --git a/test/render.test.js b/test/render.test.js
index 8c704ad..0d6c7a6 100644
--- a/test/render.test.js
+++ b/test/render.test.js
@@ -1309,6 +1309,24 @@ describe('render', () => {
 		expect(render(<div>{() => {}}</div>)).to.equal('<div></div>');
 	});
 
+	describe('HTML Comments', () => {
+		it('should render HTML comments via Fragments', () => {
+			expect(render(<Fragment UNSTABLE_comment="foo" />)).to.equal(
+				'<!--foo-->'
+			);
+		});
+
+		it('should ignore children with comment prop', () => {
+			expect(
+				render(
+					<Fragment UNSTABLE_comment="foo">
+						<p>foo</p>
+					</Fragment>
+				)
+			).to.equal('<!--foo-->');
+		});
+	});
+
 	describe('vnode masks (useId)', () => {
 		it('should skip component top level Fragment child', () => {
 			const Wrapper = ({ children }) => <Fragment>{children}</Fragment>;
Repository: preactjs/preact-render-to-string
Pull request #347 (2024-04-08 20:35:31)

fix: precompile template empty HTML
Since we use a `Fragment` for the template we need to ensure that we don't fall into the logic where we detect if a component returned a top level `Fragment`.

This fixes an issue discovered when using Preact with Deno's `precompile` JSX transform.


Patch:
diff --git a/.changeset/nine-buckets-pull.md b/.changeset/nine-buckets-pull.md
new file mode 100644
index 0000000..0b47385
--- /dev/null
+++ b/.changeset/nine-buckets-pull.md
@@ -0,0 +1,5 @@
+---
+'preact-render-to-string': patch
+---
+
+Fix JSX template being detected as a top level Fragment when Deno's jsx `precompile` option is used
diff --git a/src/index.js b/src/index.js
index 6be1784..903216c 100644
--- a/src/index.js
+++ b/src/index.js
@@ -435,7 +435,10 @@ function _renderToString(
 		// When a component returns a Fragment node we flatten it in core, so we
 		// need to mirror that logic here too
 		let isTopLevelFragment =
-			rendered != null && rendered.type === Fragment && rendered.key == null;
+			rendered != null &&
+			rendered.type === Fragment &&
+			rendered.key == null &&
+			rendered.props.tpl == null;
 		rendered = isTopLevelFragment ? rendered.props.children : rendered;
 
 		const renderChildren = () =>


Test patch:
diff --git a/test/render.test.jsx b/test/render.test.jsx
index 8d099b7..588c86f 100644
--- a/test/render.test.jsx
+++ b/test/render.test.jsx
@@ -1686,5 +1686,18 @@ describe('render', () => {
 				'<div>foo<span>bar</span><p>foo</p><p>bar</p></div>'
 			);
 		});
+
+		it('should bypass top level fragment detection', () => {
+			function Foo(props) {
+				return props.children;
+			}
+			let vnode = (
+				<Foo>
+					<Fragment tpl={['<div>foo', '</div>']} exprs={[<span>bar</span>]} />
+				</Foo>
+			);
+			let rendered = render(vnode);
+			expect(rendered).to.equal('<div>foo<span>bar</span></div>');
+		});
 	});
 });
Repository: preactjs/preact-render-to-string
Pull request #352 (2024-05-11 01:39:03)

fix: Ensure `cellPadding`, `cellSpacing`, and `useMap` are lower-cased


Patch:
diff --git a/.changeset/gorgeous-eyes-cheer.md b/.changeset/gorgeous-eyes-cheer.md
new file mode 100644
index 0000000..cc85c9d
--- /dev/null
+++ b/.changeset/gorgeous-eyes-cheer.md
@@ -0,0 +1,5 @@
+---
+'preact-render-to-string': patch
+---
+
+Ensure `cellPadding`, `cellSpacing`, and `useMap` are serialized to lower case
diff --git a/src/lib/util.js b/src/lib/util.js
index 12b5a4c..fd86e5d 100644
--- a/src/lib/util.js
+++ b/src/lib/util.js
@@ -1,7 +1,7 @@
 export const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/;
 export const UNSAFE_NAME = /[\s\n\\/='"\0<>]/;
 export const NAMESPACE_REPLACE_REGEX = /^(xlink|xmlns|xml)([A-Z])/;
-export const HTML_LOWER_CASE = /^accessK|^auto[A-Z]|^ch|^col|cont|cross|dateT|encT|form[A-Z]|frame|hrefL|inputM|maxL|minL|noV|playsI|popoverT|readO|rowS|spellC|src[A-Z]|tabI|item[A-Z]/;
+export const HTML_LOWER_CASE = /^accessK|^auto[A-Z]|^cell|^ch|^col|cont|cross|dateT|encT|form[A-Z]|frame|hrefL|inputM|maxL|minL|noV|playsI|popoverT|readO|rowS|spellC|src[A-Z]|tabI|useM|item[A-Z]/;
 export const SVG_CAMEL_CASE = /^ac|^ali|arabic|basel|cap|clipPath$|clipRule$|color|dominant|enable|fill|flood|font|glyph[^R]|horiz|image|letter|lighting|marker[^WUH]|overline|panose|pointe|paint|rendering|shape|stop|strikethrough|stroke|text[^L]|transform|underline|unicode|units|^v[^i]|^w|^xH/;
 
 // DOM properties that should NOT have "px" added when numeric


Test patch:
diff --git a/test/utils.js b/test/utils.js
index cadfb55..068a114 100644
--- a/test/utils.js
+++ b/test/utils.js
@@ -297,8 +297,8 @@ export const htmlAttributes = {
 	autoFocus: 'autofocus',
 	autoPlay: 'autoplay',
 	capture: 'capture',
-	cellPadding: 'cellPadding',
-	cellSpacing: 'cellSpacing',
+	cellPadding: 'cellpadding',
+	cellSpacing: 'cellspacing',
 	charSet: 'charset',
 	challenge: 'challenge',
 	checked: 'checked',
@@ -414,7 +414,7 @@ export const htmlAttributes = {
 	target: 'target',
 	title: 'title',
 	type: 'type',
-	useMap: 'useMap',
+	useMap: 'usemap',
 	value: 'value',
 	volume: 'volume',
 	width: 'width',
Repository: preactjs/preact-render-to-string
Pull request #353 (2024-05-11 01:46:56)

fix: Ensure `popoverTarget` and `popoverTargetAction` are lower-cased


Patch:
diff --git a/.changeset/blue-moons-behave.md b/.changeset/blue-moons-behave.md
new file mode 100644
index 0000000..497be8a
--- /dev/null
+++ b/.changeset/blue-moons-behave.md
@@ -0,0 +1,5 @@
+---
+'preact-render-to-string': patch
+---
+
+Ensure `popoverTarget` and `popoverTargetAction` are serialized to lower case
diff --git a/src/lib/util.js b/src/lib/util.js
index 55fc0b1..12b5a4c 100644
--- a/src/lib/util.js
+++ b/src/lib/util.js
@@ -1,7 +1,7 @@
 export const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/;
 export const UNSAFE_NAME = /[\s\n\\/='"\0<>]/;
 export const NAMESPACE_REPLACE_REGEX = /^(xlink|xmlns|xml)([A-Z])/;
-export const HTML_LOWER_CASE = /^accessK|^auto[A-Z]|^ch|^col|cont|cross|dateT|encT|form[A-Z]|frame|hrefL|inputM|maxL|minL|noV|playsI|readO|rowS|spellC|src[A-Z]|tabI|item[A-Z]/;
+export const HTML_LOWER_CASE = /^accessK|^auto[A-Z]|^ch|^col|cont|cross|dateT|encT|form[A-Z]|frame|hrefL|inputM|maxL|minL|noV|playsI|popoverT|readO|rowS|spellC|src[A-Z]|tabI|item[A-Z]/;
 export const SVG_CAMEL_CASE = /^ac|^ali|arabic|basel|cap|clipPath$|clipRule$|color|dominant|enable|fill|flood|font|glyph[^R]|horiz|image|letter|lighting|marker[^WUH]|overline|panose|pointe|paint|rendering|shape|stop|strikethrough|stroke|text[^L]|transform|underline|unicode|units|^v[^i]|^w|^xH/;
 
 // DOM properties that should NOT have "px" added when numeric


Test patch:
diff --git a/test/utils.js b/test/utils.js
index d0438a3..cadfb55 100644
--- a/test/utils.js
+++ b/test/utils.js
@@ -375,6 +375,8 @@ export const htmlAttributes = {
 	ping: 'ping',
 	placeholder: 'placeholder',
 	playsInline: 'playsinline',
+	popoverTarget: 'popovertarget',
+	popoverTargetAction: 'popovertargetaction',
 	poster: 'poster',
 	preload: 'preload',
 	readonly: 'readonly',
Repository: preactjs/preact-render-to-string
Pull request #388 (2024-08-15 07:53:35)

fix: wrong spellcheck attribute value
Fixes https://github.com/preactjs/preact-render-to-string/issues/387


Patch:
diff --git a/.changeset/young-avocados-float.md b/.changeset/young-avocados-float.md
new file mode 100644
index 0000000..e8c9ece
--- /dev/null
+++ b/.changeset/young-avocados-float.md
@@ -0,0 +1,5 @@
+---
+'preact-render-to-string': patch
+---
+
+Fix `spellCheck={false}` not rendering as `spellcheck="false"`
diff --git a/src/index.js b/src/index.js
index 1ac2147..5362a9c 100644
--- a/src/index.js
+++ b/src/index.js
@@ -635,6 +635,9 @@ function _renderToString(
 					}
 				} else if (HTML_LOWER_CASE.test(name)) {
 					name = name.toLowerCase();
+					if (name === 'spellcheck') {
+						v = '' + v;
+					}
 				}
 			}
 		}
diff --git a/src/lib/util.js b/src/lib/util.js
index e0002a8..48c02a0 100644
--- a/src/lib/util.js
+++ b/src/lib/util.js
@@ -2,7 +2,7 @@ export const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|link|meta|
 export const UNSAFE_NAME = /[\s\n\\/='"\0<>]/;
 export const NAMESPACE_REPLACE_REGEX = /^(xlink|xmlns|xml)([A-Z])/;
 export const HTML_LOWER_CASE = /^accessK|^auto[A-Z]|^cell|^ch|^col|cont|cross|dateT|encT|form[A-Z]|frame|hrefL|inputM|maxL|minL|noV|playsI|popoverT|readO|rowS|spellC|src[A-Z]|tabI|useM|item[A-Z]/;
-export const SVG_CAMEL_CASE = /^ac|^ali|arabic|basel|cap|clipPath$|clipRule$|color|dominant|enable|fill|flood|font|glyph[^R]|horiz|image|letter|lighting|marker[^WUH]|overline|panose|pointe|paint|rendering|shape|stop|strikethrough|stroke|text[^L]|transform|underline|unicode|units|^v[^i]|^w|^xH/;
+export const SVG_CAMEL_CASE = /^ac|^ali|arabic|basel|cap|clipPath$|clipRule$|color|dominant|enable|fill|flood|font|glyph[^R]|horiz|image|letter|lighting|marker[^WUH]|overline|panose|pointe|paint|rendering|shape|stop|strikethrough|stroke|spel|text[^L]|transform|underline|unicode|units|^v[^i]|^w|^xH/;
 
 // DOM properties that should NOT have "px" added when numeric
 const ENCODED_ENTITIES = /["&<]/;


Test patch:
diff --git a/test/render.test.jsx b/test/render.test.jsx
index db418c2..39521cc 100644
--- a/test/render.test.jsx
+++ b/test/render.test.jsx
@@ -154,6 +154,14 @@ describe('render', () => {
 			expect(rendered).to.equal(`<div data-checked="false"></div>`);
 		});
 
+		it('should support spellCheck', () => {
+			let rendered = render(<div spellCheck={false} />);
+			expect(rendered).to.equal(`<div spellcheck="false"></div>`);
+
+			rendered = render(<div spellCheck />);
+			expect(rendered).to.equal(`<div spellcheck="true"></div>`);
+		});
+
 		describe('attribute name sanitization', () => {
 			it('should omit attributes with invalid names', () => {
 				let rendered = render(