Skip to content

Commit ddb7fb7

Browse files
authored
Merge branch 'master' into ReactDOMComponentTree-test
2 parents 8da97de + 2c228f1 commit ddb7fb7

File tree

105 files changed

+2662
-2446
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+2662
-2446
lines changed

.flowconfig

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,15 @@
22

33
<PROJECT_ROOT>/fixtures/.*
44
<PROJECT_ROOT>/build/.*
5-
<PROJECT_ROOT>/scripts/.*
5+
<PROJECT_ROOT>/scripts/bench/.*
6+
7+
# These shims are copied into external projects:
8+
<PROJECT_ROOT>/scripts/rollup/shims/facebook-www/.*
9+
<PROJECT_ROOT>/scripts/rollup/shims/react-native/.*
10+
11+
# Note: intentionally *don't* ignore /scripts/rollup/shims/rollup/
12+
# because it is part of the build and isn't external.
13+
614
<PROJECT_ROOT>/.*/node_modules/y18n/.*
715
<PROJECT_ROOT>/node_modules/chrome-devtools-frontend/.*
816
<PROJECT_ROOT>/node_modules/devtools-timeline-model/.*

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Starting with 16.1.0, we will no longer be publishing new releases on Bower. You
4040
* Improve the warning about booleans passed to event handlers. ([@NicBonetto](https://github.com/NicBonetto) in [#11308](https://github.com/facebook/react/pull/11308))
4141
* Improve the warning when a multiple `select` gets null `value`. ([@Hendeca](https://github.com/Hendeca) in [#11141](https://github.com/facebook/react/pull/11141))
4242
* Move link in the warning message to avoid redirect. ([@marciovicente](https://github.com/marciovicente) in [#11400](https://github.com/facebook/react/pull/11400))
43+
* Add a way to suppress the React DevTools installation prompt. ([@gaearon](http://github.com/gaearon) in [#11448](https://github.com/facebook/react/pull/11448))
4344
* Remove unused code. ([@gaearon](https://github.com/gaearon) in [#10802](https://github.com/facebook/react/pull/10802), [#10803](https://github.com/facebook/react/pull/10803))
4445

4546
### React DOM Server
@@ -52,7 +53,8 @@ Starting with 16.1.0, we will no longer be publishing new releases on Bower. You
5253
### React Test Renderer and Test Utils
5354

5455
* Fix multiple `setState()` calls in `componentWillMount()` in shallow renderer. ([@Hypnosphi](https://github.com/Hypnosphi) in [#11167](https://github.com/facebook/react/pull/11167))
55-
* Fix shallow renderer to ignore `shouldComponentUpdate()` after `forceUpdate()`. ([@d4rky-pl](https://github.com/d4rky-pl) in [#11239](https://github.com/facebook/react/pull/11239))
56+
* Fix shallow renderer to ignore `shouldComponentUpdate()` after `forceUpdate()`. ([@d4rky-pl](https://github.com/d4rky-pl) in [#11239](https://github.com/facebook/react/pull/11239) and [#11439](https://github.com/facebook/react/pull/11439))
57+
* Handle `forceUpdate()` and `React.PureComponent` correctly. ([@koba04](https://github.com/koba04) in [#11440](https://github.com/facebook/react/pull/11440))
5658
* Add back support for running in production mode. ([@gaearon](https://github.com/gaearon) in [#11112](https://github.com/facebook/react/pull/11112))
5759
* Add a missing `package.json` dependency. ([@gaearon](https://github.com/gaearon) in [#11340](https://github.com/facebook/react/pull/11340))
5860

@@ -64,6 +66,7 @@ Starting with 16.1.0, we will no longer be publishing new releases on Bower. You
6466
### React Reconciler (Experimental)
6567

6668
* First release of the [new experimental package](https://github.com/facebook/react/blob/master/packages/react-reconciler/README.md) for creating custom renderers. ([@iamdustan](https://github.com/iamdustan) in [#10758](https://github.com/facebook/react/pull/10758))
69+
* Add support for React DevTools. ([@gaearon](https://github.com/gaearon) in [#11463](https://github.com/facebook/react/pull/11463))
6770

6871
### React Call Return (Experimental)
6972

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ Facebook has adopted a Code of Conduct that we expect project participants to ad
6767

6868
Read our [contributing guide](https://reactjs.org/contributing/how-to-contribute.html) to learn about our development process, how to propose bugfixes and improvements, and how to build and test your changes to React.
6969

70-
### Beginner Friendly Bugs
70+
### Good First Issues
7171

72-
To help you get your feet wet and get you familiar with our contribution process, we have a list of [beginner friendly bugs](https://github.com/facebook/react/labels/Difficulty%3A%20beginner) that contain bugs which are fairly easy to fix. This is a great place to get started.
72+
To help you get your feet wet and get you familiar with our contribution process, we have a list of [good first issues](https://github.com/facebook/react/labels/good%20first%20issue) that contain bugs which have a relatively limited scope. This is a great place to get started.
7373

7474
### License
7575

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
},
9999
"scripts": {
100100
"build": "npm run version-check && node scripts/rollup/build.js",
101-
"linc": "git diff --name-only --diff-filter=ACMRTUB `git merge-base HEAD master` | grep '\\.js$' | xargs eslint --",
101+
"linc": "node ./scripts/tasks/linc.js",
102102
"lint": "node ./scripts/tasks/eslint.js",
103103
"postinstall": "node node_modules/fbjs-scripts/node/check-dev-engines.js package.json",
104104
"test": "jest",

packages/events/EventPluginHub.js

Lines changed: 122 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,15 @@
88
import ReactErrorUtils from 'shared/ReactErrorUtils';
99
import invariant from 'fbjs/lib/invariant';
1010

11-
import EventPluginRegistry from './EventPluginRegistry';
12-
import EventPluginUtils from './EventPluginUtils';
11+
import {
12+
injectEventPluginOrder,
13+
injectEventPluginsByName,
14+
plugins,
15+
} from './EventPluginRegistry';
16+
import {
17+
executeDispatchesInOrder,
18+
getFiberCurrentPropsFromNode,
19+
} from './EventPluginUtils';
1320
import accumulateInto from './accumulateInto';
1421
import forEachAccumulated from './forEachAccumulated';
1522

@@ -28,7 +35,7 @@ var eventQueue = null;
2835
*/
2936
var executeDispatchesAndRelease = function(event, simulated) {
3037
if (event) {
31-
EventPluginUtils.executeDispatchesInOrder(event, simulated);
38+
executeDispatchesInOrder(event, simulated);
3239

3340
if (!event.isPersistent()) {
3441
event.constructor.release(event);
@@ -91,131 +98,127 @@ function shouldPreventMouseEvent(name, type, props) {
9198
*
9299
* @public
93100
*/
94-
var EventPluginHub = {
101+
102+
/**
103+
* Methods for injecting dependencies.
104+
*/
105+
export const injection = {
95106
/**
96-
* Methods for injecting dependencies.
107+
* @param {array} InjectedEventPluginOrder
108+
* @public
97109
*/
98-
injection: {
99-
/**
100-
* @param {array} InjectedEventPluginOrder
101-
* @public
102-
*/
103-
injectEventPluginOrder: EventPluginRegistry.injectEventPluginOrder,
104-
105-
/**
106-
* @param {object} injectedNamesToPlugins Map from names to plugin modules.
107-
*/
108-
injectEventPluginsByName: EventPluginRegistry.injectEventPluginsByName,
109-
},
110+
injectEventPluginOrder,
110111

111112
/**
112-
* @param {object} inst The instance, which is the source of events.
113-
* @param {string} registrationName Name of listener (e.g. `onClick`).
114-
* @return {?function} The stored callback.
113+
* @param {object} injectedNamesToPlugins Map from names to plugin modules.
115114
*/
116-
getListener: function(inst, registrationName) {
117-
var listener;
115+
injectEventPluginsByName,
116+
};
118117

119-
// TODO: shouldPreventMouseEvent is DOM-specific and definitely should not
120-
// live here; needs to be moved to a better place soon
121-
const stateNode = inst.stateNode;
122-
if (!stateNode) {
123-
// Work in progress (ex: onload events in incremental mode).
124-
return null;
125-
}
126-
const props = EventPluginUtils.getFiberCurrentPropsFromNode(stateNode);
127-
if (!props) {
128-
// Work in progress.
129-
return null;
130-
}
131-
listener = props[registrationName];
132-
if (shouldPreventMouseEvent(registrationName, inst.type, props)) {
133-
return null;
134-
}
135-
invariant(
136-
!listener || typeof listener === 'function',
137-
'Expected `%s` listener to be a function, instead got a value of `%s` type.',
138-
registrationName,
139-
typeof listener,
140-
);
141-
return listener;
142-
},
118+
/**
119+
* @param {object} inst The instance, which is the source of events.
120+
* @param {string} registrationName Name of listener (e.g. `onClick`).
121+
* @return {?function} The stored callback.
122+
*/
123+
export function getListener(inst, registrationName) {
124+
var listener;
143125

144-
/**
145-
* Allows registered plugins an opportunity to extract events from top-level
146-
* native browser events.
147-
*
148-
* @return {*} An accumulation of synthetic events.
149-
* @internal
150-
*/
151-
extractEvents: function(
152-
topLevelType,
153-
targetInst,
154-
nativeEvent,
155-
nativeEventTarget,
156-
) {
157-
var events;
158-
var plugins = EventPluginRegistry.plugins;
159-
for (var i = 0; i < plugins.length; i++) {
160-
// Not every plugin in the ordering may be loaded at runtime.
161-
var possiblePlugin = plugins[i];
162-
if (possiblePlugin) {
163-
var extractedEvents = possiblePlugin.extractEvents(
164-
topLevelType,
165-
targetInst,
166-
nativeEvent,
167-
nativeEventTarget,
168-
);
169-
if (extractedEvents) {
170-
events = accumulateInto(events, extractedEvents);
171-
}
126+
// TODO: shouldPreventMouseEvent is DOM-specific and definitely should not
127+
// live here; needs to be moved to a better place soon
128+
const stateNode = inst.stateNode;
129+
if (!stateNode) {
130+
// Work in progress (ex: onload events in incremental mode).
131+
return null;
132+
}
133+
const props = getFiberCurrentPropsFromNode(stateNode);
134+
if (!props) {
135+
// Work in progress.
136+
return null;
137+
}
138+
listener = props[registrationName];
139+
if (shouldPreventMouseEvent(registrationName, inst.type, props)) {
140+
return null;
141+
}
142+
invariant(
143+
!listener || typeof listener === 'function',
144+
'Expected `%s` listener to be a function, instead got a value of `%s` type.',
145+
registrationName,
146+
typeof listener,
147+
);
148+
return listener;
149+
}
150+
151+
/**
152+
* Allows registered plugins an opportunity to extract events from top-level
153+
* native browser events.
154+
*
155+
* @return {*} An accumulation of synthetic events.
156+
* @internal
157+
*/
158+
export function extractEvents(
159+
topLevelType,
160+
targetInst,
161+
nativeEvent,
162+
nativeEventTarget,
163+
) {
164+
var events;
165+
for (var i = 0; i < plugins.length; i++) {
166+
// Not every plugin in the ordering may be loaded at runtime.
167+
var possiblePlugin = plugins[i];
168+
if (possiblePlugin) {
169+
var extractedEvents = possiblePlugin.extractEvents(
170+
topLevelType,
171+
targetInst,
172+
nativeEvent,
173+
nativeEventTarget,
174+
);
175+
if (extractedEvents) {
176+
events = accumulateInto(events, extractedEvents);
172177
}
173178
}
174-
return events;
175-
},
179+
}
180+
return events;
181+
}
176182

177-
/**
178-
* Enqueues a synthetic event that should be dispatched when
179-
* `processEventQueue` is invoked.
180-
*
181-
* @param {*} events An accumulation of synthetic events.
182-
* @internal
183-
*/
184-
enqueueEvents: function(events) {
185-
if (events) {
186-
eventQueue = accumulateInto(eventQueue, events);
187-
}
188-
},
183+
/**
184+
* Enqueues a synthetic event that should be dispatched when
185+
* `processEventQueue` is invoked.
186+
*
187+
* @param {*} events An accumulation of synthetic events.
188+
* @internal
189+
*/
190+
export function enqueueEvents(events) {
191+
if (events) {
192+
eventQueue = accumulateInto(eventQueue, events);
193+
}
194+
}
189195

190-
/**
191-
* Dispatches all synthetic events on the event queue.
192-
*
193-
* @internal
194-
*/
195-
processEventQueue: function(simulated) {
196-
// Set `eventQueue` to null before processing it so that we can tell if more
197-
// events get enqueued while processing.
198-
var processingEventQueue = eventQueue;
199-
eventQueue = null;
200-
if (simulated) {
201-
forEachAccumulated(
202-
processingEventQueue,
203-
executeDispatchesAndReleaseSimulated,
204-
);
205-
} else {
206-
forEachAccumulated(
207-
processingEventQueue,
208-
executeDispatchesAndReleaseTopLevel,
209-
);
210-
}
211-
invariant(
212-
!eventQueue,
213-
'processEventQueue(): Additional events were enqueued while processing ' +
214-
'an event queue. Support for this has not yet been implemented.',
196+
/**
197+
* Dispatches all synthetic events on the event queue.
198+
*
199+
* @internal
200+
*/
201+
export function processEventQueue(simulated) {
202+
// Set `eventQueue` to null before processing it so that we can tell if more
203+
// events get enqueued while processing.
204+
var processingEventQueue = eventQueue;
205+
eventQueue = null;
206+
if (simulated) {
207+
forEachAccumulated(
208+
processingEventQueue,
209+
executeDispatchesAndReleaseSimulated,
215210
);
216-
// This would be a good time to rethrow if any of the event handlers threw.
217-
ReactErrorUtils.rethrowCaughtError();
218-
},
219-
};
220-
221-
export default EventPluginHub;
211+
} else {
212+
forEachAccumulated(
213+
processingEventQueue,
214+
executeDispatchesAndReleaseTopLevel,
215+
);
216+
}
217+
invariant(
218+
!eventQueue,
219+
'processEventQueue(): Additional events were enqueued while processing ' +
220+
'an event queue. Support for this has not yet been implemented.',
221+
);
222+
// This would be a good time to rethrow if any of the event handlers threw.
223+
ReactErrorUtils.rethrowCaughtError();
224+
}

0 commit comments

Comments
 (0)