Skip to content

Commit 3b3880c

Browse files
author
rawls238
committed
one more try at this
1 parent ff32c91 commit 3b3880c

File tree

5 files changed

+32
-30
lines changed

5 files changed

+32
-30
lines changed

dist/react-experiments.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ return /******/ (function(modules) { // webpackBootstrap
9090

9191
var React = _interopRequire(__webpack_require__(2));
9292

93-
var getExposedExperimentVariation = __webpack_require__(3).getExposedExperimentVariation;
93+
var ExperimentEnrollment = _interopRequire(__webpack_require__(3));
9494

9595
var suppressAutoExposureLogging = __webpack_require__(5).suppressAutoExposureLogging;
9696

@@ -142,7 +142,7 @@ return /******/ (function(modules) { // webpackBootstrap
142142
},
143143

144144
renderExposedVariation: function renderExposedVariation() {
145-
var variationComponent = getExposedExperimentVariation(this.props.children, this.state.exposedVariation);
145+
var variationComponent = ExperimentEnrollment.getExposedExperimentVariation(this.props.children, this.state.exposedVariation);
146146

147147
if (variationComponent.exposedVariation) {
148148
this.props.experimentClass.logExposure();
@@ -174,6 +174,16 @@ return /******/ (function(modules) { // webpackBootstrap
174174
var DEFAULT_EXPERIMENT_COMPONENT = __webpack_require__(4).DEFAULT_EXPERIMENT_COMPONENT;
175175

176176
module.exports = {
177+
178+
enrollInExperiment: function enrollInExperiment(component, child, variationName) {
179+
if (variationName && child.props.name === variationName) {
180+
component.exposedVariation = child;
181+
} else if (child.props.displayName === DEFAULT_EXPERIMENT_COMPONENT) {
182+
component.defaultComponent = child;
183+
}
184+
return component;
185+
},
186+
177187
getExposedExperimentVariation: function getExposedExperimentVariation(childrenComponents, variationName) {
178188
var _this = this;
179189

@@ -188,15 +198,6 @@ return /******/ (function(modules) { // webpackBootstrap
188198

189199
return _this.enrollInExperiment(component, child, variationName);
190200
}, {});
191-
},
192-
193-
enrollInExperiment: function enrollInExperiment(component, child, variationName) {
194-
if (variationName && child.props.name === variationName) {
195-
component.exposedVariation = child;
196-
} else if (child.props.displayName === DEFAULT_EXPERIMENT_COMPONENT) {
197-
component.defaultComponent = child;
198-
}
199-
return component;
200201
}
201202
};
202203

@@ -243,7 +244,7 @@ return /******/ (function(modules) { // webpackBootstrap
243244

244245
var DEFAULT_EXPERIMENT_COMPONENT = __webpack_require__(4).DEFAULT_EXPERIMENT_COMPONENT;
245246

246-
var getExposedExperimentVariation = __webpack_require__(3).getExposedExperimentVariation;
247+
var ExperimentEnrollment = _interopRequire(__webpack_require__(3));
247248

248249
var suppressAutoExposureLogging = __webpack_require__(5).suppressAutoExposureLogging;
249250

@@ -272,7 +273,7 @@ return /******/ (function(modules) { // webpackBootstrap
272273
component.defaultComponent = child;
273274
} else if (child.props.isEnrolled) {
274275
var experimentParam = experiment.get(child.props.param);
275-
if (experimentParam && getExposedExperimentVariation(child.props.children, experimentParam).exposedVariation) {
276+
if (experimentParam && ExperimentEnrollment.getExposedExperimentVariation(child.props.children, experimentParam).exposedVariation) {
276277
component.exposedExperiment = child;
277278
}
278279
}

dist/react-experiments.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/experiment.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import {getExposedExperimentVariation} from './experimentEnrollment';
2+
import ExperimentEnrollment from './experimentEnrollment';
33
import {suppressAutoExposureLogging} from './utils';
44

55
export const Experiment = React.createClass({
@@ -46,7 +46,7 @@ export const Experiment = React.createClass({
4646
},
4747

4848
renderExposedVariation() {
49-
let variationComponent = getExposedExperimentVariation(this.props.children, this.state.exposedVariation);
49+
let variationComponent = ExperimentEnrollment.getExposedExperimentVariation(this.props.children, this.state.exposedVariation);
5050

5151
if (variationComponent.exposedVariation) {
5252
this.props.experimentClass.logExposure();

src/experimentEnrollment.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
import {DEFAULT_EXPERIMENT_COMPONENT} from './constants';
22

33
export default {
4+
5+
enrollInExperiment(component, child, variationName) {
6+
if (variationName && child.props.name === variationName) {
7+
component.exposedVariation = child;
8+
} else if (child.props.displayName === DEFAULT_EXPERIMENT_COMPONENT) {
9+
component.defaultComponent = child;
10+
}
11+
return component;
12+
},
13+
414
getExposedExperimentVariation(childrenComponents, variationName) {
515
if (!childrenComponents.reduce) {
6-
return this.enrollInExperiment({}, childrenComponents, variationName);
7-
}
16+
return this.enrollInExperiment({}, childrenComponents, variationName);
17+
}
818

919
return childrenComponents.reduce((component, child) => {
1020
if (component.exposedVariation) {
1121
return component;
1222
}
1323

1424
return this.enrollInExperiment(component, child, variationName);
15-
}, {})
16-
},
17-
18-
enrollInExperiment(component, child, variationName) {
19-
if (variationName && child.props.name === variationName) {
20-
component.exposedVariation = child;
21-
} else if (child.props.displayName === DEFAULT_EXPERIMENT_COMPONENT) {
22-
component.defaultComponent = child;
23-
}
24-
return component;
25+
}, {});
2526
}
2627
};

src/namespace.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import {DEFAULT_EXPERIMENT_COMPONENT} from './constants';
3-
import {getExposedExperimentVariation} from './experimentEnrollment';
3+
import ExperimentEnrollment from './experimentEnrollment';
44
import {suppressAutoExposureLogging} from './utils';
55

66
export const Namespace = React.createClass({
@@ -24,7 +24,7 @@ export const Namespace = React.createClass({
2424
component.defaultComponent = child;
2525
} else if (child.props.isEnrolled) {
2626
const experimentParam = experiment.get(child.props.param);
27-
if (experimentParam && getExposedExperimentVariation(child.props.children, experimentParam).exposedVariation) {
27+
if (experimentParam && ExperimentEnrollment.getExposedExperimentVariation(child.props.children, experimentParam).exposedVariation) {
2828
component.exposedExperiment = child;
2929
}
3030
}

0 commit comments

Comments
 (0)