Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions fixtures/dom/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ coverage
# production
build
public/react.development.js
public/react.production.min.js
public/react-dom.development.js
public/react-dom.production.min.js
public/react-dom-server.browser.development.js

# misc
Expand Down
2 changes: 1 addition & 1 deletion fixtures/dom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"scripts": {
"start": "react-scripts start",
"prestart": "cp ../../build/dist/react.development.js ../../build/dist/react-dom.development.js ../../build/dist/react-dom-server.browser.development.js public/",
"prestart": "cp ../../build/dist/react.development.js ../../build/dist/react-dom.development.js ../../build/dist/react.production.min.js ../../build/dist/react-dom.production.min.js ../../build/dist/react-dom-server.browser.development.js public/",
"build": "react-scripts build && cp build/index.html build/200.html",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
Expand Down
20 changes: 19 additions & 1 deletion fixtures/dom/src/components/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ class Header extends React.Component {
super(props, context);
const query = parse(window.location.search);
const version = query.version || 'local';
const production = query.production || false;
const versions = [version];
this.state = {version, versions};
this.state = {version, versions, production};
}
componentWillMount() {
getVersionTags().then(tags => {
Expand All @@ -25,6 +26,14 @@ class Header extends React.Component {
}
window.location.search = stringify(query);
}
handleProductionChange(event) {
const query = parse(window.location.search);
query.production = event.target.checked;
if (!query.production) {
delete query.production;
}
window.location.search = stringify(query);
}
handleFixtureChange(event) {
window.location.pathname = event.target.value;
}
Expand Down Expand Up @@ -82,6 +91,15 @@ class Header extends React.Component {
))}
</select>
</label>
<input
id="react_production"
type="checkbox"
checked={this.state.production}
onChange={this.handleProductionChange}
/>
<label htmlFor="react_production">
<span className="header__label">Production</span>
</label>
</div>
</div>
</header>
Expand Down
27 changes: 17 additions & 10 deletions fixtures/dom/src/react-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,29 +43,36 @@ export function reactPaths() {

let query = parseQuery(window.location.search);
let version = query.version || 'local';
let production = query.production === 'true';

if (version !== 'local') {
if (version === 'local' && production) {
reactPath = 'react.production.min.js';
reactDOMPath = 'react-dom.production.min.js';
} else if (version !== 'local') {
const {major, minor, prerelease} = semver(version);
const [preReleaseStage] = prerelease;
// The file structure was updated in 16. This wasn't the case for alphas.
// Load the old module location for anything less than 16 RC
if (major >= 16 && !(minor === 0 && preReleaseStage === 'alpha')) {
reactPath =
'https://unpkg.com/react@' + version + '/umd/react.development.js';
const suffix = production ? '.production.min.js' : '.development.js';
reactPath = 'https://unpkg.com/react@' + version + '/umd/react' + suffix;
reactDOMPath =
'https://unpkg.com/react-dom@' +
version +
'/umd/react-dom.development.js';
'https://unpkg.com/react-dom@' + version + '/umd/react-dom' + suffix;
reactDOMServerPath =
'https://unpkg.com/react-dom@' +
version +
'/umd/react-dom-server.browser.development';
'/umd/react-dom-server.browser' +
suffix;
} else {
reactPath = 'https://unpkg.com/react@' + version + '/dist/react.js';
const suffix = production ? '.min.js' : '.js';
reactPath = 'https://unpkg.com/react@' + version + '/dist/react' + suffix;
reactDOMPath =
'https://unpkg.com/react-dom@' + version + '/dist/react-dom.js';
'https://unpkg.com/react-dom@' + version + '/dist/react-dom' + suffix;
reactDOMServerPath =
'https://unpkg.com/react-dom@' + version + '/dist/react-dom-server.js';
'https://unpkg.com/react-dom@' +
version +
'/dist/react-dom-server' +
suffix;
}
}

Expand Down
5 changes: 5 additions & 0 deletions fixtures/dom/src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ textarea {
width: 100%;
}

.header__label {
font-size: 12px;
color: #ccc;
}

.sr-only {
clip: rect(0, 0, 0, 0);
height: 0;
Expand Down
37 changes: 6 additions & 31 deletions packages/events/EventPluginHub.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,30 +33,11 @@ import type {TopLevelType} from './TopLevelEventTypes';
*/
let eventQueue: ?(Array<ReactSyntheticEvent> | ReactSyntheticEvent) = null;

/**
* Dispatches an event and releases it back into the pool, unless persistent.
*
* @param {?object} event Synthetic event to be dispatched.
* @param {boolean} simulated If the event is simulated (changes exn behavior)
* @private
*/
const executeDispatchesAndRelease = function(
event: ReactSyntheticEvent,
simulated: boolean,
) {
if (event) {
executeDispatchesInOrder(event, simulated);

if (!event.isPersistent()) {
event.constructor.release(event);
}
}
};
const executeDispatchesAndReleaseSimulated = function(e) {
return executeDispatchesAndRelease(e, true);
const executeDispatchesSimulated = function(e) {
return executeDispatchesInOrder(e, true);
};
const executeDispatchesAndReleaseTopLevel = function(e) {
return executeDispatchesAndRelease(e, false);
const executeDispatchesTopLevel = function(e) {
return executeDispatchesInOrder(e, false);
};

function isInteractive(tag) {
Expand Down Expand Up @@ -208,15 +189,9 @@ export function runEventsInBatch(
}

if (simulated) {
forEachAccumulated(
processingEventQueue,
executeDispatchesAndReleaseSimulated,
);
forEachAccumulated(processingEventQueue, executeDispatchesSimulated);
} else {
forEachAccumulated(
processingEventQueue,
executeDispatchesAndReleaseTopLevel,
);
forEachAccumulated(processingEventQueue, executeDispatchesTopLevel);
}
invariant(
!eventQueue,
Expand Down
20 changes: 7 additions & 13 deletions packages/events/ResponderEventPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ function setResponderAndExtractTransfer(
// It's strange to get an `onMoveShouldSetResponder` when you're *already*
// the responder.
const skipOverBubbleShouldSetFrom = bubbleShouldSetFrom === responderInst;
const shouldSetEvent = ResponderSyntheticEvent.getPooled(
const shouldSetEvent = new ResponderSyntheticEvent(
shouldSetEventType,
bubbleShouldSetFrom,
nativeEvent,
Expand All @@ -378,15 +378,12 @@ function setResponderAndExtractTransfer(
accumulateTwoPhaseDispatches(shouldSetEvent);
}
const wantsResponderInst = executeDispatchesInOrderStopAtTrue(shouldSetEvent);
if (!shouldSetEvent.isPersistent()) {
shouldSetEvent.constructor.release(shouldSetEvent);
}

if (!wantsResponderInst || wantsResponderInst === responderInst) {
return null;
}
let extracted;
const grantEvent = ResponderSyntheticEvent.getPooled(
const grantEvent = new ResponderSyntheticEvent(
eventTypes.responderGrant,
wantsResponderInst,
nativeEvent,
Expand All @@ -397,7 +394,7 @@ function setResponderAndExtractTransfer(
accumulateDirectDispatches(grantEvent);
const blockHostResponder = executeDirectDispatch(grantEvent) === true;
if (responderInst) {
const terminationRequestEvent = ResponderSyntheticEvent.getPooled(
const terminationRequestEvent = new ResponderSyntheticEvent(
eventTypes.responderTerminationRequest,
responderInst,
nativeEvent,
Expand All @@ -409,12 +406,9 @@ function setResponderAndExtractTransfer(
const shouldSwitch =
!hasDispatches(terminationRequestEvent) ||
executeDirectDispatch(terminationRequestEvent);
if (!terminationRequestEvent.isPersistent()) {
terminationRequestEvent.constructor.release(terminationRequestEvent);
}

if (shouldSwitch) {
const terminateEvent = ResponderSyntheticEvent.getPooled(
const terminateEvent = new ResponderSyntheticEvent(
eventTypes.responderTerminate,
responderInst,
nativeEvent,
Expand All @@ -425,7 +419,7 @@ function setResponderAndExtractTransfer(
extracted = accumulate(extracted, [grantEvent, terminateEvent]);
changeResponder(wantsResponderInst, blockHostResponder);
} else {
const rejectEvent = ResponderSyntheticEvent.getPooled(
const rejectEvent = new ResponderSyntheticEvent(
eventTypes.responderReject,
wantsResponderInst,
nativeEvent,
Expand Down Expand Up @@ -553,7 +547,7 @@ const ResponderEventPlugin = {
: null;

if (incrementalTouch) {
const gesture = ResponderSyntheticEvent.getPooled(
const gesture = new ResponderSyntheticEvent(
incrementalTouch,
responderInst,
nativeEvent,
Expand All @@ -577,7 +571,7 @@ const ResponderEventPlugin = {
? eventTypes.responderRelease
: null;
if (finalTouch) {
const finalEvent = ResponderSyntheticEvent.getPooled(
const finalEvent = new ResponderSyntheticEvent(
finalTouch,
responderInst,
nativeEvent,
Expand Down
Loading