Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita5662a0

Browse files
committed
Fixup enum properties
1 parent99df7ab commita5662a0

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"test":"oxlint && tsc && npm run test:vitest:run && npm run bench",
5151
"test:vitest":"vitest",
5252
"test:vitest:run":"vitest run",
53-
"format":"prettier src/**/*.{d.ts,js} test/**/*.js --write",
53+
"format":"prettier src/**/*.{d.ts,js} test/**/*.{js,jsx} --write",
5454
"prepublishOnly":"npm run build",
5555
"release":"npm run build && git commit -am $npm_package_version && git tag $npm_package_version && git push && git push --tags && npm publish"
5656
},

‎src/pretty.js‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
VOID_ELEMENTS,
1010
NAMESPACE_REPLACE_REGEX,
1111
SVG_CAMEL_CASE,
12+
HTML_ENUMERATED,
1213
HTML_LOWER_CASE,
1314
getContext,
1415
setDirty,
@@ -22,7 +23,7 @@ import { options, Fragment } from 'preact';
2223
constUNNAMED=[];
2324

2425
constEMPTY_ARR=[];
25-
26+
constEMPTY_STR='';
2627
/**
2728
* Render Preact JSX + Components to a pretty-printed HTML-like string.
2829
*@param {VNode} vnodeJSX Element / VNode to render
@@ -254,6 +255,11 @@ function _renderToStringPretty(
254255
name='http-equiv';
255256
}elseif(NAMESPACE_REPLACE_REGEX.test(name)){
256257
name=name.replace(NAMESPACE_REPLACE_REGEX,'$1:$2').toLowerCase();
258+
}elseif(
259+
(name.at(4)==='-'||HTML_ENUMERATED.has(name))&&
260+
v!=null
261+
){
262+
v=v+EMPTY_STR;
257263
}elseif(isSvgMode){
258264
if(SVG_CAMEL_CASE.test(name)){
259265
name=

‎test/jsx.test.jsx‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,13 @@ describe('jsx', () => {
171171
it('should not render function children',()=>{
172172
expect(renderJsx(<div>{()=>{}}</div>)).to.equal('<div></div>');
173173
});
174+
175+
it('should render enumerated attributes',()=>{
176+
expect(renderJsx(<divdraggable={true}/>)).to.equal(
177+
'<div draggable="true"></div>'
178+
);
179+
expect(renderJsx(<divdraggable={false}/>)).to.equal(
180+
'<div draggable="false"></div>'
181+
);
182+
});
174183
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp