diff --git a/changelog.md b/changelog.md index fc7257ee5..ded894706 100755 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,9 @@ +## Next + +## Bug fixes + +- [jss] Fix SSR aggregation regression ([#1064](https://github.com/cssinjs/jss/pull/1064)) + ## 10.0.0-alpha.13 (2019-3-12) ### Bug fixes diff --git a/packages/jss/.size-snapshot.json b/packages/jss/.size-snapshot.json index da842e7f9..0424e2707 100644 --- a/packages/jss/.size-snapshot.json +++ b/packages/jss/.size-snapshot.json @@ -1,30 +1,30 @@ { "dist/jss.js": { - "bundled": 58916, - "minified": 21875, - "gzipped": 6588 + "bundled": 58897, + "minified": 21872, + "gzipped": 6582 }, "dist/jss.min.js": { - "bundled": 57750, - "minified": 20957, - "gzipped": 6146 + "bundled": 57731, + "minified": 20954, + "gzipped": 6139 }, "dist/jss.cjs.js": { - "bundled": 54372, - "minified": 23786, - "gzipped": 6638 + "bundled": 54357, + "minified": 23783, + "gzipped": 6633 }, "dist/jss.esm.js": { - "bundled": 53876, - "minified": 23382, - "gzipped": 6555, + "bundled": 53861, + "minified": 23379, + "gzipped": 6550, "treeshaked": { "rollup": { - "code": 19017, + "code": 19014, "import_statements": 281 }, "webpack": { - "code": 20432 + "code": 20429 } } } diff --git a/packages/jss/src/StyleSheet.js b/packages/jss/src/StyleSheet.js index 27b886795..319e566ff 100644 --- a/packages/jss/src/StyleSheet.js +++ b/packages/jss/src/StyleSheet.js @@ -59,8 +59,8 @@ export default class StyleSheet { * Attach renderable to the render tree. */ attach(): this { - if (this.attached || !this.renderer) return this - this.renderer.attach() + if (this.attached) return this + if (this.renderer) this.renderer.attach() this.attached = true // Order is important, because we can't use insertRule API if style element is not attached. if (!this.deployed) this.deploy() @@ -71,8 +71,8 @@ export default class StyleSheet { * Remove renderable from render tree. */ detach(): this { - if (!this.attached || !this.renderer) return this - this.renderer.detach() + if (!this.attached) return this + if (this.renderer) this.renderer.detach() this.attached = false return this } @@ -175,10 +175,8 @@ export default class StyleSheet { * Deploy pure CSS string to a renderable. */ deploy(): this { - if (this.renderer) { - this.renderer.deploy() - this.deployed = true - } + if (this.renderer) this.renderer.deploy() + this.deployed = true return this } diff --git a/packages/react-jss/src/JssProvider.test.js b/packages/react-jss/src/JssProvider.test.js index 0a60c2971..dcb7c28a8 100644 --- a/packages/react-jss/src/JssProvider.test.js +++ b/packages/react-jss/src/JssProvider.test.js @@ -5,6 +5,7 @@ import React from 'react' import {stripIndent} from 'common-tags' import {create} from 'jss' import TestRenderer from 'react-test-renderer' +import preset from 'jss-preset-default' import withStyles, {SheetsRegistry, JssProvider} from '.' @@ -249,9 +250,11 @@ describe('React-JSS: JssProvider', () => { } const MyComponent = withStyles(styles)() let generateId = createGenerateId() + // Remove renderer to simulate a non-browser env. + const jss = create({...preset(), Renderer: null}) TestRenderer.create( - + ) @@ -269,7 +272,7 @@ describe('React-JSS: JssProvider', () => { generateId = createGenerateId() TestRenderer.create( - + ) @@ -295,15 +298,17 @@ describe('React-JSS: JssProvider', () => { const customSheets2 = new SheetsRegistry() const generateId1 = createGenerateId() const generateId2 = createGenerateId() + // Remove renderer to simulate a non-browser env. + const jss = create({...preset(), Renderer: null}) TestRenderer.create( - + ) TestRenderer.create( - + ) @@ -312,6 +317,7 @@ describe('React-JSS: JssProvider', () => { const result2 = customSheets2.toString() expect(result1).to.equal(result2) + expect(result1.length > 0).to.be(true) }) }) })