Skip to content

Commit ba0ea8d

Browse files
committed
fix(Fragment): fix tsconfig Fragment
1 parent 540c551 commit ba0ea8d

File tree

6 files changed

+36
-3
lines changed

6 files changed

+36
-3
lines changed

src/compiler/transpile/transpile-module.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export const transpileModule = (config: d.Config, input: string, transformOpts:
5959
tsCompilerOptions.jsxFactory = 'h';
6060
}
6161

62-
if (tsCompilerOptions.jsxFragmentFactory != null && !isString(tsCompilerOptions.jsxFragmentFactory)) {
62+
if (tsCompilerOptions.jsx != null && !isString(tsCompilerOptions.jsxFragmentFactory)) {
6363
tsCompilerOptions.jsxFragmentFactory = 'Fragment';
6464
}
6565

src/internal/stencil-core/index.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export {
3131
getElement,
3232
getMode,
3333
getRenderingRef,
34+
Fragment,
3435
forceUpdate,
3536
h,
3637
Host,

src/runtime/test/jsx.spec.tsx

+31-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,38 @@
1-
import { Component, Host, Prop, State, h } from '@stencil/core';
1+
import { Component, Host, Prop, State, h, Fragment } from '@stencil/core';
22
import { newSpecPage } from '@stencil/core/testing';
33
import { FunctionalComponent } from '../../declarations';
44

55
describe('jsx', () => {
6+
it('Fragment', async () => {
7+
@Component({ tag: 'cmp-a' })
8+
class CmpA {
9+
render() {
10+
return (
11+
<>
12+
<div>A</div>
13+
<div>B</div>
14+
</>
15+
);
16+
}
17+
}
18+
19+
const { root } = await newSpecPage({
20+
components: [CmpA],
21+
html: `<cmp-a></cmp-a>`,
22+
});
23+
24+
expect(root).toEqualHtml(`
25+
<cmp-a>
26+
<div>
27+
A
28+
</div>
29+
<div>
30+
B
31+
</div>
32+
</cmp-a>
33+
`);
34+
});
35+
636
it('render template', async () => {
737
@Component({ tag: 'cmp-a' })
838
class CmpA {

src/runtime/test/tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"forceConsistentCasingInFileNames": true,
99
"jsx": "react",
1010
"jsxFactory": "h",
11+
"jsxFragmentFactory": "Fragment",
1112
"lib": ["dom", "es2017", "esnext.array"],
1213
"module": "esnext",
1314
"moduleResolution": "node",

src/testing/jest/jest-preprocessor.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export const jestPreprocessor = {
5858
filePath,
5959
jestConfigStr,
6060
!!transformOptions.instrument,
61-
5, // cache buster
61+
6, // cache buster
6262
];
6363

6464
return key.join(':');

tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"forceConsistentCasingInFileNames": true,
99
"jsx": "react",
1010
"jsxFactory": "h",
11+
"jsxFragmentFactory": "Fragment",
1112
"lib": ["dom", "es2018", "esnext.array"],
1213
"module": "esnext",
1314
"moduleResolution": "node",

0 commit comments

Comments
 (0)