@@ -8,6 +8,7 @@ var constructorFromRequireContext = require("./src/getConstructor/fromRequireCon
8
8
var constructorFromRequireContextWithGlobalFallback = require ( "./src/getConstructor/fromRequireContextWithGlobalFallback" )
9
9
var constructorFromRequireContextsWithGlobalFallback = require ( "./src/getConstructor/fromRequireContextsWithGlobalFallback" )
10
10
const { supportsHydration, reactHydrate, createReactRootLike } = require ( "./src/renderHelpers" )
11
+ const { replaceNullWithUndefined } = require ( "./src/options" )
11
12
12
13
var ReactRailsUJS = {
13
14
// This attribute holds the name of component which should be mounted
@@ -31,6 +32,11 @@ var ReactRailsUJS = {
31
32
32
33
components : { } ,
33
34
35
+ // Set default values for options.
36
+ options : {
37
+ replaceNull : false ,
38
+ } ,
39
+
34
40
// helper method for the mount and unmount methods to find the
35
41
// `data-react-class` DOM elements
36
42
findDOMNodes : function ( searchSelector ) {
@@ -106,7 +112,8 @@ var ReactRailsUJS = {
106
112
var className = node . getAttribute ( ujs . CLASS_NAME_ATTR ) ;
107
113
var constructor = ujs . getConstructor ( className ) ;
108
114
var propsJson = node . getAttribute ( ujs . PROPS_ATTR ) ;
109
- var props = propsJson && JSON . parse ( propsJson ) ;
115
+ var props = propsJson && ( ujs . options . replaceNull ? replaceNullWithUndefined ( JSON . parse ( propsJson ) )
116
+ : JSON . parse ( propsJson ) ) ;
110
117
var hydrate = node . getAttribute ( ujs . RENDER_ATTR ) ;
111
118
var cacheId = node . getAttribute ( ujs . CACHE_ID_ATTR ) ;
112
119
var turbolinksPermanent = node . hasAttribute ( ujs . TURBOLINKS_PERMANENT_ATTR ) ;
0 commit comments