@@ -42,7 +42,7 @@ export default class SplitRoute extends React.Component {
42
42
* of loaded stylesheets, which is how our CSS should be written. */
43
43
const { chunkName } = this . props ;
44
44
const link = document . querySelector ( `link[data-chunk="${ chunkName } "]` ) ;
45
- link . setAttribute ( 'data-chunk-unused' , unusedCssStamp += 1 ) ;
45
+ if ( link ) link . setAttribute ( 'data-chunk-unused' , unusedCssStamp += 1 ) ;
46
46
47
47
/* Reset to the initial state. */
48
48
this . setState ( { component : null } ) ;
@@ -100,14 +100,14 @@ export default class SplitRoute extends React.Component {
100
100
/* eslint-disable react/prop-types */
101
101
const { splits } = props . staticContext ;
102
102
/* eslint-enable react/prop-types */
103
- if ( splits [ ` ${ chunkName } ` ] ) throw new Error ( 'SplitRoute: IDs clash!' ) ;
104
- else splits [ ` ${ chunkName } ` ] = html ;
103
+ if ( splits [ chunkName ] ) throw new Error ( 'SplitRoute: IDs clash!' ) ;
104
+ else splits [ chunkName ] = html ;
105
105
106
106
/* 3. The stylesheet links are injected via links elements in the
107
107
* header of the document, to have a better control over styles
108
108
* (re-)loading, independent of ReactJS mechanics of
109
109
* the document updates. */
110
- props . staticContext . chunks . push ( ` ${ chunkName } ` ) ;
110
+ props . staticContext . chunks . push ( chunkName ) ;
111
111
112
112
/* 4. We also render the mounted component, or the placeholder,
113
113
* into the document, using dangerouslySetInnerHTML to inject
@@ -121,14 +121,14 @@ export default class SplitRoute extends React.Component {
121
121
/* eslint-enable react/no-danger */
122
122
} else {
123
123
/* Client side rendering */
124
- if ( window . SPLITS [ ` ${ chunkName } ` ] ) {
124
+ if ( window . SPLITS [ chunkName ] ) {
125
125
/* If the page has been pre-rendered at the server-side, we render
126
126
* exactly the same until the splitted code is loaded. */
127
127
/* eslint-disable react/no-danger */
128
128
res = (
129
129
< div
130
130
dangerouslySetInnerHTML = { {
131
- __html : window . SPLITS [ ` ${ chunkName } ` ] ,
131
+ __html : window . SPLITS [ chunkName ] ,
132
132
} }
133
133
/>
134
134
) ;
@@ -138,7 +138,7 @@ export default class SplitRoute extends React.Component {
138
138
* because if the vistor navigates around the app and comes back
139
139
* to this route, we want to re-render the page from scratch in
140
140
* that case (because the state of app has changed). */
141
- delete window . SPLITS [ ` ${ chunkName } ` ] ;
141
+ delete window . SPLITS [ chunkName ] ;
142
142
} else if ( renderPlaceholder ) {
143
143
/* If the page has not been pre-rendered, the best we can do prior
144
144
* the loading of split code, is to render the placeholder, if
@@ -169,7 +169,7 @@ export default class SplitRoute extends React.Component {
169
169
link . removeAttribute ( 'data-chunk-unused' ) ;
170
170
} else {
171
171
link = document . createElement ( 'link' ) ;
172
- link . setAttribute ( 'data-chunk' , ` ${ chunkName } ` ) ;
172
+ link . setAttribute ( 'data-chunk' , chunkName ) ;
173
173
link . setAttribute ( 'href' , `${ PUBLIC_PATH } /${ chunkName } -${ timestamp } .css` ) ;
174
174
link . setAttribute ( 'id' , 'tru-style' ) ;
175
175
link . setAttribute ( 'rel' , 'stylesheet' ) ;
@@ -229,7 +229,7 @@ export default class SplitRoute extends React.Component {
229
229
component : ( ) => (
230
230
< div >
231
231
< ContentWrapper
232
- chunkName = { ` ${ chunkName } ` }
232
+ chunkName = { chunkName }
233
233
content = { component2 }
234
234
parent = { this }
235
235
/>
@@ -249,7 +249,6 @@ export default class SplitRoute extends React.Component {
249
249
}
250
250
251
251
SplitRoute . defaultProps = {
252
- // cacheCss: false,
253
252
exact : false ,
254
253
location : null ,
255
254
path : null ,
@@ -259,7 +258,6 @@ SplitRoute.defaultProps = {
259
258
} ;
260
259
261
260
SplitRoute . propTypes = {
262
- // cacheCss: PT.bool,
263
261
chunkName : PT . string . isRequired ,
264
262
exact : PT . bool ,
265
263
location : PT . shape ( ) ,
0 commit comments