Skip to content

Commit

Permalink
fix(Fragment): fix tsconfig Fragment
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley committed Aug 24, 2020
1 parent 540c551 commit ba0ea8d
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/compiler/transpile/transpile-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const transpileModule = (config: d.Config, input: string, transformOpts:
tsCompilerOptions.jsxFactory = 'h';
}

if (tsCompilerOptions.jsxFragmentFactory != null && !isString(tsCompilerOptions.jsxFragmentFactory)) {
if (tsCompilerOptions.jsx != null && !isString(tsCompilerOptions.jsxFragmentFactory)) {
tsCompilerOptions.jsxFragmentFactory = 'Fragment';
}

Expand Down
1 change: 1 addition & 0 deletions src/internal/stencil-core/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export {
getElement,
getMode,
getRenderingRef,
Fragment,
forceUpdate,
h,
Host,
Expand Down
32 changes: 31 additions & 1 deletion src/runtime/test/jsx.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,38 @@
import { Component, Host, Prop, State, h } from '@stencil/core';
import { Component, Host, Prop, State, h, Fragment } from '@stencil/core';
import { newSpecPage } from '@stencil/core/testing';
import { FunctionalComponent } from '../../declarations';

describe('jsx', () => {
it('Fragment', async () => {
@Component({ tag: 'cmp-a' })
class CmpA {
render() {
return (
<>
<div>A</div>
<div>B</div>
</>
);
}
}

const { root } = await newSpecPage({
components: [CmpA],
html: `<cmp-a></cmp-a>`,
});

expect(root).toEqualHtml(`
<cmp-a>
<div>
A
</div>
<div>
B
</div>
</cmp-a>
`);
});

it('render template', async () => {
@Component({ tag: 'cmp-a' })
class CmpA {
Expand Down
1 change: 1 addition & 0 deletions src/runtime/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"forceConsistentCasingInFileNames": true,
"jsx": "react",
"jsxFactory": "h",
"jsxFragmentFactory": "Fragment",
"lib": ["dom", "es2017", "esnext.array"],
"module": "esnext",
"moduleResolution": "node",
Expand Down
2 changes: 1 addition & 1 deletion src/testing/jest/jest-preprocessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const jestPreprocessor = {
filePath,
jestConfigStr,
!!transformOptions.instrument,
5, // cache buster
6, // cache buster
];

return key.join(':');
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"forceConsistentCasingInFileNames": true,
"jsx": "react",
"jsxFactory": "h",
"jsxFragmentFactory": "Fragment",
"lib": ["dom", "es2018", "esnext.array"],
"module": "esnext",
"moduleResolution": "node",
Expand Down

0 comments on commit ba0ea8d

Please sign in to comment.