1
1
( function webpackUniversalModuleDefinition ( root , factory ) {
2
2
if ( typeof exports === 'object' && typeof module === 'object' )
3
- module . exports = factory ( require ( "react" ) , require ( "react-dom" ) ) ;
3
+ module . exports = factory ( require ( "react" ) , require ( "react-dom" ) , require ( "react-dom/server" ) ) ;
4
4
else if ( typeof define === 'function' && define . amd )
5
- define ( [ "react" , "react-dom" ] , factory ) ;
5
+ define ( [ "react" , "react-dom" , "react-dom/server" ] , factory ) ;
6
6
else if ( typeof exports === 'object' )
7
- exports [ "ReactRailsUJS" ] = factory ( require ( "react" ) , require ( "react-dom" ) ) ;
7
+ exports [ "ReactRailsUJS" ] = factory ( require ( "react" ) , require ( "react-dom" ) , require ( "react-dom/server" ) ) ;
8
8
else
9
- root [ "ReactRailsUJS" ] = factory ( root [ "React" ] , root [ "ReactDOM" ] ) ;
10
- } ) ( this , function ( __WEBPACK_EXTERNAL_MODULE_3__ , __WEBPACK_EXTERNAL_MODULE_4__ ) {
9
+ root [ "ReactRailsUJS" ] = factory ( root [ "React" ] , root [ "ReactDOM" ] , root [ "ReactDOMServer" ] ) ;
10
+ } ) ( this , function ( __WEBPACK_EXTERNAL_MODULE_3__ , __WEBPACK_EXTERNAL_MODULE_4__ , __WEBPACK_EXTERNAL_MODULE_5__ ) {
11
11
return /******/ ( function ( modules ) { // webpackBootstrap
12
12
/******/ // The module cache
13
13
/******/ var installedModules = { } ;
@@ -73,18 +73,18 @@ return /******/ (function(modules) { // webpackBootstrap
73
73
/******/ __webpack_require__ . p = "" ;
74
74
/******/
75
75
/******/ // Load entry module and return exports
76
- /******/ return __webpack_require__ ( __webpack_require__ . s = 5 ) ;
76
+ /******/ return __webpack_require__ ( __webpack_require__ . s = 6 ) ;
77
77
/******/ } )
78
78
/************************************************************************/
79
79
/******/ ( [
80
80
/* 0 */
81
81
/***/ ( function ( module , exports , __webpack_require__ ) {
82
82
83
- var nativeEvents = __webpack_require__ ( 6 )
84
- var pjaxEvents = __webpack_require__ ( 7 )
85
- var turbolinksEvents = __webpack_require__ ( 8 )
86
- var turbolinksClassicDeprecatedEvents = __webpack_require__ ( 10 )
87
- var turbolinksClassicEvents = __webpack_require__ ( 9 )
83
+ var nativeEvents = __webpack_require__ ( 7 )
84
+ var pjaxEvents = __webpack_require__ ( 8 )
85
+ var turbolinksEvents = __webpack_require__ ( 9 )
86
+ var turbolinksClassicDeprecatedEvents = __webpack_require__ ( 11 )
87
+ var turbolinksClassicEvents = __webpack_require__ ( 10 )
88
88
89
89
// see what things are globally available
90
90
// and setup event handlers to those things
@@ -127,13 +127,13 @@ module.exports = function(ujs) {
127
127
// Also, try to gracefully import Babel 6 style default exports
128
128
module . exports = function ( className ) {
129
129
var constructor ;
130
-
130
+ var topLevel = typeof window === "undefined" ? this : window ;
131
131
// Try to access the class globally first
132
- constructor = window [ className ] ;
132
+ constructor = topLevel [ className ] ;
133
133
134
134
// If that didn't work, try eval
135
135
if ( ! constructor ) {
136
- constructor = eval . call ( window , className ) ;
136
+ constructor = eval . call ( topLevel , className ) ;
137
137
}
138
138
139
139
// Lastly, if there is a default attribute try that
@@ -160,7 +160,6 @@ module.exports = function(reqctx) {
160
160
var parts = className . split ( "." )
161
161
var filename = parts . shift ( )
162
162
var keys = parts
163
- console . log ( filename , keys )
164
163
// Load the module:
165
164
var component = reqctx ( "./" + filename )
166
165
// Then access each key:
@@ -190,10 +189,17 @@ module.exports = __WEBPACK_EXTERNAL_MODULE_4__;
190
189
191
190
/***/ } ) ,
192
191
/* 5 */
192
+ /***/ ( function ( module , exports ) {
193
+
194
+ module . exports = __WEBPACK_EXTERNAL_MODULE_5__ ;
195
+
196
+ /***/ } ) ,
197
+ /* 6 */
193
198
/***/ ( function ( module , exports , __webpack_require__ ) {
194
199
195
200
var React = __webpack_require__ ( 3 )
196
201
var ReactDOM = __webpack_require__ ( 4 )
202
+ var ReactDOMServer = __webpack_require__ ( 5 )
197
203
198
204
var detectEvents = __webpack_require__ ( 0 )
199
205
var constructorFromGlobal = __webpack_require__ ( 1 )
@@ -209,7 +215,7 @@ var ReactRailsUJS = {
209
215
PROPS_ATTR : 'data-react-props' ,
210
216
211
217
// If jQuery is detected, save a reference to it for event handlers
212
- jQuery : ( typeof window . jQuery !== 'undefined' ) && window . jQuery ,
218
+ jQuery : ( typeof window !== 'undefined' ) && ( typeof window . jQuery !== 'undefined' ) && window . jQuery ,
213
219
214
220
// helper method for the mount and unmount methods to find the
215
221
// `data-react-class` DOM elements
@@ -252,6 +258,14 @@ var ReactRailsUJS = {
252
258
this . getConstructor = constructorFromRequireContext ( req )
253
259
} ,
254
260
261
+ // Render `componentName` with `props` to a string,
262
+ // using the specified `renderFunction` from `react-dom/server`.
263
+ serverRender : function ( renderFunction , componentName , props ) {
264
+ var componentClass = this . getConstructor ( componentName )
265
+ var element = React . createElement ( componentClass , props )
266
+ return ReactDOMServer [ renderFunction ] ( element )
267
+ } ,
268
+
255
269
// Within `searchSelector`, find nodes which should have React components
256
270
// inside them, and mount them with their props.
257
271
mountComponents : function ( searchSelector ) {
@@ -289,13 +303,16 @@ var ReactRailsUJS = {
289
303
} ,
290
304
}
291
305
292
- detectEvents ( ReactRailsUJS )
306
+ if ( typeof window !== "undefined" ) {
307
+ // Only setup events for browser (not server-rendering)
308
+ detectEvents ( ReactRailsUJS )
309
+ }
293
310
294
311
module . exports = ReactRailsUJS
295
312
296
313
297
314
/***/ } ) ,
298
- /* 6 */
315
+ /* 7 */
299
316
/***/ ( function ( module , exports ) {
300
317
301
318
module . exports = {
@@ -316,7 +333,7 @@ module.exports = {
316
333
317
334
318
335
/***/ } ) ,
319
- /* 7 */
336
+ /* 8 */
320
337
/***/ ( function ( module , exports ) {
321
338
322
339
module . exports = {
@@ -330,7 +347,7 @@ module.exports = {
330
347
331
348
332
349
/***/ } ) ,
333
- /* 8 */
350
+ /* 9 */
334
351
/***/ ( function ( module , exports ) {
335
352
336
353
module . exports = {
@@ -343,7 +360,7 @@ module.exports = {
343
360
344
361
345
362
/***/ } ) ,
346
- /* 9 */
363
+ /* 10 */
347
364
/***/ ( function ( module , exports ) {
348
365
349
366
module . exports = {
@@ -357,7 +374,7 @@ module.exports = {
357
374
358
375
359
376
/***/ } ) ,
360
- /* 10 */
377
+ /* 11 */
361
378
/***/ ( function ( module , exports ) {
362
379
363
380
module . exports = {
0 commit comments