diff --git a/lib/head.js b/lib/head.js index 34733320..5dadb1b6 100644 --- a/lib/head.js +++ b/lib/head.js @@ -21,6 +21,12 @@ function reduceComponents (components) { .map((c) => c.props.children) .map((children) => React.Children.toArray(children)) .reduce((a, b) => a.concat(b), []) + .reduce((a, b) => { + if (React.Fragment && b.type === React.Fragment) { + return a.concat(React.Children.toArray(b.props.children)) + } + return a.concat(b) + }, []) .reverse() .concat(...defaultHead()) .filter((c) => !!c) @@ -54,7 +60,7 @@ function unique () { const metaCategories = {} return (h) => { - if (h.key) { + if (h.key && h.key.startsWith('.$')) { if (keys.has(h.key)) return false keys.add(h.key) } diff --git a/package.json b/package.json index 651a5e1d..38f1175c 100644 --- a/package.json +++ b/package.json @@ -105,7 +105,7 @@ "webpack-hot-middleware": "2.19.1", "write-file-webpack-plugin": "4.2.0", "xss-filters": "1.2.7", - "uglifyjs-webpack-plugin": "^1.1.1" + "uglifyjs-webpack-plugin": "^1.1.1" }, "devDependencies": { "@taskr/babel": "1.1.0", @@ -131,8 +131,8 @@ "node-notifier": "5.1.2", "nyc": "11.2.1", "portfinder": "1.0.13", - "react": "16.0.0", - "react-dom": "16.0.0", + "react": "16.2.0", + "react-dom": "16.2.0", "standard": "9.0.2", "taskr": "1.1.0", "wd": "1.4.1" diff --git a/test/integration/basic/pages/head.js b/test/integration/basic/pages/head.js index 95463be1..b344c695 100644 --- a/test/integration/basic/pages/head.js +++ b/test/integration/basic/pages/head.js @@ -10,6 +10,11 @@ export default () =>
+ + Fragment title + + + {/* the following 2 links tag will be rendered both */} diff --git a/test/integration/basic/test/rendering.js b/test/integration/basic/test/rendering.js index 20b69243..08c87f76 100644 --- a/test/integration/basic/test/rendering.js +++ b/test/integration/basic/test/rendering.js @@ -38,6 +38,12 @@ export default function ({ app }, suiteName, render, fetch) { expect(html).not.toContain('') }) + test('header helper renders Fragment children', async () => { + const html = await (render('/head')) + expect(html).toContain('Fragment title') + expect(html).toContain('') + }) + it('should render the page with custom extension', async () => { const html = await render('/custom-extension') expect(html).toContain('
Hello
') diff --git a/yarn.lock b/yarn.lock index 7a0af4fa..399a0094 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4803,9 +4803,9 @@ react-deep-force-update@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/react-deep-force-update/-/react-deep-force-update-2.1.1.tgz#8ea4263cd6455a050b37445b3f08fd839d86e909" -react-dom@16.0.0: - version "16.0.0" - resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.0.0.tgz#9cc3079c3dcd70d4c6e01b84aab2a7e34c303f58" +react-dom@16.2.0: + version "16.2.0" + resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.2.0.tgz#69003178601c0ca19b709b33a83369fe6124c044" dependencies: fbjs "^0.8.16" loose-envify "^1.1.0" @@ -4828,9 +4828,9 @@ react-proxy@^3.0.0-alpha.0: dependencies: lodash "^4.6.1" -react@16.0.0: - version "16.0.0" - resolved "https://registry.yarnpkg.com/react/-/react-16.0.0.tgz#ce7df8f1941b036f02b2cca9dbd0cb1f0e855e2d" +react@16.2.0: + version "16.2.0" + resolved "https://registry.yarnpkg.com/react/-/react-16.2.0.tgz#a31bd2dab89bff65d42134fa187f24d054c273ba" dependencies: fbjs "^0.8.16" loose-envify "^1.1.0"