Compare commits

...

1009 Commits

Author SHA1 Message Date
Sophie Alpert
4c67be212d Fix lint after automated replacements 2018-10-20 00:33:18 -07:00
Sophie Alpert
93e0bdf2ee Remove unnecessary comparisons
Ran these, then prettier, then these again.

```
codemod --accept-all -d packages -m '\(\s*([a-zA-Z.]+) === NoWork\s*\|\|\s*\1 (>=?) ([a-zA-Z.]+)\s*\)' '(\1 \2 \3)'
codemod --accept-all -d packages -m '\(\s*([a-zA-Z.]+) === NoWork\s*\|\|\s*([a-zA-Z.]+) (<=?) \1\s*\)' '(\2 \3 \1)'

codemod --accept-all -d packages -m '(?<![.\w])([a-zA-Z.]+) !== NoWork\s*&&\s*\1 (<) ([a-zA-Z.]+)' '\1 \2 \3'
codemod --accept-all -d packages -m '(?<![.\w])([a-zA-Z.]+) !== NoWork\s*&&\s*([a-zA-Z.]+) (>) \1' '\2 \3 \1'

codemod --accept-all -d packages -m '(?<![.\w])([a-zA-Z.]+) === NoWork\s*\|\|\s*\1 (>=?) ([a-zA-Z.]+)\s*\?\s' '\1 \2 \3 ? '
codemod --accept-all -d packages -m '(?<![.\w])([a-zA-Z.]+) === NoWork\s*\|\|\s*([a-zA-Z.]+) (<=?) \1\s*\?\s' '\2 \3 \1 ? '
```
2018-10-20 00:31:21 -07:00
Sophie Alpert
a684f09e58 Make NoWork big instead of small 2018-10-20 00:16:42 -07:00
Sebastian Markbåge
7268d97d2b Centralize props memoization (#13900)
* Move memoizedProps to after beginWork remove memoizeProps helper

We always call this at the end. This is now enforced to line up since
we do the equality check in the beginning of beginWork. So we can't
have special cases.

* Inline the one caller of memoizeState
2018-10-19 20:12:02 -07:00
Andrew Clark
0fc0446798 Class component can suspend without losing state outside concurrent mode (#13899)
Outside of concurrent mode, schedules a force update on a suspended
class component to force it to prevent it from bailing out and
reusing the current fiber, which we know to be inconsistent.
2018-10-19 18:41:47 -07:00
Andrew Clark
36db538226 Bugfix for #13886 (#13896)
Fixes a bug where a lazy component does not cache the result of
its constructor.
2018-10-19 13:57:42 -07:00
Sebastian Markbåge
6938dcaacb SSR support for class contextType (#13889) 2018-10-19 11:18:32 -07:00
Sebastian Markbåge
fa65c58e15 Add readContext to SSR (#13888)
Will be used by react-cache.
2018-10-18 20:20:03 -07:00
Andrew Clark
d9a3cc070c React.lazy constructor must return result of a dynamic import (#13886)
We may want to change the protocol later, so until then we'll be
restrictive. Heuristic is to check for existence of `default`.
2018-10-18 19:58:25 -07:00
Andrew Clark
d9659e499e Lazy components must use React.lazy (#13885)
Removes support for using arbitrary promises as the type of a React
element. Instead, promises must be wrapped in React.lazy. This gives us
flexibility later if we need to change the protocol.

The reason is that promises do not provide a way to call their
constructor multiple times. For example:

const promiseForA = new Promise(resolve => {
  fetchA(a => resolve(a));
});

Given a reference to `promiseForA`, there's no way to call `fetchA`
again. Calling `then` on the promise doesn't run the constructor again;
it only attaches another listener.

In the future we will likely introduce an API like `React.eager` that
is similar to `lazy` but eagerly calls the constructor. That gives us
the ability to call the constructor multiple times. E.g. to increase
the priority, or to retry if the first operation failed.
2018-10-18 19:57:12 -07:00
Sophie Alpert
0648ca618d Revert "React.pure automatically forwards ref" (#13887)
Reverts #13822. We're not sure we want to do this.
2018-10-18 18:53:10 -07:00
Andrew Clark
4dd772ac10 Prettier :( 2018-10-18 18:38:44 -07:00
Andrew Clark
98bab66c35 Fix lint 2018-10-18 18:06:39 -07:00
Andrew Clark
8ced545e3d Suspense component does not capture if fallback is not defined (#13879)
* Suspense component does not capture if `fallback` is not defined

A missing fallback prop means the exception should propagate to the next
parent (like a rethrow). That way a Suspense component can specify other
props like maxDuration without needing to provide a fallback, too.

Closes #13864

* Change order of checks
2018-10-18 16:07:22 -07:00
Andrew Clark
b738ced477 Remove render prop option from Suspense (#13880)
This was the original, lower-level API before we landed on `fallback`
instead. (We might add a different lower-level API in the future, likely
alongside a new API for catching errors).
2018-10-18 15:48:11 -07:00
Andrew Clark
55b8279423 Strict mode and default mode should have same Suspense semantics (#13882)
In the default mode, Suspense has special semantics where, in
addition to timing out immediately, we don't unwind the stack before
rendering the fallback. Instead, we commit the tree in an inconsistent
state, then synchronous render *again* to switch to the fallback. This
is slower but is less likely to cause issues with older components that
perform side effects in the render phase (e.g. componentWillMount,
componentWillUpdate, and componentWillReceiveProps).

We should do this in strict mode, too, so that there are no semantic
differences (in prod, at least) between default mode and strict mode.
The rationale is that it makes it easier to wrap a tree in strict mode
and start migrating components incrementally without worrying about new
bugs in production.
2018-10-18 15:42:40 -07:00
Andrew Clark
dac9202a9c Hide timed-out children instead of deleting them so their state is preserved (#13823)
* Store the start time on `updateQueue` instead of `stateNode`

Originally I did this to free the `stateNode` field to store a second
set of children. I don't we'll need this anymore, since we use fragment
fibers instead. But I still think using `updateQueue` makes more sense
so I'll leave this in.

* Use fragment fibers to keep the primary and fallback children separate

If the children timeout, we switch to showing the fallback children in
place of the "primary" children. However, we don't want to delete the
primary children because then their state will be lost (both the React
state and the host state, e.g. uncontrolled form inputs). Instead we
keep them mounted and hide them. Both the fallback children AND the
primary children are rendered at the same time. Once the primary
children are un-suspended, we can delete the fallback children — don't
need to preserve their state.

The two sets of children are siblings in the host environment, but
semantically, for purposes of reconciliation, they are two separate
sets. So we store them using two fragment fibers.

However, we want to avoid allocating extra fibers for every placeholder.
They're only necessary when the children time out, because that's the
only time when both sets are mounted.

So, the extra fragment fibers are only used if the children time out.
Otherwise, we render the primary children directly. This requires some
custom reconciliation logic to preserve the state of the primary
children. It's essentially a very basic form of re-parenting.

* Use `memoizedState` to store various pieces of SuspenseComponent's state

SuspenseComponent has three pieces of state:

- alreadyCaptured: Whether a component in the child subtree already
suspended. If true, subsequent suspends should bubble up to the
next boundary.
- didTimeout: Whether the boundary renders the primary or fallback
children. This is separate from `alreadyCaptured` because outside of
strict mode, when a boundary times out, the first commit renders the
primary children in an incomplete state, then performs a second commit
to switch the fallback. In that first commit, `alreadyCaptured` is
false and `didTimeout` is true.
- timedOutAt: The time at which the boundary timed out. This is separate
from `didTimeout` because it's not set unless the boundary
actually commits.


These were previously spread across several fields.

This happens to make the non-strict case a bit less hacky; the logic for
that special case is now mostly localized to the UnwindWork module.

* Hide timed-out Suspense children

When a subtree takes too long to load, we swap its contents out for
a fallback to unblock the rest of the tree. Because we don't want
to lose the state of the timed out view, we shouldn't actually delete
the nodes from the tree. Instead, we'll keep them mounted and hide
them visually. When the subtree is unblocked, we un-hide it, having
preserved the existing state.

Adds additional host config methods. For mutation mode:

- hideInstance
- hideTextInstance
- unhideInstance
- unhideTextInstance

For persistent mode:

- cloneHiddenInstance
- cloneUnhiddenInstance
- createHiddenTextInstance

I've only implemented the new methods in the noop and test renderers.
I'll implement them in the other renderers in subsequent commits.

* Include `hidden` prop in noop renderer's output

This will be used in subsequent commits to test that timed-out children
are properly hidden.

Also adds getChildrenAsJSX() method as an alternative to using
getChildren(). (Ideally all our tests would use test renderer #oneday.)

* Implement hide/unhide host config methods for DOM renderer

For DOM nodes, we hide using `el.style.display = 'none'`.

Text nodes don't have style, so we hide using `text.textContent = ''`.

* Implement hide/unhide host config methods for Art renderer

* Create DOM fixture that tests state preservation of timed out content

* Account for class components that suspend outside concurrent mode

Need to distinguish mount from update. An unfortunate edge case :(

* Fork appendAllChildren between persistent and mutation mode

* Remove redundant check for existence of el.style

* Schedule placement effect on indeterminate components

In non-concurrent mode, indeterminate fibers may commit in an
inconsistent state. But when they update, we should throw out the
old fiber and start fresh. Which means the new fiber needs a
placement effect.

* Pass null instead of current everywhere in mountIndeterminateComponent
2018-10-18 15:37:16 -07:00
Pablo Javier D. A
4f0bd45905 Replacement of old links, by the new ones of the documentation. (#13871) 2018-10-17 10:08:06 -04:00
Dan Abramov
7685b55d27 Remove unstable_read() in favor of direct dispatcher call (#13861)
* Remove unstable_read() in favor of direct dispatcher call

* This no longer throws immediately
2018-10-16 14:58:00 -04:00
Trivikram Kamat
21a79a1d9f [schedule] Call ensureHostCallbackIsScheduled without args (#13852)
ensureHostCallbackIsScheduled reads firstCallbackNode from global scope
and need not be passed in function call
2018-10-15 10:26:40 -07:00
Dan Abramov
9ea4bc6ed6 Fix false positive context warning when using an old React (#13850) 2018-10-14 15:35:52 +01:00
Sebastian Markbåge
4773fdf7cd Deprecate findDOMNode in StrictMode (#13841)
* Deprecate findDOMNode in StrictMode

There are two scenarios. One is that we pass a component instance that is
already in strict mode or the node that we find is in strict mode if
an outer component renders into strict mode.

I use a separate method findHostInstanceWithWarning for this so that
a) I can pass the method name (findDOMNode/findNodeHandle).
b) Can ignore this warning in React Native mixins/NativeComponent that use this helper.

I don't want to expose the fiber to the renderers themselves.
2018-10-12 15:42:00 -07:00
Andrew Clark
c9be16f5b6 [scheduler] Rename priority levels (#13842)
- "Interactive" -> "user-blocking"
- "Whenever" -> "Idle"

These are the terms used by @spanicker in their main-thread scheduling
proposal: https://github.com/spanicker/main-thread-scheduling#api-sketch

That proposal also uses "microtask" instead of "immediate" and "default"
instead of "normal." Not sure about "microtask" because I don't think
most people know what that is. And our implementation isn't a proper
microtask, though you could use it to implement microtasks if you made
sure to wrap every entry point. I don't really have a preference between
"default" and "normal."

These aren't necessarily the final names. Still prefixed by `unstable_`.
2018-10-12 14:42:15 -07:00
Dominic Gannaway
3b7ee26925 Deprecate context object as a consumer and add a warning message (#13829)
* Deprecate context object as a consumer and add various warning messages for unsupported usage.
2018-10-12 17:46:47 +01:00
Dan Abramov
8ca8a594e6 Error gracefully for unsupported SSR features (#13839) 2018-10-12 14:47:02 +01:00
Dan Abramov
6d5d250bef Use React.lazy in Suspense fixture (#13834) 2018-10-12 03:37:53 +01:00
Dan Abramov
4a635785f5 Fix User Timing oddities with Suspense, pure, and lazy (#13833)
* Show pure components in fiber timings with name

* Fix Suspense and lazy user timings

* Tweak message and type name

* Fix Flow
2018-10-12 03:15:14 +01:00
Nadia Osipova
d270db1c38 Merge branch 'master' of github.com:facebook/react
Fixed my own author name and email
2018-10-11 17:13:08 -07:00
Nadia Osipova
a165cf7473 Renamed 4 Internal React Modules 2018-10-11 17:12:31 -07:00
Nadia--
30b6076157 Renamed 4 Internal React Modules 2018-10-11 16:41:31 -07:00
Sophie Alpert
a68ca9a5b5 React.pure automatically forwards ref (#13822)
We're not planning to encourage legacy context, and without this change, it's difficult to use pure+forwardRef together. We could special-case `pure(forwardRef(...))` but this is hopefully simpler.

```js
React.pure(function(props, ref) {
  // ...
});
```
2018-10-11 13:04:42 -07:00
Dan Abramov
0af8199709 Revert "comment out temporarily"
This reverts commit 9abb9cd50a.
2018-10-10 17:23:18 +01:00
Dan Abramov
c73497c3c7 Update bundle sizes for 16.6.0-alpha.8af6728 release 2018-10-10 17:19:00 +01:00
Dan Abramov
101ea6b84d Update error codes for 16.6.0-alpha.8af6728 release 2018-10-10 17:18:59 +01:00
Dan Abramov
1a57dc6689 Updating dependencies for react-noop-renderer 2018-10-10 17:12:05 +01:00
Dan Abramov
77f8dfd81e Updating package versions for release 16.6.0-alpha.8af6728 2018-10-10 17:12:05 +01:00
Dan Abramov
9abb9cd50a comment out temporarily 2018-10-10 17:11:44 +01:00
Dan Abramov
8af6728c6f Enable Suspense + rename Placeholder (#13799)
* Enable Suspense

* <unstable_Placeholder delayMs> => <unstable_Suspense maxDuration>

* Update suspense fixture
2018-10-10 17:02:04 +01:00
Philipp
f47a958ea8 Don’t add onclick listener to React root (#13778)
Fixes #13777

As part of #11927 we introduced a regression by adding onclick handler
to the React root. This causes the whole React tree to flash when tapped
on iOS devices (for reasons I outlined in
https://github.com/facebook/react/issues/12989#issuecomment-414266839).

To fix this, we should only apply onclick listeners to portal roots. I
verified that my proposed fix indeed works by checking out our DOM
fixtures and adding regression tests.

Strangely, I had to make changes to the DOM fixtures to see the behavior
in the first place. This seems to be caused by our normal sites (and 
thus their React root) being bigger than the viewport:

![](http://cl.ly/3f18f8b85e91/Screen%20Recording%202018-10-05%20at%2001.32%20AM.gif)

An alternative approach to finding out if we're appending to a React
root would be to add a third parameter to `appendChildToContainer` based
on the tag of the parent fiber.
2018-10-09 10:27:06 +02:00
Andrew Clark
b2cea9078d [scheduler] Eagerly schedule rAF at beginning of frame (#13785)
* [scheduler] Eagerly schedule rAF at beginning of frame

Eagerly schedule the next animation callback at the beginning of the
frame. If the scheduler queue is not empty at the end of the frame, it
will continue flushing inside that callback. If the queue *is* empty,
then it will exit immediately. Posting the callback at the start of the
frame ensures it's fired within the earliest possible frame. If we
waited until the end of the frame to post the callback, we risk the
browser skipping a frame and not firing the callback until the frame
after that.

* Re-name scheduledCallback -> scheduledHostCallback
2018-10-08 17:28:58 -07:00
plievone
e2e7cb9f4c [scheduler] add a test documenting current behavior (#13687)
* [scheduler] add a test documenting current behavior

* Update with latest changes from master and confirm fixed behavior
2018-10-05 11:25:03 -07:00
Sophie Alpert
d83601080a Wrap retrySuspendedRoot using SchedulerTracing (#13776)
Previously, we were emptying root.pendingInteractionMap and permanently losing those interactions when applying an unrelated update to a tree that has no scheduled work that is waiting on promise resolution. (That is, one that is showing a fallback and waiting for the suspended content to resolve.)

The logic I'm leaving untouched with `nextRenderIncludesTimedOutPlaceholder` is *not* correct -- what we want is instead to know if *any* placeholder anywhere in the tree is showing its fallback -- but we don't currently have a better replacement, and this should unblock tracing with suspense again.
2018-10-04 15:11:12 -07:00
Dan Abramov
40a521aa72 Terminology: Functional -> Function Component (#13775)
* Terminology: Functional -> Function Component

* Drop the "stateless" (functions are already stateless, right?)
2018-10-04 22:44:46 +01:00
Michael Ridgway
605ab10a4a Add envify transform to scheduler package (#13766)
This package uses `process.env.NODE_ENV` but does not transform its usage during bundling like the rest of the React libraries do. This causes issues when `process` is not defined globally.
2018-10-04 14:18:19 -07:00
Andrew Clark
acc7f404ce Restart from root if promise pings before end of render phase (#13774)
* Restart from root if promise pings before end of render phase

* Test that placeholder resolves successfully even if fallback render is pending
2018-10-04 12:55:52 -07:00
Spencer Davies
cbc2240288 fix - small misspelling (#13768)
longer term needs a hyphen.
2018-10-04 04:05:51 -04:00
Andrew Clark
4eabeef11b Rename ReactSuspenseWithTestRenderer-test -> ReactSuspense-test 2018-10-03 18:54:38 -06:00
Andrew Clark
95a3e1c2e7 Rename ReactSuspense-test -> ReactSuspenseWithNoopRenderer-test
Doing this in its own commit to preserve history
2018-10-03 18:52:56 -06:00
Andrew Clark
96bcae9d50 Jest + test renderer helpers for concurrent mode (#13751)
* Jest + test renderer helpers for concurrent mode

Most of our concurrent React tests use the noop renderer. But most
of those tests don't test the renderer API, and could instead be
written with the test renderer. We should switch to using the test
renderer whenever possible, because that's what we expect product devs
and library authors to do. If test renderer is sufficient for writing
most React core tests, it should be sufficient for others, too. (The
converse isn't true but we should aim to dogfood test renderer as much
as possible.)

This PR adds a new package, jest-react (thanks @cpojer). I've moved
our existing Jest matchers into that package and added some new ones.

I'm not expecting to figure out the final API in this PR. My goal is
to land something good enough that we can start dogfooding in www.

TODO: Continue migrating Suspense tests, decide on better API names

* Add additional invariants to prevent common errors

- Errors if user attempts to flush when log of yields is not empty
- Throws if argument passed to toClearYields is not ReactTestRenderer

* Better method names

- toFlushAll -> toFlushAndYield
- toFlushAndYieldThrough ->
- toClearYields -> toHaveYielded

Also added toFlushWithoutYielding

* Fix jest-react exports

* Tweak README
2018-10-03 18:37:41 -06:00
Heaven
5c783ee751 Remove unreachable code (#13762) 2018-10-03 18:03:01 -06:00
Brian Vaughn
36c5d69caa Always warn about legacy context within StrictMode tree (#13760) 2018-10-03 08:40:45 -07:00
Maksim Markelov
3e9a5de888 UMD react-cache build (#13761) 2018-10-03 15:09:17 +01:00
Andrew Clark
3c60f32747 Fix simple-cache-provider import that I missed 2018-10-02 00:50:33 -06:00
Joe Cortopassi
8315a30b9b --save is no longer needed (#13756)
`--save` is on by default as of [npm 5](https://blog.npmjs.org/post/161081169345/v500), and `npm install aphrodite` is functionally equivalent to `npm install --save aphrodite` now
2018-10-01 19:15:11 +01:00
Andrew Clark
ce96e2df4d Rename simple-cache-provider to react-cache (#13755) 2018-10-01 09:07:40 -06:00
Brian Vaughn
c5212646f8 Removed extra typeof checks for contextType.unstable_read (#13736) 2018-09-28 13:12:26 -07:00
Brian Vaughn
806eebdaee Enable getDerivedStateFromError (#13746)
* Removed the enableGetDerivedStateFromCatch feature flag (aka permanently enabled the feature)
* Forked/copied ReactErrorBoundaries to ReactLegacyErrorBoundaries for testing componentDidCatch
* Updated error boundaries tests to apply to getDerivedStateFromCatch
* Renamed getDerivedStateFromCatch -> getDerivedStateFromError
* Warn if boundary with only componentDidCatch swallows error
* Fixed a subtle reconciliation bug with render phase error boundary
2018-09-28 13:05:01 -07:00
Andrew Clark
a0733fe13d pure (#13748)
* pure

A higher-order component version of the `React.PureComponent` class.
During an update, the previous props are compared to the new props. If
they are the same, React will skip rendering the component and
its children.

Unlike userspace implementations, `pure` will not add an additional
fiber to the tree.

The first argument must be a functional component; it does not work
with classes.

`pure` uses shallow comparison by default, like `React.PureComponent`.
A custom comparison can be passed as the second argument.

Co-authored-by: Andrew Clark <acdlite@fb.com>
Co-authored-by: Sophie Alpert <sophiebits@fb.com>

* Warn if first argument is not a functional component
2018-09-27 15:25:38 -07:00
Andrew Clark
4d17c3f051 [scheduler] Improve naive fallback version used in non-DOM environments
Added some tests for the non-DOM version of Scheduler that is used
as a fallback, e.g. Jest. The tests use Jest's fake timers API:

- `jest.runAllTimers(ms)` flushes all scheduled work, as expected
- `jest.advanceTimersByTime(ms)` flushes only callbacks that expire
within the given milliseconds.

These capabilities should be sufficient for most product tests. Because
jest's fake timers do not override performance.now or Date.now, we
assume time is constant. This means Scheduler's internal time will not
be aligned with other code that reads from `performance.now`. For finer
control, the user can override `window._sched` like we do in our tests.
We will likely publish a Jest package that has this built in.
2018-09-26 20:25:21 -07:00
Timothy Yung
469005d87b Revise AttributeType React Native Flow Type (#13737) 2018-09-26 14:40:57 -07:00
Dominic Gannaway
0dc0ddc1ef Rename AsyncMode -> ConcurrentMode (#13732)
* Rename AsyncMode -> ConcurrentMode
2018-09-26 17:13:02 +01:00
Dominic Gannaway
7601c37654 Ensure "addEventListener" exists on "window" for "scheduler" package (#13731)
* Ensure addEventListener exists on "window"
2018-09-26 13:38:56 +01:00
Brian Vaughn
d0c0ec98ef Added a PureComponent contextType test (#13729) 2018-09-25 17:28:33 -07:00
Brian Vaughn
4b68a6498b Support class component static contextType attribute (#13728)
* Support class component static contextType attribute
2018-09-25 15:49:46 -07:00
Andrew Clark
f305d2a489 [scheduler] Priority levels, continuations, and wrapped callbacks (#13720)
All of these features are based on features of React's internal
scheduler. The eventual goal is to lift as much as possible out of the
React internals into the Scheduler package.

Includes some renaming of existing methods.

- `scheduleWork` is now `scheduleCallback`
- `cancelScheduledWork` is now `cancelCallback`


Priority levels
---------------

Adds the ability to schedule callbacks at different priority levels.
The current levels are (final names TBD):

- Immediate priority. Fires at the end of the outermost currently
executing (similar to a microtask).
- Interactive priority. Fires within a few hundred milliseconds. This
should only be used to provide quick feedback to the user as a result
of an interaction.
- Normal priority. This is the default. Fires within several seconds.
- "Maybe" priority. Only fires if there's nothing else to do. Used for
prerendering or warming a cache.

The priority is changed using `runWithPriority`:

```js
runWithPriority(InteractivePriority, () => {
  scheduleCallback(callback);
});
```


Continuations
-------------

Adds the ability for a callback to yield without losing its place
in the queue, by returning a continuation. The continuation will have
the same expiration as the callback that yielded.


Wrapped callbacks
-----------------

Adds the ability to wrap a callback so that, when it is called, it
receives the priority of the current execution context.
2018-09-25 15:11:42 -07:00
Brian Ng
970a34baed Bump babel-eslint and remove flow supressions (#13727) 2018-09-25 22:48:31 +01:00
Brian Vaughn
13965b4d30 Interaction tracking ref-counting bug fixes (WIP) (#13590)
* Added new (failing) suspense+interaction tests
* Add new tracing+suspense test harness fixture
* Refactored interaction tracing to fix ref counting bug
2018-09-25 09:27:41 -07:00
Sergei Startsev
17e703cb96 Restore global window.event after event dispatching (#13688) (#13697) 2018-09-25 16:24:23 +01:00
Heaven
a775a767a1 Remove redundant logic (#13502) 2018-09-24 17:59:29 -07:00
Philipp
2c7b78f216 Add closing parenthesis (#13712)
I’ve first seen it in the [releases view](https://github.com/facebook/react/releases/tag/v16.5.2) and fixed it there as well.
2018-09-23 12:36:47 +02:00
Maksim Markelov
e1a067dea0 Fix circular dependency in TracingSubscriptions (#13689) 2018-09-19 18:48:32 +01:00
Heaven
518812eeb8 Clarify comment (#13684)
* fix comment typo

* Update Scheduler.js
2018-09-19 13:14:32 +01:00
Dan
eeb817785c Remove some old files from stats 2018-09-19 01:36:31 +01:00
Dan Abramov
7ea3ca1d13 Rename schedule to scheduler (#13683) 2018-09-19 01:26:28 +01:00
Brian Vaughn
9b70816642 Added another bullet to the CHANGELOG 2018-09-18 12:45:31 -07:00
Brian Vaughn
db9d51b65c Rename 'Schedule' header -> 'Schedule (Experimental)' 2018-09-18 12:41:14 -07:00
Brian Vaughn
0823f845cf 16.5.2 CHANGELOG 2018-09-18 12:39:32 -07:00
Brian Vaughn
bec2ddaf15 Update bundle sizes for 16.5.2 release 2018-09-18 11:30:50 -07:00
Brian Vaughn
789e714bd7 Update error codes for 16.5.2 release 2018-09-18 11:30:50 -07:00
Brian Vaughn
4269fafb0a Updating package versions for release 16.5.2 2018-09-18 11:24:33 -07:00
Brian Vaughn
4380f9ba17 Revert "Updating package versions for release 16.6.0-alpha.0"
This reverts commit 351c9015c8.
2018-09-18 11:00:13 -07:00
Brian Vaughn
72fad84e76 Revert "Updating dependencies for react-noop-renderer"
This reverts commit 489614c4fc.
2018-09-18 11:00:09 -07:00
Brian Vaughn
39f93f7987 Revert "Update error codes for 16.6.0-alpha.0 release"
This reverts commit 21ceb19ea0.
2018-09-18 11:00:04 -07:00
Brian Vaughn
c3fad5acf8 Revert "Update bundle sizes for 16.6.0-alpha.0 release"
This reverts commit 42d12317a7.
2018-09-18 10:59:57 -07:00
Heaven
dd91205617 Kepp calling peformWork consistent (#13596) 2018-09-18 07:48:18 -07:00
Brian Vaughn
42d12317a7 Update bundle sizes for 16.6.0-alpha.0 release 2018-09-17 15:05:46 -07:00
Brian Vaughn
21ceb19ea0 Update error codes for 16.6.0-alpha.0 release 2018-09-17 15:05:46 -07:00
Brian Vaughn
489614c4fc Updating dependencies for react-noop-renderer 2018-09-17 14:59:57 -07:00
Brian Vaughn
351c9015c8 Updating package versions for release 16.6.0-alpha.0 2018-09-17 14:59:57 -07:00
Dan Abramov
a210b5b440 Revert "Do not bind topLevelType to dispatch" (#13674)
* Revert "Do not bind topLevelType to dispatch (#13618)"

This reverts commit 0c9c591bfb.
2018-09-17 18:43:16 +01:00
Sam Kvale
2f54a0467b docs(changelog): Fix misspelling (#13663)
dangerouslySetInnerHTML was misspelled dangerousSetInnerHTML
2018-09-15 08:16:58 -07:00
Alexey Raspopov
1d8a75fef0 remove flow typings from Schedule.js (#13662) 2018-09-15 03:55:23 +01:00
Nathan Hunzaker
d92114b98e Resubmit: Fix updateWrapper causing re-render textarea, even though their data (#13643)
* fix updateWrapper causing re-render textarea, even though their data has not changed

* fix updateWrapper causing re-render textarea, even though their data, prettier-all

* minor changes to updateWrapper, add test
2018-09-14 16:09:07 -07:00
Nathan Hunzaker
0c9c591bfb Do not bind topLevelType to dispatch (#13618)
* Do not bind topLevelType to dispatch

A previous change made it such that all top level event types
correspond to their associated native event string values. This commit
eliminates the .bind attached to dispatch and fixes a related flow
type.

* Add note about why casting event.type to a topLevelType is safe

* Move interactiveUpdates comment to point of assignment
2018-09-14 16:08:37 -07:00
Andrew Clark
9f819a5ea9 [schedule] Refactor Schedule, remove React-isms (#13582)
* Refactor Schedule, remove React-isms

Once the API stabilizes, we will move Schedule this into a separate
repo. To promote adoption, especially by projects outside the React
ecosystem, we'll remove all React-isms from the source and keep it as
simple as possible:

- No build step.
- No static types.
- Everything is in a single file.

If we end up needing to support multiple targets, like CommonJS and ESM,
we can still avoid a build step by maintaining two copies of the same
file, but with different exports.

This commit also refactors the implementation to split out the DOM-
specific parts (essentially a requestIdleCallback polyfill). Aside from
the architectural benefits, this also makes it possible to write host-
agnostic tests. If/when we publish a version of Schedule that targets
other environments, like React Native, we can run these same tests
across all implementations.

* Edits in response to Dan's PR feedback
2018-09-14 14:05:55 -07:00
Jérôme Steunou
9c961c0a27 Fix some iframe edge cases (#13650)
Should fix #13648 by fallback on `window` when `document.defaultView` does not exists anymore
2018-09-14 16:44:14 +01:00
Brian Vaughn
8bc0bcabe7 Add UMD production+profiling entry points (#13642)
* Added UMD_PROFILING type to react-dom and scheduling package. Added UMD shim to schedule package.
* Added new schedule umd prod+prof bundle to API test
2018-09-13 17:44:08 -07:00
Heaven
b488a5d9c5 Fix test comment typo (#13568) 2018-09-13 17:33:16 -07:00
Brian Vaughn
4bcee56210 Rename "tracking" API to "tracing" (#13641)
* Replaced "tracking" with "tracing" in all directory and file names
* Global rename of track/tracking/tracked to trace/tracing/traced
2018-09-13 14:23:16 -07:00
Dan Abramov
9a6c5ba72d Fix packaging fixtures 2018-09-13 19:31:18 +01:00
Dan Abramov
72217d0819 Update bundle sizes for 16.5.1 release 2018-09-13 19:31:18 +01:00
Dan Abramov
cc66a1aa23 Update error codes for 16.5.1 release 2018-09-13 19:31:18 +01:00
Dan Abramov
8b93a60c5e Updating package versions for release 16.5.1 2018-09-13 19:31:18 +01:00
Dan Abramov
7a5eecc073 Add 16.5.1 changelog (#13638) 2018-09-13 19:31:00 +01:00
Andres Rojas
ecbf7af40b Enhance dev warnings for forwardRef render function (#13627) (#13636)
* Enhance dev warnings for forwardRef render function

- For 0 parameters: Do not warn because it may be due to usage of the
  arguments object.

- For 1 parameter: Warn about missing the 'ref' parameter.

- For 2 parameters: This is the ideal. Do not warn.

- For more than 2 parameters: Warn about undefined parameters.

* Make test cases for forwardRef warnings more realistic

* Add period to warning sentence
2018-09-13 16:12:34 +01:00
Dan Abramov
2282400850 Delete TapEventPlugin (#13630) 2018-09-12 19:53:29 +01:00
Nathan Hunzaker
a079011f95 🔥 Stop syncing the value attribute on inputs (behind a feature flag) (#13526)
* 🔥 Stop syncing the value attribute on inputs

* Eliminate some additional checks

* Remove initialValue and initialWrapper from wrapperState flow type

* Update tests with new sync logic, reduce some operations

* Update tests, add some caveats for SSR mismatches

* Revert newline change

* Remove unused type

* Call toString to safely type string values

* Add disableInputAttributeSyncing feature flag

Reverts tests to original state, adds attribute sync feature flag,
then moves all affected tests to ReactFire-test.js.

* Revert position of types in toStringValues

* Invert flag on number input blur

* Add clarification why double blur is necessary

* Update ReactFire number cases to be more explicite about blur

* Move comments to reduce diff size

* Add comments to clarify behavior in each branch

* There is no need to assign a different checked behavior in Fire

* Use checked reference

* Format

* Avoid precomputing stringable values

* Revert getToStringValue comment

* Revert placement of undefined in getToStringValue

* Do not eagerly stringify value

* Unify Fire test cases with normal ones

* Revert toString change. Only assign unsynced values when not nully
2018-09-12 19:29:23 +01:00
Dan Abramov
a7bd7c3c04 Allow reading default feature flags from bundle tests (#13629) 2018-09-12 16:56:04 +01:00
Dan Abramov
7204b636ee Run tests for Fire feature flags (#13628)
* Run tests for Fire feature flags

* Only run ReactDOM tests for Fire
2018-09-12 16:17:36 +01:00
Dan Abramov
d3bbfe09cc Fix IE version in comment 2018-09-12 15:10:28 +01:00
Aliaksandr Manzhula
1b2646a403 Fix warning without stack for ie9 (#13620)
* Fix warning without stack for ie9

Where console methods like log, error etc. don't have 'apply' method.
Because of the lot of tests already expect that exactly console['method']
will be called - had to reapply references for console.error method

https://github.com/facebook/react/issues/13610

* pass parameters explicitly to avoid using .apply
which is not supported for console methods in ie9

* Minor tweaks
2018-09-12 15:09:57 +01:00
Héctor Ramos
dde0645fcf Switch to @sizebot token (#13622) 2018-09-11 21:06:44 +01:00
Evan Jacobs
e49f3ca08e honor displayName set on ForwardRef if available (#13615)
* add failing test

* honor displayName set on ForwardRef if available

Since React.forwardRef returns a component object, some users
(including styled-components and react-native) are starting to
decorate them with various statics including displayName.

This adjusts React's various name-getters to honor this if set and
surface the name in warnings and hopefully DevTools.

* fix typing

* Refine later
2018-09-11 20:19:54 +01:00
Nathan Hunzaker
f6fb03edff Hydration DOM Fixture (#13521)
* Add home component. Async load fixtures.

This commit adds a homepage to the DOM fixtures that includes browser
testing information and asynchronously loads fixtures.

This should make it easier to find DOM testing information and keep
the payload size in check as we add more components to the fixtures.

* Adds experimental hydration fixture

This commit adds a first pass at a fixture that makes it easier to
debug the process of hydrating static markup. This is not complete:

1. It needs to be verified across multiple browsers
2. It needs to render with the current version of react

Still, it at least demonstrates the idea. A fixture like this will
also be helpful for debugging change events for hydrated inputs, which
presently do not fire if the user changes an input's text before
hydration.

* Tweak select width

* Manually join extra attributes in warning

This prevents a bug where Chrome reports `Array(n)` where `n` is the
size of the array.

* Transform with buble

* Eliminate dependencies

* Pull in react-live for better editing

* Handle encoding errors, pass react version

* Load the correct version of React

* Tweaks

* Revert style change

* Revert warning update

* Properly handle script errors. Fix dom-server CDN loading

* Fix 15.x releases

* Use postMessage to reduce latency, support older browsers

This commit makes a few tweaks to support older browsers and updates
the code transition process to use window.postMessage. This avoids
loading React on every single change.

* Fix fixture renamespacing bug

* Gracefully fallback to textarea in React 14

* Replace buble with babel, react-live with codemirror

* Simplify layout to resolve production code-mirror issues

* Tweak height rules for code-mirror

* Update theme to paraiso

* Format Code.js

* Adjust viewport to fix CodeMirror resize issue in production build

* Eliminate react-code-mirror

* Improve error state. Make full stack collapsable

* Add link to license in codemirror stylesheet

* Make code example more concise

* Replace "Hydrate" with "Auto-hydrate" for clarity

* Remove border below hydration header

* Rename query function in render.js

* Use Function(code) to evaluate hydration fixture

For clarity, and so that the Fixture component does not need to be
assigned to the window, this commit changes the way code is executed
such that it evaluates using a Function constructor.

* Extend hydration fixture to fill width. Design adjustments

This commit extends the hydration fixture such that it takes up the
full screen view. To accomplish this, the container that wraps all
fixtures has been moved to the FixtureSet component, utilized by all
other fixtures.

* Improve error scroll state

* Lazy load CodeMirror together before executing

This commit fixes an issue where CodeMirror wouldn't layout correctly
in production builds because the editor executes before the stylesheet
loaded. CodeMirror needs layout information, and was rendering
off-screen without correct CSS layout measurements.

* Fix indentation on error message

* Do not highlight errors from Babel. Add setPrototypeOf polyfill

This commit fixes an error in Safari 7.1 where Chalk highlighted Babel
errors caused a crash when setPrototypeOf was called within the
library.

This is also an issue on IE9, however this fix does not resolve issues
in that browser.

* Increase resilience to bad errors in Hydration fixture

- Reverts highlighting change. Polyfilling Safari 7.1 is sufficient
- Do not render a details tag in IE9
2018-09-10 14:04:14 -07:00
Brian Vaughn
54bfab5d6d Release script updates private package dependencies also (#13612) 2018-09-10 13:14:34 -07:00
Brian Vaughn
ade5e69288 Manually update schedule dep in react-native-renderer (#13609) 2018-09-10 11:07:08 -07:00
Dan Abramov
f260b14a8f Fix host bailout for the persistent mode (#13611)
* Add regression test for persistent bailout bug

* Fork more logic into updateHostComponent

This is mostly copy paste. But I added a bailout only to mutation mode. Persistent mode doesn't have that props equality bailout anymore, so the Fabric test now passes.

* Add failing test for persistence host minimalism

* Add bailouts to the persistent host updates
2018-09-10 19:05:40 +01:00
Dan Abramov
4a40d76245 Fix a regression related to isReactComponent prototype check (#13608) 2018-09-10 17:54:45 +01:00
Brian Vaughn
03ab1efeb4 Improve DX when combining react-dom/profiling and schedule/tracking (#13605)
* Added blessed production+profiling entry point for schedule/tracking
* Add invariant when profiling renderer is used with non-profiling schedule/tracking
2018-09-10 08:32:56 -07:00
Dan Abramov
144328fe81 Enable no-use-before-define rule (#13606) 2018-09-10 16:15:18 +01:00
Dan
8a8d973d3c Use clearer wording
Fixes #13604
2018-09-09 16:54:31 +01:00
Brandon Dail
7d1169b2d7 Remove injectComponentTree from unstable-native-dependencies, add EventPluginHub (#13598)
* Remove injectComponentTree from unstable-native-dependencies, add
EventPluginHub

injectComponentTree was exposed for react-native-web, but wasn't
actually being used by the project. They were using EventPluginHub
through ReactDOM's secret internals, but that was removed in https://github.com/facebook/react/pull/13539

This removes the unused injectComponentTree export, refactors the
ResponderEventPlugin test so it doesn't depend on it, and also adds
EventPluginHub to the exports to unbreak react-native-web

* Re-export injectEventPluginsByName from ReactDOM internals
2018-09-08 12:07:59 -07:00
Nathan Hunzaker
8d1038fc6d Break up ReactDOMServerIntegrationForm-test (#13600)
In https://github.com/facebook/react/pull/13394, I encountered an
issue where the ReactDOMServerIntegrationForm test suite consumed
sufficient memory to crash CircleCI. Breaking up this test suite by
form element type resolved the issue.

This commit performs that change separate from the Symbol/Function
stringification changes in #13394.
2018-09-08 11:31:32 -07:00
Héctor Ramos
b87aabdfe1 Drop the year from Facebook copyright headers and the LICENSE file. (#13593) 2018-09-07 15:11:23 -07:00
Ali Torki
12f3a5475f chore: remove duplicate **when** (#13587) 2018-09-07 07:52:31 -10:00
Nish
c6dcf46d65 Build schedule which is required for time slicing demo (#13588)
* Build schedule which is required for time slicing demo

* Update suspense demo README too

* Update README.md

* Update README.md

* Update README.md
2018-09-07 17:11:19 +01:00
Brian Vaughn
7bcc0778fd Fixed small CHANGELOG error (#13583) 2018-09-06 18:03:58 -07:00
Brian Vaughn
d66505dbc7 Updated 16.5 changelog 2018-09-06 12:59:22 -07:00
Timothy Yung
e417e0bf7c Update ReactNativeViewConfigRegistry Flow Types (#13579) 2018-09-06 12:27:44 -07:00
Brian Vaughn
8f45a685be Add 2fa OTP code to npm dist-tag command too 2018-09-06 09:49:42 -07:00
Brian Vaughn
71c0e05ba7 Update bundle sizes for 16.5.0 release 2018-09-06 09:34:27 -07:00
Brian Vaughn
92a620e214 Update error codes for 16.5.0 release 2018-09-06 09:34:27 -07:00
Brian Vaughn
6255cc3949 Updating package versions for release 16.5.0 2018-09-06 09:29:36 -07:00
Brian Vaughn
5c5fc5f473 Updating yarn.lock file for 16.5.0 release 2018-09-06 09:27:41 -07:00
Brian Vaughn
1bede616d1 Build script correctly bumps prerelease deps (e.g. schedule) for react (#13577) 2018-09-06 08:59:51 -07:00
Brian Vaughn
0a8740db61 Build script correctly bumps prerelease deps (e.g. schedule) (#13576) 2018-09-06 08:06:05 -07:00
Brian Vaughn
28cb379782 Added a test for Profiler onRender that throws (#13575) 2018-09-06 08:03:09 -07:00
Dan Abramov
8963118b3c Update react-dom README 2018-09-06 15:27:06 +01:00
Dan Abramov
b47a28cb9e Tweak react-dom README 2018-09-06 15:22:10 +01:00
Andrew Clark
f765f02253 When a root expires, flush all expired work in a single batch (#13503)
Instead of flushing each level one at a time.
2018-09-06 15:07:02 +01:00
Dan Abramov
0156740610 Changelog for 16.5.0 (#13571) 2018-09-06 15:06:32 +01:00
Brian Vaughn
550dd1d2ec Call Profiler onRender after mutations (#13572) 2018-09-05 17:55:12 -07:00
Alex Taylor
34348a45b4 Add enableSuspenseServerRenderer feature flag (#13573) 2018-09-05 15:04:59 -07:00
Brian Vaughn
4e744be6ee Added react-dom/profiling entry point to NPM package (#13570) 2018-09-05 11:16:43 -07:00
laoxiong
bb627228ea test: add test for fragement props (#13565) 2018-09-05 16:28:50 +01:00
Brian Vaughn
9a110ebd8c Cleaned up 'schedule' API wrt interactions and subscriber ref: (#13561)
* Removed 'private' ref methods from UMD forwarding API
* Replaced getters with exported constants since they were no longer referenced for UMD forwarding
2018-09-05 07:29:30 -07:00
Brian Vaughn
fb88fd9d8c Fixed schedule/tracking require for www sync script (#13556)
* Fixed schedule/tracking require for www sync script

* Remove unused remapped FB modules from bundle as well

* Remove www module rename plugin

* Revert unnecessary change to strip-unused-imports plugin
2018-09-04 10:31:52 -07:00
Dan Abramov
2d5c590cc2 Change async fixtures to use schedule 2018-09-04 15:27:07 +01:00
laoxiong
955393cab9 refactor: remove emove type judgment when defining warning props (#13553) 2018-09-04 15:03:10 +01:00
Dan Abramov
ff93996028 Fix import of ReactDOM in server env 2018-09-04 15:00:03 +01:00
Dan Abramov
281bd64c00 Fix test file name 2018-09-04 14:27:35 +01:00
Dan Abramov
d6b59e3d26 Check document.documentMode once 2018-09-04 14:27:21 +01:00
Dan Abramov
52633c84e2 Try/finally 2018-09-04 14:27:14 +01:00
Michał Gołębiowski-Owczarek
2d4705e753 Make IE 11 not complain about non-crucial style attribute hydration mismatch (#13534)
IE 11 parses & normalizes the style attribute as opposed to other
browsers. It adds spaces and sorts the properties in some
non-alphabetical order. Handling that would require sorting CSS
properties in the client & server versions or applying
`expectedStyle` to a temporary DOM node to read its `style` attribute
normalized. Since it only affects IE, we're skipping style warnings
in that browser completely in favor of doing all that work.

Fixes #11807
2018-09-04 14:26:51 +01:00
Michał Gołębiowski-Owczarek
25d48a7281 Add gridArea to unitless CSS properties (#13550)
Ref #9185
2018-09-04 12:22:21 +01:00
Brian Vaughn
877f8bc6b2 Renamed schedule UMD forwarding methods to stay in-sync with SECRET_INTERNALS change (#13549) 2018-09-03 18:48:47 -07:00
Dan Abramov
0a96f90572 Revert "Extract common logic" (#13547)
* Revert "Fix test"

This reverts commit 17a57adde2.

* Revert "Extract common logic (#13535)"

This reverts commit 605da8b420.
2018-09-03 21:46:16 +01:00
Dan Abramov
17a57adde2 Fix test 2018-09-03 21:39:45 +01:00
Heaven
605da8b420 Extract common logic (#13535) 2018-09-03 20:57:13 +01:00
Philipp
69f9f4127a Document event bubble order (#13546)
This is documenting the current order in which events are dispatched
when interacting with native document listeners and other React apps.

For more context, check out #12919.
2018-09-03 21:39:20 +02:00
Dan Abramov
c1ba7b8cfd Remove www scheduler fork (#13545)
Remove unused www scheduler fork
2018-09-03 19:55:58 +01:00
Dan Abramov
b473d5f864 Secret exports: Scheduler => Schedule (#13544) 2018-09-03 19:51:30 +01:00
Dan Abramov
6312efc34f Tweak README and description 2018-09-03 19:34:04 +01:00
Brian Vaughn
b92f947af1 Rename "react-scheduler" package to "schedule" (#13543)
* Git moved packages/react-scheduler -> packages/schedule

* Global find+replace 'react-scheduler' -> 'schedule'

* Global find+replace 'ReactScheduler' -> 'Scheduler'

* Renamed remaining files "ReactScheduler" -> "Schedule"

* Add thank-you note to schedule package README

* Replaced schedule package versions 0.1.0-alpha-1 -> 0.2.0

* Patched our local fixtures to work around Yarn install issue

* Removed some fixture hacks
2018-09-03 19:27:50 +01:00
Dan Abramov
3c1dcd349a Expose less internals for TestUtils (#13539)
* Expose less internals for TestUtils

* Keep EventPluginHub for www

* Reorder to simplify
2018-09-03 17:21:00 +01:00
Fredrik Höglund
0b74e95d7b Ignore noscript content on the client (#13537)
* Ignore noscript content on the client (#11423)

* Fix failing test for ignoring noscript content

* Add a ServerIntegration test for noscript
2018-09-03 17:17:53 +01:00
Brian Vaughn
8a1e3962ab Remove negative lookbehind from Rollup plugin that broke Node <= v8.9 (#13538) 2018-09-02 17:59:29 -07:00
Dan Abramov
9604d26aec Rename ReactDOMFiber* to ReactDOM* (#13540) 2018-09-03 01:45:12 +01:00
Brian Vaughn
28b9289022 Tidied up scheduling UMD API forwarding test (#13533) 2018-09-01 13:05:21 -07:00
Brian Vaughn
bf8aa60925 Added Jest test to verify UMD API-forwarding for scheduling package (#13532)
* Added Jest test to verify UMD API-forwarding for scheduling package
* Added separate dev/prod UMD bundles for scheduler package
2018-09-01 12:52:26 -07:00
Heaven
0040efc8d8 Fix a typo (#13531) 2018-09-01 20:40:17 +01:00
Brian Vaughn
46950a3dfc Interaction tracking follow up (#13509)
* Merged interaction-tracking package into react-scheduler
* Add tracking API to FB+www builds
* Added Rollup plugin to strip no-side-effect imports from Rollup bundles
* Re-bundle tracking and scheduling APIs on SECRET_INTERNALS object for UMD build (and provide lazy forwarding methods)
* Added some additional tests and fixtures
* Fixed broken UMD fixture in master (#13512)
2018-09-01 12:00:00 -07:00
Dan Abramov
0452c9bba5 Add a regression test for #4618 2018-08-31 16:40:05 +01:00
Dan Abramov
c21bab6940 Add SSR regression test for #6119 2018-08-31 16:15:05 +01:00
Dan Abramov
0d3fc9de10 Add regression test for #6119 2018-08-31 16:09:29 +01:00
Dan Abramov
0f050ad7cc Make regression test better 2018-08-31 15:57:02 +01:00
Dan Abramov
f943423231 Add a more precise regression test for #6219 2018-08-31 15:54:39 +01:00
Dan Abramov
6ff062e048 Fetch all tags in DOM fixtures 2018-08-31 14:38:53 +01:00
Ivan
a3e4d00089 Fixed typo (#13519) 2018-08-30 16:33:47 -07:00
Dan Abramov
b3d8c5376f [RN] Remove isMounted() false positive warning (#13511) 2018-08-30 18:42:09 +01:00
Timothy Yung
d2123d6569 Sync React Native Flow Changes (#13513) 2018-08-29 13:54:58 -07:00
Dan
1c0ba70b4b Fix test to use AsyncMode
Addresses one of the issues brought up by @NE-SmallTown in https://github.com/facebook/react/pull/13488#issuecomment-416805935
2018-08-29 13:20:16 +01:00
Brian Vaughn
6e4f7c7886 Profiler integration with interaction-tracking package (#13253)
* Updated suspense fixture to use new interaction-tracking API

* Integrated Profiler API with interaction-tracking API (and added tests)

* Pass interaction Set (rather than Array) to Profiler onRender callback

* Removed some :any casts for enableInteractionTracking fields in FiberRoot type

* Refactored threadID calculation into a helper method

* Errors thrown by interaction tracking hooks use unhandledError to rethrow more safely.
Reverted try/finally change to ReactTestRendererScheduling

* Added a $FlowFixMe above the FiberRoot :any cast

* Reduce overhead from calling work-started hook

* Remove interaction-tracking wrap() references from unwind work in favor of managing suspense/interaction continuations in the scheduler
* Moved the logic for calling work-started hook from performWorkOnRoot() to renderRoot()

* Add interaction-tracking to bundle externals. Set feature flag to __PROFILE__

* Renamed the freezeInteractionCount flag and replaced one use-case with a method param

* let -> const

* Updated suspense fixture to handle recent API changes
2018-08-28 18:58:11 -07:00
Dan Abramov
2967ebdbea Remove buggy unstable_deferredUpdates() (#13488)
* Add a failing test for deferredUpdates not being respected

* Don't consider deferred updates interactive

* Remove now-unnecessary setTimeout hack in the fixture

* Remove unstable_deferredUpdates
2018-08-28 18:12:51 +01:00
Bryan M
1664b08f0c added flow types to setInnerHTML (#13495) 2018-08-28 07:37:29 -07:00
Veekas Shrivastava
672e859d31 Add warning to prevent setting this.state to this.props referentially (#11658)
* add test to warn if setting this.state to this.props referentially

* Avoid an extra check
2018-08-28 14:17:44 +01:00
Heaven
29287f0886 Rename lowestPendingInteractiveExpirationTime (#13484)
* Rename lowestPendingInteractiveExpirationTime

* fix prettier
2018-08-27 10:27:45 -07:00
ryota-murakami
bb48622a36 [SSR Fixture] Update yarn.lock (#13481)
* Update yarn.lock
2018-08-27 08:28:06 -07:00
Heaven
d400d6d5ef Replace magic number 1 with ELEMENT_NODE (#13479)
* Replace magic number 1 with ELEMENT_NODE

* Add flow pragma to HTMLNodeType
2018-08-27 08:16:24 -07:00
Sophie Alpert
340bfd9393 Rename ReactTypeOfWork to ReactWorkTags, ReactTypeOfSideEffect to ReactSideEffectTags (#13476)
* Rename ReactTypeOfWork to ReactWorkTags

And `type TypeOfWork` to `type WorkTag`.

* Rename ReactTypeOfSideEffect too
2018-08-26 13:40:27 -07:00
Rodrigo Bermúdez Schettino
53ddcec4f1 Correct syntax in CHANGELOG (#13474)
Non-breakable space was replaced with whitespace.
2018-08-25 19:08:20 +01:00
Dan Abramov
5cefd9b1e2 Stringify <option> children (#13465) 2018-08-23 00:24:05 +01:00
Philipp Spieß
3661616c28 Improve test harness of submit events (#13463)
This PR includes a test that I've enabled in #13358 and another test that we've discussed in #13462 as well as some random cleanup while I'm at it.
2018-08-22 22:46:37 +02:00
Dan Abramov
a1be17140d Revert "Rely on bubbling for submit and reset events (#13358)" (#13462)
This reverts commit 725e499cfb.
2018-08-22 19:33:42 +01:00
Dan Abramov
90c92c7007 Fix warning message 2018-08-21 18:44:34 +01:00
Dan Abramov
5cb0f2bf51 Change www error shim API (#13454) 2018-08-21 18:38:27 +01:00
Brian Vaughn
e106b8c44f Warn about unsafe toWarnDev() nesting in tests (#12457)
* Add lint run to warn about improperly nested toWarnDev matchers
* Updated tests to avoid invalid nesting
2018-08-21 07:43:02 -07:00
Brian Vaughn
026aa9c978 Bumped version to 16.4.3-alpha.0 (#13448)
* Bumped version to 16.4.3-alpha.0
* Bump react-is peer dep version in react-test-renderer
2018-08-20 14:28:43 -07:00
Matt Hamlin
3cae7543be Update scroll restoration logic in suspense fixture (#13437) 2018-08-20 14:01:12 -07:00
Brian Vaughn
d670bdc6b1 Warn about ReactDOM.createPortal usage within ReactTestRenderer (#12895) 2018-08-20 10:03:22 -07:00
Dan Abramov
bf1abf478b Fix React.lazy(forwardRef) (#13446)
* Fix React.lazy(forwardRef)

* Forbid bad typeof
2018-08-20 17:28:04 +01:00
Dan Abramov
e8571c798d Tweak ReactTypeOfWork order (#13444) 2018-08-20 16:51:09 +01:00
Dan Abramov
973496b40c Fix component name for React.lazy (#13443)
* Fix component name for React.lazy

* Fix lint
2018-08-20 16:43:25 +01:00
Dan Abramov
0beb2ee76b Fix incorrect legacy context for factory components (#13441)
* Add a repro case for context bug

* Be explicit about whether context has been pushed

* Put cheaper check first

* Naming
2018-08-20 16:08:46 +01:00
Joseph
004cb21bbb Short circuit the logic for exporting a module (#13392)
* short circuit some logic

* revert back to ternary operator
2018-08-20 12:29:40 +01:00
Brandon Dail
f7a538c913 Remove getTextContentAccessor (#13434)
According to caniuse the only browsers that don't support textContent
are <=IE8, which we no longer support.
2018-08-20 12:28:41 +01:00
Brandon Dail
d1c42d2f1e Remove addEventListener check in isEventSupported (#13435)
* Remove addEventListener check in isEventSupported

All browsers we support also support addEventListener, so this check is
unncessary

* Remove capture argument from isEventSupported
2018-08-20 12:26:06 +01:00
Brandon Dail
a869f992a8 Remove helper object from FallbackCompositionState (#13430)
There's no good reason for this to be an object. This refactors it so
that we just use three variables instead. We can avoid the property reads/writes and also minify better, since property names don't get mangled but variables do.
2018-08-18 08:07:12 -06:00
Nathan Hunzaker
0cd8d470da Do not toLowerCase lists of lowercase words (#13428)
* Do not toLowerCase lists of lowercase words

* Add notes about downcasing to DOMProperty.js

* Use consistent comment breakout

* Make toLowerCase more obvious
2018-08-17 19:52:30 -07:00
Brandon Dail
b3a4cfea57 Trap click events for portal root (#11927)
* Trap click events for portal root

* Trap click event on container in appendChildToContainer

* Add a comment
2018-08-18 02:10:20 +01:00
Brian Vaughn
0da5102cf0 Add interaction-tracking/subscriptions (#13426)
* Removed enableInteractionTrackingObserver as a separate flag; only enableInteractionTracking is used now

* Added interaction-tracking/subscriptions bundle and split tests

* Added multi-subscriber support

* Moved subscriptions behind feature flag

* Fixed bug with wrap() parameters and added test

* Replaced wrap arrow function
2018-08-17 14:45:18 -06:00
Dan Abramov
4b32f525e1 Refactor away some namespace imports (#13427)
* Replace some namespace imports

* Simplify the controlled component injection

* Simplify the batching injection

* Simplify the component tree injection
2018-08-17 21:17:37 +01:00
Dan Abramov
d2f5c3fbc2 Don't diff memoized host components in completion phase (#13423)
* Add a regression test for 12643#issuecomment-413727104

* Don't diff memoized host components

* Add regression tests for noop renderer

* No early return

* Strengthen the test for host siblings

* Flow types
2018-08-17 18:13:46 +01:00
Brian Vaughn
5e0f073d50 interaction-tracking package (#13234)
Add new interaction-tracking package/bundle
2018-08-17 10:16:05 -06:00
Dan Abramov
d14e443d6e Resume onSelect tracking after dragend (#13422) 2018-08-17 00:22:16 +01:00
Nathan Hunzaker
146c9fb307 Update attribute table for master (#13421) 2018-08-16 13:40:11 -07:00
Esteban
d5edc1f51e Remove unused ReactCall & ReactReturn types (#13419)
These are no longer used after the removal of the `react-call-return` package.
2018-08-16 18:48:13 +01:00
Sebastian Markbåge
4fa20b53b7 Don't pass instanceHandle to clones (#13125)
We will instead just reuse the first one.
2018-08-16 09:54:12 -07:00
Andrew Clark
fe959eea73 React.lazy (#13398)
Lazily starts loading a component the first time it's rendered. The
implementation is fairly simple and could be left to userspace, but since
this is an important use case, there's value in standardization.
2018-08-16 09:43:32 -07:00
Andrew Clark
2b30828000 Fix wrong Flow return type 2018-08-16 09:29:17 -07:00
Andrew Clark
5031ebf6be Accept promise as element type (#13397)
* Accept promise as element type

On the initial render, the element will suspend as if a promise were
thrown from inside the body of the unresolved component. Siblings should
continue rendering and if the parent is a Placeholder, the promise
should be captured by that Placeholder.

When the promise resolves, rendering resumes. If the resolved value
has a `default` property, it is assumed to be the default export of
an ES module, and we use that as the component type. If it does not have
a `default` property, we use the resolved value itself.

The resolved value is stored as an expando on the promise/thenable.

* Use special types of work for lazy components

Because reconciliation is a hot path, this adds ClassComponentLazy,
FunctionalComponentLazy, and ForwardRefLazy as special types of work.
The other types are not supported, but wouldn't be placed into a
separate module regardless.

* Resolve defaultProps for lazy types

* Remove some calls to isContextProvider

isContextProvider checks the fiber tag, but it's typically called after
we've already refined the type of work. We should get rid of it. I
removed some of them in the previous commit, and deleted a few more
in this one. I left a few behind because the remaining ones would
require additional refactoring that feels outside the scope of this PR.

* Remove getLazyComponentTypeIfResolved

* Return baseProps instead of null

The caller compares the result to baseProps to see if anything changed.

* Avoid redundant checks by inlining getFiberTagFromObjectType

* Move tag resolution to ReactFiber module

* Pass next props to update* functions

We should do this with all types of work in the future.

* Refine component type before pushing/popping context

Removes unnecessary checks.

* Replace all occurrences of _reactResult with helper

* Move shared thenable logic to `shared` package

* Check type of wrapper object before resolving to `default` export

* Return resolved tag instead of reassigning
2018-08-16 09:21:59 -07:00
Rauno Freiberg
77b7a660b9 fix: do not reconcile children that are iterable functions (#13416)
* fix: do not reconcile children that are iterable functions

* fix: remove fit

* Refactor comparison to exclude anything that isnt an object

* Remove redundant undefined check
2018-08-16 16:38:10 +01:00
Kartik Lad
cb7745c6cf remove unused state initialValue from ReactDOMFiberSelect (#13412) 2018-08-16 07:55:57 -07:00
Ellis Clayton
9832a1b6d5 Avoid setting empty value on reset & submit inputs (#12780)
* Avoid setting empty value on reset & submit inputs

* Update ReactDOMFiberInput.js

* More test coverage
2018-08-16 15:19:03 +01:00
Aaron Brager
8862172fa3 Provide a better error message (#12421) 2018-08-16 14:54:45 +01:00
Ruud Burger
5816829170 De-duplicate commitUpdateQueue effect commit (#13403) 2018-08-15 11:21:08 -07:00
Andrew Clark
1bc975d073 Don't stop context traversal at matching consumers (#13391)
* Don't stop context traversal at matching consumers

Originally, the idea was to time slice the traversal. This worked when
there was only a single context type per consumer.

Now that each fiber may have a list of context dependencies, including
duplicate entries, that optimization no longer makes sense – we could
end up scanning the same subtree multiple times.

* Remove changedBits from context object and stack

Don't need it anymore, yay
2018-08-15 11:19:53 -07:00
Dan Abramov
83e446e1d8 Refactor ReactErrorUtils (#13406)
* Refactor ReactErrorUtils

* Remove unnecessary assignments
2018-08-15 19:02:11 +01:00
Dan Abramov
13fa96a547 Improve bad ref invariant (#13408) 2018-08-15 18:30:17 +01:00
Dan Abramov
b2adcfba32 Don't suppress jsdom error reporting in our tests (#13401)
* Don't suppress jsdom error reporting

* Address review
2018-08-15 17:44:46 +01:00
Conrad Irwin
69e2a0d732 Ability to access window.event in development (#11687) (#11696)
Before this change in development window.event was overridden
in invokeGuardedCallback.

After this change window.event is preserved in the browsers that
support it.
2018-08-14 21:35:31 +01:00
davidblnc
ade4dd3f6f Fix typo in a comment (#13373)
* Typo

* Changed to use rest parameter

* 'Bugfix'

* Typo fix
2018-08-14 20:58:35 +01:00
Moti Zilberman
2c59076d26 Warn when "false" or "true" is the value of a boolean DOM prop (#13372)
* Warn when the string "false" is the value of a boolean DOM prop

* Only warn on exact case match for "false" in DOM boolean props

* Warn on string "true" as well as "false" in DOM boolean props

* Clarify warnings on "true" / "false" values in DOM boolean props
2018-08-14 20:51:33 +01:00
Esteban
24b0ed7a2e Remove 'flow-coverage-report' script. (#13395)
`flow-coverage-report` stopped working after Flow was set to run for each renderer separately (#12846). As discussed in #13393, this is hard to fix without adding complexity to `.flowconfig`'s generation.
2018-08-14 19:21:57 +01:00
Rauno Freiberg
de5102c4cd Ignore symbols and functions in select tag (#13389)
* wip: ignore symbols and functions in select tag

* fix: Use ToStringValue as a maybe type

* refactor: remove unnecessary test

* refactor: remove implicit return from tests
2018-08-14 10:31:41 -07:00
Nathan Hunzaker
e3d5b5ea7f DOM fixture updates (#13368)
* Add home component. Async load fixtures.

This commit adds a homepage to the DOM fixtures that includes browser
testing information and asynchronously loads fixtures.

This should make it easier to find DOM testing information and keep
the payload size in check as we add more components to the fixtures.

* Update browser support fields

* Tweak select width

* Fix typo

* Report actual error when fixture fails to load

* Update browser information

* Update browserstack subscription info

* English

* Switch let for const in fixture loader
2018-08-14 07:32:52 -07:00
Rauno Freiberg
d04d03e470 Fix passing symbols and functions to textarea (#13362)
* refactor: move getSafeValue to separate file

* fix(?): ReactDOMFiberTextarea sanitization for symbols and functions

* tests: add TODOs for warnings

* fix: restore accidentally removed test

* fix: remove redundant logic for initialValue

* refactor: integrate SafeValue typings into textarea

* fix: restore stringified newValue for equality check

* fix: remove getSafeValue from hostProps

* refactor: SafeValue -> ToStringValue

* refactor: update TODO comment in test file

* refactor: no need to convert children to ToStringValue
2018-08-14 07:16:48 -07:00
Nathan Hunzaker
5550ed4a8f Ensure arguments are coerced to strings in warnings (#13385)
* Manually join extra attributes in warning

This prevents a bug where Chrome reports `Array(n)` where `n` is the
size of the array.

* Prettier

* Stringify all %s replaced symbols in warning

* Eliminate extra string coercion

* Pass args through with spread, convert all arguments to strings

* Rename strings to stringArgs
2018-08-13 16:13:51 -07:00
Dan Abramov
3938ccc88a Allow the user to opt out of seeing "The above error..." addendum (#13384)
* Remove e.suppressReactErrorLogging check before last resort throw

It's unnecessary here. It was here because this method called console.error().
But we now rethrow with a clean stack, and that's worth doing regardless of whether the logging is silenced.

* Don't print error addendum if 'error' event got preventDefault()

* Add fixtures

* Use an expando property instead of a WeakSet

* Make it a bit less fragile

* Clarify comments
2018-08-13 21:33:55 +01:00
Rauno Freiberg
47e217a77d Provide component reference in ReactDOMFiberTextarea warnings (#13361)
* Provide component reference if possible in ReactDOMFiberTextarea.js warning

* Nits
2018-08-13 15:55:56 +01:00
Rauno Freiberg
714c78d5a1 Fixtures nits (#13375)
* fix: PropTypes failing in textarea fixtures

* fix: Iframe title attribute in fixtures

* Make description a optional prop in FixtureSet
2018-08-13 07:08:44 -07:00
Philipp Spieß
a0190f828f Rename SafeValue to ToStringValue (#13376)
Following up on the changes I made in #13367, @gaearon suggest that
"safe" could be read as necessary for security. To avoid misleading a
reader, I'm changing the name.

A few names where discussed in the previous PR. I think `ToStringValue`
makes sense since the value itself is not a string yet but an opaque
type that can be cast to a string. For the actual string concatenation,
I've used `toString` now to avoid confusion: `toStringValueToString`
is super weird and it's namespaced anyhow.

Definitely open for suggestions here. :) I'll wait until we wrap up
#13362 and take care of rebase afterwards.
2018-08-13 14:58:59 +01:00
Ryan Florence
d1e589137f Fix fixture title (#13377)
about time I made a significant commit to the react project directly
2018-08-12 17:12:31 -07:00
Philipp Spieß
33602d435a Improve soundness of ReactDOMFiberInput typings (#13367)
* Improve soundness of ReactDOMFiberInput typings

This is an attempt in improving the soundness for the safe value cast
that was added in #11741. We want this to avoid situations like [this
one](https://github.com/facebook/react/pull/13362#discussion_r209380079)
where we need to remember why we have certain type casts. Additionally
we can be sure that we only cast safe values to string.

The problem was `getSafeValue()`. It used the (deprecated) `*` type to
infer the type which resulted in a passing-through of the implicit `any`
of the props `Object`. So `getSafeValue()` was effectively returning
`any`.

Once I fixed this, I found out that Flow does not allow concatenating
all possible types to a string (e.g `"" + false` fails in Flow). To
fix this as well, I've opted into making the SafeValue type opaque and
added a function that can be used to get the string value. This is sound
because we know that SafeValue is already checked.

I've verified that the interim function is inlined by the compiler and
also looked at a diff of the compiled react-dom bundles to see if I've
regressed anything. Seems like we're good.

* Fix typo
2018-08-12 17:14:05 +02:00
Moti Zilberman
ae855cec22 Support tangentialPressure and twist fields of pointer events (#13374)
While working on https://github.com/facebook/flow/pull/6728 I noticed React's recently-added `SyntheticPointerEvent` was missing the [`tangentialPressure`](https://www.w3.org/TR/pointerevents/#dom-pointerevent-tangentialpressure) and [`twist`](https://www.w3.org/TR/pointerevents/#dom-pointerevent-twist) fields. I couldn't find any reason for their omission in https://github.com/facebook/react/pull/12507 (nor in the spec) so I assume they were meant to be included, like the rest of `PointerEvent`. This PR adds these two fields to `SyntheticPointerEvent`.
2018-08-12 15:16:23 +02:00
Philipp Spieß
725e499cfb Rely on bubbling for submit and reset events (#13358)
* Bring back onSubmit bubble test

I found a test that was written more than 5 years ago and probably never
run until now. The behavior still works, although the API changed quite
a bit over the years.

Seems like this was part of the initial public release already:

75897c2dcd (diff-1bf5126edab96f3b7fea034cd3b0c742R31)

* Rely on bubbling for submit and reset events

* Update dom fixture lockfile

* Revet rollup results

Whoopsie.
2018-08-10 21:10:35 +02:00
Alex Rohleder
e07a3cd28f fix typo on inline comment (#13364) 2018-08-10 16:51:06 +01:00
Kazuhiro Sera
e0204084a0 Fix typos detected by github.com/client9/misspell (#13349) 2018-08-10 14:06:08 +01:00
Dan Abramov
be4533af7d Fix hydration of non-string dangerousSetInnerHTML.__html (#13353)
* Consistently handle non-string dangerousSetInnerHTML.__html in SSR

* Add another test
2018-08-09 18:05:05 +01:00
Dan Abramov
0072b59984 Improve scry() error message for bad first argument (#13351) 2018-08-09 15:05:44 +01:00
Dan
d59b993a74 Make nicer stacks DEV-only
No need to spend production bytes on this.
2018-08-09 03:44:56 +01:00
Billy Janitsch
54d86eb822 Improve display of filenames in component stack (#12059)
* Improve display of filenames in component stack

* Add explanatory comment

* tests: add tests for component stack trace displaying

* Tweak test

* Rewrite test and revert implementation

* Extract a variable

* Rewrite implementation
2018-08-09 03:33:30 +01:00
Brian Vaughn
067cc24f55 Profiler actualDuration bugfix (#13313)
* Simplified profiler actualDuration timing

While testing the new DevTools profiler, I noticed that sometimes– in larger, more complicated applications– the actualDuration value was incorrect (either too large, or sometimes negative). I was not able to reproduce this in a smaller application or test (which sucks) but I assume it has something to do with the way I was tracking render times across priorities/roots. So this PR replaces the previous approach with a simpler one.

* Changed bubbling logic after chatting out of band with Andrew

* Replaced __PROFILE__ with feature-flag conditionals in test

* Updated test comment
2018-08-08 09:42:53 -07:00
Bartosz Kaszubowski
1209ae50f3 Bump "fbjs-scripts" to remove Babel 5 from dependencies (#13344) 2018-08-08 11:43:35 +01:00
Dan Abramov
3cfab14b96 Treat focusable as enumerated boolean SVG attribute (#13339)
* Treat focusable as enumerated boolean attribute

* Update attribute table
2018-08-07 19:39:56 +01:00
Dan Abramov
a66217b571 Update attribute table (#13343)
* Update table for React 16.3

* Update table for master

* Re-run the table with recent Chrome
2018-08-07 19:35:28 +01:00
Esteban
212437eaf0 Remove unused dependencies from workspace root. (#13340)
Remove 'async', 'bundle-collapser', 'del', 'derequire', 'escape-string-regexp', 'git-branch', 'gzip-js',
'merge-stream', 'platform', 'run-sequence' & 'yargs'.

Most of them were used in the old Grunt build system.

This ends up removing 32 packages, according to yarn.lock.
2018-08-07 11:38:25 +01:00
Dan Abramov
3b3b7fcbbd Don't search beyond Sync roots for highest priority work (#13335) 2018-08-07 01:59:18 +01:00
nico
43a137d9c1 Fix undefined variable on suspense fixture (#13325) 2018-08-05 15:28:08 +01:00
Bartosz Kaszubowski
08e32263f9 Fix Prettier "No parser" warning while building (#13323) 2018-08-05 02:50:58 +01:00
Clark Du
f8456b2ecb refactor: remove promise on checkModule (#13318)
* refactor: remove promise on checkModule
* refactor: use forEach instead of map for checkModule
2018-08-03 13:25:31 -07:00
Alexey Raspopov
61122347dd Suspense/UserPage: id -> name (#13320)
* Suspense/UserPage: id -> name

* Suspense/UserPage: review -> repo
2018-08-03 12:59:34 -07:00
Alexey Raspopov
c0bf34c9c4 Suspense/Spinner: class -> className (#13319) 2018-08-03 12:17:36 -07:00
Jason Quense
ac72388563 Add support for auxclick event (#11571)
* Add support for auxclick event

* Add to simpleEventPLugin

* Add auxclick as interactive event type in SimpleEventPlugin

* Update ReactTestUtils fixture to include auxClick
2018-08-03 11:57:34 -07:00
Gareth Small
75491a8f4b Add a regression test for #12200 (#12242)
* fix selectedIndex in postMountWrapper in ReactDOMFiberSelected

* comment in ReactDomFiberSelect in postMountWrapper for selectedIndex fix

* test for selectedIndex fix

* set boolean value for multiple

* Revert the fix which has been fixed on master
2018-08-03 18:10:18 +01:00
Dmytro Zasyadko
2d0356a524 Make sure that select has multiple attribute set to appropriate state before appending options (#13270)
* Make sure that `select` has `multiple` attribute set to appropriate state before appending options
fixes #13222

* Add dom test fixture to test long multiple select scrolling to the first selected option
fixes #13222

* typo fix

* update comment
remove redundant conversion to bool type

* change a way of assigning property to domElement

* Remove unused ref on select fixture form
2018-08-03 18:05:25 +01:00
Felix Wu
b179bae0ae Enhance get derived state from props state warning - #12670 (#13317)
* Enhance warning message for missing state with getDerivedStateFromProps

* Adapt tests

* style fix

* Tweak da message

* Fix test
2018-08-03 16:09:57 +01:00
Dan
fa824d0921 Fix lint 2018-08-03 13:31:20 +01:00
Alex Jegtnes
f265d545a1 Suspense fixture placeholder styling improvement (#13314)
Vertically and horizontally center 'large' placeholder spinner in suspense demo
as per @gaearon's tweet:
https://twitter.com/dan_abramov/status/1025190261784289280
2018-08-03 13:08:45 +01:00
Alexey
15a8f03183 Fix ambiguity in doc comment for isValidElement (#12826)
`isValidElement(object)` checks if object is a ReactElement.

`@return {boolean} True if `object` is a valid component.` leading to confusion which was described in several blog posts:
- https://reactjs.org/blog/2015/12/18/react-components-elements-and-instances.html
- https://medium.com/@fay_jai/react-elements-vs-react-components-vs-component-backing-instances-14d42729f62
2018-08-02 21:32:41 -07:00
ryota-murakami
5cff212072 add flowtype to function signature (#13285) 2018-08-02 21:23:07 -07:00
Dan Abramov
261da3f0a9 Update fixture instructions 2018-08-03 01:56:03 +01:00
Andrew Patton
b565f49531 Minimally support iframes (nested browsing contexts) in selection event handling (#12037)
* Prefer node’s window and document over globals

* Support active elements in nested browsing contexts

* Avoid invoking defaultView getter unnecessarily

* Prefer node’s window and document over globals

* Support active elements in nested browsing contexts

* Avoid invoking defaultView getter unnecessarily

* Implement selection event fixtures

* Prefer node’s window and document over globals

* Avoid invoking defaultView getter unnecessarily

* Fix react-scripts to work with alphas after 16.0.0

The current logic just checks if the version is an alpha with a major version of 16 to account for weirdness with the 16 RC releases, but now we have alphas for newer minor releases that don't have weirdness

* Run prettier on new selection events fixtures

* Add fixture for onSelect in iframes, remove DraftJS fixture

The DraftJs fixture wasn't really working in all supported browsers anyways, so just drop it and try to cover our bases without using it directly

* Purge remnants of draft.js from fixtures

* Use prop-types import instead of window global

* Make fixtures’ Iframe component Firefox-compatible

* Fix switch case for SelectionEventsFixture

* Remove draft.js / immutable.js dependencies

* Cache owner doc as var to avoid reading it twice

* Add documentation for getActiveElementDeep to explain try/catch

Add documentation for getActiveElementDeep to explain try/catch

* Ensure getActiveElement always returns DOM element

* Tighten up isNode and isTextNode

* Remove ie8 compatibility

* Specify cross-origin example in getActiveElementDeep

* Revert back to returning null if document is not defined
2018-08-02 23:23:07 +01:00
Dan Abramov
1609cf3432 Warn about rendering Generators (#13312)
* Warn about rendering Generators

* Fix Flow

* Add an explicit test for iterable

* Moar test coverage
2018-08-02 20:04:03 +01:00
Dan Abramov
46d5afc54d Replace console.error() with a throw in setTimeout() as last resort exception logging (#13310)
* Add a regression test for #13188

* Replace console.error() with a throw in setTimeout() as last resort

* Fix lint and comment

* Fix tests to check we throw after all

* Fix build tests
2018-08-02 18:16:47 +01:00
Yunchan Cho
b3b80a4835 Inject react-art renderer into react-devtools (#13173)
* Inject react-art renderer into react-devtools

This commit makes react-art renderer to be injected to react-devtools,
so that component tree of the renderer is presented on debug panel of browser.

* Update ReactART.js
2018-08-02 12:04:31 +01:00
Dan Abramov
5e8beec84b Add a regression test for #11602 2018-08-02 02:46:08 +01:00
Dan Abramov
470377bbdb Remove extraneous condition
It's covered by a check below.
2018-08-02 02:33:54 +01:00
Dan Abramov
ad17ca639b Fix Prettier 2018-08-02 02:29:15 +01:00
Ideveloper
6db080154b Remove irrelevant suggestion of a legacy method from a warning (#13169)
* Edit warn message what use deprecated lifecycle method

* delete setState warn message about prescriptive and deprecated life cycle

* fix lint

* Prettier

* Formatting
2018-08-02 02:11:17 +01:00
Dan Abramov
fddb23601f Tweak other fixture instructions 2018-08-02 01:36:44 +01:00
Dan Abramov
95738e5cfd Tweak fixture instructions 2018-08-02 01:34:08 +01:00
Jiawen Geng
d79238f1ee add nodejs 10 to windows test (#13241)
* add nodejs 10 to windows test

* remove node 8 for better build speed
2018-08-02 01:09:37 +01:00
Dan Abramov
ae63110335 Fix time slicing fixture (#13305)
* Fix time slicing fixture

* Remove unused option
2018-08-02 00:02:24 +01:00
Dan Abramov
e341e503b2 Move async fixtures (#13304) 2018-08-01 22:21:26 +01:00
Brian Vaughn
00cd4444e2 [WIP] Add suspense fixtures for IO and CPU demo (#13295)
Add suspense fixtures for IO and CPU demo
2018-08-01 14:10:28 -07:00
Dan Abramov
41f6d8cc7a Fix incorrect changelog entry for 16.3.3 2018-08-01 21:12:51 +01:00
Dan Abramov
0624c719f4 Add 16.4.2 and other releases to changelog 2018-08-01 20:29:05 +01:00
Dan Abramov
f60a7f722c Fix SSR crash on a hasOwnProperty attribute (#13303) 2018-08-01 20:23:19 +01:00
Dan Abramov
ff41519ec2 Sanitize unknown attribute names for SSR (#13302) 2018-08-01 20:23:10 +01:00
Dylan Cutler
c44c2a2161 More helpful message when passing an element to createElement() (#13131)
* [#13130] Add a more helpful message when passing an element to createElement()

* better conditional flow

* update after review

* move last condition inside last else clause

* Added test case

* compare 25132typeof to REACT_ELEMENT_TYPE

* runs prettier

* remove unrelated changes

* Tweak the message
2018-08-01 18:45:08 +01:00
Dan Abramov
28cd494bdf Refactor validateDOMNesting a bit (#13300) 2018-08-01 17:08:03 +01:00
Philipp Spieß
b381f41411 Allow Electrons <webview> tag (#13301)
Fixes #13299

Adds Electrons <webview> tag to the attribute whitelist.
2018-08-01 17:07:52 +01:00
Konstantin Yakushin
0182a74632 Fix a crash when using dynamic children in <option> tag (#13261)
* Make option children a text content by default

fix #11911

* Apply requested changes

- Remove meaningless comments
- revert scripts/rollup/results.json

* remove empty row

* Update comment

* Add a simple unit-test

* [WIP: no flow] Pass through hostContext

* [WIP: no flow] Give better description for test

* Fixes

* Don't pass hostContext through

It ended up being more complicated than I thought.

* Also warn on hydration
2018-08-01 16:16:34 +01:00
Andrew Clark
2a2ef7e0fd Remove unnecessary branching from updateContextProvider (#13282)
This code had gotten unnecessarily complex after some recent changes.
Cleaned it up a bit.
2018-07-27 13:42:17 -07:00
Dan Abramov
840cb1a268 Add an invariant to createRoot() to validate containers (#13279) 2018-07-27 16:50:20 +02:00
Andrew Clark
bc1ea9cd96 Handle errors thrown in gDSFP of a module-style context provider (#13269)
Context should be pushed before calling any user code, so if it errors
the stack unwinds correctly.
2018-07-25 14:22:27 -07:00
Flarnie Marchan
0154a79fed Remove 'warning' module from the JS scheduler (#13264)
* Remove 'warning' module from the JS scheduler

**what is the change?:**
See title

**why make this change?:**
Internally the 'warning' module has some dependencies which we want to
avoid pulling in during the very early stages of initial pageload. It is
creating a cyclical dependency.

And we wanted to remove this dependency anyway, because this module
should be kept small and decoupled.

**test plan:**
- Tested the exact same change internally in Facebook.com
- Ran unit tests
- Tried out the fixture

**issue:**
Internal task T31831021

* check for console existence before calling console.error

* Move DEV check into separate block
2018-07-25 08:58:18 -07:00
Brian Vaughn
dbd16c8a96 Add @flow directive to findDOMNode shim (#13265)
* Add @flow directive to findDOMNode shim
2018-07-24 14:53:54 -07:00
Andrew Clark
ca0941fce3 Add regression test for Placeholder fallbacks with lifecycle methods (#13254)
Found by @rhagigi

Co-authored-by: Royi Hagigi <rhagigi@gmail.com>
Co-authored-by: Andrew Clark <acdlite@me.com>
2018-07-23 17:47:40 -07:00
Sebastian Markbåge
a32c727f2e Optimize readContext for Subsequent Reads of All Bits (#13248)
This is likely the common case because individual component authors
will casually call read on common contexts like the cache, or cache
provider.

Where as libraries like Relay only call read once per fragment and pass
all observed bits at once.
2018-07-21 20:13:46 -07:00
Andrew Clark
2b509e2c8c [Experimental] API for reading context from within any render phase function (#13139)
* Store list of contexts on the fiber

Currently, context can only be read by a special type of component,
ContextConsumer. We want to add support to all fibers, including
classes and functional components.

Each fiber may read from one or more contexts. To enable quick, mono-
morphic access of this list, we'll store them on a fiber property.

* Context.unstable_read

unstable_read can be called anywhere within the render phase. That
includes the render method, getDerivedStateFromProps, constructors,
functional components, and context consumer render props.

If it's called outside the render phase, an error is thrown.

* Remove vestigial context cursor

Wasn't being used.

* Split fiber.expirationTime into two separate fields

Currently, the `expirationTime` field represents the pending work of
both the fiber itself — including new props, state, and context — and of
any updates in that fiber's subtree.

This commit adds a second field called `childExpirationTime`. Now
`expirationTime` only represents the pending work of the fiber itself.
The subtree's pending work is represented by `childExpirationTime`.

The biggest advantage is it requires fewer checks to bailout on already
finished work. For most types of work, if the `expirationTime` does not
match the render expiration time, we can bailout immediately without
any further checks. This won't work for fibers that have
`shouldComponentUpdate` semantics (class components), for which we still
need to check for props and state changes explicitly.

* Performance nits

Optimize `readContext` for most common case
2018-07-20 16:49:06 -07:00
Dan Abramov
5776fa3fcf Update www warning shim (#13244) 2018-07-20 16:50:43 +01:00
Dan Abramov
3d3506d37d Include Modes in the component stack (#13240)
* Add a test that StrictMode shows up in the component stack

The SSR test passes. The client one doesn't.

* Include Modes in component stack

* Update other tests to include modes
2018-07-19 22:11:59 +01:00
Andrew Clark
71b4e99901 [react-test-renderer] Jest matchers for async tests (#13236)
Adds custom Jest matchers that help with writing async tests:

- `toFlushThrough`
- `toFlushAll`
- `toFlushAndThrow`
- `toClearYields`

Each one accepts an array of expected yielded values, to prevent
false negatives.

Eventually I imagine we'll want to publish this on npm.
2018-07-19 10:26:24 -07:00
Dan Abramov
8121212f0d Fix warning extraction script 2018-07-19 13:04:56 +01:00
Dan Abramov
2a1bc3f74c Format messages in unexpected console.error() test failure 2018-07-19 12:15:01 +01:00
Dan Abramov
2c560cb995 Fix unwinding starting with a wrong Fiber on error in the complete phase (#13237)
* Add a repro case for profiler unwinding

This currently fails the tests due to an unexpected warning.

* Add a regression test for context stack

* Simplify the first test case

* Update nextUnitOfWork inside completeUnitOfWork()

The bug was caused by a structure like this:

    </Provider>
  </div>
</errorInCompletePhase>

We forgot to update nextUnitOfWork so it was still pointing at Provider when errorInCompletePhase threw. As a result, we would try to unwind from Provider (rather than from errorInCompletePhase), and thus pop the Provider twice.
2018-07-19 02:16:10 +01:00
Dan Abramov
ead08827d0 Add more flexibility in testing errors in begin/complete phases (#13235)
* Add more flexibility in testing errors in begin/complete phases

* Update too
2018-07-19 00:23:10 +01:00
Andrew Clark
e4e58343e4 Move unstable_yield to main export (#13232)
The `yield` method isn't tied to any specific root. Putting this
on the main export enables test components that are not within scope
to yield even if they don't have access to the currently rendering
root instance. This follows the pattern established by ReactNoop.

Added a `clearYields` method, too, for reading values that were yielded
out of band. This is also based on ReactNoop.
2018-07-18 16:10:56 -07:00
Mateusz Burzyński
0e235bb8f7 Removed unused state argument in unsubscribe method of <Subscription /> (#13233) 2018-07-18 13:52:59 -07:00
Dan Abramov
236f608723 Fail tests if toWarnDev() does not wrap warnings in array (#13227)
* Fail tests if toWarn() does not wrap warnings in array

* Fix newly failing tests

* Another fix
2018-07-18 02:38:39 +01:00
Dan Abramov
acbb4f93f0 Remove the use of proxies for synthetic events in DEV (#13225)
* Revert #5947 and disable the test

* Fix isDefaultPrevented and isPropagationStopped to not get nulled

This was a bug introduced by #5947. It's very confusing that they become nulled while stopPropagation/preventDefault don't.

* Add a comment

* Run Prettier

* Fix grammar
2018-07-18 00:14:13 +01:00
Nicole Levy
171e0b7d44 Fix “no onChange handler” warning to fire on falsy values ("", 0, false) too (#12628)
* throw warning for falsey `value` prop

* add nop onChange handler to tests for `value` prop

* prettier

* check for falsey checked

* fix tests for `checked` prop

* new tests for `value` prop

* test formatting

* forgot 0 (:

* test for falsey `checked` prop

* add null check

* Update ReactDOMInput-test.js

* revert unneeded change

* prettier

* Update DOMPropertyOperations-test.js

* Update ReactDOMInput-test.js

* Update ReactDOMSelect-test.js

* Fixes and tests

* Remove unnecessary changes
2018-07-17 22:46:43 +01:00
Fumiya Shibusawa
606c30aa5f fixed a typo in commentout in ReactFiberUnwindWork.js (#13172) 2018-07-17 20:21:53 +01:00
Johan Henriksson
9f78913b20 Update prettier (#13205)
* Update Prettier to 1.13.7

* Apply Prettier changes

* Pin prettier version

* EOL
2018-07-17 20:18:34 +01:00
jddxf
6d3e262880 Remove unnecessary typeof checks (#13196)
This aligns with #10351 which removed extra check on `injectInternals`.
2018-07-17 20:18:15 +01:00
Dan Abramov
82c7ca4cca Add component stacks to some warnings (#13218) 2018-07-17 20:15:03 +01:00
Thibault Malbranche
21ac62c77a Fix a portal unmounting crash for renderers with distinct Instance and Container (#13220)
* Fix Portal unmount

Before that change, currentParent is not set as a container even if it should so it break on react-native and probably other custom renderers

* Assert that *ToContainer() methods receive containers

* Add regression tests

* Add comments
2018-07-17 01:35:33 +01:00
Dan Abramov
d6a0626b38 Set current fiber during before-mutation traversal (#13219) 2018-07-17 01:11:56 +01:00
Dan Abramov
fd410f43fc Protect against passing component stack twice
This is a leftover from #13161 that I forgot to include.
It ensures we don't accidentally write code in the old way and end up passing the stack twice.
2018-07-16 22:47:41 +01:00
Dan Abramov
f9358c51c8 Change warning() to automatically inject the stack, and add warningWithoutStack() as opt-out (#13161)
* Use %s in the console calls

* Add shared/warningWithStack

* Convert some warning callsites to warningWithStack

* Use warningInStack in shared utilities and remove unnecessary checks

* Replace more warning() calls with warningWithStack()

* Fixes after rebase + use warningWithStack in react

* Make warning have stack by default; warningWithoutStack opts out

* Forbid builds that may not use internals

* Revert newly added stacks

I changed my mind and want to keep this PR without functional changes. So we won't "fix" any warnings that are already missing stacks. We'll do it in follow-ups instead.

* Fix silly find/replace mistake

* Reorder imports

* Add protection against warning argument count mismatches

* Address review
2018-07-16 22:31:59 +01:00
Dan Abramov
854c953905 Fix matcher tests to be DEV-only 2018-07-16 20:35:43 +01:00
Dan Abramov
467d139101 Enforce presence or absence of component stack in tests (#13215)
* Enforce presence or absence of stack in tests

* Rename expectNoStack to withoutStack

* Fix lint

* Add some tests for toWarnDev()
2018-07-16 20:20:18 +01:00
Andrew Clark
43ffae2d17 Suspending inside a constructor outside of strict mode (#13200)
* Suspending inside a constructor outside of strict mode

Outside of strict mode, suspended components commit in an incomplete
state, then are synchronously deleted in a subsequent commit. If a
component suspends inside the constructor, it mounts without
an instance.

This breaks at least one invariant: during deletion, we assume that
every mounted component has an instance, and check the instance for
the existence of `componentWillUnmount`.

Rather than add a redundant check to the deletion of every class
component, components that suspend inside their constructor and outside
of strict mode are turned into empty functional components before they
are mounted. This is a bit weird, but it's an edge case, and the empty
component will be synchronously unmounted regardless.

* Do not fire lifecycles of a suspended component

In non-strict mode, suspended components commit, but their lifecycles
should not fire.
2018-07-13 11:24:03 -07:00
Dan Abramov
659a29cecf Reorganize how shared internals are accessed (#13201)
* Reorganize how shared internals are accessed

* Update forks.js
2018-07-13 02:45:37 +01:00
Brian Vaughn
58f3b29d91 Added SSR/hydration tests for modes, forwardRef, and Profiler (#13195)
* Added more SSR tests for modes, profiler, and forward-ref
2018-07-12 08:35:21 -07:00
Dan Abramov
1c89cb62fd Use ReactDebugCurrentFrame.getStackAddendum() in element validator (#13198)
Instead of wrapping ReactDebugCurrentFrame.getStackAddendum() call into a custom wrapper inside ReactElementValidator, "teach" the main ReactDebugCurrentFrame.getStackAddendum() to take currently validating element into account.
2018-07-12 16:18:24 +01:00
Dan Abramov
e6076ecf48 Remove ad-hoc forks of getComponentName() and fix it (#13197)
* Fix getComponentName() for types with nested $$typeof

* Temporarily remove Profiler ID from messages

* Change getComponentName() signature to take just type

It doesn't actually need the whole Fiber.

* Remove getComponentName() forks in isomorphic and SSR

* Remove unnecessary .type access where we already have a type

* Remove unused type
2018-07-12 07:32:06 -07:00
Philipp Spieß
32f6f258ba Remove event simulation of onChange events (#13176)
* Remove event simulation of onChange events

It’s time to get rid of even more `ReactTestUtils.Simulate`s. In this PR
we remove the event simulation from all onChange tests. To do this, we
have to get a setter to the untracked value/checked props.

All remaining `ReactTestUtils.Simulate` calls are either testing
ReactTestUtils or assert that they do/don't throw.

* Use input instead of change event for all but checkbox, radio, and select
2018-07-12 12:11:35 +01:00
Sen Yang
9ca37f8431 docs: update comments (#13043) 2018-07-11 14:31:48 -07:00
Moti Zilberman
f89f25f471 Correct type of ref in forwardRef render() (#13100)
`React$ElementRef<T>` is the type of the ref _instance_ for a component of type T, whereas `React$Ref<T>` is the type of the ref _prop_ for a component of type T, which seems to be the intended type here.
2018-07-11 14:27:46 -07:00
Brian Vaughn
7b99ceabec Deprecate test utils mock component follow up (#13194)
* De-duplicate the mockComponent deprecation warning

* Added fb.me link to mockComponent
2018-07-11 11:56:44 -07:00
Dan Abramov
6ebc8f3c07 Add support for re-entrant SSR stacks (#13181)
* Add failing tests

* Fix re-entrancy in ReactDOMServer
2018-07-11 19:43:54 +01:00
Brian Vaughn
d64d1ddb57 Deprecate ReactTestUtils.mockComponent() (#13193)
Deprecate ReactTestUtils.mockComponent()
2018-07-11 10:18:49 -07:00
dongyuwei
afd46490d0 update devEngines to include nodejs 10.x (#13190) 2018-07-11 11:46:44 +01:00
Brian Vaughn
e79366d549 Link create-subscription doc to GH issue with de-opt explanation (#13187) 2018-07-10 14:00:06 -07:00
Brian Vaughn
1f32d3c6dc Test renderer flushAll method verifies an array of expected yields (#13174) 2018-07-09 09:05:13 -07:00
Dan Abramov
377e1a049e Add a test for SSR stack traces (#13180) 2018-07-09 14:41:48 +01:00
Dan Abramov
96d38d178a Fix concatenation of null to a warning message (#13166) 2018-07-09 13:56:24 +01:00
Brian Vaughn
095dd5049c Add DEV warning if forwardRef function doesn't use the ref param (#13168)
* Add DEV warning if forwardRef function doesn't use the ref param
* Fixed a forwardRef arity warning in another test
2018-07-07 08:11:30 -07:00
Dan Abramov
5662595677 Refactor stack handling (no functional changes) (#13165)
* Refactor ReactDebugCurrentFiber to use named exports

This makes the difference between it and ReactFiberCurrentFrame a bit clearer.

ReactDebugCurrentFiber is Fiber's own implementation.
ReactFiberCurrentFrame is the thing that holds a reference to the current implementation and delegates to it.

* Unify ReactFiberComponentTreeHook and ReactDebugCurrentFiber

Conceptually they're very related.

ReactFiberComponentTreeHook contains implementation details of reading Fiber's stack (both in DEV and PROD).
ReactDebugCurrentFiber contained a reference to the current fiber, and used the above utility.

It was confusing when to use which one. Colocating them makes it clearer what you could do with each method.

In the future, the plan is to stop using these methods explicitly in most places, and instead delegate to a warning system that includes stacks automatically. This change makes future refactorings simpler by colocating related logic.

* Rename methods to better reflect their meanings

Clarify which are DEV or PROD-only.
Clarify which can return null.

I believe the "work in progress only" was a mistake. I introduced it because I wasn't sure what guarantees we have around .return. But we know for sure that following a .return chain gives us an accurate stack even if we get into WIP trees because we don't have reparenting. So it's fine to relax that naming.

* Rename ReactDebugCurrentFiber -> ReactCurrentFiber

It's not completely DEV-only anymore.
Individual methods already specify whether they work in DEV or PROD in their names.
2018-07-07 01:09:41 +01:00
Brandon Dail
ebbd221432 Configure react-test-renderer as a secondary (#13164) 2018-07-06 16:04:45 -07:00
Andrew Clark
ddc91af795 Decrease nested update limit from 1000 to 50 (#13163)
An infinite update loop can occur when an update is scheduled inside a
lifecycle method, which causes a re-render, which schedules another
update, and so on. Before the Fiber rewrite, this scenario resulted in a
stack overflow.

Because Fiber does not use the JavaScript stack, we maintain our own
counter to track the number of nested, synchronous updates. We throw an
error if the limit is exceeded.

The nested update limit is currently 1000. I chose this number
arbitrarily, certain that there was no valid reason for a component to
schedule so many synchronous re-renders.

I think we can go much lower. This commit decreases the limit to 50. I
believe this is still comfortably above the reasonable number of
synchronous re-renders a component may perform.

This will make it easier for developers to debug infinite update bugs
when they occur.
2018-07-06 15:50:31 -07:00
Andrew Clark
3596e40b39 Fix nested update bug (#13160)
A recent change to the scheduler caused a regression when scheduling
many updates within a single batch. Added a test case that would
have caught this.
2018-07-06 13:55:18 -07:00
Chang Yan
449f6ddd5c create a new FeatureFlags file for test renderer on www (#13159) 2018-07-06 12:55:29 -07:00
Dan Abramov
f762b3abb1 Run react-dom SSR import test in jsdom-less environment (#13157) 2018-07-06 16:43:43 +01:00
Brian Vaughn
6f6b560a64 Renamed selfBaseTime/treeBaseTime Fiber attributes to selfBaseDuration/treeBaseDuration (#13156)
This is an unobservable change to all but the (under development) DevTools Profiler plugin. It is being done so that the plugin can safely feature detect a version of React that supports it. The profiler API has existed since the 16.4.0 release, but it did not support the DevTools plugin prior to PR #13058.

Side note: I am not a big fan of the term "base duration". Both it and "actual duration" are kind of awkward and vague. If anyone has suggestions for better names– this is the best time to bikeshed about them.
2018-07-06 08:25:29 -07:00
Dan Abramov
1386ccddd8 Fix ReferenceError when requestAnimationFrame isn't defined (#13152)
* Make the test fail

* Fix rAF detection to avoid a ReferenceError
2018-07-05 19:42:45 +01:00
Dan Abramov
f5779bbc10 Run server rendering test on bundles (#13153) 2018-07-05 19:42:22 +01:00
Brian Vaughn
9faf389e79 Reset profiler timer correctly after errors (#13123)
* Reset ReactProfilerTimer's DEV-only Fiber stack after an error

* Added ReactNoop functionality to error during "complete" phase

* Added failing profiler stack unwinding test

* Potential fix for unwinding time bug

* Renamed test

* Don't record time until complete phase succeeds. Simplifies unwinding.

* Expanded ReactProfilerDevToolsIntegration-test coverage a bit

* Added unstable_flushWithoutCommitting method to noop renderer

* Added failing multi-root/batch test to ReactProfiler-test

* Beefed up tests a bit and added some TODOs

* Profiler timer differentiates between batched commits and in-progress async work

This was a two-part change:
1) Don't count time spent working on a batched commit against yielded async work.
2) Don't assert an empty stack after processing a batched commit (because there may be yielded async work)

This is kind of a hacky solution, and may have problems that I haven't thought of yet. I need to commit this so I can mentally clock out for a bit without worrying about it. I will think about it more when I'm back from PTO. In the meanwhile, input is welcome.

* Removed TODO

* Replaced FiberRoot map with boolean

* Removed unnecessary whitespace edit
2018-07-05 11:38:06 -07:00
XuMM_12
85fe4ddce7 Fix - issue #12765 / the checked attribute is not initially set on the input (#13114) 2018-07-04 16:00:42 -04:00
Rouven Weßling
07fefe3331 Drop handling for ms and O prefixes for CSS transition and animation events. (#13133)
Internet Explorer never needed the prefix and Opera 11.5 is no longer supported by React.
2018-07-04 18:20:02 +01:00
Andrew Clark
88d7ed8bfb React.Timeout -> React.Placeholder (#13105)
Changed the API to match what we've been using in our latest discussions.

Our tentative plans are for <Placeholder> to automatically hide the timed-out
children, instead of removing them, so their state is not lost. This part is
not yet implemented. We'll likely have a lower level API that does not include
the hiding behavior. This is also not yet implemented.
2018-07-03 19:47:00 -07:00
Andrew Clark
f128fdea48 Suspending outside of strict trees and async trees (#13098)
We can support components that suspend outside of an async mode tree
by immediately committing their placeholders.

In strict mode, the Timeout acts effectively like an error boundary.
Within a single render pass, we unwind to the nearest Timeout and
re-render the placeholder view.

Outside of strict mode, it's not safe to unwind and re-render the
siblings without committing. (Technically, this is true of error
boundaries, too, though probably not a huge deal, since we don't support
using error boundaries for control flow (yet, at least)). We need to be
clever. What we do is pretend the suspended component rendered null.*
There's no unwinding. The siblings commit like normal.

Then, in the commit phase, schedule an update on the Timeout to
synchronously re-render the placeholder. Although this requires an extra
commit, it will not be observable. And because the siblings were not
blocked from committing, they don't have to be strict mode compatible.

Another caveat is that if a component suspends during an async render,
but it's captured by a non-async Timeout, we need to revert to sync
mode. In other words, if any non-async component renders, the entire
tree must complete and commit without yielding.

* The downside of rendering null is that the existing children will be
deleted. We should hide them instead. I'll work on this in a follow-up.
2018-07-03 19:44:19 -07:00
Andrew Clark
aa8266c4f7 Prepare placeholders before timing out (#13092)
* Prepare placeholders before timing out

While a tree is suspended, prepare for the timeout by pre-rendering the
placeholder state.

This simplifies the implementation a bit because every render now
results in a completed tree.

* Suspend inside an already timed out Placeholder

A component should be able to suspend inside an already timed out
placeholder. The time at which the placeholder committed is used as 
the start time for a subsequent suspend.

So, if a placeholder times out after 3 seconds, and an inner
placeholder has a threshold of 2 seconds, the inner placeholder will
not time out until 5 seconds total have elapsed.
2018-07-03 19:22:41 -07:00
Toru Kobayashi
c039c16f21 Fix this in a functional component for ShallowRenderer (#13144) 2018-07-03 17:47:40 +01:00
Joseph Lin
6731bfbed7 Update README.md (#13085)
Fix grammatical error via addition of comma.
2018-06-30 23:45:06 +01:00
Sebastian Markbåge
64e1921aab Fix Flow type that event target can be null (#13124)
We pass null sometimes when the event target has disappeared. E.g. when
touches fires on a deleted node.
2018-06-29 12:51:48 -07:00
Hilbrand Bouwkamp
bf32a3d195 Updated url to Code of Conduct page (#13126)
url is not working. Did a search on code.fb.com that returned the page I've put in the commit.
2018-06-29 13:27:24 +01:00
Dan Abramov
183aefa51f More links 2018-06-27 17:59:29 +01:00
Dan Abramov
3297102de6 Reorder sections 2018-06-27 17:12:12 +01:00
Dan Abramov
f4b6a9f8ee Just remove this sentence 2018-06-27 17:09:45 +01:00
Dan Abramov
3eedcb1fda Tweak links in README 2018-06-27 17:07:26 +01:00
Brian Vaughn
6d6de6011c Add PROFILE bundles for www+DOM and fbsource+RN/RF (#13112) 2018-06-26 13:28:41 -07:00
Dan Abramov
71a60ddb16 Add link to another article about React renderers 2018-06-26 16:45:03 +01:00
Rauno Freiberg
9e6c99ca2e Fix README typo (#13110) 2018-06-26 07:17:02 -04:00
Dan Abramov
baff5cc2f6 Update links 2018-06-26 01:31:36 +01:00
Jason Williams
6a530e3baa adding check for mousemove (#13090)
* adding check for mousemove

* adding unit test for SyntheticMouseEvent

* changing test to start with 2, removing comments
2018-06-24 10:24:54 +01:00
Dustin Masters
c35a1e7483 Fix crash during server render in react 16.4.1. (#13088)
* Fix crash during server render.

setTimeout and clearTimeout may not be available in some server-render environments (such as ChakraCore in React.NET), and loading ReactScheduler.js will cause a crash unless the existence of the variables are checked via a typeof comparison.

https://github.com/reactjs/React.NET/issues/555

The crash did not occur in 16.4.0, and the change appears to have been introduced here: https://github.com/facebook/react/pull/12931/files#diff-bbebc3357e1fb99ab13ad796e04b69a6L47

I tested this by using yarn link and running it with a local copy of React.NET. I am unsure the best way to unit test this change, since assigning null to `setTimeout` causes an immediate crash within the Node REPL.

* Fix flow errors and log warning if setTimeout / clearTimeout are
not defined / not a function.

* Use invariant to assert setTimeout / clearTimeout are functions

* Remove use of invariant

* Explain
2018-06-22 20:07:54 +01:00
Flarnie Marchan
076bbeace7 Fall back to 'setTimeout' when 'requestAnimationFrame' is not called (#13091)
* Add fixture test for schedule running when tab is backgrounded

**what is the change?:**
Just adding a test to the fixture, where we can easily see whether
scheduled callbacks are called after switching away from the fixture
tab.

**why make this change?:**
We are about to fix the schedule module so that it still runs even when
the tab is in the backround.

**test plan:**
Manually tested the fixture, verified that it works as expected and
right now callbacks are not called when the tab is in the background.

**issue:**
Internal task T30754186

* Fall back to 'setTimeout' when 'requestAnimationFrame' is not called

**what is the change?:**
If 'requestAnimationFrame' is not called for 100ms we fall back to
'setTimeout' to schedule the postmessage.

**why make this change?:**
When you start loading a page, and then switch tabs,
'requestAnimationFrame' is throttled or not called until you come back
to that tab. That means React's rendering, any any other scheduled work,
are paused.

Users expect the page to continue loading, and rendering is part of the
page load in a React app. So we need to continue calling callbacks.

**test plan:**
Manually tested using the new fixture test, observed that the callbacks
were called while switched to another tab. They were called more
slowly, but that seems like a reasonable thing.

**issue:**
Internal task T30754186

* make arguments more explicit
2018-06-22 09:13:47 -07:00
Michael Ridgway
da5c87bdfa Fixes children when using dangerouslySetInnerHtml in a selected <option> (#13078)
* Fixes children when using dangerouslySetInnerHtml in a selected <option>

This fixes an inadvertent cast of undefined children to an empty string when creating an option tag that will be selected:

```
  <select defaultValue="test">
    <option value='test' dangerouslySetInnerHTML={{ __html: '&rlm; test'}} />
  </select>
```

This causes an invariant error because both children and dangerouslySetInnerHTML are set.

* PR fix and new ReactDOMServerIntegrationForms test

* Account for null case

* Combine test cases into single test

* Add tests for failure cases

* Fix lint
2018-06-21 20:21:21 +01:00
Nathan Quarles
a960d18bc7 eliminate unnecessary do-while loop in renderRoot() (#13087) 2018-06-21 18:52:26 +01:00
Jason Williams
5b3d17a5f7 setting a flag, so that the first movement will have the correct value (#13082) 2018-06-20 22:48:53 +01:00
Brian Vaughn
b0f60895f7 Automatically Profile roots when DevTools is present (#13058)
* react-test-renderer injects itself into DevTools if present
* Fibers are always opted into ProfileMode if DevTools is present
* Added simple test for DevTools + always profiling behavior
2018-06-20 09:24:52 -07:00
Nathan Quarles
ae8c6dd534 remove some redundant lines (#13077)
* remove another couple of redundant lines

* a few more
2018-06-20 16:35:03 +01:00
Dan Abramov
0fcf92d06d Add a link to custom renderer intro article 2018-06-20 14:46:18 +01:00
Andrew Clark
97af3e1f3a Do not add additional work to a batch that is already rendering (#13072)
* Do not add additional work to a batch that is already rendering.

Otherwise, the part of the tree that hasn't rendered yet will receive
the latest state, but the already rendered part will show the state
as it was before the intervening update.

* Reduce non-helpfulness of comments
2018-06-19 10:36:56 -07:00
Andrew Clark
4fe6eec15b Always batch updates of like priority within the same event (#13071)
Expiration times are computed by adding to the current time (the start
time). However, if two updates are scheduled within the same event, we
should treat their start times as simultaneous, even if the actual clock
time has advanced between the first and second call.

In other words, because expiration times determine how updates are
batched, we want all updates of like priority that occur within the same
event to receive the same expiration time. Otherwise we get tearing.

We keep track of two separate times: the current "renderer" time and the
current "scheduler" time. The renderer time can be updated whenever; it
only exists to minimize the calls performance.now.

But the scheduler time can only be updated if there's no pending work,
or if we know for certain that we're not in the middle of an event.
2018-06-19 10:34:19 -07:00
Dan Abramov
8e87c139b4 Remove transitive dependency on fbjs (#13075) 2018-06-19 17:52:37 +01:00
Dan Abramov
aeda7b745d Remove fbjs dependency (#13069)
* Inline fbjs/lib/invariant

* Inline fbjs/lib/warning

* Remove remaining usage of fbjs in packages/*.js

* Fix lint

* Remove fbjs from dependencies

* Protect against accidental fbjs imports

* Fix broken test mocks

* Allow transitive deps on fbjs/ for UMD bundles

* Remove fbjs from release script
2018-06-19 16:03:45 +01:00
Dan Abramov
b1b3acbd6b Inline fbjs/lib/emptyObject (#13055)
* Inline fbjs/lib/emptyObject

* Explicit naming

* Compare to undefined

* Another approach for detecting whether we can mutate

Each renderer would have its own local LegacyRefsObject function.

While in general we don't want `instanceof`, here it lets us do a simple check: did *we* create the refs object?
Then we can mutate it.

If the check didn't pass, either we're attaching ref for the first time (so we know to use the constructor),
or (unlikely) we're attaching a ref to a component owned by another renderer. In this case, to avoid "losing"
refs, we assign them onto the new object. Even in that case it shouldn't "hop" between renderers anymore.

* Clearer naming

* Add test case for strings refs across renderers

* Use a shared empty object for refs by reading it from React

* Remove string refs from ReactART test

It's not currently possible to resetModules() between several renderers
without also resetting the `React` module. However, that leads to losing
the referential identity of the empty ref object, and thus subsequent
checks in the renderers for whether it is pooled fail (and cause assignments
to a frozen object).

This has always been the case, but we used to work around it by shimming
fbjs/lib/emptyObject in tests and preserving its referential identity.
This won't work anymore because we've inlined it. And preserving referential
identity of React itself wouldn't be great because it could be confusing during
testing (although we might want to revisit this in the future by moving its
stateful parts into a separate package).

For now, I'm removing string ref usage from this test because only this is
the only place in our tests where we hit this problem, and it's only
related to string refs, and not just ref mechanism in general.

* Simplify the condition
2018-06-19 13:41:42 +01:00
Dan Abramov
ae14317d68 Inline fbjs/lib/emptyFunction (#13054) 2018-06-15 18:45:14 +01:00
Dan Abramov
72434a7686 Remove or inline some fbjs dependencies (#13046) 2018-06-15 18:12:45 +01:00
Jason Williams
64c54edea4 Adding movementX and movementY to synthenticMouseEvent fixes #6723 (#9018)
* adding movementX and movementY into syntheticMouseEvent

* fixing case mistake

* Add test fixture for movementX/Y fields
2018-06-15 09:15:36 -04:00
Andrew Clark
9bd4d1fae2 Synchronously restart when an error is thrown during async rendering (#13041)
In async mode, events are interleaved with rendering. If one of those
events mutates state that is later accessed during render, it can lead
to inconsistencies/tearing.

Restarting the render from the root is often sufficient to fix the
inconsistency. We'll flush the restart synchronously to prevent yet
another mutation from happening during an interleaved event.

We'll only restart during an async render. Sync renders are already
sync, so there's no benefit in restarting. (Unless a mutation happens
during the render phase, but we don't support that.)
2018-06-14 16:37:30 -07:00
Andrew Clark
9bda7b28f3 Suspended high pri work forces lower priority work to expire early (#12965)
* onFatal, onComplete, onSuspend, onYield

For every call to renderRoot, one of onFatal, onComplete, onSuspend,
and onYield is called upon exiting. We use these in lieu of returning a
tuple. I've also chosen not to inline them into renderRoot because these
will eventually be lifted into the renderer.

* Suspended high pri work forces lower priority work to expire early

If an error is thrown, and there is lower priority pending work, we
retry at the lower priority. The lower priority work should expire
at the same time at which the high priority work would have expired.
Effectively, this increases the priority of the low priority work.

Simple example: If an error is thrown during a synchronous render, and
there's an async update, the async update should flush synchronously in
case it's able to fix the error. I've added a unit test for
this scenario.

User provided timeouts should have the same behavior, but I'll leave
that for a future PR.
2018-06-14 15:29:27 -07:00
Crux
2e75779075 Fix incorrect data in compositionend event with Korean IME on IE11 (#10217) (#12563)
* Add isUsingKoreanIME function to check if a composition event was triggered by Korean IME

* Add Korean IME check alongside useFallbackCompositionData and disable fallback mode with Korean IME
2018-06-14 16:35:05 +01:00
Sebastian Markbåge
bc963f353d setJSResponder in Fabric renderer (#13031) 2018-06-13 17:03:26 -07:00
Sebastian Markbåge
051637da61 Extract Fabric event handlers from canonical props (#13024)
We need a different "component tree" thingy for Fabric.

A lot of this doesn't really make much sense in a persistent world but
currently we can't dispatch events to memoizedProps on a Fiber since
they're pooled. Also, it's unclear what the semantics should be when we
dispatch an event that happened when the old props were in effect but now
we have new props already.

This implementation tries to use the last committed props but also fails
at that because we don't have a commit hook in the persistent mode.

However, at least it doesn't crash when dispatching. :)
2018-06-13 16:20:48 -07:00
Flarnie Marchan
2a8085980f Remove rAF fork (#12980)
* Remove rAF fork

**what is the change?:**
Undid https://github.com/facebook/react/pull/12837

**why make this change?:**
We originally forked rAF because we needed to pull in a particular
version of rAF internally at Facebook, to avoid grabbing the default
polyfilled version.

The longer term solution, until we can get rid of the global polyfill
behavior, is to initialize 'schedule' before the polyfilling happens.

Now that we have landed and synced
https://github.com/facebook/react/pull/12900 successfully, we can
initialize 'schedule' before the polyfill runs.
So we can remove the rAF fork. Here is how it will work:

1. Land this PR on Github.
2. Flarnie will quickly run a sync getting this change into www.
3. We delete the internal forked version of
   'requestAnimationFrameForReact'.
4. We require 'schedule' in the polyfill file itself, before the
   polyfilling happens.

**test plan:**
Flarnie will manually try the above steps locally and verify that things
work.

**issue:**
Internal task T29442940

* fix nits

* fix tests, fix changes from rebasing

* fix lint
2018-06-13 10:57:35 -07:00
Andrew Clark
e0c78344e2 Retry on error if there's lower priority pending work (#12957)
* Remove enableSuspense flag from PendingPriority module

We're going to use this for suspending on error, too.

* Retry on error if there's lower priority pending work

If an error is thrown, and there's lower priority work, it's possible
the lower priority work will fix the error. Retry at the lower priority.

If an error is thrown and there's no more work to try, handle the error
like we normally do (trigger the nearest error boundary).
2018-06-13 10:47:14 -07:00
Dan Abramov
74b1723df1 Update changelog for 16.4.1 2018-06-13 17:23:59 +01:00
Dan Abramov
9725065eb4 Update bundle sizes for 16.4.1 release 2018-06-13 17:20:35 +01:00
Dan Abramov
a5957bf296 Update error codes for 16.4.1 release 2018-06-13 17:20:35 +01:00
Dan Abramov
0b87b27906 Updating package versions for release 16.4.1 2018-06-13 17:16:10 +01:00
Dan Abramov
65eb6b94ac Updating yarn.lock file for 16.4.1 release 2018-06-13 17:13:29 +01:00
Dan Abramov
c469e3b422 Add unreleased changelog 2018-06-13 16:57:46 +01:00
Philipp Spieß
036ae3c6e2 Use native event dispatching instead of Simulate or SimulateNative (#13023)
* Use native event dispatching instead of Simulate or SimulateNative

In #12629 @gaearon suggested that it would be better to drop usage of
`ReactTestUtils.Simulate` and `ReactTestUtils.SimulateNative`. In this
PR I’m attempting at removing it from a lot of places with only a few
leftovers.

Those leftovers can be categorized into three groups:

1. Anything that tests that `SimulateNative` throws. This is a property
   that native event dispatching doesn’t have so I can’t convert that
   easily. Affected test suites: `EventPluginHub-test`,
   `ReactBrowserEventEmitter-test`.
2. Anything that tests `ReactTestUtils` directly. Affected test suites:
   `ReactBrowserEventEmitter-test` (this file has one test that reads
    "should have mouse enter simulated by test utils"),
    `ReactTestUtils-test`.
3. Anything that dispatches a `change` event. The reason here goes a bit
   deeper and is rooted in the way we shim onChange. Usually when using
   native event dispatching, you would set the node’s `.value` and then
   dispatch the event. However inside [`inputValueTracking.js`][] we
   install a setter on the node’s `.value` that will ignore the next
   `change` event (I found [this][near-perfect-oninput-shim] article
   from Sophie that explains that this is to avoid onChange when
   updating the value via JavaScript).

All remaining usages of `Simulate` or `SimulateNative` can be avoided
by mounting the containers inside the `document` and dispatching native
events.

Here some remarks:

1. I’m using `Element#click()` instead of `dispatchEvent`. In the jsdom
   changelog I read that `click()` now properly sets the correct values
   (you can also verify it does the same thing by looking at the
   [source][jsdom-source]).
2. I had to update jsdom in order to get `TouchEvent` constructors
   working (and while doing so also updated jest). There was one
   unexpected surprise: `ReactScheduler-test` was relying on not having
   `window.performance` available. I’ve recreated the previous
   environment by deleting this property from the global object.
3. I was a bit confused that `ReactTestUtils.renderIntoDocument()` does
   not render into the document 🤷‍

[`inputValueTracking.js`]: 392530104c/packages/react-dom/src/client/inputValueTracking.js (L79)
[near-perfect-oninput-shim]: https://sophiebits.com/2013/06/18/a-near-perfect-oninput-shim-for-ie-8-and-9.html
[jsdom-source]: 45b77f5d21/lib/jsdom/living/nodes/HTMLElement-impl.js (L43-L76)

* Make sure contains are unlinked from the document even if the test fails

* Remove unnecessary findDOMNode calls
2018-06-13 12:41:23 +01:00
Rafał Ruciński
945fc1bfce Call gDSFP with the right state in react-test-render (#13030)
* Call gDSFP with the right state in react-test-render

* Change the test
2018-06-12 23:36:50 +01:00
Flarnie Marchan
392530104c Remove feature flag around 'getDerivedStateFromProps' bug fix (#13022)
**what is the change?:**
Basically undoes 4b2e65d32e (diff-904ceabd8a1e9a07ab1d876d843d62e1)

**why make this change?:**
We rolled out this fix internally and in open source weeks ago, and now
we're cleaning up.

**test plan:**
Ran tests and lint, and really we have been testing this because the
flag is open internally as of last week or so.

**issue:**
Internal task T29948812 has some info.
2018-06-11 16:31:07 -07:00
Dan Abramov
1594409fab Scheduler depends on common packages (#13020) 2018-06-11 22:13:05 +01:00
Brian Vaughn
d5c11193e2 Added production profiling bundle type (#12886)
* Added profiling bundle
* Turned profiling on for React Fabric OSS profiling and dev bundles
* Added new global var "__PROFILE__" for profiling DCE
2018-06-11 13:16:27 -07:00
Dan Abramov
ec60457bcd Popping context is O(1) in SSR (#13019) 2018-06-11 20:52:39 +01:00
Dan Abramov
30bc8ef792 Allow multiple root children in test renderer traversal API (#13017) 2018-06-11 20:03:51 +01:00
Philipp Spieß
d480782c41 Don’t error when returning an empty Fragment (#12966)
* Don’t error when returning an empty Fragment

When a fragment is reconciled, we directly move onto it’s children.
Since an empty `<React.Fragment/>` will have children of `undefined`,
this would always throw.

To fix this, we bail out in those cases.

* Test the update path as well

* Reuse existing code path

* An even more explicit solution that also fixes Flow
2018-06-11 14:43:30 +01:00
Nathan Hunzaker
4ac6f133af Fallback to event.srcElement for IE9 (#12976)
It looks like we accidentally removed a fallback condition for the
event target in IE9 when we dropped some support for IE8. This commit
adds the event target specific support code back to getEventTarget.js

Fixes #12506
2018-06-11 14:35:42 +01:00
Eric Soderberg
23be4102df Fixed an issue with nested contexts unwinding when server rendering. Issue #12984 (#12985)
* Fixed an issue with nested contexts unwinding when server rendering. GitHub issue #12984

* Fixed an issue with search direction and stricter false checking

* Use decrement infix operator

* Streamlined existence checks

* Streamlined assignment. Removed redundant comment. Use null for array values

* Made prettier

* Relaxed type checking and improved comment

* Improve test coverage
2018-06-11 14:25:18 +01:00
Nathan Hunzaker
d0d4280640 Remove old reference to inst._wrapperState (#12987)
This commit removes a reference to inst._wrapperState, which was the
old way of tracking input state in the stack renderer.

This means we no longer need to pass the instance into the associated
function, allowing us to eliminate an exception for IE (and a TODO).
2018-06-11 14:16:50 +01:00
Jifa Jiang
c78957eac8 Fix an SVG focusing crash in IE11 (#12996)
* revert #11800

because #12763

* use try/catch for SVG in IE11

* use focusNode(element) when element.focus isn't a function.

* revert #11800
2018-06-11 03:39:29 +01:00
Nathan Quarles
bfb12ebb52 delete a couple of redundant lines in performWorkOnRoot() in ReactFiberScheduler.js (#13003) 2018-06-09 22:56:21 +01:00
Dan Abramov
394b17eede Update custom renderer docs 2018-06-09 22:19:12 +01:00
Ivan Babak
188c4252a2 Fix react-dom ReferenceError requestAnimationFrame in non-browser env (#13000) (#13001)
* Fix react-dom ReferenceError requestAnimationFrame in non-browser env (#13000)

The https://github.com/facebook/react/pull/12931 ( 79a740c6e3 ) broke the server-side rendering: in the `fixtures/ssr` the following error appeared from the server-side when `localhost:3000` is requested:
```
ReferenceError: requestAnimationFrame is not defined
    at /__CENSORED__/react/build/node_modules/react-dom/cjs/react-dom.development.js:5232:34
    at Object.<anonymous> (/__CENSORED__/react/build/node_modules/react-dom/cjs/react-dom.development.js:17632:5)
    at Module._compile (module.js:624:30)
    at Module._extensions..js (module.js:635:10)
    at Object.require.extensions.(anonymous function) [as .js] (/__CENSORED__/react/fixtures/ssr/node_modules/babel-register/lib/node.js:152:7)
    at Module.load (module.js:545:32)
    at tryModuleLoad (module.js:508:12)
    at Function.Module._load (module.js:500:3)
    at Module.require (module.js:568:17)
    at require (internal/module.js:11:18)
```

The exception pointed to this line:
```js
// We capture a local reference to any global, in case it gets polyfilled after
// this module is initially evaluated.
// We want to be using a consistent implementation.
const localRequestAnimationFrame = requestAnimationFrame;
```

**Test plan**

1. In `react` repo root, `yarn && yarn build`.
2. In `fixtures/ssr`, `yarn && yarn start`,
3. In browser, go to `http://localhost:3000`.
4. Observe the fixture page, not the exception message.

* Move the requestAnimationFrameForReact check and warning to callsites (#13000)

According to the comment by @gaearon: https://github.com/facebook/react/pull/13001#issuecomment-395803076

* Use `invariant` instead of `throw new Error`, use the same message (#13000)

According to the comment by @gaearon: https://github.com/facebook/react/pull/13001#discussion_r194133355
2018-06-08 23:12:20 +01:00
Ivan Babak
d3e0a3aaf3 Fix jest/matchers/toWarnDev expected, actual order for jest-diff (#12285) (#12288)
`toWarnDev` calls `jestDiff(a, b)` which calls `diffStrings(a, b)` where by default `a` is annotated as `'Expected'` (green), `b` as `'Received'` (red).

So the first argument passed into `jestDiff` should be the expected message, the second should be the actual message.
It was vice versa previously.

- 457776b288/packages/jest-diff/src/index.js (L54)
- 457776b288/packages/jest-diff/src/index.js (L93)
- 457776b288/packages/jest-diff/src/diff_strings.js (L249-L251)
2018-06-08 13:18:22 +01:00
Nathan Quarles
9cf3733a9a update comment in computeAsyncExpiration() to reflect code (#12994) 2018-06-07 21:12:08 +01:00
Demian Dekoninck
52fbe7612e use --frozen-lockfile in AppVeyor (#12950) 2018-06-06 15:19:33 +02:00
Ende93
c5a733e1e3 Fix links of docs on the comment (#12795) 2018-06-05 08:03:03 -04:00
Maxime Nory
36546b5137 Set the correct initial value on input range (#12939)
* Set the correct initial value on input range

* Add description and update value diff check for input range

* add isHydrating argument and tests

* update node value according to isHydrating
2018-05-31 17:23:26 -04:00
Héctor Ramos
65ab53694f Update token (#12956) 2018-05-31 21:36:55 +01:00
Flarnie Marchan
15767a8f8f [scheduler] 5/n Error handling in scheduler (#12920)
* Initial failing unit test for error handling in schedule

**what is the change?:**
see title

**why make this change?:**
Adding tests for the error handling behavior we are about to add. This
test is failing, which gives us the chance to make it pass.

Wrote skeletons of some other tests to add.

Unit testing this way is really hacky, and I'm also adding to the
fixture to test this in the real browser environment.

**test plan:**
Ran new test, saw it fail!

* Add fixture for testing error handling in scheduler

**what is the change?:**
Added a fixture which does the following -
logs in the console to show what happens when you use
`requestAnimationFrame` to schedule a series of callbacks and some of
them throw errors.

Then does the same actions with the `scheduler` and verifies that it
behaves in a similar way.

Hard to really verify the errors get thrown at the proper time without
looking at the console.

**why make this change?:**
We want the most authentic, accurate test of how errors are handled in
the scheduler. That's what this fixture should be.

**test plan:**
Manually verified that this test does what I expect - right now it's
failing but follow up commits will fix that.

* Handle errors in scheduler

**what is the change?:**
We set a flag before calling any callback, and then use a 'try/finally'
block to wrap it. Note that we *do not* catch the error, if one is
thrown. But, we only unset the flag after the callback successfully
finishes.

If we reach the 'finally' block and the flag was not unset, then it
means an error was thrown.

In that case we start a new postMessage callback, to finish calling any
other pending callbacks if there is time.

**why make this change?:**
We need to make sure that an error thrown from one callback doesn't stop
other callbacks from firing, but we also don't want to catch or swallow
the error because we want engineers to still be able to log and debug
errors.

**test plan:**
New tests added are passing, and we verified that they fail without this
change.

* Add more tests for error handling in scheduler

**what is the change?:**
Added tests for more situations where error handling may come up.

**why make this change?:**
To get additional protection against this being broken in the future.

**test plan:**
Ran new tests and verified that they fail when error handling fails.

* callSafely -> callUnsafely

* Fix bugs with error handling in schedule

**what is the change?:**
- ensure that we properly remove the callback from the linked list, even
if it throws an error and is timed out.
- ensure that you can call 'cancelScheduledWork' more than once and it
is idempotent.

**why make this change?:**
To fix bugs :)

**test plan:**
Existing tests pass, and we'll add more tests in a follow up commit.

* Unit tests for error handling with timed out callbacks

**what is the change?:**
More unit tests, to cover behavior which we missed; error handling of
timed out callbacks.

**why make this change?:**
To protect the future!~

**test plan:**
Run the new tests.

* Adds fixture to test timed out callbacks with scheduler

**what is the change?:**
See title

In the other error handling fixture we compare 'scheduleWork' error
handling to 'requestAnimationFrame' and try to get as close as possible.
There is no 'timing out' feature with 'requestAnimationFrame' but
effectively the 'timing out' feature changes the order in which things
are called. So we just changed the order in the 'requestAnimationFrame'
version and that works well for illustrating the behavior we expect in
the 'scheduleWork' test.

**why make this change?:**
We need more test coverage of timed out callbacks.

**test plan:**
Executed the fixture manually in Firefox and Chrome. Results looked
good.

* fix rebase problems

* make fixture compensate for chrome JS speed

* ran prettier

* Remove 'cancelled' flag on callbackConfig in scheduler, add test

**what is the change?:**
- Instead of using a 'cancelled' flag on the callbackConfig, it's easier
to just check the state of the callbackConfig inside
'cancelScheduledWork' to determine if it's already been cancelled. That
way we don't have to remember to set the 'cancelled' flag every time we
call a callback or cancel it. One less thing to remember.
- We added a test for calling 'cancelScheduledWork' more than once,
which would have failed before.

Thanks @acdlite for suggesting this in code review. :)

**why make this change?:**
To increase stability of the schedule module, increase test coverage.

**test plan:**
Existing tests pass and we added a new test to cover this behavior.

* fix typo
2018-05-30 15:38:48 -07:00
Andrew Clark
3118ed9d64 Expose unstable_interactiveUpdates on ReactDOM (#12943) 2018-05-30 15:31:59 -07:00
Flarnie Marchan
524a743313 Fix for Flow issues in SimpleCacheProvider (#12942)
* Fix for Flow issues in SimpleCacheProvider

**what is the change?:**
- Fixed some flow errors which were somehow swallowed when CI
originally
- Loosen flow types to avoid issue with recursive loop in Flow; https://github.com/facebook/flow/issues/5870

**why make this change?:**
To unbreak master and unblock other changes we want to make.

**test plan:**
Flow passes!

**issue:**
https://github.com/facebook/react/issues/12941

* Fix lints
2018-05-30 15:31:41 -07:00
Andrew Clark
ae57b125c7 [simple-cache-provider] Use LRU cache eviction (#12851)
* [simple-cache-provider] Use LRU cache eviction

Max size is hard-coded to 500. In the future, we should make this
configurable per resource.

* Evict PAGE_SIZE records from cache when max limit is reached
2018-05-30 13:12:29 -07:00
Spyros Ioakeimidis
e0a03c1b4d Extend input type check in selection capabilities (#12062) (#12135)
* Do not set selection when prior selection is undefined (#12062)

`restoreSelection` did not account for input elements that have changed
type after the commit phase. The new `text` input supported selection
but the old `email` did not and `setSelection` was incorrectly trying to
restore `null` selection state.

We also extend input type check in selection capabilities to cover cases
where input type is `search`, `tel`, `url`, or `password`.

* Add link to HTML spec for element types and selection

* Add reset button to ReplaceEmailInput

This commit adds a button to restore the original state of the
ReplaceEmailInput fixture so that it can be run multiple times without
refreshing the page.
2018-05-30 07:08:21 -04:00
Flarnie Marchan
79a740c6e3 Rename variables to remove references to 'global' global (#12931)
**what is the change?:**
In a recent PR we were referencing some global variables and storing
local references to them.

To make things more natural, we co-opted the original name of the global
for our local reference. To make this work with Flow, we get the
original reference from 'window.requestAnimationFrame' and assign it to
'const requestAnimationFrame'.

Sometimes React is used in an environment where 'window' is not defined
- in that case we need to use something else, or hide the 'window'
reference somewhere.

We opted to use 'global' thinking that Babel transforms would fill that
in with the proper thing.

But for some of our fixtures we are not doing that transform on the
bundle.

**why make this change?:**
I want to unbreak this on master and then investigate more about what we
should do to fix this.

**test plan:**
run `yarn build` and open the fixtures.

**issue:**
https://github.com/facebook/react/issues/12930
2018-05-29 17:54:38 -07:00
Flarnie Marchan
ff724d3c28 [scheduler] 4/n Allow splitting out schedule in fb-www, prepare to fix polyfill issue internally (#12900)
* Use local references to global things inside 'scheduler'

**what is the change?:**
See title

**why make this change?:**
We want to avoid initially calling one version of an API and then later
accessing a polyfilled version.

**test plan:**
Run existing tests.

* Shim ReactScheduler for www

**what is the change?:**
In 'www' we want to reference the separate build of ReactScheduler,
which allows treating it as a separate module internally.

**why make this change?:**
We need to require the ReactScheduler before our rAF polyfill activates,
in order to customize which custom behaviors we want.

This is also a step towards being able to experiment with using it
outside of React.

**test plan:**
Ran tests, ran the build, and ran `test-build`.

* Generate a bundle for fb-www

**what is the change?:**
See title

**why make this change?:**
Splitting out the 'schedule' module allows us to load it before
polyfills kick in for rAF and other APIs.

And long term we want to split this into a separate module anyway, this
is a step towards that.

**test plan:**
I'll run the sync next week and verify that this all works. :)

* ran prettier

* fix rebase issues

* Change names of variables used for holding globals
2018-05-29 13:30:04 -07:00
Brian Vaughn
001f9ef471 Release script prompts for NPM 2FA code (#12908)
* Release script prompts for NPM 2fa code
2018-05-29 12:50:04 -07:00
Brian Vaughn
83f76e4db9 ForwardRefs supports propTypes (#12911)
* Moved some internal forwardRef tests to not be internal
* ForwardRef supports propTypes
2018-05-29 09:50:49 -07:00
Dan Abramov
4f1f909b5b Disable Flow on AppVeyor again
It runs out of memory.
2018-05-29 15:47:14 +01:00
Nathan Hunzaker
8aeea5afa2 Do not assign node.value on input creation if no change will occur (#12925)
This commit fixes an issue where assigning an empty string to required
text inputs triggers the invalid state in Firefox (~60.0.1).

It does this by first comparing the initial state value to the current
value property on the text element. This:

1. Prevents the validation issue
2. Avoids an extra DOM Mutation in some cases
2018-05-29 14:48:58 +01:00
Simen Bekkhus
aa85b0fd5f Upgrade to Jest 23 (#12894)
* Upgrade to Jest 23 beta

* prefer `.toHaveBeenCalledTimes`

* 23 stable
2018-05-28 23:03:15 +01:00
Daniel Lo Nigro
a32f857ac7 Use --frozen-lockfile for Yarn in CI build (#12914)
CI builds should always use the `--frozen-lockfile` option. It will fail the build if the lockfile is out-of-date:

> If you need reproducible dependencies, which is usually the case with the continuous integration systems, you should pass --frozen-lockfile flag.

(https://yarnpkg.com/en/docs/cli/install/)
2018-05-28 19:52:42 +01:00
Flarnie Marchan
61777a78f6 [scheduler] 3/n Use a linked list instead of map and queue for callback storage (#12893)
* [schedule] Use linked list instead of queue and map for storing cbs

NOTE: This PR depends on https://github.com/facebook/react/pull/12880
and https://github.com/facebook/react/pull/12884
Please review those first, and after they land Flarnie will rebase on
top of them.

---

**what is the change?:**
See title

**why make this change?:**
This seems to make the code simpler, and potentially saves space of
having an array and object around holding references to the callbacks.

**test plan:**
Run existing tests

* minor style improvements

* refactor conditionals in cancelScheduledWork for increased clarity

* Remove 'canUseDOM' condition and fix some flow issues w/callbackID type

**what is the change?:**
- Removed conditional which fell back to 'setTimeout' when the
environment doesn't have DOM. This appears to be an old polyfill used
for test environments and we don't use it any more.
- Fixed type definitions around the callbackID to be more accurate in
the scheduler itself, and more loose in the React code.

**why make this change?:**
To get Flow passing, simplify the scheduler code, make things accurate.

**test plan:**
Run tests and flow.

* Rewrite 'cancelScheduledWork' so that Flow accepts it

**what is the change?:**
Adding verification that 'previousCallbackConfig' and
'nextCallbackConfig' are not null before accessing properties on them.

Slightly concerned because this implementation relies on these
properties being untouched and correct on the config which is passed to
'cancelScheduledWork' but I guess we already rely heavily on that for
this whole approach. :\

**why make this change?:**
To get Flow passing.

Not sure why it passed earlier and in CI, but now it's not.

**test plan:**
`yarn flow dom` and other flow tests, lint, tests, etc.

* ran prettier

* Put back the fallback implementation of scheduler for node environment

**what is the change?:**
We had tried removing the fallback implementation of `scheduler` but
tests reminded us that this is important for supporting isomorphic uses
of React.

Long term we will move this out of the `schedule` module but for now
let's keep things simple.

**why make this change?:**
Keep things working!

**test plan:**
Ran tests and flow

* Shorten properties stored in objects by sheduler

**what is the change?:**
`previousScheduledCallback` -> `prev`
`nextScheduledCallback` -> `next`

**why make this change?:**
We want this package to be smaller, and less letters means less code
means smaller!

**test plan:**
ran existing tests

* further remove extra lines in scheduler
2018-05-26 15:55:57 -07:00
Sebastian Markbåge
e7bd3d59a9 No longer expose ReactNativeComponentTree (#12904) 2018-05-25 21:17:37 -07:00
Brian Vaughn
f35d989bea TestRenderer warns if flushThrough is passed the wrong params (#12909)
TestRenderer throws if flushThrough is passed the expected yield values that don't match actual yield values.
2018-05-25 14:53:24 -07:00
Brian Vaughn
5578700671 Record "actual" times for all Fibers within a Profiler tree (alt) (#12910)
* Moved actual time fields from Profiler stateNode to Fiber

* Record actual time for all Fibers within a ProfileMode tree

* Changed how profiler accumulates time

This change gives up on accumulating time across renders of different priority, but in exchange- simplifies how the commit phase (reset) code works, and perhaps also makes the profiling code more compatible with future resuming behavior
2018-05-25 14:51:13 -07:00
Flarnie Marchan
76e07071a1 [scheduler] 2/n Adding 'schedule' fixture (#12884)
* Adding 'schedule' fixture

**what is the change?:**
We need to test the `schedule` module against real live browser APIs. As
a quick solution we're writing a fixture for using in manual testing.
Later we plan on adding automated browser testing, using this or a
similar fixture as the test page.

**why make this change?:**
To further solidify test coverage for `schedule` before making further
improvements/refactors to the module.

**test plan:**
`open fixtures/schedule/index.html` and inspect the results. It should
be clear that things pass.

We also temporarily broke the scheduler and verified that this fixture
demonstrates the problems.

**issue:**
Internal task T29442940

* Made fixture tests display red or green border depending on pass/fail

**what is the change?:**
Added red/green solid/dashed border for test results when using the
schedule fixture.

We also tweaked the timing of the last test because it was on the line
in terms of whether it passed or failed.

**why make this change?:**
To make it faster to use the fixture - it takes more time to read
through the results line by line and check that they match what is
expected.

**test plan:**
Looked at the fixture, and also tried modifying a test to show what it
looks like when something fails.
2018-05-24 14:11:25 -07:00
Flarnie Marchan
345e0a71ac Improve tests for 'schedule' module (#12880)
**what is the change?:**
Renamed some methods, and made a method to advance a frame in the test
environment.

**why make this change?:**
We often need to simulate a frame passing with some amount of idle time
or lack of idle time, and the new method makes it easier to write that
out.

**test plan:**
Run the updated tests.
Also temporarily tried breaking the scheduler and verified that the
tests will fail.

**issue:**
See internal task T29442940
2018-05-24 10:27:23 -07:00
Andrew Clark
fa7fa812c7 Update CHANGELOG for 16.4.0 2018-05-23 18:20:27 -07:00
Andrew Clark
8765d60893 Update bundle sizes for 16.4.0 release 2018-05-23 17:35:31 -07:00
Andrew Clark
d31e753f89 Update error codes for 16.4.0 release 2018-05-23 17:35:31 -07:00
Andrew Clark
d427a563d5 Updating package versions for release 16.4.0 2018-05-23 17:30:33 -07:00
Andrew Clark
eca59ec1b3 Updating yarn.lock file for 16.4.0 release 2018-05-23 17:26:46 -07:00
Chang Yan
53852a887b add functional components warning about legacy context api (#12892) 2018-05-23 14:16:39 -07:00
Toru Kobayashi
fe747a51c1 Add React.Timeout to getComponentName (#12890) 2018-05-23 18:39:20 +01:00
Toru Kobayashi
3df157480a Fix a typo (#12889) 2018-05-23 17:47:23 +01:00
Dan Abramov
6f4fb4a059 Tweak the changelog 2018-05-23 17:04:42 +01:00
Dan Abramov
d1be01f079 Add upcoming 16.4.0 changelog 2018-05-23 16:40:35 +01:00
Chang Yan
c601f7a646 add siblings Timeout components test case (#12862) 2018-05-22 15:39:40 -07:00
Chang Yan
7350358374 add legacy context API warning in strict mode (#12849)
* add legacy context APIs warning in strict mode

* refactor if statement and the warning message

* add other flags for type check

* add component stack tree and refactor wording

* fix the nits
2018-05-22 15:38:02 -07:00
Dan Abramov
e885791842 Fix a regression that caused us to listen to extra events at the top (#12878)
* Rewrite to a switch

I find it a bit easier to follow than many comparison conditions.

* Remove unnecessary assignments

They are being assigned below anyway. This is likely a copypasta from the FOCUS/BLUR special case (which *does* need those assignments).

* Unify "cancel" and "close" cases

Their logic is identical.

* Don't listen to media events at the top

* Add a unit test for double-invoking form events

* Remove an unused case and document it in a test

The case I added was wrong (just like including this event in the top level list was always wrong).

In fact it never bubbles, even for <img>. And since we don't special case it in the <img> event
attachment logic when we create it, we never supported <img onLoadStart> at all.

We could fix it. But Chrome doesn't support it either: https://bugs.chromium.org/p/chromium/issues/detail?id=458851.
Nobody asked us for it yet. And supporting it would require attaching an extra listener to every <img>.

So maybe we don't need it? Let's document the existing state of things.

* Add a test verifying we don't attach unnecessary listeners

* Add a comment

* Add a test for submit (bubbles: false)
2018-05-22 19:50:36 +01:00
Brian Vaughn
7c0aca289d Rollup freeze: false (#12879)
* Tell Rollup not to freeze bundles
* Only freeze bundles for DEV builds
2018-05-22 08:16:59 -07:00
Flarnie Marchan
33289b530c Tests and fixes for 'timing out' behavior (#12858)
**what is the change?:**
Test coverage checking that callbacks are called when they time out.

This test surfaced a bug and this commit includes the fix.

I want to refine this approach, but basically we can simulate time outs
by controlling the return value of 'now()' and the argument passed to
the rAF callback.

Next we will write a browser fixture to further test this against real
browser APIs.

**why make this change?:**
Better tests will keep this module working smoothly while we continue
refactoring and improving it.

**test plan:**
Run the new tests, see that it fails without the bug fix.
2018-05-22 08:03:55 -07:00
Sophie Alpert
ad27845ccd Fix double-firing submit events (#12877)
We were adding a listener at the root when we weren't meant to. Blames to e96dc14059.

This now alerts once (at FORM) instead of twice (at FORM, #document):

```
var Hello = class extends React.Component {
  render() {
    return (
      <form onSubmit={(e) => {e.preventDefault(); alert('hi ' + e.nativeEvent.currentTarget.nodeName);}}>
        <button>hi</button>
      </form>
    );
  }
};
```
2018-05-21 17:47:56 -07:00
Dan Abramov
60853f09f3 Try to reenable Flow on Windows CI
We should have more memory now
2018-05-21 18:53:00 +01:00
Dan Abramov
dd5fad2961 Update Flow to 0.70 (#12875)
* Update Flow to 0.70

* Remove unnecessary condition

* Fix wrong assertion

* Strict check
2018-05-21 17:54:48 +01:00
Brian Vaughn
13003654e7 Pass "start time" and "commit time" to Profiler callback (#12852)
* Added start time parameter to Profiler onRender callback
* Profiler also captures commit time
* Only init Profiler stateNode if enableProfilerTimer feature flag enabled
2018-05-21 09:49:22 -07:00
Dan Abramov
12c8a88cd9 Update Jest (#12874) 2018-05-21 16:17:11 +01:00
Dan Abramov
dc3b144f41 Treat Rollup "warnings" as errors (#12868) 2018-05-21 15:38:46 +01:00
Dan Abramov
0442e8275f Add a clear error when renderers clash in tests (#12867) 2018-05-21 15:38:35 +01:00
Kevin Lamping
089d2deb20 add netlify toml file (#12350) 2018-05-20 21:03:51 +01:00
Kevin (Kun) "Kassimo" Qian
d7b9b4921b Fix react native example links in README of 'react-reconciler' (#12871) 2018-05-20 12:01:00 +01:00
Sophie Alpert
9bed4a6aee https in reactProdInvariant text (#12869) 2018-05-19 17:29:41 -07:00
Dan Abramov
397d6115b7 Temporarily disable Flow on AppVeyor
I think it runs out of memory. I’ll reenable if we can bump the limit.
2018-05-19 13:54:44 +01:00
Dan Abramov
47b003a828 Resolve host configs at build time (#12792)
* Extract base Jest config

This makes it easier to change the source config without affecting the build test config.

* Statically import the host config

This changes react-reconciler to import HostConfig instead of getting it through a function argument.

Rather than start with packages like ReactDOM that want to inline it, I started with React Noop and ensured that *custom* renderers using react-reconciler package still work. To do this, I'm making HostConfig module in the reconciler look at a global variable by default (which, in case of the react-reconciler npm package, ends up being the host config argument in the top-level scope).

This is still very broken.

* Add scaffolding for importing an inlined renderer

* Fix the build

* ES exports for renderer methods

* ES modules for host configs

* Remove closures from the reconciler

* Check each renderer's config with Flow

* Fix uncovered Flow issue

We know nextHydratableInstance doesn't get mutated inside this function, but Flow doesn't so it thinks it may be null.
Help Flow.

* Prettier

* Get rid of enable*Reconciler flags

They are not as useful anymore because for almost all cases (except third party renderers) we *know* whether it supports mutation or persistence.

This refactoring means react-reconciler and react-reconciler/persistent third-party packages now ship the same thing.
Not ideal, but this seems worth how simpler the code becomes. We can later look into addressing it by having a single toggle instead.

* Prettier again

* Fix Flow config creation issue

* Fix imprecise Flow typing

* Revert accidental changes
2018-05-19 11:29:11 +01:00
Royi Hagigi
c0fe8d6f69 Adds ReactScheduler red->green unit test for bug fixed in #12834 (#12861)
* Scheduler red->green unit test for bug

* fix lint issue

* ran prettier
2018-05-18 15:05:21 -07:00
Flarnie Marchan
5e80d81f37 High pri - ensure we call timed out callbacks in schedule (#12857)
**what is the change?:**
Fix a typo which caused timed out callbacks to not be called.

**why make this change?:**
This is a bug caught by tests I'm in the process of writing, and we
should fix it asap.

**test plan:**
Tests in a WIP PR - will push and share the WIP test in comments on this
PR.
2018-05-18 10:05:49 -07:00
Brian Vaughn
17908c8ac9 Add test to ensure no duplicate values in ReactSymbols (#12845) 2018-05-18 07:57:25 -07:00
Dan
96992f2a6c Try to fix Windows CI 2018-05-18 09:25:50 +01:00
Pete Nykänen
972d209dcc Fix sample command in scripts/bench/README.md (#12853) 2018-05-18 09:18:35 +01:00
Dan Abramov
40addbd110 Run Flow for each renderer separately (#12846)
* Generate Flow config on install

We'll need to do pre-renderer Flow passes with different configs.
This is the first step to get it working. We only want the original version checked in.

* Create multiple Flow configs from a template

* Run Flow per renderer

* Lint

* Revert the environment consolidation

I thought this would be a bit cleaner at first because we now have non-environment files in this directory.
But Sebastian is changing these files at the same time so I want to avoid conflicts and keep the PR more tightly scoped. Undo.

* Misc
2018-05-18 02:05:19 +01:00
Sebastian Markbåge
40ea053bac Remove incorrect comment
Better to not have it than it being wrong.
2018-05-17 15:47:10 -07:00
Sebastian Markbåge
c5a8dae025 [Fabric] Wire up event emitters (#12847)
I'm exposing a new native method to wire up the event emitter. This will
use a straight fiber pointer instead of react tags to do the dispatching.
2018-05-17 12:38:50 -07:00
Dan Abramov
9d71ef26c3 Run the CI script on Windows 2018-05-17 19:18:47 +01:00
Gary Wang
1a0afed771 getPeerGlobals should check bundleType instead of moduleType (#12839) 2018-05-17 17:16:03 +01:00
Dan Abramov
b245795de3 Re-enable Flow for ReactFiber and fix Flow issues (#12842)
* Lint for untyped imports and enable Flow typing in ReactFiber

* Re-enable Flow for ReactFiber and fix Flow issues

* Avoid an invariant in DEV-only code

I just introduced it, but on a second thought, it's better to keep it as a warning.

* Address review
2018-05-17 17:14:12 +01:00
Flarnie Marchan
7ccb37161f Temporary fix for grabbing wrong rAF polyfill in ReactScheduler (#12837)
* Temporary fix for grabbing wrong rAF polyfill in ReactScheduler

**what is the change?:**
For now...
We need to grab a slightly different implementation of rAF internally at
FB than in Open Source. Making rAF a dependency of the ReactScheduler
module allows us to fork the dependency at FB.

NOTE: After this lands we have an alternative plan to make this module
separate from React and require it before our Facebook timer polyfills
are applied. But want to land this now to keep master in a working state
and fix bugs folks are seeing at Facebook.

Thanks @sebmarkbage @acdlite and @sophiebits for discussing the options
and trade-offs for solving this issue.

**why make this change?:**
This fixes a problem we're running into when experimenting with
ReactScheduler internally at Facebook, **and* it's part of our long term
plan to use dependency injection with the scheduler to make it easier to
test and adjust.

**test plan:**
Ran tests, lint, flow, and will manually test when syncing into
Facebook's codebase.

**issue:**
See internal task T29442940

* ran prettier
2018-05-17 08:57:45 -07:00
Brian Vaughn
4b8510be0f Make REACT_PROFILER_TYPE numeric value unique (#12843) 2018-05-17 08:55:41 -07:00
Dan Abramov
2d20dc47a3 Separate yarn flow and yarn flow-ci (#12841) 2018-05-17 14:29:37 +01:00
Sebastian Markbåge
d4123b4784 Relax current renderer warning (#12838)
If you use an older version of `react` this won't get initialized to null. We don't really need it to be initialized to work.
2018-05-16 17:31:56 -07:00
Brian Vaughn
2ace49362a Removed duplicate feature flag in test (#12836) 2018-05-16 15:39:32 -07:00
Flarnie Marchan
2da155a4c3 Quick fix for minor typo in ReactScheduler (#12834)
**what is the change?:**
We were setting a flag after some early returns, should have set it
right away.

To be fair, it's not clear how you can hit a problem with the current
state of things. Even if a callback is cancelled, it's still in the
'pendingCallbacks' queue until the rAF runs, and we only schedule a rAF
when there are pendingCallbacks in the queue.

But since this is obviously wrong, going to fix it.

We will be adding a regression test in a follow-up PR.

**why make this change?:**
To fix a random bug which was popping up.

**test plan:**
Adding a regression unit test in a follow-up PR.
2018-05-16 14:18:22 -07:00
Brian Vaughn
d6f304e889 Remove Timeout export on React object unless enableSuspense flag (#12833) 2018-05-16 14:02:34 -07:00
Flarnie Marchan
8227e54ccf Quick fix for ReactScheduler type inconsistency (#12828)
**what is the change?:**
In some cases we had defined the 'callback' as taking two arguments,
when really we meant to indicate the second argument passed to
'scheduleWork'.

**why make this change?:**
For correctness and to unblock something @gaearon is working on. A bit
surprised Flow didn't catch this in the first place.

**test plan:**
Ran tests, flow, lint.
2018-05-16 08:07:42 -07:00
Flarnie Marchan
ef294ed6fc Rename Scheduler methods more accurately (#12770)
* Rename Scheduler methods more accurately

**what is the change?:**
```
rIC -> scheduleCallback
```
We will later expose a second method for different priority level, name
TBD. Since we only have one priority right now we can delay the
bikeshedding about the priority names.

cIC -> cancelScheduledCallback
This method can be used to cancel callbacks scheduled at any priority
level, and will remain named this way.

why make this change?:
Originally this module contained a polyfill for requestIdleCallback
and cancelIdleCallback but we are changing the behavior so it's no
longer just a polyfill. The new names are more semantic and distinguish
this from the original polyfill functionality.

**test plan:**
Ran the tests

**why make this change?:**
Getting this out of the way so things are more clear.

**Coming Up Next:**
- Switching from a Map of ids and an array to a linked list for storing
callbacks.
- Error handling

* callback -> work

* update callsites in new places after rebase

* fix typo
2018-05-16 06:36:06 -07:00
Philipp Spieß
49979bbf52 Support Pointer Events (#12507)
* Support Pointer Events

* Add Pointer Events DOM Fixture
2018-05-16 14:34:33 +01:00
Brian Vaughn
de84d5c107 Enable Profiler timing for DOM and RN dev bundles (#12823)
* Enable Profiler timing for DOM and RN dev bundles
* Disable enableProfilerTimer feature flag for ReactIncrementalPerf-test
2018-05-15 15:26:46 -07:00
Sebastian Markbåge
f792275972 Pass instance handle to all Fabric clone methods (#12824)
We might need this in the future if we want to ensure event handler
consistency when an event handler target has been removed before it is
called.
2018-05-15 14:35:13 -07:00
Andrew Clark
a5184b215d Add FB www build of simple-cache-provider (#12822) 2018-05-15 13:21:07 -07:00
Brian Vaughn
103503eb69 Only measure "base" times within ProfileMode (#12821)
* Conditionally start/stop base timer only within Profile mode tree
* Added test to ensure ProfilerTimer not called outside of Profiler root
2018-05-15 12:43:42 -07:00
Dan Abramov
9097f3cdf0 Delete React Call/Return experiment (#12820) 2018-05-15 19:16:29 +01:00
Dan Abramov
d758960116 Tweak comments 2018-05-15 15:42:43 +01:00
Dan Abramov
025d867dce Try another approach at fixing Windows Flow issues 2018-05-15 15:20:15 +01:00
Dan Abramov
fe7890d569 Revert recent Flow changes 2018-05-15 15:03:21 +01:00
Dan Abramov
7ba1abecaa Try to fix Flow issue on Windows (part 5) 2018-05-15 14:55:38 +01:00
Dan Abramov
f2252a2ad4 Try to fix Flow issue on Windows (part 4) 2018-05-15 14:46:58 +01:00
Dan Abramov
b998357f9d Try to fix Flow issue on Windows (part 3) 2018-05-15 14:26:32 +01:00
Dan Abramov
7631024722 Try to fix Flow issue on Windows 2018-05-15 14:07:01 +01:00
Dan Abramov
bb44feb05d Try to fix Flow circular dependency 2018-05-15 13:55:01 +01:00
Dan Abramov
7dc1a176b5 Skip special nodes when reading TestInstance.parent (#12813) 2018-05-15 11:11:19 +01:00
Philipp Spieß
e96dc14059 Use browser event names for top-level event types in React DOM (#12629)
* Add TopLevelEventTypes

* Fix `ReactBrowserEventEmitter`

* Fix EventPluginUtils

* Fix TapEventPlugin

* Fix ResponderEventPlugin

* Update ReactDOMFiberComponent

* Fix BeforeInputEventPlugin

* Fix ChangeEventPlugin

* Fix EnterLeaveEventPlugin

* Add missing non top event type used in ChangeEventPlugin

* Fix SelectEventPlugin

* Fix SimpleEventPlugin

* Fix outstanding Flow issues and move TopLevelEventTypes

* Inline a list of all events in `ReactTestUtils`

* Fix tests

* Make it pretty

* Fix completly unrelated typo

* Don’t use map constructor because of IE11

* Update typings, revert changes to native code

* Make topLevelTypes in ResponderEventPlugin injectable and create DOM and ReactNative variant

* Set proper dependencies for DOMResponderEventPlugin

* Prettify

* Make some react dom tests no longer depend on internal API

* Use factories to create top level speific generic event modules

* Remove unused dependency

* Revert exposed module renaming, hide store creation, and inline dependency decleration

* Add Flow types to createResponderEventPlugin and its consumers

* Remove unused dependency

* Use opaque flow type for TopLevelType

* Add missing semis

* Use raw event names as top level identifer

* Upgrade baylon

This is required for parsing opaque flow types in our CI tests.

* Clean up flow types

* Revert Map changes of ReactBrowserEventEmitter

* Upgrade babel-* packages

Apparently local unit tests also have issues with parsing JavaScript
modules that contain opaque types (not sure why I didn't notice
earlier!?).

* Revert Map changes of SimpleEventPlugin

* Clean up ReactTestUtils

* Add missing semi

* Fix Flow issue

* Make TopLevelType clearer

* Favor for loops

* Explain the new DOMTopLevelEventTypes concept

* Use static injection for Responder plugin types

* Remove null check and rely on flow checks

* Add missing ResponderEventPlugin dependencies
2018-05-15 10:38:50 +01:00
Maxim
1047980dca Remove unused context param from countChildren (#12787) 2018-05-15 10:18:35 +01:00
Timothy Yung
bde4b1659f Delete ReactPerf and ReactDebugTool Stubs (#12809) 2018-05-14 20:28:55 -07:00
Andrew Clark
73f59e6f31 Use global state for hasForceUpdate instead of persisting to queue (#12808)
* Use global state for `hasForceUpdate` instead of persisting to queue

Fixes a bug where `hasForceUpdate` was not reset on commit.

Ideally we'd use a tuple and return `hasForceUpdate` from
`processUpdateQueue`.

* Remove underscore and add comment

* Remove temporary variables
2018-05-14 19:18:47 -07:00
Sophie Alpert
8c747d01cb Use ReactFiberErrorDialog fork for Fabric renderer (#12807) 2018-05-14 18:47:40 -07:00
Timothy Yung
369dd4fb17 Update headers for React Native shims (#12806) 2018-05-15 01:47:47 +01:00
Dan Abramov
45b90d4866 Move renderer host configs into separate modules (#12791)
* Separate test renderer host config

* Separate ART renderer host config

* Separate ReactDOM host config

* Extract RN Fabric host config

* Extract RN host config
2018-05-15 01:12:28 +01:00
Timothy Yung
b2d16047ae Fix Type for ReactNative.NativeComponent (#12805) 2018-05-14 16:36:50 -07:00
Brian Vaughn
c802d29bd1 Use HostContext to warn about invalid View/Text nesting (#12766) 2018-05-14 15:34:01 -07:00
Andrew Clark
c5d3104fc0 Do not fire getDerivedStateFromProps unless props or state have changed (#12802)
Fixes an oversight from #12600. getDerivedStateFromProps should fire
if either props *or* state have changed, but not if *neither* have
changed. This prevents a parent from re-rendering if a deep child
receives an update.
2018-05-14 14:56:48 -07:00
Brian Vaughn
0ba63aa141 Mark React Native and Fabric renderers as @generated (#12801)
Mark React Native and Fabric renderers as @generated
2018-05-14 10:39:30 -07:00
Sophie Alpert
c4abfa4015 Add context provider/consumer to getComponentName (#12778)
RN Inspector uses these.
2018-05-14 10:10:36 -07:00
Sophie Alpert
2a4d2ca7fc Set owner correctly inside forwardRef and context consumer (#12777)
Previously, _owner would be null if you create an element inside forwardRef or inside a context consumer. This is used by ReactNativeFiberInspector when traversing the hierarchy and also to give more info in some warning texts. This also means you'll now correctly get a warning if you call setState inside one of these.

Test Plan: Tim tried it in the RN inspector.
2018-05-14 10:07:31 -07:00
Dan Abramov
72542030cf Use Java version of Google Closure Compiler (#12800)
* makes closure compiler threaded

* Dans PR with a closure compiler java version

* Remove unused dep

* Pin GCC

* Prettier

* Nit rename

* Fix error handling

* Name plugins consistently

* Fix lint

* Maybe this works?

* or this

* AppVeyor

* Fix lint
2018-05-14 17:49:41 +01:00
Dan Abramov
37d12e2916 Update lockfile 2018-05-14 16:20:33 +01:00
Dan Abramov
0470854f55 Split ReactNoop into normal and persistent exports (#12793)
* Copy-paste ReactNoop into ReactNoopPersistent

* Split ReactNoop into normal and persistent exports

* ReactNoopShared -> createReactNoop
2018-05-14 13:57:33 +01:00
Toru Kobayashi
d430e13582 Fix a typo (#12798) 2018-05-14 12:35:20 +01:00
Bartosz Kaszubowski
8506062975 remove unused ES3-specific packages - refs #12716 (#12797) 2018-05-14 11:18:31 +01:00
Dan
7b19f93ab9 Record sizes 2018-05-13 21:12:25 +01:00
Andrew Clark
4b2e65d32e Put recent change to getDerivedStateFromProps behind a feature flag (#12788)
This will allow us to safely ship it at Facebook and get a better idea
for if/how it breaks existing product code.
2018-05-11 18:45:00 -07:00
Filipp Riabchun
4f459bb144 Shallow renderer: pass component instance to setState updater as this (#12784)
* Shallow renderer: pass component instance to setState updater as `this`

* Run prettier
2018-05-11 18:03:08 +01:00
Andrew Clark
b0726e9947 Support sharing context objects between concurrent renderers (#12779)
* Support concurrent primary and secondary renderers.

As a workaround to support multiple concurrent renderers, we categorize
some renderers as primary and others as secondary. We only expect
there to be two concurrent renderers at most: React Native (primary) and
Fabric (secondary); React DOM (primary) and React ART (secondary).
Secondary renderers store their context values on separate fields.

* Add back concurrent renderer warning

Only warn for two concurrent primary or two concurrent secondary renderers.

* Change "_secondary" suffix to "2"

#EveryBitCounts
2018-05-10 18:34:01 -07:00
Andrew Clark
6565795377 Suspense (#12279)
* Timeout component

Adds Timeout component. If a promise is thrown from inside a Timeout component,
React will suspend the in-progress render from committing. When the promise
resolves, React will retry. If the render is suspended for longer than the
maximum threshold, the Timeout switches to a placeholder state.

The timeout threshold is defined as the minimum of:
- The expiration time of the current render
- The `ms` prop given to each Timeout component in the ancestor path of the
thrown promise.

* Add a test for nested fallbacks

Co-authored-by: Andrew Clark <acdlite@fb.com>

* Resume on promise rejection

React should resume rendering regardless of whether it resolves
or rejects.

* Wrap Suspense code in feature flag

* Children of a Timeout must be strict mode compatible

Async is not required for Suspense, but strict mode is.

* Simplify list of pending work

Some of this was added with "soft expiration" in mind, but now with our revised
model for how soft expiration will work, this isn't necessary.

It would be nice to remove more of this, but I think the list itself is inherent
because we need a way to track the start times, for <Timeout ms={ms} />.

* Only use the Timeout update queue to store promises, not for state

It already worked this way in practice.

* Wrap more Suspense-only paths in the feature flag

* Attach promise listener immediately on suspend

Instead of waiting for commit phase.

* Infer approximate start time using expiration time

* Remove list of pending priority levels

We can replicate almost all the functionality by tracking just five
separate levels: the highest/lowest priority pending levels, the
highest/lowest priority suspended levels, and the lowest pinged level.

We lose a bit of granularity, in that if there are multiple levels of
pending updates, only the first and last ones are known. But in practice
this likely isn't a big deal.

These heuristics are almost entirely isolated to a single module and
can be adjusted later, without API changes, if necessary.

Non-IO-bound work is not affected at all.

* ReactFiberPendingWork -> ReactFiberPendingPriority

* Renaming method names from "pending work" to "pending priority"

* Get rid of SuspenseThenable module

Idk why I thought this was neccessary

* Nits based on Sebastian's feedback

* More naming nits + comments

* Add test for hiding a suspended tree to unblock

* Revert change to expiration time rounding

This means you have to account for the start time approximation
heuristic when writing Suspense tests, but that's going to be
true regardless.

When updating the tests, I also made a fix related to offscreen
priority. We should never timeout inside a hidden tree.

* palceholder -> placeholder
2018-05-10 18:09:10 -07:00
Andrew Clark
42a1262375 Update sizes 2018-05-10 18:08:11 -07:00
Brian Vaughn
fc3777b1fe Add Profiler component for collecting new render timing info (#12745)
Add a new component type, Profiler, that can be used to collect new render time metrics. Since this is a new, experimental API, it will be exported as React.unstable_Profiler initially.

Most of the functionality for this component has been added behind a feature flag, enableProfileModeMetrics. When the feature flag is disabled, the component will just render its children with no additional behavior. When the flag is enabled, React will also collect timing information and pass it to the onRender function (as described below).
2018-05-10 15:25:32 -07:00
Flarnie Marchan
a9abd27e4f [schedule] Support multiple callbacks in scheduler (#12746)
* Support using id to cancel scheduled callback

**what is the change?:**
see title

**why make this change?:**
Once we support multiple callbacks you will need to use the id to
specify which callback you mean.

**test plan:**
Added a test, ran all tests, lint, etc.

* ran prettier

* fix lint

* Use object for storing callback info in scheduler

* Wrap initial test in a describe block

* Support multiple callbacks in `ReactScheduler`

**what is the change?:**
We keep a queue of callbacks instead of just one at a time, and call
them in order first by their timeoutTime and then by the order which
they were scheduled in.

**why make this change?:**
We plan on using this module to coordinate JS outside of React, so we
will need to schedule more than one callback at a time.

**test plan:**
Added a boatload of shiny new tests. :)

Plus ran all the old ones.

NOTE: The tests do not yet cover the vital logic of callbacks timing
out, and later commits will add the missing test coverage.

* Heuristic to avoid looking for timed out callbacks when none timed out

**what is the change?:**
Tracks the current soonest timeOut time for all scheduled callbacks.

**why make this change?:**
We were checking every scheduled callback to see if it timed out on
every tick. It's more efficient to skip that O(n) check if we know that
none have timed out.

**test plan:**
Ran existing tests.

Will write new tests to cover timeout behavior in more detail soon.

* Put multiple callback support under a disabled feature flag

**what is the change?:**
See title

**why make this change?:**
We don't have error handling in place yet, so should maintain the old
behavior until that is in place.

But want to get this far to continue making incremental changes.

**test plan:**
Updated and ran tests.

* Hide support for multiple callbacks under a feature flag

**what is the change?:**
see title

**why make this change?:**
We haven't added error handling yet, so should not expose this feature.

**test plan:**
Ran all tests, temporarily split out the tests for multiple callbacks
into separate file. Will recombine once we remove the flag.

* Fix nits from code review

See comments on https://github.com/facebook/react/pull/12743

* update checklist in comments

* Remove nested loop which calls additional timed out callbacks

**what is the change?:**
We used to re-run any callbacks which time out whilst other callbacks
are running, but now we will only check once for timed out callbacks
then then run them.

**why make this change?:**
To simplify the code and the behavior of this module.

**test plan:**
Ran all existing tests.

* Remove feature flag

**what is the change?:**
see title

**why make this change?:**
Because only React is using this, and it sounds like async. rendering
won't hit any different behavior due to these changes.

**test plan:**
Existing tests pass, and this allowed us to recombine all tests to run
in both 'test' and 'test-build' modes.

* remove outdated file

* fix typo
2018-05-09 15:28:13 -07:00
bee0060
3fb8be5c30 Minor fix params description for addPercent function (#12669) 2018-05-07 17:46:42 -07:00
Toru Kobayashi
0bf24cc83e setState returning null and undefined is no-op on the ShallowRenderer (#12756) 2018-05-07 17:31:33 -07:00
Dan Abramov
25dda90c1e Mark context consumers with PerformedWork effect on render (#12729)
* Mark new component types with PerformedWork effect

* Don't do it for ForwardRef

Since this has some overhead and ForwardRef is likely going to be used around context, let's skip it.
We don't highlight ForwardRef alone in DevTools anyway.
2018-05-02 16:35:16 +01:00
Dan Abramov
ad7cd68667 Rename internal property to fix React DevTools (#12727) 2018-05-01 21:04:20 +01:00
Sophie Alpert
200357596a Add error when running jest directly (#12726)
```
$ jest
 FAIL  scripts/jest/dont-run-jest-directly.js
  ● Test suite failed to run

    Don't run `jest` directly. Run `yarn test` instead.

    > 1 | throw new Error("Don't run `jest` directly. Run `yarn test` instead.");
      2 |

      at Object.<anonymous> (scripts/jest/dont-run-jest-directly.js:1:96)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        0.866s
Ran all test suites.
```
2018-05-01 12:46:17 -07:00
Dan Abramov
e0ca51a85d Make React.forwardRef() components discoverable by TestRenderer traversal (#12725) 2018-05-01 19:55:06 +01:00
Toru Kobayashi
7dd4ca2911 Call getDerivedStateFromProps even for setState of ShallowRenderer (#12676) 2018-04-30 17:04:40 +01:00
Dan Abramov
9a9f54720f Remove ES3-specific transforms (#12716) 2018-04-30 14:30:37 +01:00
Airam
dcc854bcc3 prevent removing attributes on custom component tags (#12702) 2018-04-28 20:52:30 +01:00
Dan Abramov
045d4f166d Fix a context propagation bug (#12708)
* Fix a context propagation bug

* Add a regression test
2018-04-28 01:52:48 +01:00
Dan Abramov
7c39328571 Don't bail on new context Provider if a legacy provider rendered above (#12586)
* Don't bail on new context Provider if a legacy provider rendered above

* Avoid an extra variable
2018-04-26 20:59:17 +01:00
Dan Abramov
d883d59863 forwardRef() components should not re-render on deep setState() (#12690)
* Add a failing test for forwardRef memoization

* Memoize forwardRef props and bail out on strict equality

* Bail out only when ref matches the current ref
2018-04-26 19:47:34 +01:00
Heaven
ec57d29941 Remove redundant feature flag in the test due to https://github.com/facebook/react/pull/12117 (#12696) 2018-04-26 18:39:11 +01:00
Flarnie Marchan
9c77ffb444 Dedup conditional in ReactScheduler (#12680)
**what is the change?:**
We had a condition to set either 'performance.now' or 'Date.now' as the
'now' function.

Then later we had another conditional checking again if
'performance.now' was supported, and using it if so, otherwise falling
back to 'Date.now'.

More efficient to just use the 'now' shortcut defined above.

**why make this change?:**
Fewer lines, clearer code.

**test plan:**
Now that we have tests we can run them :)
2018-04-24 08:54:31 -07:00
Andrew Clark
09a14eacd4 Update bundle sizes 2018-04-23 19:38:07 -07:00
Andrew Clark
1673485720 Revert stray console.log 2018-04-23 18:44:14 -07:00
Flarnie Marchan
1e3cd332a0 Remove the 'alwaysUseRequestIdleCallbackPolyfill' feature flag (#12648)
* Remove the 'alwaysUseRequestIdleCallbackPolyfill' feature flag

**what is the change?:**
Removes the feature flag 'alwaysUseRequestIdleCallbackPolyfill', such
that we **always** use the polyfill for requestIdleCallback.

**why make this change?:**
We have been testing this feature flag at 100% for some time internally,
and determined it works better for React than the native implementation.
Looks like RN was overriding the flag to use the native when possible,
but since no RN products are using 'async' mode it should be safe to
switch this flag over for RN as well.

**test plan:**
We have already been testing this internally for some time.

**issue:**
internal task t28128480

* fix mistaken conditional

* Add mocking of rAF, postMessage, and initial test for ReactScheduler

**what is the change?:**
- In all tests where we previously mocked rIC or relied on native
mocking which no longer works, we are now mocking rAF and postMessage.
- Also adds a basic initial test for ReactScheduler.
NOTE -> we do plan to write headless browser tests for ReactScheduler!
This is just an initial test, to verify that it works with the mocked
out browser APIs as expected.

**why make this change?:**
We need to mock out the browser APIs more completely for the new
'ReactScheduler' to work in our tests. Many tests are depending on it,
since it's used at a low level.

By mocking the browser APIs rather than the 'react-scheduler' module, we
enable testing the production bundles. This approach is trading
isolation for accuracy. These tests will be closer to a real use.

**test plan:**
run the tests :)

**issue:**
internal task T28128480
2018-04-23 15:25:46 -07:00
Brian Vaughn
149a34f735 Exposed flushSync on the test renderer (#12672) 2018-04-23 10:27:39 -07:00
Andrew Clark
b548b3cd64 Decouple update queue from Fiber type (#12600)
* Decouple update queue from Fiber type

The update queue is in need of a refactor. Recent bugfixes (#12528) have
exposed some flaws in how it's modeled. Upcoming features like Suspense
and [redacted] also rely on the update queue in ways that weren't
anticipated in the original design.

Major changes:

- Instead of boolean flags for `isReplace` and `isForceUpdate`, updates
have a `tag` field (like Fiber). This lowers the cost for adding new
types of updates.
- Render phase updates are special cased. Updates scheduled during
the render phase are dropped if the work-in-progress does not commit.
This is used for `getDerivedStateFrom{Props,Catch}`.
- `callbackList` has been replaced with a generic effect list. Aside
from callbacks, this is also used for `componentDidCatch`.

* Remove first class UpdateQueue types and use closures instead

I tried to avoid this at first, since we avoid it everywhere else in the Fiber
codebase, but since updates are not in a hot path, the trade off with file size
seems worth it.

* Store captured errors on a separate part of the update queue

This way they can be reused independently of updates like
getDerivedStateFromProps. This will be important for resuming.

* Revert back to storing hasForceUpdate on the update queue

Instead of using the effect tag. Ideally, this would be part of the
return type of processUpdateQueue.

* Rename UpdateQueue effect type back to Callback

I don't love this name either, but it's less confusing than UpdateQueue
I suppose. Conceptually, this is usually a callback: setState callbacks,
componentDidCatch. The only case that feels a bit weird is Timeouts,
which use this effect to attach a promise listener. I guess that kinda
fits, too.

* Call getDerivedStateFromProps every render, even if props did not change

Rather than enqueue a new setState updater for every props change, we
can skip the update queue entirely and merge the result into state at
the end. This makes more sense, since "receiving props" is not an event
that should be observed. It's still a bit weird, since eventually we do
persist the derived state (in other words, it accumulates).

* Store captured effects on separate list from "own" effects (callbacks)

For resuming, we need the ability to discard the "own" effects while
reusing the captured effects.

* Optimize for class components

Change `process` and `callback` to match the expected payload types
for class components. I had intended for the update queue to be reusable
for both class components and a future React API, but we'll likely have
to fork anyway.

* Only double-invoke render phase lifecycles functions in DEV

* Use global state to track currently processing queue in DEV
2018-04-22 23:05:28 -07:00
Nicole Levy
5dcf93d146 Validate props on context providers (#12658)
* checkPropTypes in updateContextProvider

* invalid “prop”

* `type not `types` .. :l

* test

* don’t need extra check with no spelling mistake (:

* change error message to specifically address provider

* don’t need class, add extra render to make sure good props go through

* nitpicky rename

* prettier

* switch to `Context.Provider`

* add stack to warning, add extra undefined check

* separate dev check

* add stack to test

* more efficient

* remove unused function

* prettier

* const to top
2018-04-22 13:39:38 +01:00
Dan Abramov
c040bcbea8 Add server integration tests for new context (#12654)
* Add server integration tests for new context

* Pretty please

* Remove unused
2018-04-21 21:21:05 +01:00
Flarnie Marchan
999b656ed1 Initial commit (#12624)
This is the first step - pulling the ReactDOMFrameScheduling module out
into a separate package.

Co-authored-by: Brandon Dail <aweary@users.noreply.github.com>
2018-04-19 09:29:08 -07:00
Brian Vaughn
f80bbf88e5 StrictMode should not warn about polyfilled getSnapshotBeforeUpdate (#12647)
* Installed 3.x release of react-lifecycles-compat
* Updated ReactComponentLifeCycle-test and ReactDOMServerLifecycles-test to cover both polyfilled lifecycles in StrictMode
* Updated StrictMode warnings to not warn about polyfilled getSnapshotBeforeUpdate
2018-04-19 09:08:44 -07:00
Brian Vaughn
920f30ef77 Add forwardRef DEV warning for prop-types on render function (#12644) 2018-04-18 16:36:31 -07:00
Brian Vaughn
0887c7d56c Fork React Native renderer into FB and OSS bundles (#12625)
* Added new "native-fb" and "native-fabric-fb" bundles.
* Split RN_DEV and RN_PROD bundle types into RN_OSS_DEV, RN_OSS_PROD, RN_FB_DEV, and RN_FB_PROD. (This is a bit redundant but it seemed the least intrusive way of supporting a forked feature flags file for these bundles.)
* Renamed FB_DEV and FB_PROD bundle types to be more explicitly for www (FB_WWW_DEV and FB_WWW_PROD)
* Removed Haste @providesModule headers from the RB-specific RN renderer bundles to avoid a duplicate name conflicts.
* Remove dynamic values from OSS RN feature flags. (Leave them in FB RN feature flags.)
* Updated the sync script(s) to account for new renderer type.
* Move ReactFeatureFlags.js shim to FB bundle only (since OSS bundle no longer needs dynamic values).
2018-04-18 13:16:50 -07:00
Sebastian Markbåge
039695cc01 [RN] Update Secret Types (#12635) 2018-04-17 19:21:46 -07:00
Dan Abramov
b05e67e36a Bump Prettier (#12622) 2018-04-17 01:43:55 +01:00
Brian Vaughn
77ebeb1b09 Don't git commit noop-renderer unless package deps change (#12623) 2018-04-16 09:46:39 -07:00
Heaven
b85c5cd188 remove duplicate code in test (#12620) 2018-04-16 16:36:49 +01:00
Dan Abramov
01402f4ad9 Add 16.3.2 changelog (#12621) 2018-04-16 16:31:48 +01:00
Dan Abramov
3232616348 Update bundle sizes for 16.3.2 release 2018-04-16 16:23:13 +01:00
Dan Abramov
6494f6b6b8 Update error codes for 16.3.2 release 2018-04-16 16:23:12 +01:00
Dan Abramov
82f67d65fd Updating package versions for release 16.3.2 2018-04-16 16:14:28 +01:00
Dan Abramov
66c44a7bc3 Updating yarn.lock file for 16.3.2 release 2018-04-16 16:12:35 +01:00
Floris Doolaard
1e97a71a82 Fix documentation of the release process (#12337)
* Adusted grammar in release script readme.

* Adjusts title and explanation about the release process.
2018-04-16 15:45:13 +01:00
Alex Zherdev
2e1cc28027 Fix small typos in create-subscription readme (#12399) 2018-04-16 15:44:38 +01:00
Rauno Freiberg
a4cef29703 tests: add regression test for reading ReactCurrentOwner stateNode (#12412)
* tests: add regression test for reading ReactCurrentOwner stateNode

* tests: replace expect with just rendering the component
2018-04-16 15:44:17 +01:00
Dan Abramov
1591c8ebab Update GCC (#12618) 2018-04-16 15:42:10 +01:00
Brian Vaughn
5dfbfe9da7 Fixed debug performance labels for new component types (#12609)
* Added new debug performance tests for AsyncMode, StrictMode, forwardRef, and context provider/consumer components.
* Updated performance labels to exclude AsyncMode and StrictMode.
* Added labels for forwardRef (and inner function) that mirror DevTools labels.
2018-04-12 09:39:05 -07:00
Dan Abramov
c27a99812e [Danger] Minor fixes (#12606)
* Don't download bundle stats from master on CI

This was temporarily necessary in the past because we didn't have the logic that downloads actual *merge base* stats.

We do have that now as part of the Danger script. So we can remove this.

* Use absolute threshold for whether to show a change

* Download master stats, but only for other master builds

* Rewrite sizes
2018-04-11 18:46:02 +01:00
Flarnie Marchan
915bb5321a Bump expiration for interactive updates to 150ms in production (#12599)
* Bump expiration for interactive updates to 150ms in production

**what is the change?:**
Changes the expiration deadline from 500ms to 150ms, only in production.
In development it will still be 500ms.

I'm thinking we may want to change the 'bucket size' too, will look into
that a bit.

**why make this change?:**
We need to ensure interactions are responsive enough in order to gather
more test data on async. mode.

**test plan:**
No tests failed - where shall we add a test for this?

* Add comments
2018-04-11 07:27:16 -07:00
Dan Abramov
3e9515eede Remove @providesModule in www shims 2018-04-10 16:53:36 +01:00
Brian Vaughn
b8461524db Added UMD build to test renderer package (#12594) 2018-04-10 07:49:19 -07:00
Steven Frieson
3eae866e03 Fixes language in error message. (#12590) 2018-04-10 15:09:45 +01:00
Sebastian Markbåge
52afbe0ebb createReactNativeComponentClass needs to be CommonJS
oops
2018-04-09 20:41:49 -07:00
Sebastian Markbåge
725c054d4d Refactor findHostInstance and findNodeHandle (#12575)
* Move findNodeHandle into the renderers and use instantiation

This is just like ReactDOM does it. This also lets us get rid of injection
for findNodeHandle. Instead I move NativeMethodsMixin and ReactNativeComponent
to use instantiation.

* Refactor findHostInstance

The reconciler shouldn't expose the Fiber data structure. We should pass
the component instance to the reconciler, since the reconciler is the
thing that is supposed to be instancemap aware.

* Fix devtools injection
2018-04-09 20:15:10 -07:00
Sebastian Markbåge
b99d0b1416 [RN] Move view config registry to shims (#12569)
* Move view config registry to shims

This ensures that both Fabric and RN renderers share the same view config
registry since it is stateful.

I had to duplicate in the mocks for testing.

* Move createReactNativeComponentClass to shims and delete internal usage

Since createReactNativeComponentClass is just an alias for the register
there's no need to bundle it. This file should probably just move back
to RN too.
2018-04-09 20:05:57 -07:00
Sebastian Markbåge
b6e0512a81 Consolidate eventTypes registry with view configs (#12556)
We already have one stateful module that contains all the view config.
We might as well store the event types there too. That way the shared
state is compartmentalized (and I can move it out in a follow up PR).

The view config registry also already has an appropriate place to call
processEventTypes so now we no longer have to do it in RN.

Will follow up with a PR to RN to remove that call.
2018-04-09 19:42:23 -07:00
Sebastian Markbåge
40d07724fc [RN] Remove unstable_batchedUpdates and unmountComponentAtNodeAndRemoveContainer from Fabric (#12571)
These don't make much sense in Fabric, since Fabric will be async by default only.

And unmount+remove container is a sketchy API we should remove so we might
as well make sure modern containers enforce that.
2018-04-09 19:36:13 -07:00
Sebastian Markbåge
933f882a9d Remove ReactNativePropRegistry (#12559)
This has always been an unnecessary indirection to protect opaqueness,
which hasn't really worked out.
2018-04-09 19:02:46 -07:00
Sebastian Markbåge
2f7bca0eb2 Allocate unique reactTags for RN and Fabric (#12587)
Took this opportunity to remove some abstract overhead.

In Fabric it is extra simple since they no longer overlap with root tags.
2018-04-09 18:41:13 -07:00
Nicole Levy
f88deda83b Throw more specific error if passed undefined in React.cloneElement (#12534)
* throw error if passed undefined

* should be TypeError

* simplify

* use invariant

* editor messed up spacing

* better check

* Revert "better check"

This reverts commit 273370758eafa54d329577b3dc942c70587eccd3.

* yarn prettier test was failing

* more explicit copy

* es6 import

* tests

* formatting

* Move import
2018-04-10 02:16:36 +01:00
Dan Abramov
8dfb057881 Unfork invariant and instead use it from reactProdInvariant (#12585) 2018-04-09 23:58:34 +01:00
Dan Abramov
76b4ba0129 Preserve error codes for invariants on www (#12539)
* Preserve error codes for invariants on www

* Remove unintentional change
2018-04-09 18:57:52 +01:00
Rafael Hovhannisyan
ea37545037 Must be *a* before PlacementAndUpdate (#12580) 2018-04-08 18:29:37 +01:00
Heaven
20c5d97bb6 Keep consistency in the comment (#12579) 2018-04-08 17:29:02 +01:00
Sebastian Markbåge
181747a6cc [RN] Move takeSnapshot to RN (#12574)
It only uses public APIs. I have a diff on the other side.
2018-04-07 23:13:34 -07:00
Sebastian Markbåge
bc753a716e Support findNodeHandle in Fabric (#12573)
This doesn't actually need to share any state because it goes through
the instance to the fiber structure. Since Fabric is on the same version
as RN, calling it on either renderer works.
2018-04-07 22:33:49 -07:00
Sebastian Markbåge
6bf2797d6c Remove flushSync from React Native (#12565)
There are no plans to enable async in the old renderer. In the new renderer
it only really makes sense to do from the main thread and probably from
native since it'll have to yield to native first.
2018-04-06 17:10:16 -07:00
Sebastian Markbåge
5b16b39508 Bug fix 2018-04-06 14:26:00 -07:00
Sebastian Markbåge
cf649b40a5 Move TouchHistoryMath to React Native repo (#12557)
This isn't used by React core and is just a pure helper so it might as
well live where it's used. The React Native repo.
2018-04-05 20:29:04 -07:00
Sebastian Markbåge
7a3416f275 Expose component stack from reactTag to React Native renderer (#12549)
This is not safe in general and therefore shouldn't be exposed to anything
other than React Native internals.

It will also need a different version in Fabric that will not have the
reactTag exposed.
2018-04-04 17:18:44 -07:00
Nicole Levy
27535e7bfc Clarify ReactDOM's case warning for html tags (#12533)
* update warning text

* update tests to match

* `yarn prettier`

* include note on HTML5 custom elements

* dan’s copy suggestion

* remove ‘letters’
2018-04-04 22:21:06 +01:00
Brian Vaughn
8ec0e4a99d Removed Array.from() usage (#12546) 2018-04-04 13:54:27 -07:00
Brian Vaughn
d328e362e8 Removed duplicate typeof check (#12541) 2018-04-04 13:30:48 -07:00
Dan Abramov
e932e321a8 facebook.github.io/react -> reactjs.org (#12545) 2018-04-04 21:20:41 +01:00
Dan Abramov
5e3706cca0 Don't render bitmask-bailing consumers even if there's a deeper matching child (#12543)
* Don't render consumers that bailed out with bitmask even if there's a deeper matching child

* Use a render prop in the test

Without it, <Indirection> doesn't do anything because we bail out on constant element anyway.
That's not what we're testing, and could be confusing.
2018-04-04 19:44:14 +01:00
Dan Abramov
1c2876d5b5 Add a build step to hoist warning conditions (#12537) 2018-04-04 17:04:40 +01:00
Dan Abramov
b15b165e07 Changelog for 16.3.1 2018-04-04 01:35:36 +01:00
Dan Abramov
dc059579c3 Update bundle sizes for 16.3.1 release 2018-04-04 01:33:06 +01:00
Dan Abramov
787b343f67 Updating package versions for release 16.3.1 2018-04-04 01:22:30 +01:00
Dan Abramov
2279843ef9 Updating yarn.lock file for 16.3.1 release 2018-04-04 01:20:48 +01:00
Dan Abramov
a2cc3c38e2 Follow up: make new warning less wordy (#12532) 2018-04-03 21:56:21 +01:00
Dan Abramov
36c2939372 Improve not-yet-mounted setState warning (#12531)
* Tweak not-yet-mounted setState warning

* Add \n\n
2018-04-03 21:22:44 +01:00
Andrew Clark
0f2f90bd9a getDerivedStateFrom{Props,Catch} should update updateQueue.baseState (#12528)
Based on a bug found in UFI2.

There have been several bugs related to the update queue (and
specifically baseState) recently, so I'm going to follow-up with some
refactoring to clean it up. This is a quick fix so we can ship a
patch release.
2018-04-03 13:02:46 -07:00
Dan Abramov
da4e85567b Remove @providesModule in www bundles (#12529) 2018-04-03 20:12:29 +01:00
Brian Vaughn
eb6e752cab Bumped create-subscription package version (#12526) 2018-04-03 11:06:52 -07:00
Mateusz Burzyński
ba245f6f9b Prefix _context property on returned ReactContext from createContext - it's private (#12501) 2018-04-03 01:47:25 +01:00
Andrew Clark
6f2ea73978 Extract throw to separate function so performUnitOfWork does not deopt (#12521)
Only affects DEV mode, but still important I think.
2018-04-03 01:45:52 +01:00
Dan Abramov
4ccf58a94d Fix context stack misalignment caused by error replay (#12508)
* Add regression tests for error boundary replay bugs

* Ensure the context stack is aligned if renderer throws

* Always throw when replaying a failed unit of work

Replaying a failed unit of work should always throw, because the render
phase is meant to be idempotent, If it doesn't throw, rethrow the
original error, so React's internal stack is not misaligned.

* Reset originalReplayError after replaying

* Typo fix
2018-04-03 00:08:30 +01:00
Flarnie Marchan
7a27ebd52a Update user timing to record when we are about to commit (#12384)
* Update user timing to record when we are about to commit

**what is the change?:**
After repeatedly logging '(React Tree Reconciliation)' we vary the
message slightly for the last reconciliation, which happens right before
we commit.

**why make this change?:**
When debugging performance in the devtools it will be helpful if we can
quickly see where the 'commit' happens in a potentially long list of
sliced '(React Tree Reconciliation)' logs.

**test plan:**
Built and ran one of the fixtures. Also ran the unit test.

(Flarnie will insert a screenshot)

* Ran prettier

* Fixes in response to code review

* Update snapshot tests

* Move isWorking assignment out of branches to top

* Stricter type for stopWorkLoopTimer args
2018-04-02 15:27:33 -07:00
Dan Abramov
6b99c6f9d3 Add missing changelog item 2018-04-02 16:07:16 +01:00
Dan Abramov
59dac9d7a6 Fix DEV performance regression by avoiding Object.assign on Fibers (#12510)
* Fix DEV performance regression by avoiding Object.assign on Fibers

* Reduce allocations in hot path by reusing the stash

Since performUnitOfWork() is not reentrant, it should be safe to reuse the same stash every time instead of creating a new object.
2018-04-01 19:10:37 +01:00
heikkilamarko
0c80977061 Validate React.Fragment props without Map. (#12504) 2018-04-01 01:14:36 +01:00
Minh Nguyen
fa8e67893f Change create-subscription's peerDep on react to ^16.3.0 (#12496) 2018-03-30 14:49:34 -07:00
Dan Abramov
59b39056d9 Fix method name in changelog 2018-03-29 23:27:06 +01:00
Dan Abramov
18ba36d891 Move context API in Changelog to "React" section 2018-03-29 23:19:53 +01:00
Dan Abramov
43044757e5 Fix links 2018-03-29 22:08:20 +01:00
Dan Abramov
2c3f5fb97b Add React 16.3.0 changelog (#12488) 2018-03-29 21:56:45 +01:00
Brian Vaughn
8e3d94ffa1 Update bundle sizes for 16.3.0 release 2018-03-29 13:07:12 -07:00
Brian Vaughn
9778873143 Updating dependencies for react-noop-renderer 2018-03-29 13:03:33 -07:00
Brian Vaughn
b2379d4cbe Updating package versions for release 16.3.0 2018-03-29 13:03:33 -07:00
Brian Vaughn
6294b67a40 unstable_createRoot (#12487)
* Removed enableCreateRoot flag. Renamed createRoot to unstable_createRoot

* ReactDOMRoot test is no longer internal
2018-03-29 12:51:34 -07:00
Dan Abramov
8650d2a135 Disable createRoot for open source builds (#12486) 2018-03-29 20:25:20 +01:00
Brian Vaughn
53fdc19df0 Updated react-is README to show new isValidElementType() 2018-03-29 11:46:18 -07:00
James Reggio
96fe3b1be2 Add React.isValidElementType() (#12483)
* Add React.isValidElementType()

Per the conversation on #12453, there are a number of third-party
libraries (particularly those that generate higher-order components)
that are performing suboptimal validation of element types.

This commit exposes a function that can perform the desired check
without depending upon React internals.

* Move isValidElementType to shared/
2018-03-29 11:45:41 -07:00
Flarnie Marchan
125dd16ba0 Update user timing to record the timeout deadline with 'waiting' events (#12479)
* Update user timing to record the timeout deadline with 'waiting' events

**what is the change?:**
When we are processing work during reconciliation, we have a "timeout"
deadline to finish the work. It's a safety measure that forces things to
finish up synchronously if they are taking too long.

The "timeout" is different depending on the type of interaction which
triggered the reconciliation. We currently have a shorter "timeout" for
"interactive updates", meaning we will try to finish work faster if the
reconciliation was triggered by a click or other user interaction.

For collecting more data in our logs we want to differentiate the
'waiting for async callback...' events based on the "timeout" so I'm
adding that to the logging.

One interesting note - in one of the snapshot tests the "timeout" was
super high. Going to look into that.

**why make this change?:**
Right now we are debugging cases where an interaction triggers a
reconciliation and the "waiting for async callback...' events are too
long, getting blocked because the main thread is too busy. We are
keeping logs of these user timing events and want to filter to focus on
the reconciliation triggered by interaction.

**test plan:**
Manually tested and also updated snapshot tests.

(Flarnie will insert a screenshot)

* Improve wording of message

* ran prettier
2018-03-29 11:26:11 -07:00
Dustan Kasten
15e3dffb4c Don't bail out on referential equality of Consumer's props.children function (#12470)
* Test case for React Context bailing out unexpectedly

* This is 💯% definitely not the correct fix at all

* Revert "This is 💯% definitely not the correct fix at all"

This reverts commit 8686c0f6bdc1cba3056fb2212f3f7740c749d33a.

* Formatting + minor tweaks to the test

* Don't bail out on consumer child equality

* Tweak the comment

* Pretty lint

* Silly Dan
2018-03-29 19:16:02 +01:00
Sophie Alpert
5855e9f215 Improve warning message for setState-on-unmounted (#12347)
This is one of the most common warnings people see, and I don't think the old text is especially clear. Improve it.
2018-03-29 16:21:22 +01:00
Dan Abramov
7a833dad95 setState() in componentDidMount() should flush synchronously even with createBatch() (#12466)
* Add a failing test for setState in cDM during batch.commit()

* Copy pasta

* Flush all follow-up Sync work on the committed batch

* Nit: Use performSyncWork

Call performSyncWork right after flushing the batch. Does effectively
the same thing by reusing the existing function.

Also added some comments.

* Delete accidentally duplicated test
2018-03-29 02:41:42 +01:00
Andrew Clark
c44665e832 Fix bug when fatal error is thrown as a result of batch.commit (#12480)
Fixes #12474
2018-03-28 18:18:09 -07:00
Andrew Clark
268a3f60df Add unstable APIs for async rendering to test renderer (#12478)
These are based on the ReactNoop renderer, which we use to test React
itself. This gives library authors (Relay, Apollo, Redux, et al.) a way
to test their components for async compatibility.

- Pass `unstable_isAsync` to `TestRenderer.create` to create an async
renderer instance. This causes updates to be lazily flushed.
- `renderer.unstable_yield` tells React to yield execution after the
currently rendering component.
- `renderer.unstable_flushAll` flushes all pending async work, and
returns an array of yielded values.
- `renderer.unstable_flushThrough` receives an array of expected values,
begins rendering, and stops once those values have been yielded. It
returns the array of values that are actually yielded. The user should
assert that they are equal.

Although we've used this pattern successfully in our own tests, I'm not
sure if these are the final APIs we'll make public.
2018-03-28 14:57:25 -07:00
Brian Vaughn
c1b21a746c Added DEV warning if getSnapshotBeforeUpdate is defined as a static method (#12475) 2018-03-28 13:35:32 -07:00
Nikolay
488ad5a6b9 Fix typo in create-subscription readme
PR: #12473
2018-03-28 08:51:16 -04:00
Brian Vaughn
c2c3c0cc36 Fix build script to handle react-is (no peer deps) (#12471) 2018-03-27 19:19:34 -07:00
Brian Vaughn
b3d883630c Update bundle sizes for 16.3.0-rc.0 release 2018-03-27 19:11:20 -07:00
Brian Vaughn
80ddd15b72 Updating dependencies for react-noop-renderer 2018-03-27 19:07:53 -07:00
Brian Vaughn
61444a415b Updating package versions for release 16.3.0-rc.0 2018-03-27 19:07:53 -07:00
Andrew Clark
ff32420e57 Caveat about async in create-subscription README (#12469)
* Caveat about async in create-subscription README

* Address Sophie's comments

* Dan's nits
2018-03-27 16:50:12 -07:00
Brian Vaughn
ad5273d348 Call getSnapshotBeforeUpdate before mutation (#12468)
* Call getSnapshotBeforeUpdate in separate traversal, before mutation (aka revert db84b9a) and add unit test.

* Added a new timer to ReactDebugFiberPerf for Snapshot effects
2018-03-27 15:37:13 -07:00
Brian Vaughn
90c41a2e56 Rename react-is import alias in FB bundles (#12459) 2018-03-27 08:57:11 -07:00
Brian Vaughn
718d0d21f2 Include react-is in FB build targets (#12458) 2018-03-26 16:56:06 -07:00
Brian Vaughn
e1a106a071 New commit phase lifecycle: getSnapshotBeforeUpdate (#12404)
* Implemented new getSnapshotBeforeUpdate lifecycle
* Store snapshot value from Fiber to instance (__reactInternalSnapshotBeforeUpdate)
* Use commitAllHostEffects() traversal for getSnapshotBeforeUpdate()
* Added DEV warnings and tests for new lifecycle
* Don't invoke legacy lifecycles if getSnapshotBeforeUpdate() is defined. DEV warn about this.
* Converted did-warn objects to Sets in ReactFiberClassComponent
* Replaced redundant new lifecycle checks in a few methods
* Check for polyfill suppress flag on cWU as well before warning
* Added Snapshot bit to HostEffectMask
2018-03-26 13:28:10 -07:00
Brian Vaughn
e9ba8ec866 Workaround jest-diff single line string limitation (#12456) 2018-03-26 10:48:36 -07:00
Jason Quense
dadafd6bd8 Remove dependency on React (#12448)
Is this necessary? I'd like to use the package in enzyme to avoid having to recopy/paste the symbols for better debugging names, but at hard dep in enzyme proper on a version of react isn't gonna work. This seems safe since nothing explicitly depends on React in here?
2018-03-24 16:59:36 +00:00
Dan Abramov
7d31311de3 Don't pass a Fiber to showErrorDialog() (#12445)
* Don't pass a Fiber to showErrorDialog()

* Only fill in the fields for classes

* Reorder for clarity
2018-03-23 21:52:53 +00:00
Maël Nison
1bab82a9de Tweaks the build script (#12444)
Branch: build-tweaks
2018-03-23 19:51:04 +00:00
Maël Nison
cc616b01fc Adds semver to the package dev dependencies (#12442)
Branch: semver
2018-03-23 19:31:16 +00:00
Rene Hangstrup Møller
1a71c4de13 Rename bits to unstable_observedBits (#12440) 2018-03-23 15:58:49 +00:00
Brian Vaughn
cafee5cb2f Update bundle sizes for 16.3.0-alpha.3 release 2018-03-22 12:45:10 -07:00
Brian Vaughn
3cdb5780d4 Updating dependencies for react-noop-renderer 2018-03-22 12:41:43 -07:00
Brian Vaughn
02d4e5dd39 Updating package versions for release 16.3.0-alpha.3 2018-03-22 12:41:43 -07:00
Brian Vaughn
8c20615b06 Removed dev warnings from shallow renderer. (#12433) 2018-03-22 11:32:37 -07:00
Brian Vaughn
c1308adb4b Expanded DEV-only warnings for gDSFP and legacy lifecycles (#12419) 2018-03-22 11:16:54 -07:00
Dan Abramov
0af384b4c3 Warn about non-static getDerivedStateFromProps/Catch (#12431) 2018-03-22 17:54:51 +00:00
Dan Abramov
12687ff331 Use "Component" as fallback name in more places (#12430) 2018-03-22 17:26:46 +00:00
Dan Abramov
dcbb4301f0 Add a fallback component name for warnings (#12429) 2018-03-22 17:22:13 +00:00
Brian Vaughn
40fa616053 Subscriptions shouldn't call setState after unmount even for Promises (#12425) 2018-03-22 08:54:57 -07:00
Rajendra arora
f94a6b4fed Removed documentation badge from readme.md (#12424)
* Added badge for react documentation

* Updated reference documentation link for badge

* Update README.md

* Update README.md

* Update README.md

* Removed reference badge from Readme.md
2018-03-22 15:48:52 +00:00
Brian Vaughn
dc48326cd5 Fixed a batched-state update bug with getDerivedStateFromProps (#12408) 2018-03-21 11:42:52 -07:00
Rajendra arora
c6b7cea343 Added badge for react documentation (#12191)
* Added badge for react documentation

* Updated reference documentation link for badge
2018-03-21 13:05:02 -04:00
Dan Abramov
3553489f7b Fix now-missing errorInfo argument to componentDidCatch() (#12416)
* Add a failing test verifying componentInfo is missing

* Pass componentInfo to componentDidCatch and getDerivedStateFromCatch

* Only expect stack in DEV

* Don't pass the stack to getDerivedStateFromCatch()
2018-03-21 16:38:24 +00:00
Léo Andrès
3ed6483e14 Clean shell scripts (#12365) 2018-03-21 12:03:09 -04:00
Barry Michael Doyle
f9377c1762 Replaced object building loop with Object.assign function (#12414) 2018-03-21 09:45:45 -04:00
Vasiliy
33eddbc0c8 Fix falling in dev mode (#12407)
FiberNode stateNode could be null

So I get TypeError:

```
  at performWorkOnRoot (/tmp/my-project/node_modules/react-dom/cjs/react-dom.development.js:11014:24) TypeError: Cannot read property '_warnedAboutRefsInRender' of null
          at findDOMNode (/tmp/my-project/node_modules/react-dom/cjs/react-dom.development.js:15264:55)
```
2018-03-21 09:41:50 +00:00
Dan Abramov
ab4dc50146 Fix Prettier 2018-03-21 09:41:23 +00:00
Kevin Gozali
9d484edc4b [fabric] register ReactFabric to be callable module (#12405) 2018-03-20 14:56:18 +00:00
Dan Abramov
8d09422424 Fix an infinite loop in new context (#12402)
* Add a regression test for the context infinite loop

* Fix the bug

We set .return pointer inside the loop, but the top-level parent-child relationship happens outside.

This ensures the top-level parent's child points to the right copy of the parent.

Otherwise we may end up in a situation where (workInProgress === nextFiber) is never true and we loop forever.
2018-03-20 13:06:59 +00:00
Jason Quense
e1ff342bf7 Support ForwardRef type of work in TestRenderer (#12392)
* Support ForwardRef type of work in TestRenderer and ShallowRenderer.
* Release script now updates inter-package dependencies too (e.g. react-test-renderer depends on react-is).
2018-03-16 11:18:50 -07:00
Andrew Clark
7e87df8090 Feature flag: Use custom requestIdleCallback even when native one exists (#12385)
We'll use this in www to test whether the polyfill is better at
scheduling high-pri async work than the native one. My preliminary tests
suggest "yes" but it's hard to say for certain, given how difficult it
is to consistently reproduce the starvation issues we've been seeing.
2018-03-15 19:28:21 -07:00
Andrew Clark
208b490ed9 Unify context stack implementations (#12359)
* Use module pattern so context stack is isolated per renderer

* Unify context implementations

Implements the new context API on top of the existing ReactStack that we
already use for host context and legacy context. Now there is a single
array that we push and pop from.

This makes the interrupt path slightly slower, since when we reset the
unit of work pointer, we have to iterate over the stack (like before)
*and* switch on the type of work (not like before). On the other hand,
this unifies all of the unwinding behavior in the UnwindWork module.

* Add DEV only warning if stack is not reset properly
2018-03-15 19:27:44 -07:00
Brian Vaughn
2738e84805 Removed an unnecessary wrapper object from state (#12383)
* Removed an unnecessary wrapper object from state
* Moved unsubscribe from state to class field and tweaked comments
2018-03-15 11:43:01 -07:00
Roman Hotsiy
d38616d693 Fix typo in unexpected ref object warning (#12377) 2018-03-15 12:30:50 +00:00
Brian Vaughn
ced176edb7 Updated create-subscription description 2018-03-14 15:39:38 -07:00
Brian Vaughn
ccec542ad3 Update bundle sizes for 16.3.0-alpha.2 release 2018-03-14 13:26:40 -07:00
Brian Vaughn
45300e8e5b Update error codes for 16.3.0-alpha.2 release 2018-03-14 13:26:40 -07:00
Brian Vaughn
da0fbe78b6 Updating dependencies for react-noop-renderer 2018-03-14 13:23:21 -07:00
Brian Vaughn
3961b8c7e7 Updating package versions for release 16.3.0-alpha.2 2018-03-14 13:23:21 -07:00
Brian Vaughn
64136f300d Updating yarn.lock file for 16.3.0-alpha.2 release 2018-03-14 13:21:11 -07:00
Brian Vaughn
bc70441c8b RFC #30: React.forwardRef implementation (#12346)
Added React.forwardRef support to react-reconciler based renders and the SSR partial renderer.
2018-03-14 13:07:58 -07:00
Brian Vaughn
77196100b8 Renamed createRef .value attribute to .current (#12375)
* Renamed createRef .value attribute to .current

* Warn if invalid ref object is passed
2018-03-14 09:43:20 -07:00
Andrew Clark
9d24a81054 resumeMountClassComponent should check for mount lifecycles, not update (#12371)
We have other tests that would have caught this if resuming were enabled
in all cases, but since it's currently only enabled for error
boundaries, the test I've added to prevent a regression is a
bit contrived.
2018-03-13 16:36:31 -07:00
Brian Vaughn
00a0e3c14f create-subscription (#12325)
create-subscription provides an simple, async-safe interface to manage a subscription.
2018-03-13 13:59:09 -07:00
Andrew Clark
ad9544f48e Prefix internal context properties with underscore (#12358)
So these aren't mistaken for public properties. Ideally, we'd use
symbols or private fields.
2018-03-12 14:30:47 -07:00
Andrew Clark
551a0765de Add unstable prefix to observedBits prop until its proven to work in practice (#12357) 2018-03-12 13:57:33 -07:00
Andrew Clark
c7f364d95b Context providers and consumers should bailout on already finished work (#12254)
* Context providers and consumers should bail-out on already finished work

Fixes bug where a consumer would re-render even if its props and context
had not changed.

* Encode output as JSON string

* Add weights to random action generator

* Add context to triangle fuzz tester

* Move bailouts to as early as possible

* Bailout if neither context value nor children haven't changed (sCU)

* Change prop type invariant to a DEV-only warning
2018-03-12 13:39:18 -07:00
Brandon Dail
280acbcb71 Initialize React prop name/attribute name mapping without Map (#12353)
Using `new Map(iterable)` isn't supported in IE11, so it ends up trying to iterate through an empty map and these attributes don't get defined in properties. Since this is only run once on startup inlining the attributeName array is probably fine.
2018-03-12 17:42:17 +00:00
Timothy Yung
fcc4f52cdd Remove DefaultProps type parameter from ReactNativeComponent (#12332) 2018-03-06 17:45:45 -08:00
Brian Emil Hartz
399b14d190 added link to reactjs docs for test renderer (#12293)
* add link to reactjs doc for test renderer

* add documentation clarification
2018-03-03 22:25:29 -05:00
Kiho · Cham
049fe7d6fd annotation typo (#12272)
* comment typo

* change after then to after that
2018-03-03 22:24:33 -05:00
Sophie Alpert
1d220ce0b7 Bug fix: SSR setState in diff components don't mix (#12323)
Previously, the `queue` and `replace` arguments were leaking across loops even though they should be captured.
2018-03-03 10:27:57 -08:00
Gustavo Saiani
373a33f9d3 Fix comment type in ReactElement (#12314) 2018-03-03 13:13:16 -05:00
Andrew Clark
2cf9063318 createResource returns an object with methods instead of a read function (#12304)
Changes `createResource` to return an object with `read` and `preload`
methods. Future methods may include `set`, `subscribe`, `invalidate`,
and so on.
2018-02-28 10:17:03 -08:00
Andrew Clark
86d04f6ea2 Do not clear errors after they are thrown (#12303)
Instead, to trigger a retry, the consumer should invalidate the cache.

In the future, we will likely add a way to invalidate only the failed
records.
2018-02-27 20:02:43 -08:00
Sebastian Markbåge
ab4280b3e9 Don't expose ReactGlobalSharedState on React Native renderer (#12298)
* Don't expose ReactGlobalSharedState on React Native renderer

We should just go through the "react" package if need access to this one.

Removed the dependencies in React Native.

* No longer used by InspectorUtils
2018-02-27 07:57:50 -08:00
Sebastian Markbåge
db47031e63 [Persistent] Finalize children after we've actually inserted them (#12300)
The order of this was wrong. We also unconditionally mark for updates so
killed that unused branch.
2018-02-26 23:34:53 -08:00
Andrew Clark
8e5f12ca6c Fixes bug when initial mount of a host component is hidden (#12294)
`oldProps` was null. This went uncaught by the unit tests because
ReactNoop did not use `oldProps` in either `prepareUpdate` or
`completeUpdate`. I added some invariants so we don't regress in
the future.
2018-02-26 17:50:07 -08:00
Brandon Dail
2f5eaccb4c Revert "Temporarily disable Danger in CI" (#12296)
* Revert "Replace danger token with a refreshed facebook-open-source-bot token (#12295)"

This reverts commit 2d511479c4.

* Revert "Temporarily disable Danger in CI (#12291)"

This reverts commit 925fc93389.
2018-02-26 16:33:50 -08:00
Héctor Ramos
2d511479c4 Replace danger token with a refreshed facebook-open-source-bot token (#12295) 2018-02-26 16:20:54 -08:00
Brandon Dail
925fc93389 Temporarily disable Danger in CI (#12291) 2018-02-26 11:40:23 -08:00
Andrew Clark
94518b068b Add stack unwinding phase for handling errors (#12201)
* Add stack unwinding phase for handling errors

A rewrite of error handling, with semantics that more closely match
stack unwinding.

Errors that are thrown during the render phase unwind to the nearest
error boundary, like before. But rather than synchronously unmount the
children before retrying, we restart the failed subtree within the same
render phase. The failed children are still unmounted (as if all their
keys changed) but without an extra commit.

Commit phase errors are different. They work by scheduling an error on
the update queue of the error boundary. When we enter the render phase,
the error is popped off the queue. The rest of the algorithm is
the same.

This approach is designed to work for throwing non-errors, too, though
that feature is not implemented yet.

* Add experimental getDerivedStateFromCatch lifecycle

Fires during the render phase, so you can recover from an error within the same
pass. This aligns error boundaries more closely with try-catch semantics.

Let's keep this behind a feature flag until a future release. For now, the
recommendation is to keep using componentDidCatch. Eventually, the advice will
be to use getDerivedStateFromCatch for handling errors and componentDidCatch
only for logging.

* Reconcile twice to remount failed children, instead of using a boolean

* Handle effect immediately after its thrown

This way we don't have to store the thrown values on the effect list.

* ReactFiberIncompleteWork -> ReactFiberUnwindWork

* Remove startTime

* Remove TypeOfException

We don't need it yet. We'll reconsider once we add another exception type.

* Move replay to outer catch block

This moves it out of the hot path.
2018-02-23 17:38:42 -08:00
Rauno Freiberg
6d7c847f30 Add a clearer error message for the Consumer render (#12241) (#12267) 2018-02-22 20:06:17 +00:00
Gordon Dent
cf58f296e9 Add test exercising public API to test BeforeInputEventPlugin + FallbackCompositionState (#11849)
* Add test exercising public API to test BeforeInputEventPlugin + FallbackCompositionState

 - I've adopted a similar approach to the existing test for BeforeInputEventPlugin
 - I've simulated events and then assert the event handler for onBeforeInput is fired or not fired based on the test conditions
 - The scenarios are tested against IE11, Webkite and Presto environment simulations
 - I've encorporated what I understand to be the functionality in the FallbackCompositionState test

* Prettier

* Linting fixes

* Remove test for contenteditable in Presto - the contenteditable type is not supported in Presto powered browsers (Opera).

* Remove mention of Presto as this explicit condition is no longer handled in BeforeInputEventPlugin.

We still need to exercise usage of FallbackCompositionState though so let's keep a test where the env does not support Composition and Text events.

* Add tests for envs with only CompositionEvent support

* Remove internal tests no longer needed

* Shorten test case names to satisfy lint rules

* Add tests for onCompositionStart and onCompositionUpdte events

The BeforeInputEventPlugin is responsible for emitting these events so we need to add tests for this. This also ensure we exercise the code path that, L207, that was not previously exercised with the public tests.
2018-02-22 18:27:36 +00:00
Sophie Alpert
2bd1222a82 Format danger percents better (#12256)
Test Plan: yolo? yarn danger pr didn't give me any useful output. :\
2018-02-21 15:48:37 -08:00
Kevin Gozali
02f4e7a80b [fabric] Forked ReactNativeInjection for Fabric and avoid RCTEventEmitter setup in Fabric (#12265) 2018-02-21 15:40:47 -08:00
Sophie Alpert
b17e4c204e Ignore RN events on unknown nodes (#12264)
If we have multiple RN renderers running simultaneously, we should be able to send a single event to all of them and only if it recognizes the event will it do anything with it. Crucially, this avoids the 'Unsupported top level event type "%s" dispatched' invariant in those cases.
2018-02-21 13:47:17 -08:00
Abhay Nikam
48ffbf06be Ignored fiber tags which shows unknow in performance tabs (#12250) 2018-02-19 21:58:41 +00:00
Andrew Clark
e68c0164aa Update test renderer to support new types of work (#12237)
Adds support for ContextProvider, ContextConsumer, and Mode.
2018-02-16 11:27:20 -08:00
Andrew Clark
93ce76b7ea Update bundle sizes for simple-cache-provider 2018-02-15 19:19:40 -08:00
Andrew Clark
0859e3a0d9 Bump simple-cache-provider version 2018-02-15 19:19:27 -08:00
Andrew Clark
4312b82932 [experimental] simple-cache-provider (#12224)
* [experimental] simple-cache-provider

Pushing an early version of this for testing and demonstration purposes.

* Change invariant to DEV-only warning

* Use function overloading for createResource type

Expresses that primitive keys do not require a hash function, but
non-primitive keys do.

* More tests

* Use export *

* Make Record type a disjoint union

* Pass miss argument separate from key to avoid a closure
2018-02-15 16:38:15 -08:00
Toru Kobayashi
5cd5f63a77 Add an unit test for React.Fragment with ShallowRenderer (#12220) 2018-02-15 14:19:08 +00:00
Orta
e8ee1b92dc [Danger] Add a remote for the upstream repo, and try use that for the merge base for danger (#12229) 2018-02-15 12:19:31 +00:00
Andrew Clark
1fd205ad2d Additional release script options for publishing canary versions (#12219)
* Additional release script options for publishing canary versions

- `branch` specifies a branch other than master
- `local` skips pulling from the remote branch and checking CircleCI
- `tag` specifies an npm dist tag other than `latest` or `next`

We may add a higher-level `canary` option in the future.

* Address Brian's feedback:

- Updated description of `local` option
- Throws if the `latest` tag is specified for a prerelease version
2018-02-13 11:44:27 -08:00
Brian Vaughn
e2563a3c52 Handle packages without dependencies (#12217) 2018-02-12 15:46:43 -08:00
Brian Vaughn
fb85cf2e9c Update bundle sizes for 16.3.0-alpha.1 release 2018-02-12 10:41:41 -08:00
Brian Vaughn
e588a371e2 Updating dependencies for react-noop-renderer 2018-02-12 10:38:24 -08:00
Brian Vaughn
e00f8429bc Updating package versions for release 16.3.0-alpha.1 2018-02-12 10:38:24 -08:00
Brian Vaughn
d4afeb5aff Added ReactFabric shim (#12216) 2018-02-12 10:12:46 -08:00
Orta
a634e53d2f [Danger] Include 1% changes in a build, not just greater than (#12213) 2018-02-12 12:44:18 +00:00
Brian Vaughn
86ee9e8488 NativeMethodsMixin DEV-only methods should not warn (#12212)
* Disable DEV-only warnings for RN NativeMethodsMixin/create-react-class

* Tiny bit of cleanup

* Make strict-mode suppression check a little more robust
2018-02-11 16:29:02 -08:00
Brian Vaughn
41b8c65f1e Add react-is package (#12199)
Authoritative brand checking library.

Can be used without any dependency on React. Plausible replacement for `React.isValidElement.`
2018-02-11 14:08:40 -08:00
Orta
c7ce0091dc [Danger] Use the PR's mergebase for a branch in the dangerfile (#12049)
* [Danger] Use the PR's mergebase for a branch in the dangerfile instead of
the root commit's parent.

* [Danger] Get the full history to find the merge base
2018-02-11 19:43:29 +00:00
Dan Abramov
29e8924c70 Move ReactContext source to React package (#12205) 2018-02-10 16:41:33 +00:00
Dan Abramov
78a595aeb7 Update sizes 2018-02-10 13:48:07 +00:00
Dan Abramov
f07dd45b75 Fix build stats display 2018-02-10 13:37:33 +00:00
Dan Abramov
467b1034ce Disable for...of by default, rewrite cases where it matters (#12198)
* Add no-for-of lint rule

* Ignore legit use cases of for..of

* Rewrite for..of in source code
2018-02-09 16:11:22 +00:00
Brian Vaughn
b5e9615087 Interleaved Context.Provider bugfix (#12187)
* Added failing unit test

* Maybe fixed interleaved context provider bug?
2018-02-08 14:23:41 -08:00
Sophie Alpert
49b0ca1b83 Fix finding Fabric feature flags (#12189)
Test Plan: yarn build fabric, inspect build/react-native/ReactFabric-dev.js to see enablePersistentReconciler = true.
2018-02-08 13:28:17 -08:00
Brian Vaughn
cbf729659e Enable warnAboutDeprecatedLifecycles for ReactNative (#12186) 2018-02-08 10:48:18 -08:00
Brian Vaughn
d529d2035e Fixed descrepancy between host and class component refs (#12178)
When a ref is removed from a class component, React now calls the previous ref-setter (if there was one) with null. Previously this was the case only for host component refs.

A new test has been added.
2018-02-07 12:13:42 -08:00
C. T. Lin
4a20ff26ec Fix server render async mode (#12173)
* add failed tests for <unstable_AsyncMode> with server rendering

* Fix server render with <unstable_AsyncMode> component

* Merge StrictMode and AsyncMode tests into Modes file
2018-02-07 11:51:53 +00:00
C. T. Lin
18a81a4445 Fix server render strict mode (#12170)
* Fix server render with <StrictMode> component

* add failed tests for <StrictMode> with server rendering
2018-02-07 07:51:13 +00:00
Dominic Gannaway
8dc8f88d5a Adds createRef() as per RFC (#12162)
* Adds createRef() as per RFC
2018-02-06 20:19:49 +00:00
Nicolas Gallagher
3d8f465d99 Revert deprecation warnings for custom event plugin injection (#12167) 2018-02-06 18:39:03 +00:00
Brian Vaughn
578c82d6a0 String ref warning shows name of ref (#12164) 2018-02-06 09:00:44 -08:00
Brian Vaughn
6f2f55ed56 Warn about string refs within strict mode trees (#12161)
* Warn about string refs within strict mode trees

* Improved string ref warning message
2018-02-06 07:43:31 -08:00
Brian Vaughn
f05296baf5 Changed cWM/cWRP/cWU deprecations to low-pri warnings (#12159) 2018-02-05 13:39:07 -08:00
Jordan Tepper
86914cb30a Clearer ssr error message 11902 (#11966)
* Match error message to one in `ReactFiber.js`

* Add undefined/null guard and tests

* Update tests and element check

* Remove beforeEach block
2018-02-05 17:09:09 +00:00
Dan Abramov
f828ca407f Expose persistent reconciler to custom renderers (#12156) 2018-02-05 16:56:21 +00:00
Dan Abramov
8b83ea02f5 Fix fragment handling in toTree() (#12154) 2018-02-05 16:55:48 +00:00
Brian Vaughn
ad07be755d Release script does a fresh Yarn install of deps (#12149)
This would have caught the recent Yarn workspaces / semver issue sooner.
2018-02-04 17:06:14 -08:00
Brian Vaughn
dc271876a2 Pre-release version fix (#12148)
* Ran updated release script to fix deps
* Release script handles prerelease deps correctly
* Update noop-renderer dependencies on reconciler package
2018-02-04 08:54:42 -08:00
Ivan Starkov
be85544b89 Fix process.CI typo (#12146) 2018-02-04 01:56:06 +00:00
Brian Vaughn
885a291141 Update bundle sizes for 16.3.0-alpha.0 release 2018-02-02 13:01:34 -08:00
Brian Vaughn
4da13ec5e1 Update error codes for 16.3.0-alpha.0 release 2018-02-02 13:01:33 -08:00
Brian Vaughn
8a995f7d56 Updating package versions for release 16.3.0-alpha.0 2018-02-02 12:58:26 -08:00
Brian Vaughn
4eed18dd72 Invoke both legacy and UNSAFE_ lifecycles when both are present (#12134)
* Invoke both legacy and UNSAFE_ lifecycles when both are present

This is to support edge cases with eg create-react-class where a mixin defines a legacy lifecycle but the component being created defines an UNSAFE one (or vice versa).

I did not warn about this case because the warning would be a bit redundant with the deprecation warning which we will soon be enabling. I could be convinced to change my stance here though.

* Added explicit function-type check to SS ReactPartialRenderer
2018-02-01 11:15:57 -08:00
Maël Nison
aeba3c42aa Exposes the host container to prepareForCommit and resetAfterCommit (#12098)
* Exposes the host container to prepareForCommit and resetAfterCommit

* Uses better typing

* Adds tests

* Removes commit data
2018-02-01 10:38:19 -08:00
Brian Vaughn
e202f984ea Add react-lifecycles-compat and update tests (#12127)
* Installed react-lifecycles-compat module

* Updated react-lifecycles-compat integration tests to use real polyfill
2018-01-31 10:33:59 -08:00
Brian Vaughn
5f95fdee63 Updated create-react-class to 15.6.3 (and updated tests) (#12126) 2018-01-31 09:41:09 -08:00
Andrew Clark
27fe752eea Interactive updates shouldn't flush until the end of the outermost batch
Accounts for the case where an event is dispatched synchronously from
inside another event, like `el.focus`. I've added a test, but in general
we need more coverage around this area.
2018-01-30 23:17:22 -08:00
Andrew Clark
28aa084ad8 Switch to JSX API for context (#12123)
* Switch to JSX API for context

80% sure this will be the final API. Merging this now so we can get this
into the next www sync in preparation for 16.3.

* Promote context to a stable API
2018-01-30 13:06:12 -08:00
Andrew Clark
8a09a2fc53 Interactive updates (#12100)
* Updates inside controlled events (onChange) are sync even in async mode

This guarantees the DOM is in a consistent state before we yield back
to the browser.

We'll need to figure out a separate strategy for other
interactive events.

* Don't rely on flushing behavior of public batchedUpdates implementation

Flush work as an explicit step at the end of the event, right before
restoring controlled state.

* Interactive updates

At the beginning of an interactive browser event (events that fire as
the result of a user interaction, like a click), check for pending
updates that were scheduled in a previous interactive event. Flush the
pending updates synchronously so that the event handlers are up-to-date
before responding to the current event.

We now have three classes of events:

- Controlled events. Updates are always flushed synchronously.
- Interactive events. Updates are async, unless another a subsequent
event is fired before it can complete, as described above. They are
also slightly higher priority than a normal async update.
- Non-interactive events. These are treated as normal, low-priority
async updates.

* Flush lowest pending interactive update time

Accounts for case when multiple interactive updates are scheduled at
different priorities. This can happen when an interactive event is
dispatched inside an async subtree, and there's an event handler on
an ancestor that is outside the subtree.

* Update comment about restoring controlled components
2018-01-29 23:49:10 -08:00
Andrew Clark
3e08e60a34 ReactDOM.flushControlled (#12118)
* ReactDOM.flushControlled

New API for wrapping event handlers that need to fire before React
yields to the browser. Previously we thought that flushSync was
sufficient for this use case, but it turns out that flushSync is only
safe if you're guaranteed to be at the top of the stack; that is, if
you know for sure that your event handler is not nested inside another
React event handler or lifecycle. This isn't true for cases like
el.focus, el.click, or dispatchEvent, where an event handler can be
invoked synchronously from inside an existing stack.

flushControlled has similar semantics to batchedUpdates, where if you
nest multiple batches, the work is not flushed until the end of the
outermost batch. The work is not guaranteed to synchronously flush, as
with flushSync, but it is guaranteed to flush before React yields to
the browser.

flushSync is still the preferred API in most cases, such as inside
a requestAnimationFrame callback.

* Test that flushControlled does not flush inside batchedUpdates

* Make flushControlled a void function

In the future, we may want to return a thenable work object. For now,
we'll return nothing.

* flushControlled -> unstable_flushControlled
2018-01-29 22:36:35 -08:00
Andrew Clark
9ea55516e6 Replace unstable_AsyncComponent with unstable_AsyncMode (#12117)
* Replace unstable_AsyncComponent with Unstable_AsyncMode

Mirrors the StrictMode API and uses the new Mode type of work.

* internalContextTag -> mode

Change this now that we have a better name

* Unstable_ -> unstable_
2018-01-29 19:11:59 -08:00
Brian Vaughn
d27b45131d updated ReactFeatureFlags shim (#12116) 2018-01-29 16:11:18 -08:00
Brian Vaughn
a7b9f98e7a React lifecycles compat (#12105)
* Suppress unsafe/deprecation warnings for polyfilled components.
* Don't invoke deprecated lifecycles if static gDSFP exists.
* Applied recent changes to server rendering also
2018-01-29 08:06:50 -08:00
Maciej Kasprzyk
ef8d6d92a2 Handle nested Fragments in toTree (#12106) (#12107) 2018-01-27 15:03:27 -08:00
Hendrik Liebau
40a9e64e1f Move a comment to its original location (#12103)
`type` was added in #11818 below the comment that belongs to `domNamespace`
2018-01-26 13:34:05 +00:00
Brian Vaughn
d3b183c323 Debug render-phase side effects in "strict" mode (#12094)
A new feature flag has been added, debugRenderPhaseSideEffectsForStrictMode. When enabled, StrictMode subtrees will also double-invoke lifecycles in the same way as debugRenderPhaseSideEffects.

By default, this flag is enabled for __DEV__ only. Internally we can toggle it with a GK.

This breaks several of our incremental tests which make use of the noop-renderer. Updating the tests to account for the double-rendering in development mode makes them significantly more complicated. The most straight forward fix for this will be to convert them to be run as internal tests only. I believe this is reasonable since we are the only people making use of the noop renderer.
2018-01-25 14:30:53 -08:00
Brian Vaughn
6dabfca577 Coalesce lifecycle deprecation warnings until the commit phase (#12084)
Builds on top of PR #12083 and resolves issue #12044.

Coalesces deprecation warnings until the commit phase. This proposal extends the  utility introduced in #12060 to also coalesce deprecation warnings.

New warning format will look like this:
> componentWillMount is deprecated and will be removed in the next major version. Use componentDidMount instead. As a temporary workaround, you can rename to UNSAFE_componentWillMount.
>
> Please update the following components: Foo, Bar
>
> Learn more about this warning here:
> https://fb.me/react-async-component-lifecycle-hooks
2018-01-24 21:41:40 -08:00
Andrew Clark
87ae211ccd New context API (#11818)
* New context API

Introduces a declarative context API that propagates updates even when
shouldComponentUpdate returns false.

* Fuzz tester for context

* Use ReactElement for provider and consumer children

* Unify more branches in createFiberFromElement

* Compare context values using Object.is

Same semantics as PureComponent/shallowEqual.

* Add support for Provider and Consumer to server-side renderer

* Store providers on global stack

Rather than using a linked list stored on the context type. The global
stack can be reset in case of an interruption or error, whereas with the
linked list implementation, you'd need to keep track of every
context type.

* Put new context API behind a feature flag

We'll enable this in www only for now.

* Store nearest provider on context object

* Handle reentrancy in server renderer

Context stack should be per server renderer instance.

* Bailout of consumer updates using bitmask

The context type defines an optional function that compares two context
values, returning a bitfield. A consumer may specify the bits it needs
for rendering. If a provider's context changes, and the consumer's bits
do not intersect with the changed bits, we can skip the consumer.

This is similar to how selectors are used in Redux but fast enough to do
while scanning the tree. The only user code involved is the function
that computes the changed bits. But that's only called once per provider
update, not for every consumer.

* Store current value and changed bits on context object

There are fewer providers than consumers, so better to do this work
at the provider.

* Use maximum of 31 bits for bitmask

This is the largest integer size in V8 on 32-bit systems. Warn in
development if too large a number is used.

* ProviderComponent -> ContextProvider, ConsumerComponent -> ContextConsumer

* Inline Object.is

* Warn if multiple renderers concurrently render the same context provider

Let's see if we can get away with not supporting this for now. If it
turns out that it's needed, we can fall back to backtracking the
fiber return path.

* Nits that came up during review
2018-01-24 19:36:22 -08:00
Brian Vaughn
be51e6a41c Opt into unsafe lifecycle warnings without async tree (#12083)
Added new StrictMode component for enabling async warnings (without enabling async rendering). This component can be used in the future to help with other warnings (eg compilation, Fabric).
2018-01-24 17:49:43 -08:00
Brian Vaughn
431dca925a Update debugRenderPhaseSideEffects behavior (#12057)
Update debugRenderPhaseSideEffects behavior

This feature flag no longer double-invokes componentWillMount, componentWillReceiveProps, componentWillUpdate, or shouldComponentUpdate.

It continues to double-invoke the constructor, render, and setState updater functions as well as the recently added, static getDerivedStateFromProps method

Tests have been updated.
2018-01-24 15:06:25 -08:00
Brian Vaughn
d0e75dcfe2 Improve toWarnDev matcher DX for unexpected warnings (#12082)
Use jest-diff to format the warnings in a way that makes it easier to spot the differences.
2018-01-23 14:46:58 -08:00
Brian Vaughn
098745b2d1 Improved toWarnDev matcher to avoid swallowing errors (#12081)
While writing tests for unsafe async warnings, I noticed that in certain cases, errors were swallowed by the toWarnDev matcher and resulted in confusing test failures. For example, if an error prevented the code being tested from logging an expected warning- the test would fail saying that the warning hadn't been logged rather than reporting the unexpected error. I think a better approach for this is to always treat caught errors as the highest-priority reason for failing a test.

I reran all of the test cases for this matcher that I originally ran with PR #11786 and ensured they all still pass.
2018-01-23 14:46:50 -08:00
Brian Vaughn
cba51badce Warn if unsafe lifecycle methods are found in an async subtree (#12060) 2018-01-23 14:01:55 -08:00
Sebastian Markbåge
4d65408938 Test that fabric renderer sends diffs (#12075) 2018-01-22 22:29:43 -08:00
Dan Abramov
04d8fecc4a Temporarily disable Danger
Its calculation is currently a bit misleading.
@orta plans to look into this but for now I'll disable.
2018-01-22 19:31:35 +00:00
Sebastian Markbåge
6031bea239 Add Experimental Fabric Renderer (#12069) 2018-01-22 09:58:35 -08:00
Claire L
4ca7855ca0 Highlight production bundles in bold in the Danger integration comment (#12054)
* update Danger integration comments

* update Danger integration comments

* revised codes for unconditional call

* update setBoldness parameter
2018-01-19 18:07:26 +00:00
Brian Vaughn
97e2911508 RFC 6: Deprecate unsafe lifecycles (#12028)
* Added unsafe_* lifecycles and deprecation warnings
If the old lifecycle hooks (componentWillMount, componentWillUpdate, componentWillReceiveProps) are detected, these methods will be called and a deprecation warning will be logged. (In other words, we do not check for both the presence of the old and new lifecycles.) This commit is expected to fail tests.

* Ran lifecycle hook codemod over project
This should handle the bulk of the updates. I will manually update TypeScript and CoffeeScript tests with another commit.
The actual command run with this commit was: jscodeshift --parser=flow -t ../react-codemod/transforms/rename-unsafe-lifecycles.js ./packages/**/src/**/*.js

* Manually migrated CoffeeScript and TypeScript tests

* Added inline note to createReactClassIntegration-test
Explaining why lifecycles hooks have not been renamed in this test.

* Udated NativeMethodsMixin with new lifecycle hooks

* Added static getDerivedStateFromProps to ReactPartialRenderer
Also added a new set of tests focused on server side lifecycle hooks.

* Added getDerivedStateFromProps to shallow renderer
Also added warnings for several cases involving getDerivedStateFromProps() as well as the deprecated lifecycles.
Also added tests for the above.

* Dedupe and DEV-only deprecation warning in server renderer

* Renamed unsafe_* prefix to UNSAFE_* to be more noticeable

* Added getDerivedStateFromProps to ReactFiberClassComponent
Also updated class component and lifecyle tests to cover the added functionality.

* Warn about UNSAFE_componentWillRecieveProps misspelling

* Added tests to createReactClassIntegration for new lifecycles

* Added warning for stateless functional components with gDSFP

* Added createReactClass test for static gDSFP

* Moved lifecycle deprecation warnings behind (disabled) feature flag

Updated tests accordingly, by temporarily splitting tests that were specific to this feature-flag into their own, internal tests. This was the only way I knew of to interact with the feature flag without breaking our build/dist tests.

* Tidying up

* Tweaked warning message wording slightly
Replaced 'You may may have returned undefined.' with 'You may have returned undefined.'

* Replaced truthy partialState checks with != null

* Call getDerivedStateFromProps via .call(null) to prevent type access

* Move shallow-renderer didWarn* maps off the instance

* Only call getDerivedStateFromProps if props instance has changed

* Avoid creating new state object if not necessary

* Inject state as a param to callGetDerivedStateFromProps
This value will be either workInProgress.memoizedState (for updates) or instance.state (for initialization).

* Explicitly warn about uninitialized state before calling getDerivedStateFromProps.
And added some new tests for this change.

Also:
* Improved a couple of falsy null/undefined checks to more explicitly check for null or undefined.
* Made some small tweaks to ReactFiberClassComponent WRT when and how it reads instance.state and sets to null.

* Improved wording for deprecation lifecycle warnings

* Fix state-regression for module-pattern components
Also add support for new static getDerivedStateFromProps method
2018-01-19 09:36:46 -08:00
Brian Vaughn
fccd11bec0 Added 9.x to node devEngines (#12050) 2018-01-18 15:16:47 -08:00
Esben Sparre Andreasen
bd6b533c29 Fix copy paste error for file size comparison (#12040) 2018-01-18 13:55:40 +00:00
Sebastian Markbåge
d3647583b3 Remove experimental RT/CS renderers (#12032)
Will follow up with adding a new one.
2018-01-17 18:07:25 -08:00
Orta
d8d797645c Adds Danger and a rule showing build size differences (#11865)
* Adds danger_js with an initial rule for warning about large PRs

Signed-off-by: Anandaroop Roy <roop@artsymail.com>

* [WIP] Get the before and after for the build results

* [Dev] More work on the Dangerfile

* [Danger] Split the reports into sections based on their package

* Remove the --extract-errors on the circle build

* [Danger] Improve the lookup for previous -> current build to also include the environment

* Fix rebase
2018-01-17 01:49:38 +00:00
Rick Hanlon II
4f309f86df Plug ~100 test leaks (#12020) 2018-01-15 11:15:19 +00:00
Dan Abramov
80d6792882 Add a workaround for incomplete Proxy polyfill issue (#12017) 2018-01-14 18:39:33 +00:00
Nathan Hunzaker
3766a014ae Add media events back to TestUtils.Simulate (#12010)
The TestUtils lost media events when they were pulled out of the
topLevelTypes constant. This commit adds them back by concatenating
the media event keys to the list of top level types.
2018-01-11 21:02:59 -05:00
Dan Abramov
73fa26a88b Drop some top-level events from the list (#11912)
* Drop some top-level events from the list

* Put both whitelists in one file
2018-01-11 18:38:13 -05:00
Simen Bekkhus
bb0bcc0541 chore: remove unused expect beta dependency (#12008) 2018-01-11 15:01:53 +00:00
Dan Abramov
96ce986b22 Bump Jest to 22.0.6 (#12006) 2018-01-11 14:14:02 +00:00
Semen Zhydenko
5b975411a1 Minor typos fixed (#12005)
* commiting -> committing

* doens't -> doesn't

* interuption -> interruption

* inital -> initial

* statment -> statement
2018-01-11 12:24:49 +00:00
Nathan Hunzaker
b422fec459 Add test fixture for media event bubbling (#12004)
We want to start refactoring some of the event constants, but we don't
have a great way to confirm media events work as intended. This commit
adds a new DOM test fixture to verify that media events bubble.
2018-01-10 19:53:58 -05:00
Dan Abramov
4501996398 Use 2 workers for all tests on CI (#11990) 2018-01-10 23:54:23 +00:00
Nathan Hunzaker
982a828844 Add test to ensure checked inputs don't accidentally get value="on" (#12000)
In absence of a value, radio and checkboxes report a value of
"on". Between 16 and 16.2, we assigned a node's value to it's current
value in order to "dettach" it from defaultValue. This had the
unfortunate side-effect of assigning value="on" to radio and
checkboxes

Related issues:
https://github.com/facebook/react/issues/11998
2018-01-09 23:45:29 +00:00
Brian Vaughn
18288b2227 flow-coverage-report (#11545)
* Added 'flow-coverage-report' package for discussion

* Aded flow-coverage command and configuration file

* Moved FLow coverage config file to scripts/flow/coverage-config

* Moved Flow coverage config back to root as dotfile
2018-01-09 11:14:56 -08:00
Brian Vaughn
ec67ee400c Upgrade to ESLint 4.1 and add no-focused-tests rule (#11977)
* Runs a lint rule on tests only that errors if it sees `fdescribe` or `fit` calls.
* Changes `file:` to `link:` for our custom, internal rules (just to simplify updating these in the future).
* Updates `eslint` from 3.10 -> 4.1 and `babel-eslint` from 7.1 -> 8.0 so that we can run this new rule only against tests.
2018-01-09 10:55:51 -08:00
Neil Kistner
e6e393b9c5 Add warning in server renderer if class doesn't extend React.Component (#11993)
* Add warning in server renderer if class doesn't extend React.Component

In dev mode, while server rendering, a warning will be thrown if there is a class that doesn't extend React.Component.

* Use `.toWarnDev` matcher and deduplicate warnings

* Deduplicate client-side warning if class doesn't extend React.Component

* Default componentName to Unknown if null
2018-01-09 16:24:49 +00:00
Md Zubair Ahmed
77f96ed9c3 changed {} in pck.json and split them with && in fixtures (#11982) 2018-01-09 11:15:09 +00:00
Andrew Clark
13c5e2b531 Sync scheduling by default, with an async opt-in (#11771)
Removes the `useSyncScheduling` option from the HostConfig, since it's
no longer needed. Instead of globally flipping between sync and async,
our strategy will be to opt-in specific trees and subtrees.
2018-01-08 18:50:02 -08:00
Rick Hanlon II
26185759e4 Enable coverage, set jest maxWorkers to 2 (#11983) 2018-01-08 02:27:24 +00:00
Reinier Hartog
08c86dd76b Reconcile Call component children with current (#11979)
* Add test for un- and remounting children of Call

* Reconcile Call component children with `current`
2018-01-07 20:15:05 +00:00
Shi Yan
65aeb70195 Deduplicate warning on invalid callback (#11833) (#11833) 2018-01-07 11:52:52 +00:00
Lucas Azzola
052a5f27f3 Use Prettier Config API (#11980) 2018-01-07 11:51:59 +00:00
Dan Abramov
301edeaac8 Run "yarn prettier" on Appveyor
Ensures we don't break the command on Windows by accident.
2018-01-07 11:50:24 +00:00
Dan Abramov
48833f698d Disable coverage again (#11974)
* Disable coverage again

* Update test_entry_point.sh
2018-01-05 18:59:13 +00:00
Haisheng Wu
96d7e53e69 topLevelUpdateWarnings is only for dev mode hence not necessary to have extra dev mode check. (#11924) 2018-01-05 18:51:02 +00:00
Toru Kobayashi
9d310e0bc7 ShallowRenderer should filter context by contextTypes (#11922) 2018-01-05 18:49:57 +00:00
jwbay
39be83565c align shallow renderer with other renderers in defaulting state to null on mount (#11965) 2018-01-05 18:44:44 +00:00
Dan Abramov
808f31af5c Reduce the handleTopLevel() event code indirection (#11915)
* Refactor event emitters to reduce indirection

* Remove unused handleTopLevel() injection

* Rename handleTopLevel() to runExtractedEventsInBatch() and remove import indirection
2018-01-05 18:37:13 +00:00
Jason Quense
1c7c38c82a Remove extra loop (?) (#11889)
* Remove extra loop (?)

* prettier
2018-01-05 18:35:43 +00:00
Md Zubair Ahmed
ce40f4eafe issue 11768 - Error Rendering Inputs in Separate Window using Portals in ie11 (#11870)
Work around IE/Edge bug when rendering inputs in separate windows via portals
2018-01-05 18:32:43 +00:00
Roderick Hsiao
e74f3ce565 Support onLoad and onError on <link> (#11825)
* Support link event on Fiber component

* Update unit test

* prettier format

* Update test description

* Update ReactDOMComponent-test.js
2018-01-05 18:14:16 +00:00
Jason Quense
4e044f553f Clarify reason for setTextContent helper (#11813)
* Update comment on setTextContent

update the comment explaining the reason for the helper

* Use `setTextContent` in ReactDOM for consistency
2018-01-05 18:10:12 +00:00
Sotiris Kiritsis
588198d266 Updated misleading error message in production environment when adding ref to a functional component (#11761) (#11782)
* Updated misleading error message in production environment when adding ref to a functional component

* Reverted changes to codes.json

* Updated error message
2018-01-05 18:07:58 +00:00
Brian Vaughn
c94b4b8b86 Fixed potential false-positive in toWarnDev matcher (#11898)
* Warn about spying on the console

* Added suppress warning flag for spyOn(console)

* Nits

* Removed spy-on-console guard

* Fixed a potential source of false-positives in toWarnDev() matcher
Also updated (most of) ReactIncrementalErrorLogging-test.internal to use the new matcher

* Removed unused third param to spyOn

* Improved clarity of inline comments

* Removed unused normalizeCodeLocInfo() method
2018-01-05 09:44:45 -08:00
Ronald Eddy Jr
ede0b87cd1 Update HTTP to HTTPs in CHANGELOG.md (#11634)
Several URL were updated to use HTTPS protocol in CHANGELOG.md.
2018-01-05 17:26:53 +00:00
Dan Abramov
fe10b8d0cd Remove IE8 event.target polyfill via srcElement (#11515) 2018-01-05 17:21:33 +00:00
Nicolas Straub
43af41be53 enables ctrl + enter for keypress event on browsers other than firefox (#10514)
* enables ctrl + enter for keypress event on browsers other than firefox

* makes comment more descriptive as to affected platforms

* reverting fiber results

* Reset changes to results.json

* Remove old test file

* Add tests in the right place
2018-01-05 16:31:25 +00:00
Jason Quense
8d336aa97e pass host context to finalizeInitialChildren (#11970)
* pass host context to finalizeInitialChildren

* don't retrieve context an extra time
2018-01-05 10:52:19 -05:00
Santosh Venkatraman
30dac4e78d Removes legacy TODOs in createfactory methods (#11942)
* Removes legacy TODO from createFactory()

* Removes legacy TODO from createFactoryWithValidation()

* Adds comment "Legacy hook: remove it"

This is based on Dan Abramov's suggestion (source:
https://github.com/facebook/react/pull/11942#issuecomment-354818632)
2018-01-04 19:40:02 +00:00
Dan Abramov
1ebeb0542f Move npm output from build/packages/* to build/node_modules/* (#11962)
* Move build/packages/* to build/node_modules/*

This fixes Node resolution in that folder and lets us require() packages in it in Node shell for manual testing.

* Link fixtures to packages/node_modules

This updates the location and also uses link: instead of file: to avoid Yarn caching the folder contents.
2018-01-04 19:01:31 +00:00
Dan Abramov
d289d4b634 Update to Jest 22 (#11956)
* Bump deps to Jest 22

* Prevent jsdom from logging intentionally thrown errors

This relies on our existing special field that we use to mute errors.
Perhaps, it would be better to instead rely on preventDefault() directly.
I outlined a possible strategy here: https://github.com/facebook/react/issues/11098#issuecomment-355032539

* Update snapshots

* Mock out a method called by ReactART that now throws

* Calling .click() no longer works, dispatch event instead

* Fix incorrect SVG element creation in test

* Render SVG elements inside <svg> to avoid extra warnings

* Fix range input test to use numeric value

* Fix creating SVG element in test

* Replace brittle test that relied on jsdom behavior

The test passed in jsdom due to its implementation details.

The original intention was to test the mutation method, but it was removed a while ago.

Following @nhunzaker's suggestion, I moved the tests to ReactDOMInput and adjusted them to not rely on implementation details.

* Add a workaround for the expected extra client-side warning

This is a bit ugly but it's just two places. I think we can live with this.

* Only warn once for mismatches caused by bad attribute casing

We used to warn both about bad casing and about a mismatch.
The mismatch warning was a bit confusing. We didn't know we warned twice because jsdom didn't faithfully emulate SVG.

This changes the behavior to only leave the warning about bad casing if that's what caused the mismatch.
It also adjusts the test to have an expectation that matches the real world behavior.

* Add an expected warning per comment in the same test
2018-01-04 18:57:30 +00:00
Sotiris Kiritsis
4d37040cbf Removed Presto check (#11921) 2018-01-04 08:28:42 -05:00
Brian Vaughn
bb881f2de7 Updated toWarnDev matcher so that ReactFiberScheduler won't suppress its errors (#11958) 2018-01-03 15:23:05 -08:00
Brian Vaughn
9f848f8ebe Update additional tests to use .toWarnDev() matcher (#11957)
* Migrated several additional tests to use new .toWarnDev() matcher

* Migrated ReactDOMComponent-test to use .toWarnDev() matcher

Note this test previous had some hacky logic to verify errors were reported against unique line numbers. Since the new matcher doesn't suppor this, I replaced this check with an equivalent (I think) comparison of unique DOM elements (eg div -> span)

* Updated several additional tests to use the new .toWarnDev() matcher

* Updated many more tests to use .toWarnDev()

* Updated several additional tests to use .toWarnDev() matcher

* Updated ReactElementValidator to distinguish between Array and Object in its warning. Also updated its test to use .toWarnDev() matcher.

* Updated a couple of additional tests

* Removed unused normalizeCodeLocInfo() methods
2018-01-03 13:55:37 -08:00
Brian Vaughn
a442d9bc08 Update additional tests to use .toWarnDev() matcher (#11952)
* Migrated several additional tests to use new .toWarnDev() matcher

* Migrated ReactDOMComponent-test to use .toWarnDev() matcher

Note this test previous had some hacky logic to verify errors were reported against unique line numbers. Since the new matcher doesn't suppor this, I replaced this check with an equivalent (I think) comparison of unique DOM elements (eg div -> span)

* Updated several additional tests to use the new .toWarnDev() matcher

* Updated many more tests to use .toWarnDev()
2018-01-03 10:08:24 -08:00
Dan Abramov
2517be99ac Reword issue template 2018-01-03 15:58:07 +00:00
Taehwan, No
dd3e34e832 Fix links in README.md (#11954) 2018-01-03 14:02:33 +00:00
Brian Vaughn
b5334a44e9 toWarnInDev matcher; throw on unexpected console.error (#11786)
* Added toWarnInDev matcher and connected to 1 test
* Added .toLowPriorityWarnDev() matcher
* Reply Jest spy with custom spy. Unregister spy after toWarnDev() so unexpected console.error/warn calls will fail tests.
* console warn/error throws immediately in tests by default (if not spied on)
* Pass-thru console message before erroring to make it easier to identify
* More robustly handle unexpected warnings within try/catch
* Error message includes remaining expected warnings in addition to unexpected warning
2018-01-02 11:06:41 -08:00
Brandon Dail
22e2bf7684 Return event name from getVendorPrefixedEventName (#11951) 2018-01-02 10:46:51 -08:00
Dan Abramov
0deea32667 Run some tests in Node environment (#11948)
* Run some tests in Node environment

* Separate SSR tests that require DOM

This allow us to run others with Node environment.
2018-01-02 18:42:18 +00:00
Dan Abramov
dd8b387b69 Reënable stats downloading
I'm running out of ideas to keep these commit messages entertaining. Thankfully this should keep the CI green and we can forget any of it ever happened.
2017-12-24 02:09:01 +00:00
Dan Abramov
d88a033cc3 Temporarily disable downloading the results file
I promise, we're close to fixing this. I fixed the last bug and now just need to run this to upload a "good" file and then re-enable it again...
2017-12-24 01:52:37 +00:00
Dan
e5cd4dd23e Record sizes 2017-12-24 01:47:49 +00:00
Dan
251193d4fc Fix writing stats to the file 2017-12-24 01:44:08 +00:00
Dan Abramov
32797fd3a3 We can reenable this now 2017-12-24 01:25:06 +00:00
Dan
5bf608723d Fix a few more issues that should fix the CI 2017-12-24 01:16:13 +00:00
Dan Abramov
bf9b0adcbd This will fix CI, this time for real 2017-12-24 00:41:03 +00:00
Dan Abramov
021a567793 We can add this back now (should fix CI) 2017-12-23 22:31:37 +00:00
Dan Abramov
25321dcb23 Temporarily remove a script section that crashes
This will let us upload the updated stats to the server to fix this script
2017-12-23 22:22:24 +00:00
Thomas Broadley
0280e93b11 Fix typos (#11868) 2017-12-23 20:32:33 +00:00
Orta
cf96d84040 [Dev] Adds module and bundle type metadata to the rollup results json (#11914) 2017-12-23 19:22:59 +00:00
Brandon Dail
9ff3ce67ea Add noModule boolean attribute (#11900) 2017-12-22 18:18:51 +00:00
alisherdavronov
faa4218632 Fixed an issue #11853 - window.opera=null problem (#11854) 2017-12-18 22:18:30 -05:00
Dan Abramov
247c524170 Update results.json from master before the build (#11882) 2017-12-18 18:56:38 +00:00
Dan Abramov
e40f6a9568 Upload build stats to the server (#11880) 2017-12-18 18:17:27 +00:00
Raphael Amorim
ef9f1b6e23 Update flow (0.61.0) and declare context type (#11840) 2017-12-18 12:04:16 +00:00
Alexey Raspopov
7242a5caa7 Use binary numbers representation directly (#11873) 2017-12-17 17:56:16 -08:00
Sam Goldman
d906de7f60 Use declare module.exports syntax for flow libdefs (#11861)
We added this to Flow in v0.25 (about 2 years ago), but never actually
deprecated the legacy `declare var exports` syntax. Hoping to do that
soon, so clearing up uses that I can find.

Test Plan: flow
2017-12-15 12:17:46 +00:00
Nathan Hunzaker
cc52e06b49 Prevent BeforeInputPlugin from returning [null, null] (#11848)
The BeforeInputPlugin dispatches null elements in an array if
composition or beforeInput events are not extracted. This causes a
an extra array allocation, but more importantly creates null states in
later event dispatch methods that are annoying to account for.

This commit makes it so that BeforeInputPlugin never returns a null
element inside an array.
2017-12-13 20:39:11 -05:00
Yu Tian
8ec146c38e Rudimentary tests for not covered entry points (#11835)
* Add basic snapshot tests to ReactART components (Circle, Rectangle, Wedge)

* More tests on Circle, Rectangle, Wedge

* linc warning fixes

* - remove tests to Wedge component internal function

* More test on Wedge component, update snapshots
2017-12-13 12:45:30 +00:00
Andrew Clark
7a72aa0a4a Record sizes 2017-12-12 16:07:36 -08:00
Andrew Clark
b77b12311f Call and Return components should use ReactElement (#11834)
* Call and Return components should use ReactElement

ReactChildFiber contains lots of branches that do the same thing for
different child types. We can unify them by having more child types be
ReactElements. This requires that the `type` and `key` fields are
sufficient to determine the identity of the child.

The main benefit is decreased file size, especially as we add more
component types, like context providers and consumers.

This updates Call and Return components to use ReactElement. Portals are
left alone for now because their identity includes the host instance.

* Move server render invariant for call and return types

* Sort ReactElement type checks by most likely

* Performance timeline should skip over call components

Don't think these were intentionally omitted from the blacklist of
component types.

I went ahead and updated getComponentName to include special types, even
though I don't think they're used anywhere right now.

* Remove surrounding brackets from internal display names
2017-12-12 15:04:40 -08:00
Dan Abramov
73265fc478 Simplify SyntheticEvent declarations (#11837) 2017-12-12 16:45:40 +00:00
Dan Abramov
963b5d6b78 Update changelog 2017-12-12 15:06:02 +00:00
Dan Abramov
7299238278 Update Rollup deps (#11829) 2017-12-11 16:54:12 +00:00
Jack Hou
e8e62ebb59 use different eslint config for es6 and es5 (#11794)
* use different eslint config for es6 and es5

* remove confusing eslint/baseConfig.js & add more eslint setting for es5, es6

* more clear way to run eslint on es5 & es6 file

* seperate ESNext, ES6, ES6 path, and use different lint config

* rename eslint config file & update eslint rules

* Undo yarn.lock changes

* Rename a file

* Remove unnecessary exceptions

* Refactor a little bit

* Refactor and tweak the logic

* Minor issues
2017-12-11 15:52:46 +00:00
XaveScor
a5025b1610 fix #11759. false positive warning in IE11 when using React.Fragment (#11823)
* fix #11759. false positive warning in IE11 when using React.Fragment

* simplify createElementWithValidation type check

* fix mistake

* Add an explanation

* We shouldn't use `number` for anything else

* Clarify further
2017-12-11 03:25:28 +00:00
Dan Abramov
abdbb16d4b Record sizes 2017-12-10 17:05:25 +00:00
Dan Abramov
4c3470eef8 Refactor DOM attribute code (take two) (#11815)
* Harden tests around init/addition/update/removal of aliased attributes

I noticed some patterns weren't being tested.

* Call setValueForProperty() for null and undefined

The branching before the call is unnecessary because setValueForProperty() already
has an internal branch that delegates to deleteValueForProperty() for null and
undefined through the shouldIgnoreValue() check.

The goal is to start unifying these methods because their separation doesn't
reflect the current behavior (e.g. for unknown properties) anymore, and obscures
what actually happens with different inputs.

* Inline deleteValueForProperty() into setValueForProperty()

Now we don't read propertyInfo twice in this case.

I also dropped a few early returns. I added them a while ago when we had
Stack-only tracking of DOM operations, and some operations were being
counted twice because of how this code is structured. This isn't a problem
anymore (both because we don't track operations, and because I've just
inlined this method call).

* Inline deleteValueForAttribute() into setValueForAttribute()

The special cases for null and undefined already exist in setValueForAttribute().

* Delete some dead code

* Make setValueForAttribute() a branch of setValueForProperty()

Their naming is pretty confusing by now. For example setValueForProperty()
calls setValueForAttribute() when shouldSetAttribute() is false (!). I want
to refactor (as in, inline and then maybe factor it out differently) the relation
between them. For now, I'm consolidating the callers to use setValueForProperty().

* Make it more obvious where we skip and when we reset attributes

The naming of these methods is still very vague and conflicting in some cases.
Will need further work.

* Rewrite setValueForProperty() with early exits

This makes the flow clearer in my opinion.

* Move shouldIgnoreValue() into DOMProperty

It was previously duplicated.

It's also suspiciously similar in purpose to shouldTreatAttributeValueAsNull()
so I want to see if there is a way to unify them.

* Use more specific methods for testing validity

* Unify shouldTreatAttributeValueAsNull() and shouldIgnoreValue()

* Remove shouldSetAttribute()

Its naming was confusing and it was used all over the place instead of more specific checks.
Now that we only have one call site, we might as well inline and get rid of it.

* Remove unnecessary condition

* Remove another unnecessary condition

* Add Flow coverage

* Oops

* Fix lint (ESLint complains about Flow suppression)

* Fix treatment of Symbol/Function values on boolean attributes

They weren't being properly skipped because of the early return.
I added tests for this case.

* Avoid getPropertyInfo() calls

I think this PR looks worse on benchmarks because we have to read propertyInfo in different places.
Originally I tried to get rid of propertyInfo, but looks like it's important for performance after all.

So now I'm going into the opposite direction, and precompute propertyInfo as early as possible, and then just pass it around.
This way we can avoid extra lookups but keep functions nice and modular.

* Pass propertyInfo as argument to getValueForProperty()

It always exists because this function is only called for known properties.

* Make it clearer this branch is boolean-specific

I wrote this and then got confused myself.

* Memoize whether propertyInfo accepts boolean value

Since we run these checks for all booleans, might as well remember it.

* Fix a crash when numeric property is given a Symbol

* Record attribute table

The changes reflect that SSR doesn't crash with symbols anymore (and just warns, consistently with the client).

* Refactor attribute initialization

Instead of using flags, explicitly group similar attributes/properties.

* Optimization: we know built-in attributes are never invalid

* Use strict comparison

* Rename methods for clarity

* Lint nit

* Minor tweaks

* Document all the different attribute types
2017-12-10 16:58:38 +00:00
Dan Abramov
abe0faf3a1 Fix wrong deduplication condition 2017-12-10 13:09:10 +00:00
Adrian Carolli
51e3f498a2 Deduplication of warn when selected is set on <option> (#11821)
* Deduplication of warn selected on option

- Wrote a failing test
- Deduplication when selected is set on option

* Ran yarn preitter

* Fixed PR request

- Moved dedupe test to above
- Moved && case to seperate if to seperate static and dynamic things
- Render'd component twice

* Actually check for deduplication

* Minor nits
2017-12-10 02:06:41 +00:00
Nathan Hunzaker
f23dd7150f Remove unused wheel event detection in isEventSupported (#11822) 2017-12-09 18:28:26 -05:00
Dan Abramov
d9869a4561 Revert "Refactor DOM attribute code (#11804)" (#11814)
This reverts commit 47783e878d.
2017-12-08 21:05:34 +00:00
Dan Abramov
47783e878d Refactor DOM attribute code (#11804)
* Harden tests around init/addition/update/removal of aliased attributes

I noticed some patterns weren't being tested.

* Call setValueForProperty() for null and undefined

The branching before the call is unnecessary because setValueForProperty() already
has an internal branch that delegates to deleteValueForProperty() for null and
undefined through the shouldIgnoreValue() check.

The goal is to start unifying these methods because their separation doesn't
reflect the current behavior (e.g. for unknown properties) anymore, and obscures
what actually happens with different inputs.

* Inline deleteValueForProperty() into setValueForProperty()

Now we don't read propertyInfo twice in this case.

I also dropped a few early returns. I added them a while ago when we had
Stack-only tracking of DOM operations, and some operations were being
counted twice because of how this code is structured. This isn't a problem
anymore (both because we don't track operations, and because I've just
inlined this method call).

* Inline deleteValueForAttribute() into setValueForAttribute()

The special cases for null and undefined already exist in setValueForAttribute().

* Delete some dead code

* Make setValueForAttribute() a branch of setValueForProperty()

Their naming is pretty confusing by now. For example setValueForProperty()
calls setValueForAttribute() when shouldSetAttribute() is false (!). I want
to refactor (as in, inline and then maybe factor it out differently) the relation
between them. For now, I'm consolidating the callers to use setValueForProperty().

* Make it more obvious where we skip and when we reset attributes

The naming of these methods is still very vague and conflicting in some cases.
Will need further work.

* Rewrite setValueForProperty() with early exits

This makes the flow clearer in my opinion.

* Move shouldIgnoreValue() into DOMProperty

It was previously duplicated.

It's also suspiciously similar in purpose to shouldTreatAttributeValueAsNull()
so I want to see if there is a way to unify them.

* Use more specific methods for testing validity

* Unify shouldTreatAttributeValueAsNull() and shouldIgnoreValue()

* Remove shouldSetAttribute()

Its naming was confusing and it was used all over the place instead of more specific checks.
Now that we only have one call site, we might as well inline and get rid of it.

* Remove unnecessary condition

* Remove another unnecessary condition

* Add Flow coverage

* Oops

* Fix lint (ESLint complains about Flow suppression)
2017-12-08 20:42:24 +00:00
Dan Abramov
cda9fb0499 Add more coverage for custom elements (#11811) 2017-12-08 17:19:00 +00:00
Manas
ac630e4a2f Adds deprecation warning for ReactDOM.unstable_createPortal (#11747) 2017-12-08 15:59:55 +00:00
Brandon Dail
6e258c1266 Move isAttributeNameSafe to DOMProperty (#11802) 2017-12-07 17:23:02 -08:00
Dan Abramov
bee4baf1fd Oops, fix CI 2017-12-08 00:41:25 +00:00
Dan Abramov
9cccde927f Add yarn build --pretty (#11801) 2017-12-07 22:47:56 +00:00
Dan Abramov
52eb59dda2 Remove IE8-specific focus polyfill (#11800) 2017-12-07 22:47:29 +00:00
Dan Abramov
f93e34e980 Remove an extra allocation for open source bundles (#11797)
* Remove EventListener fbjs utility

EventListener normalizes event subscription for <= IE8. This is no
longer necessary. element.addEventListener is sufficient.

* Remove an extra allocation for open source bundles

* Split into two functions to avoid extra runtime checks

* Revert unrelated changes
2017-12-07 22:28:59 +00:00
Brandon Dail
5301c41417 Revert "Remove empty value for boolean attributes in SSR (#11708)" (#11798)
This reverts commit e0c3113743.
2017-12-07 22:06:20 +00:00
Dan Abramov
41f920e430 Add a test-only transform to catch infinite loops (#11790)
* Add a test-only transform to catch infinite loops

* Only track iteration count, not time

This makes the detection dramatically faster, and is okay in our case because we don't have tests that iterate so much.

* Use clearer naming

* Set different limits for tests

* Fail tests with infinite loops even if the error was caught

* Add a test
2017-12-07 20:53:13 +00:00
Anushree Subramani
825682390d ValidateDOMNesting tests(#11299) (#11742)
*  ValidateDOMNesting tests(#11299)

 * Rewrite tests using only public API.
 * Modified the tests to prevent duplication of code.
 * Code review changes implemented.
 * Removed the .internal from the test file name as
   its now written using public APIs.

* Remove mutation

* Remove unnecessary argument

Now that we pass warnings, we don't need to pass a boolean.

* Move things around a bit, and add component stack assertions
2017-12-07 18:45:42 +00:00
Dan Abramov
2d7aafd9d1 Oops 2017-12-07 12:04:51 +00:00
Dan Abramov
9fa08750c0 Mention how to use debuggers 2017-12-07 12:03:45 +00:00
Dan Abramov
ff3c1b8e12 Add yarn debug-test (#11791) 2017-12-07 11:05:39 +00:00
Dan Abramov
f72043a369 Refactor the build scripts (#11787)
* Rewrite the build scripts

* Don't crash when doing FB-only builds

* Group sync imports under Sync.*

* Don't print known errors twice

* Use an exclamation that aligns vertically
2017-12-06 20:11:32 +00:00
Toru Kobayashi
19bc2dd090 Fix autoFocus for hydration content when it is mismatched (#11737)
* Fix autoFocus for hydration content when it is mismatched

* Add a test for mismatched content

* Fix a test for production

* Fix a spec description and verify console.error output

* Run prettier

* finalizeInitialChildren always returns `true`

* Revert "finalizeInitialChildren always returns `true`"

This reverts commit 58edd228046bcafcbcd04a70cb5e78520b50a07e.

* Add a TODO comment

* Update ReactServerRendering-test.js

* Update ReactServerRendering-test.js

* Rewrite the comment
2017-12-06 15:23:37 +00:00
Raphael Amorim
5bd2321ae3 Remove vars (#11780)
* react-dom: convert packages/react-dom/src/client

* react-dom: convert packages/react-dom/src/events

* react-dom: convert packages/react-dom/src/test-utils

* react-dom: convert files on root

* react-dom: convert updated ReactDOM-test.js
2017-12-06 01:39:48 +00:00
Sophie Alpert
3145639dc3 https fb.me links (#11779) 2017-12-05 10:39:16 -08:00
Raphael Amorim
48616e591f react-dom: convert packages/react-dom/src/__tests__ (#11776) 2017-12-05 18:29:22 +00:00
Brian Vaughn
1637b43e27 Changed the way we double-invoke cWM lifecycle hook (#11764)
* Changed the way we double-invoke cWM lifecycle hook

* Explicitly pass props to super() in test
2017-12-05 08:24:45 -08:00
Dan Abramov
2e29637ddf Record sizes 2017-12-05 14:20:32 +00:00
Yu Tian
6d242904cd Issue #11257(Updated) - Change build process to include npm pack and unpacking (#11750)
* Change build process to include npm pack and unpacking generated packages to corresponding build directories.

* Update function name, change to use os's default temp directory

* appending uuid to temp npm packaging directory.
2017-12-05 13:53:53 +00:00
Raphael Amorim
37e4329bc8 Remove vars (#11766)
* react: convert packages/react

* react-reconciler: convert packages/react-reconciler

* react-noop-renderer: convert packages/react-noop-renderer

* react-dom: convert packages/react-dom/src/shared

* react-dom: convert packages/react-dom/src/server
2017-12-05 13:47:57 +00:00
Andrew Clark
4d0e8fc487 ReactDOM.createRoot creates an async root (#11769)
Makes createRoot the opt-in API for async updates. Now we don't have
to check the top-level element to see if it's an async container.
2017-12-04 14:34:02 -08:00
Dan Abramov
d7f6ece27c Remove the unused shim 2017-12-04 15:47:11 +00:00
Nathan Hunzaker
323efbc33c Ensure value and defaultValue do not assign functions and symbols (#11741)
* Ensure value and defaultValue do not assign functions and symbols

* Eliminate assignProperty method from ReactDOMInput

* Restore original placement of defaultValue reservedProp

* Reduce branching. Make assignment more consistent

* Control for warnings in symbol/function tests

* Add boolean to readOnly assignments

* Tweak the tests

* Invalid value attributes should convert to an empty string

* Revert ChangeEventPlugin update. See #11746

* Format

* Replace shouldSetAttribute call with value specific type check

DOMProperty.shouldSetAttribute runs a few other checks that aren't
appropriate for determining if a value or defaultValue should be
assigned on an input. This commit replaces that call with an input
specific check.

* Remove unused import

* Eliminate unnecessary numeric equality checks (#11751)

* Eliminate unnecessary numeric equality checks

This commit changes the way numeric equality for number inputs works
such that it compares against `input.valueAsNumber`. This eliminates
quite a bit of branching around numeric equality.

* There is no need to compare valueAsNumber

* Add test cases for empty string to 0.

* Avoid implicit boolean JSX props

* Split up numeric equality test to isolate eslint disable command

* Fix typo in ReactDOMInput test

* Add todos

* Update the attribute table
2017-12-04 14:39:32 +00:00
Nathan Hunzaker
2091c62558 Add test fixture for initial input validation bug in Firefox (#11760) 2017-12-04 08:59:53 -05:00
Dan Abramov
62f8a822b0 Pin lighthouse at 2.0.0 2017-12-04 13:23:30 +00:00
Nathan Hunzaker
8ce53671ed Use the same value synchronization function on number blur (#11746)
I updated ReactDOMInput.synchronizeDefaultValue such that it assignes
the defaultValue property instead of the value attribute. I never
followed up on the ChangeEventPlugin's on blur behavior.
2017-12-02 16:06:32 +00:00
Dan Abramov
31ea0aa6d7 Add a test for bad Map polyfill, and work around Rollup bug (#11745)
* Add a test for bad Map polyfill

* Add a workaround for the Rollup bug

* Add a link to the bug URL
2017-12-02 00:00:40 +00:00
Dan Abramov
8540768616 Fix benchmark runner (#11749) 2017-12-02 00:00:29 +00:00
Dan Abramov
ffe8546c7d Update the attribute table
- the capture attribute changed in #11424
- changes to value/defaultValue handling of functions/Symbols are from #11534, but as per https://github.com/facebook/react/issues/11734#issuecomment-348595047 this is actually not a new problem so we're okay with it
2017-12-01 19:54:12 +00:00
Dan Abramov
59763bf7f3 Add explicit warning assertions to ReactDOMInput-test (#11744) 2017-12-01 17:16:05 +00:00
Nathan Hunzaker
0a2ed64450 Remove dead code from DOMPropertyOperations (#11740) 2017-12-01 13:27:41 +00:00
Dan Abramov
f99ecce596 Record sizes 2017-12-01 02:36:50 +00:00
Raphael Amorim
6c1fba539a shared: convert vars into let/const (#11730) 2017-12-01 00:03:27 +00:00
Raphael Amorim
2a1b1f3094 react-test-renderer: convert vars into let/const (#11731) 2017-12-01 00:01:45 +00:00
Raphael Amorim
6074664f73 react-reconciler: convert vars into let/const (#11729) 2017-11-30 23:59:05 +00:00
Dan Abramov
8ec2ed4089 Move HTML and SVG configs into DOMProperty (#11728)
* Inline HTML and SVG configs into DOMProperty

* Replace invariants with warnings

These invariants can only happen if *we* mess up, and happen during init time.
So it's safe to make these warnings, as they would fail the tests anyway.

* Clearer variable naming
2017-11-30 22:29:58 +00:00
Raphael Amorim
b3e27b2640 react-rt-renderer, react-cs-renderer, react-call-return: Convert vars to let/const (#11721)
* react-call-return: convert var to let/const

* react-cs-renderer: convert var to let/const

* react-rt-renderer: convert var to let/const
2017-11-30 21:40:12 +00:00
Raphael Amorim
ea9714807b react-native-renderer: convert vars to let/const (#11722) 2017-11-30 21:39:39 +00:00
Nathan Hunzaker
fd69c239a0 Use defaultValue instead of setAttribute('value') (#11534)
* Use defaultValue instead of setAttribute('value')

This commit replaces the method of synchronizing an input's value
attribute from using setAttribute to assigning defaultValue. This has
several benefits:

- Fixes issue where IE10+ and Edge password icon disappears (#7328)
- Fixes issue where toggling input types hides display value on dates
  in Safari (unreported)
- Removes mutationMethod behaviors from DOMPropertyOperations

* initialValue in Input wrapperState is always a string

* The value property is assigned before the value attribute. Fix related tests.

* Remove initial value tests in ReactDOMInput

I added these tests after removing the `value` mutation
method. However they do not add any additional value over existing
tests.

* Improve clarity of value checks in ReactDOMInput.postMountWrapper

* Remove value and defaultValue from InputWithWrapperState type

They are already included in the type definition for HTMLInputElement

* Inline stringification of value in ReactDOMInput

Avoids eagier stringification and makes usage more consistent.

* Use consistent value/defaultValue presence in postMountHook

Other methods in ReactDOMInput check for null instead of
hasOwnProperty.

* Add missing semicolon

* Remove unused value argument in ReactDOMInput test

* Address cases where a value switches to undefined

When a controlled input value switches to undefined, it reverts back
to the initial state of the controlled input.

We didn't have test coverage for this case, so I've added two describe
blocks to cover both null and undefined.
2017-11-30 21:24:55 +00:00
Whien
3f736c360e Test: create TapEventPlugin-test (#11727)
* Test: create TapEventPlugin-test

* move TapEventPlugin to TapEventPlugin-test.internal.js from ReactBrowserEventEmitter-test.internal.js

* Prittier: run prittier

* run prittier

* Fix: fix CI test error

fix CI test error by lint

* Test: remove TapEventPlugin test code

* remove TapEventPlugin test code from ReactBrowserEventEmitter-test.internal.js
2017-11-30 21:22:58 +00:00
Dan Abramov
46b3c3e4ae Use static injection for ReactErrorUtils (#11725)
* Use `this` inside invokeGuardedCallback

It's slightly odd but that's exactly how our www fork works.
Might as well do it in the open source version to make it clear we rely on context here.

* Move invokeGuardedCallback into a separate file

This lets us introduce forks for it.

* Add a www fork for invokeGuardedCallback

* Fix Flow
2017-11-30 19:10:46 +00:00
abiduzz420
f57d963cce Rewrote ReactIncrementalPerf-test using only public API.(#11299) (#11724)
* WIP:use public API

* ReactPortal shifted to shared:all passed

* wrote createPortal method for ReactNoop.(#11299)

* imported ReactNodeList type into ReactNoop.(#11299)

* createPortal method implemented.(#11299)

* exec yarn prettier-all.(#11299)
2017-11-30 18:10:04 +00:00
Dan Abramov
7d6b24332b Ensure ReactFiberErrorDialogWWW.showErrorDialog exists 2017-11-30 18:09:51 +00:00
Dan Abramov
642a678a80 Replace ReactFiberErrorLogger injection with static forks (#11717) 2017-11-30 17:57:13 +00:00
Dan Abramov
060581b128 Fix issues with the new fork plugin (#11723) 2017-11-30 16:20:09 +00:00
Raphael Amorim
e997756e2a react-art: convert var to let/const (#11720) 2017-11-30 15:23:24 +00:00
Dan Abramov
8cbc16f0fa Unify the way we fork modules (#11711)
* Unify the way we fork modules

* Replace rollup-plugin-alias with our own plugin

This does exactly what we need and doesn't suffer from https://github.com/rollup/rollup-plugin-alias/issues/34.

* Move the new plugin to its own file

* Rename variable for consistency

I settled on calling them "forks" since we already have a different concept of "shims".

* Move fork config into its own file
2017-11-30 12:11:00 +00:00
Raphael Amorim
3c977dea6b react: convert var to let/const (#11715) 2017-11-30 12:08:58 +00:00
Raphael Amorim
2decfe97dc events: convert var to let/const (#11714) 2017-11-30 12:07:40 +00:00
Dan Abramov
c78db58a61 Record sizes 2017-11-30 01:18:55 +00:00
Sotiris Kiritsis
d83916e4aa Rewrite SelectEventPlugin-test to test behavior using Public API (#11299) (#11676)
* Rewrite SelectEventPlugin-test to test behavior using Public API

* Minor refactor

* Make sure that we test that "focus" event is ignored
Use newer API when creating events

* Rewrote the other test to use Public API as well

* Tweak the test

* Remove -internal suffix

* Oops
2017-11-29 22:17:46 +00:00
Dan Abramov
c3f1b6cd91 Prevent infinite loop when SSR-rendering a portal (#11709) 2017-11-29 21:45:38 +00:00
Brandon Dail
e0c3113743 Remove empty value for boolean attributes in SSR (#11708) 2017-11-29 09:59:56 -08:00
Dan Abramov
3e64b18540 Deprecate injecting custom event plugins (#11690)
* Deprecate injecting custom event plugins

* Fix up tests

* Fix CI

* oh noes
2017-11-29 17:48:16 +00:00
Artem Fitiskin
8c1c5d7a5a Fixes path in package.json build script (#11707) 2017-11-29 17:32:47 +00:00
Dan Abramov
9491dee795 Throw if document is missing by the time invokeGuardedCallbackDev runs (#11677)
* Warn if `document` is missing by the time invokeGuardedCallback runs in DEV

* Typo

* Add a comment

* Use invariant() instead

* Create event immediately for clarity
2017-11-29 15:53:16 +00:00
Dan Abramov
6340d6cf2e Delete Fiber test tracker (#11704) 2017-11-29 15:27:16 +00:00
Dan Abramov
9e07008df5 Disable Flow on AppVeyor 2017-11-29 14:38:52 +00:00
Dan Abramov
bc21578fad Add more tasks to AppVeyor 2017-11-29 14:33:07 +00:00
Dan Abramov
bc1b7f3c38 Try to fix AppVeyor (#11702) 2017-11-29 14:19:33 +00:00
Tim Jacobi
c1b2a347be Rewrite ReactTreeTraversal-test.js using public APIs (#11664)
* rewrite two phase traversal tests with public APIs

* rewrite enter/leave tests

* lift render into beforeEach, organise variables

* move getLowestCommonAncestor test

* remove internal tree traversal test

* fix linter errors

* move creation of outer nodes into {before,after}Each

* explain why getLowestCommonAncestor test was moved

* remove unnessecary ARG and ARG2 token

these were used for testing the internal API to simulate synthetic
events passed to traverseEnterLeave. since we're now dealing with
actual synthetic events we can remove them.

* run prettier
2017-11-29 14:04:18 +00:00
Gabriel Kalani
b097a34eba refactor: scripts/error-codes (#11697)
Convert scripts/error-codes to use ES6 syntax
2017-11-29 01:13:12 +00:00
Andrew Clark
2ae4c62158 Always set pendingProps to the next props (#11580)
In the current implementation, pendingProps is null if there are no new
props since the last commit. When that happens, we bail out and reuse
the current props.

But it makes more sense to always set pendingProps to whatever the next
props will be. In other words, pendingProps is never null: it points to
either new props, or to the current props. Modeling it this way lets us
delete lots of code branches and is easier to reason about bail outs:
just compare the pending props to the current props.
2017-11-28 16:50:23 -08:00
Andrew Clark
1b55ad2a4b root.createBatch (#11473)
API for batching top-level updates and deferring the commit.

- `root.createBatch` creates a batch with an async expiration time
  associated with it.
- `batch.render` updates the children that the batch renders.
- `batch.then` resolves when the root has completed.
- `batch.commit` synchronously flushes any remaining work and commits.

No two batches can have the same expiration time. The only way to
commit a batch is by calling its `commit` method. E.g. flushing one
batch will not cause a different batch to also flush.
2017-11-28 16:48:35 -08:00
Brian Vaughn
9895a0ff63 Added ReactFeatureFlags shim for React Native (#11694)
* Added ReactFeatureFlags shim for React Native

* Fixed header license comment
2017-11-28 15:16:53 -08:00
Dan Abramov
18bbd644a2 Add 16.2.0 to changelog 2017-11-28 23:04:07 +00:00
Sotiris Kiritsis
e5cacb2036 Stop ESLint from looking for a configuration file in parent folders (#11695) 2017-11-28 22:56:29 +00:00
Dan Abramov
5f9b4934a0 Fix CI fact uploading (#11693) 2017-11-28 22:39:43 +00:00
Brian Vaughn
53ab1948b5 Blacklist spyOn(). Add explicit spyOnProd() and spyOnDevAndProd() (#11691)
* Blacklist spyOn(). Add explicit spyOnProd() and spyOnDevAndProd()

* Wording tweak.

* Fixed lint no-shadow warning
2017-11-28 14:06:26 -08:00
Clement Hoang
edb2b3d3a7 Update bundle sizes for 16.2.0 release 2017-11-28 13:29:23 -08:00
Clement Hoang
5a42586178 Updating package versions for release 16.2.0 2017-11-28 13:26:36 -08:00
Dominic Gannaway
363f4f14dc [WIP] Fix for fiber root scheduling memory leak (#11644)
* Fix for root memory leak

* forgot to add code
2017-11-28 12:57:32 -08:00
Dan Abramov
c611d2c215 Amend changelog 2017-11-28 19:09:23 +00:00
rivenhk
8e876d244c Move ReactFiberTreeReflection to react-reconciler/reflection (#11683)
* Move ReactFiberTreeReflection to react-reconciler/reflection #11659

* Use * for react-reconciler

We don't know the latest local version, and release script currently doesn't bump deps automatically.

* Remove unused field

* Use CommonJS in entry point for consistency

* Undo the CommonJS change

I didn't realize it would break the build.

* Record sizes

* Remove reconciler fixtures

They're unnecessary now that we run real tests on reconciler bundles.
2017-11-28 16:57:22 +00:00
Michał Pierzchała
db0454134c CI: remove unnecessary Yarn download (#11684) 2017-11-28 16:08:08 +00:00
Dan Abramov
b89dc25e3f Record sizes 2017-11-28 16:03:30 +00:00
Raphael Amorim
a2b6b6b206 Migrate to CircleCI2.0 and Add AppVeyor for master-only branch (#11605)
* add appveyor config file

* migrate circleci 1.0 to circleci 2.0

* remove upload step in favour of #11666
2017-11-28 14:39:18 +00:00
Jordan Tepper
7788bcdb26 Do not fail yarn linc for ignored file warning (#11615) (#11641)
* Add rule to ignore default handling of not linting hidden files

* Undo changes

* Add function to validate warnings

* Use validateWarnings when reporting linc command

* Restore files

* Contain code to line file
2017-11-28 13:54:46 +00:00
Ronald Eddy Jr
b542f42a0f Update README URLS to HTTPS (#11635)
URLs were updated to use HTTPS protocol in README files.
2017-11-27 18:13:41 -08:00
Alex Cordeiro
158f040d54 Lint untracked files with yarn linc (#11665)
* Lint untracked files with yarn linc (#11646)

* Run prettier on untracked files

* Unify code for listing changed files into shared utility
2017-11-27 23:30:36 +00:00
Dan Abramov
878feebe34 Remove accidentally duplicated tests (#11675)
* Remove accidentally duplicated tests

* Refactor: move unmock() call into the only test needing it

This makes the intent more explicit.
2017-11-27 22:38:50 +00:00
Dan Abramov
fe551de273 Enable bundle tests for React.Fragment (#11673) 2017-11-27 21:44:13 +00:00
Clement Hoang
f6894dc48b Set fragment export flags to true (#11672) 2017-11-27 13:09:15 -08:00
Dan Abramov
a65a8abc65 Use async/await in Rollup scripts (#11669) 2017-11-27 17:57:28 +00:00
Dan Abramov
018276976c Show nicer message on syntax errors 2017-11-27 15:55:46 +00:00
Dan Abramov
d445cd6ea3 Bump Node devEngines to 8.x 2017-11-27 15:22:42 +00:00
Dan Abramov
0c164bb485 Upload build on the same node where it happens (#11666) 2017-11-26 18:03:30 +00:00
Adrian Carolli
53ef71b8e8 Add bundle linting and tests to the release script (#11662)
* Add bundle linting and tests to the release script

 - add yarn lint-build
- use yarn lint-build in circle ci build.sh
- add yarn lint-build, yarn test-prod, yarn test-build, and yarn test-build-prod to the realse script

* Improve readability of release test messages

* Run prettier

* Updating package versions for release 16.2.0

* Seperate bundle specific tests

- Moved the runYarnTask into utils since its being used two files now
- Uncomment out checks I mistakenly committed

* Revert a bunch of version bump changes

Mistakenly commited by release script

* .js for consistency
2017-11-26 16:47:20 +00:00
Dan Abramov
f53bd033e7 Fix Jest call in the release script
Just running jest binary will no longer work
2017-11-25 16:13:28 +00:00
Anton Arboleda
d1cb28c86b Refactor SyntheticKeyboardEvent tests to only use the public API (#11631)
* KeyboardEvent interface-keypress

* Pass first 6 tests

* Roll getEventCharCode-test into SyntheticKeyboardEvent-test

* Run SyntheticKeyboardEvent-test on bundles

* Remove unused code
2017-11-25 15:47:05 +00:00
Dan Abramov
d235e61dc2 Don't reset error codes on CI build (#11655)
* Don't reset error codes on CI build

* Add an explanation
2017-11-25 02:23:13 +00:00
Dan Abramov
f0ba6bbf20 Replace inputValueTracking-test with public API tests (#11654) 2017-11-25 01:47:10 +00:00
Ethan Arrowood
a67757e115 Use only public API for ChangeEventPlugin-test.js (#11333)
* Use only public API for ChangeEventPlugin-test.js

* precommit commands complete

* Removed comments

* Improving event dispatchers

* Updated tests

* Fixed for revisions

* Prettified

* Add more details and fixes to tests

* Not internal anymore

* Remove unused code
2017-11-24 22:18:40 +00:00
Zubair Ahmed
7d27851bf4 Issue#11510: added verification check for misspelled propTypes (#11524)
* added verification check for misspelled propTypes

* added flag to check if misspelled warning was shown to developer before

* added the condition to else if and improved the warning message

* moved  variable under dev section & initialized it to false

* added test to confirm the missmatch prop type warning in both  and  tests files

* removed eslint disable and split error into 2 lines

* changed expectDev to expect in tests

* added __DEV__ condition before both tests
2017-11-24 02:59:46 +00:00
Dan Abramov
46dd197ceb Add a note about private API dependency for a test 2017-11-24 01:11:24 +00:00
Jeremias Menichelli
cafe352c1a Drop .textContent IE8 polyfill and rewrite escaping tests against public API (#11331)
* Rename escapeText util. Test quoteAttributeValueForBrowser through ReactDOMServer API

* Fix lint errors

* Prettier reformatting

* Change syntax to prevent prettier escape doble quote

* Name and description gardening. Add tests for escapeTextForBrowser. Add missing tests

* Improve script tag as text content test

* Update escapeTextForBrowser-test.js

* Update quoteAttributeValueForBrowser-test.js

* Simplify tests

* Move utilities to server folder
2017-11-23 22:41:28 +00:00
Dan Abramov
575982b96d Forbid Haste in Jest (#11647) 2017-11-23 18:02:47 +00:00
Dan Abramov
fa7a97fc46 Run 90% of tests on compiled bundles (both development and production) (#11633)
* Extract Jest config into a separate file

* Refactor Jest scripts directory structure

Introduces a more consistent naming scheme.

* Add yarn test-bundles and yarn test-prod-bundles

Only files ending with -test.public.js are opted in (so far we don't have any).

* Fix error decoding for production bundles

GCC seems to remove `new` from `new Error()` which broke our proxy.

* Build production version of react-noop-renderer

This lets us test more bundles.

* Switch to blacklist (exclude .private.js tests)

* Rename tests that are currently broken against bundles to *-test.internal.js

Some of these are using private APIs. Some have other issues.

* Add bundle tests to CI

* Split private and public ReactJSXElementValidator tests

* Remove internal deps from ReactServerRendering-test and make it public

* Only run tests directly in __tests__

This lets us share code between test files by placing them in __tests__/utils.

* Remove ExecutionEnvironment dependency from DOMServerIntegrationTest

It's not necessary since Stack.

* Split up ReactDOMServerIntegration into test suite and utilities

This enables us to further split it down. Good both for parallelization and extracting public parts.

* Split Fragment tests from other DOMServerIntegration tests

This enables them to opt other DOMServerIntegration tests into bundle testing.

* Split ReactDOMServerIntegration into different test files

It was way too slow to run all these in sequence.

* Don't reset the cache twice in DOMServerIntegration tests

We used to do this to simulate testing separate bundles.
But now we actually *do* test bundles. So there is no need for this, as it makes tests slower.

* Rename test-bundles* commands to test-build*

Also add test-prod-build as alias for test-build-prod because I keep messing them up.

* Use regenerator polyfill for react-noop

This fixes other issues and finally lets us run ReactNoop tests against a prod bundle.

* Run most Incremental tests against bundles

Now that GCC generator issue is fixed, we can do this.
I split ErrorLogging test separately because it does mocking. Other error handling tests don't need it.

* Update sizes

* Fix ReactMount test

* Enable ReactDOMComponent test

* Fix a warning issue uncovered by flat bundle testing

With flat bundles, we couldn't produce a good warning for <div onclick={}> on SSR
because it doesn't use the event system. However the issue was not visible in normal
Jest runs because the event plugins have been injected by the time the test ran.

To solve this, I am explicitly passing whether event system is available as an argument
to the hook. This makes the behavior consistent between source and bundle tests. Then
I change the tests to document the actual logic and _attempt_ to show a nice message
(e.g. we know for sure `onclick` is a bad event but we don't know the right name for it
on the server so we just say a generic message about camelCase naming convention).
2017-11-23 17:44:58 +00:00
Dan Abramov
e949d57508 Remove global mocks by adding support for "suppressReactErrorLogging" property (#11636)
* Remove global mocks

They are making it harder to test compiled bundles.

One of them (FeatureFlags) is not used. It is mocked in some specific test files (and that's fine).

The other (FiberErrorLogger) is mocked to silence its output. I'll look if there's some other way to achieve this.

* Add error.suppressReactErrorLogging and use it in tests

This adds an escape hatch to *not* log errors that go through React to the console.
We will enable it for our own tests.
2017-11-23 01:15:22 +00:00
Alex Cordeiro
f114bad09f Bug fix - SetState callback called before component state is updated in ReactShallowRenderer (#11507)
* Create test to verify ReactShallowRenderer bug (#11496)

* Fix ReactShallowRenderer callback bug on componentWillMount (#11496)

* Improve fnction naming and clean up queued callback before call

* Run prettier on ReactShallowRenderer.js

* Consolidate callback call on ReactShallowRenderer.js

* Ensure callback behavior is similar between ReactDOM and ReactShallowRenderer

* Fix Code Review requests (#11507)

* Move test to ReactCompositeComponent

* Verify the callback gets called

* Ensure multiple callbacks are correctly handled on ReactShallowRenderer

* Ensure the setState callback is called inside componentWillMount (ReactDOM)

* Clear ReactShallowRenderer callback queue before actually calling the callbacks

* Add test for multiple callbacks on ReactShallowRenderer

* Ensure the ReactShallowRenderer callback queue is cleared after invoking callbacks

* Remove references to internal fields on ReactShallowRenderer test
2017-11-22 22:15:11 +00:00
Dan Abramov
913a125ad5 Change DEV-only invariants to be warnings (#11630)
* Change DEV-only invariant about instance.state type to a warning

* Change DEV-only invariant childContextTypes check to a warning
2017-11-22 18:58:53 +00:00
Dan Abramov
1cb6199d22 Consolidate all symbols in a single file (#11629)
* Consolidate all symbols in a single file

This reduces the code duplication as we have quite a few now.

* Record sizes
2017-11-22 18:08:22 +00:00
Dan Abramov
d1f6fbd22a Record sizes 2017-11-22 16:15:04 +00:00
Dan Abramov
4c451f7f2b Add yarn test-prod to pull request steps 2017-11-22 13:11:07 +00:00
Dan Abramov
6041f481b7 Run Jest in production mode (#11616)
* Move Jest setup files to /dev/ subdirectory

* Clone Jest /dev/ files into /prod/

* Move shared code into scripts/jest

* Move Jest config into the scripts folder

* Fix the equivalence test

It fails because the config is now passed to Jest explicitly.
But the test doesn't know about the config.

To fix this, we just run it via `yarn test` (which includes the config).
We already depend on Yarn for development anyway.

* Add yarn test-prod to run Jest with production environment

* Actually flip the production tests to run in prod environment

This produces a bunch of errors:

Test Suites: 64 failed, 58 passed, 122 total
Tests:       740 failed, 26 skipped, 1809 passed, 2575 total
Snapshots:   16 failed, 4 passed, 20 total

* Ignore expectDev() calls in production

Down from 740 to 175 failed.

Test Suites: 44 failed, 78 passed, 122 total
Tests:       175 failed, 26 skipped, 2374 passed, 2575 total
Snapshots:   16 failed, 4 passed, 20 total

* Decode errors so tests can assert on their messages

Down from 175 to 129.

Test Suites: 33 failed, 89 passed, 122 total
Tests:       129 failed, 1029 skipped, 1417 passed, 2575 total
Snapshots:   16 failed, 4 passed, 20 total

* Remove ReactDOMProduction-test

There is no need for it now. The only test that was special is moved into ReactDOM-test.

* Remove production switches from ReactErrorUtils

The tests now run in production in a separate pass.

* Add and use spyOnDev() for warnings

This ensures that by default we expect no warnings in production bundles.
If the warning *is* expected, use the regular spyOn() method.

This currently breaks all expectDev() assertions without __DEV__ blocks so we go back to:

Test Suites: 56 failed, 65 passed, 121 total
Tests:       379 failed, 1029 skipped, 1148 passed, 2556 total
Snapshots:   16 failed, 4 passed, 20 total

* Replace expectDev() with expect() in __DEV__ blocks

We started using spyOnDev() for console warnings to ensure we don't *expect* them to occur in production. As a consequence, expectDev() assertions on console.error.calls fail because console.error.calls doesn't exist. This is actually good because it would help catch accidental warnings in production.

To solve this, we are getting rid of expectDev() altogether, and instead introduce explicit expectation branches. We'd need them anyway for testing intentional behavior differences.

This commit replaces all expectDev() calls with expect() calls in __DEV__ blocks. It also removes a few unnecessary expect() checks that no warnings were produced (by also removing the corresponding spyOnDev() calls).

Some DEV-only assertions used plain expect(). Those were also moved into __DEV__ blocks.

ReactFiberErrorLogger was special because it console.error()'s in production too. So in that case I intentionally used spyOn() instead of spyOnDev(), and added extra assertions.

This gets us down to:

Test Suites: 21 failed, 100 passed, 121 total
Tests:       72 failed, 26 skipped, 2458 passed, 2556 total
Snapshots:   16 failed, 4 passed, 20 total

* Enable User Timing API for production testing

We could've disabled it, but seems like a good idea to test since we use it at FB.

* Test for explicit Object.freeze() differences between PROD and DEV

This is one of the few places where DEV and PROD behavior differs for performance reasons.
Now we explicitly test both branches.

* Run Jest via "yarn test" on CI

* Remove unused variable

* Assert different error messages

* Fix error handling tests

This logic is really complicated because of the global ReactFiberErrorLogger mock.
I understand it now, so I added TODOs for later.

It can be much simpler if we change the rest of the tests that assert uncaught errors to also assert they are logged as warnings.
Which mirrors what happens in practice anyway.

* Fix more assertions

* Change tests to document the DEV/PROD difference for state invariant

It is very likely unintentional but I don't want to change behavior in this PR.
Filed a follow up as https://github.com/facebook/react/issues/11618.

* Remove unnecessary split between DEV/PROD ref tests

* Fix more test message assertions

* Make validateDOMNesting tests DEV-only

* Fix error message assertions

* Document existing DEV/PROD message difference (possible bug)

* Change mocking assertions to be DEV-only

* Fix the error code test

* Fix more error message assertions

* Fix the last failing test due to known issue

* Run production tests on CI

* Unify configuration

* Fix coverage script

* Remove expectDev from eslintrc

* Run everything in band

We used to before, too. I just forgot to add the arguments after deleting the script.
2017-11-22 13:02:26 +00:00
Dan Abramov
7e7127387b Run Jest tests with "development" environment (#11612) 2017-11-21 16:28:42 +00:00
Dan Abramov
40a176d859 Remove mentions of module map in Jest config (#11611) 2017-11-21 16:01:10 +00:00
Bryce Kalow
7e692fb496 Fixes typo in eslint script (#11607) 2017-11-21 02:46:57 +00:00
Matteo Vesprini-Heidrich
c6bde7b99f support Call and Return components in React.Children calls (#11422)
* support Call and Return components in React.Children calls

* make tests more verbose

* fix ordering of React component types

* cleanup conditional detection of children type

* directly inline callback invocation

* reduce callback invocation code re-use
2017-11-20 22:06:37 +00:00
Brian Vaughn
dbf715c958 Read debugRenderPhaseSideEffects from GK (#11603)
* Forked ReactFeatureFlags for React Native to enable debugRenderPhaseSideEffects GK
* Changed debugRenderPhaseSideEffects in www feature flags to be runtime as well
2017-11-20 14:05:53 -08:00
Andy Davies
adcf980333 Re-enable UMD build for TestUtils (#11599)
Fixes #11111
2017-11-20 12:41:01 -05:00
Tim Jacobi
669a70dab7 Rewrite SyntheticEvent tests using public APIs only (#11525)
* generate synthetics events using public API

* rewritten createEvent to use public APIs
* removed all references SyntheticEvent.release

In order to test under realistic circumstances I had to move
the expectations into a callback in mosts tests to overcome
the effects of event pooling.

* run prettier

* remove empty line

* don't use ReactTestUtils

* run prettier and fix linter issues

* remove duplicate test

* remove invalid calls to expect

The removed `expect` calls verified the correct behaviour based on
missing `preventDefault` and `stopPropagation` methods.
The was correct as we used plain objects to simulate events.
Since we switched to the public API we're using native events which
do have these methods.

* set event.defaultPrevented to undefined

This was missed when the test was first migrated.
When emulating IE8 not only has returnValue to be false.
In addition defaultPrevented must not be defined.

* run all tests and format code

* rename instance variable to node

* remove backtick

* only simulate IE in normalisation test

* include assignment in definition

* add missing `persist` test

* use method instead of field to prevent default

* expect properties to be unchanged on persisted event

* optimise tests that deal with event persitence

* declare and assign `event` on the same line if not reassigned later
2017-11-20 14:29:27 +00:00
cristidrg
bd9dbd5d60 Remove MouseWheel and MouseDOMScroll event patching
The `wheel` event has not always been supported in every browser. React would fall back to `mousewheel` and `DOMMouseScroll` when the `wheel` event was not available. All supported browsers provide the `wheel` event. This code is no longer necessary.
2017-11-20 07:40:57 -05:00
Nathan Hunzaker
57aef3f00e Format test fixtures 2017-11-19 12:12:46 -05:00
landvibe
70abda5b92 Switching the name property preserves radio selection
Fixes a case where changing the name and checked value of a radio button in the same update would lead to checking the wrong radio input. Also adds a DOM test fixture for related issue.

Related issues:
https://github.com/facebook/react/issues/7630
2017-11-19 10:44:35 -05:00
Raphael Amorim
3f405da614 Migrating to const/let and Object Spread in more places (#11535)
* Use const/let in more places (#11467)

* Convert ReactDOMFiberTextarea to const/let
* Convert ReactDOMSelection to const/let
* Convert setTextContent to const/let
* Convert validateDOMNesting to const/let

* Replace Object.assign by Object Spread

* Convert ReactDOMFiberOption to Object Spread
* Convert ReactDOMFiberTextarea to Object Spread
* Convert validateDOMNesting to Object Spread
2017-11-19 14:53:55 +00:00
Soo Jae Hwang
962042f827 Improve formatting of errors when building (#11456)
* Improve formatting of errors when building

* Remove undefined from the header when error.plugin is undefined

* Add babel-code-frame and syntax highlighting in error message

* Run yarn prettier and fix code format
2017-11-19 14:23:33 +00:00
Gordon Dent
aa0b7418c1 Rewrite ReactDOMComponentTree-test to test behavior using Public API (#11383)
* Rewrite ReactDOMComponentTree-test to test behavior using Public API

 - Part of #11299
 - I've tried to identify cases where code within ReactDOMComponentTree is exercised and have updated accordingly but I'm not entirely sure whether I'm on the right track. I thought I'd PR to get feedback from the community. Looking forward to comments.

* Prettier and lint changes

* Remove testing of internals and add test cases for testing behavior exhibited after use of getInstanceFromNode

* [RFC] Update testing approach to verify exhibited behavior dependent upon methods in ReactDOMComponentTree

* Remove tests from event handlers and use sync tests

* Prettier changes

* Rename variables to be more semantic

* Prettier updates

* Update test following review

 - Use beforeEach and afterEach to set up and tear down container element for use in each test
 - Move any functions specific to one test to within test body (improves readability imo)

* Add coverage for getNodeFromInstance and implementation of getFiberCurrentPropsFromNode
 - After researching usage of getNodeFromInstance we can test getNodeFromInstance dispatching some events and asserting the id of the currentTarget
 - After checking git blame for getFiberCurrentPropsFromNode and reading through #8607 I found a test that we can simplify to assert behavior of the function by ensuring event handler props are updated from the fiber props. Swapping out the implementation of this function with `return node[internalInstanceKey].memoizedProps` results in a failure.
2017-11-19 14:18:16 +00:00
Soo Jae Hwang
01a867b3ea Upgrade rollup dependency (#11591)
* Record build results before upgrading rollup

* Upgrade rollup and record new results.json
2017-11-18 13:49:40 +00:00
Brian Vaughn
7f68544f0d New feature flags to help detect unexpected lifecycle side effects (#11587)
Added `debugRenderPhaseSideEffects` feature flag to help detect unexpected side effects in pre-commit lifecycle hooks and `setState` reducers.
2017-11-17 10:49:54 -08:00
Brian Vaughn
b5e4b45a10 Added a .watchmanconfig file (#11581) 2017-11-16 18:39:03 -08:00
Andrew Clark
4a924a2067 Updates at the same priority should not interrupt current render (#11578)
When we're rendering work at a specific level, and a higher priority
update comes in, we interrupt the current work and restart at the
higher priority. The rationale is that the high priority update is
likely cheaper to render that the lower one, so it's usually worth
throwing out the current work to get the high pri update on the screen
as soon as possible.

Currently, we also interrupt the current work if an update of *equal*
priority is scheduled. The rationale here is less clear: the only reason
to do this is if both updates are expected to flush at the same time,
to prevent tearing. But this usually isn't the case. Separate setStates
are usually distinct updates that can be flushed separately, especially
if the components that are being updated are in separate subtrees.

An exception is in Flux-like systems where multiple setStates are the
result of a single conceptual update/event/dispatch. We can add an
explicit API for batching in the future; in fact, we'd likely need one
anyway to account for expiration accidentally causing consecutive
updates to fall into separate buckets.
2017-11-16 16:59:02 -08:00
Andrew Clark
fd03a86429 Always reconcile against current children (#11564)
The new resuming algorithm will always reconcile against the current
child set, even if there's a newer work-in-progress child set.
2017-11-16 16:58:53 -08:00
Brian Vaughn
3fb5c2a1e7 Add .watchmanconfig to .gitignore so that Jest --watch doesn't fail arbitrarily (#11579) 2017-11-16 15:25:52 -08:00
Jason Quense
e0e9131040 Update value tracking on cousin radios (#11028)
* fix radio updates

* Format fixtures and ReactDOMFiberInput
2017-11-16 09:08:14 -05:00
Andrew Clark
9b36df86c6 Use requestIdleCallback timeout to force expiration (#11548)
* Don't call idle callback unless there's time remaining

* Expiration fixture

Fixture that demonstrates how async work expires after a certain interval.
The fixture clogs the main thread with animation work, so it only works if the
`timeout` option is provided to `requestIdleCallback`.

* Pass timeout option to requestIdleCallback

Forces `requestIdleCallback` to fire if too much time has elapsed, even if the
main thread is busy. Required to make expiration times work properly. Otherwise,
async work can expire, but React never has a chance to flush it because the
browser never calls into React.
2017-11-15 13:46:17 -08:00
Andrew Clark
77f576ce16 Bugfix: nextFlushedRoot should always be set when performing work (#11558)
Fixes an issue where performWorkOnRoot was called, but nextFlushedRoot
was not set. This happened in a special branch where we synchronously
flush newly mounted DOM trees outside the normal work loop.

Arguably, performWorkOnRoot should read from the globally assigned root
and expiration time instead of accepting arguments, since those
arguments are expected to be the same as the global values, anyway. I
decided against that since the global values could be null, so reading
from them would require extra null checks.
2017-11-15 12:17:21 -08:00
Brian Vaughn
3322f6bf31 Re-add haste modules for ReactTypes and ReactNativeRTTypes shims (#11557)
* Re-add haste module for ReactNativeRTTypes

* Re-added ReactTypes @providesModule annotation as well

* Updated expected provides modules list

* Improved clarity of check_modules.sh error message

* Added ReactTypes to provides module whitelist
2017-11-15 08:17:15 -08:00
Dean Brophy
634b70a78b Add Flow types for EventPluginHub (#11465)
* Add Flow types for EventPluginHub

* add boolean and remove extraneous typing
2017-11-15 01:48:40 +00:00
HardikModha
2d23a4563e Reading package.json safely in the build script by ignoring the system files. #11544 (#11546) 2017-11-13 18:21:17 +00:00
Johnson
200db83850 lint task: update scripts/eslint.js sharing code with linc.js; (#11518)
* (build infrastructure): unify lint and linc buid task;

* Fail on warnings

* Fail on warnings
2017-11-13 17:07:35 +00:00
Dan Abramov
ffc9c37102 Updating CHANGELOG.md for 16.1.1 release 2017-11-13 16:13:02 +00:00
Dan Abramov
cc5534a66d Update bundle sizes for 16.1.1 release 2017-11-13 16:11:15 +00:00
Dan Abramov
7c5c9dd739 Updating package versions for release 16.1.1 2017-11-13 16:08:08 +00:00
Dan Abramov
b146c73c59 Amend changelog 2017-11-13 15:55:04 +00:00
Dan Abramov
afc5fab26c Don't emit autoFocus={false} attribute on the server (#11543) 2017-11-13 15:22:12 +00:00
Nathan Hunzaker
5797664094 Minor fixes to DOM Test Fixtures (#11542)
- Fix broken React logo reference
- Always use React from the window.
2017-11-13 09:27:06 -05:00
Matt Travi
901a091fe0 Unfreeze the react-dom/server interface (#11531)
* Unfreeze the react-dom/server interface

this allows stubbing of the exposed named functions, as was possible before v16.1

fixes #11526

* Fix missing version export

* Fix missing version export

* Whitespace
2017-11-13 13:52:59 +00:00
Max Schmeling
2fe3494f0d Support string values for capture attribute. (#11424)
* Uses HAS_OVERLOADED_BOOLEAN_VALUE instead of HAS_BOOLEAN_VALUE
  * Allows for <input type="file" capture="user" />
Fixes #11419
2017-11-12 09:29:27 -05:00
Sebastian Markbåge
acabf11245 Update Flow and Fix Hydration Types (#11493)
* Update Flow

* Fix createElement() issue

The * type was too ambiguous. It's always a string so what's the point?

Suppression for missing Flow support for {is: ''} web component argument to createElement() didn't work for some reason.
I don't understand what the regex is testing for anyway (a task number?) so I just removed that, and suppression got fixed.

* Remove deleted $Abstract<> feature

* Expand the unsound isAsync check

Flow now errors earlier because it can't find .type on a portal.

* Add an unsafe cast for the null State in UpdateQueue

* Introduce "hydratable instance" type

The Flow error here highlighted a quirk in our typing of hydration.
React only really knows about a subset of all possible nodes that can
exist in a hydrated tree. Currently we assume that the host renderer
filters them out to be either Instance or TextInstance. We also assume
that those are different things which they might not be. E.g. it could
be fine for a renderer to render "text" as the same type as one of the
instances, with some default props.

We don't really know what it will be narrowed down to until we call
canHydrateInstance or canHydrateTextInstance. That's when the type is
truly refined.

So to solve this I use a different type for hydratable instance that is
used in that temporary stage between us reading it from the DOM and until
it gets refined by canHydrate(Text)Instance.

* Have the renderer refine Hydratable Instance to Instance or Text Instance

Currently we assume that if canHydrateInstance or canHydrateTextInstance
returns true, then the types also match up. But we don't tell that to Flow.

It just happens to work because `fiber.stateNode` is still `any`.

We could potentially use some kind of predicate typing but instead
of that I can just return null or instance from the "can" tests.

This ensures that the renderer has to do the refinement properly.
2017-11-11 17:00:33 -08:00
Dan Abramov
13c491a828 Refactor some event tests (#11517)
* Use dispatchEvent() directly

Don't fear repetition in tests. It is clearer what's going on.

* Clean up the container after tests

* Add a comment to container code
2017-11-10 16:58:44 +00:00
DouglasGimli
b4b09cb8bb Rewrite SyntheticWheelEvent-test depending on internal API (#11299) (#11367)
* Update SyntheticWheelEvent tests to use public API

* Replace: ReactTestUtils.SimulateNative to native Events()

* Update: Replaced WheelEvent() interface to document.createEvent

* Fix: Lint SyntheticWheelEvent file

* Update: Custom WheelEvent function to a generic MouseEvent function

* Update: Prettier SyntheticWheelEvent-test.js

* Verify the `button` property is set on synthetic event

* Use MouseEvent constructor over custom helper

* Rewrite to test React rather than jsdom

* Force the .srcElement code path to execute

* Style tweaks and slight code reorganization
2017-11-10 16:39:39 +00:00
Dan Abramov
94907cdc5f Fix lint 2017-11-10 16:30:38 +00:00
Bernardo Smaniotto
7c150a8078 Refactor SyntheticClipboardEvent tests to only use the public API (#11365)
* Refactor SyntheticClipboardEvent tests to only use the public API

* Replace local document creation by document body reset on each test case execution

* Set up and tear down container separately

* Tweak test assertion logic for clarity

* Remove simulate abstraction and create events directly

* Ensure the test covers IE8 behavior

* Verify that persistence works
2017-11-10 15:53:20 +00:00
Flarnie Marchan
365c2db55e Add CODE_OF_CONDUCT.md (#11512)
**what is the change?:**
Adding a document linking to the Facebook Open Source Code of Conduct,
for visibility and to meet Github community standards.

**why make this change?:**
Facebook Open Source provides a Code of Conduct statement for all
projects to follow.

React already links to this Code of Conduct in the README, which is
great!

Exposing the COC via a separate markdown file is a standard being
promoted by Github via the Community Profile in order to meet their Open
Source Guide's recommended community standards.

As you can see, adding this file will complete [React's Community Profile](https://github.com/facebook/react/community)
checklist and increase the visibility of our COC.

**test plan:**
Viewing it on my branch -
(Flarnie will insert screenshot)

**issue:**
internal task t23481323
2017-11-10 12:17:36 +00:00
Andrew Clark
c580082861 Measure time between scheduling an async callback and flushing it (#11506)
* Measure time between scheduling an async callback and flushing it

Helps detect starvation issues.

* Debug comments should print directly above the next measure

* Better warning message

Most users won't know what "expires" means
2017-11-10 12:14:25 +00:00
Audy Tanudjaja
ae7639c116 Remove tests in ReactDOMComponent-test depending on internal API (#11337)
* Remove inputValueTracking from ReactDOMComponent-test dependency

* prettier

* use node._valueTracker and add some test cases to make sure that value being tracked

* using Object.getOwnPropertyDescriptor to get the tracked value

* move getValueTracker to each test case and use its corresponding prototype

* remove tests and move the value tracker definition before React is imported

* Delete these tests completely
2017-11-10 12:01:59 +00:00
Dan Abramov
54051f9738 Fix accidental leftover requires (#11513) 2017-11-10 11:43:13 +00:00
Kristofer Selbekk
5bfb878743 Add note about mistaken named / default export (#11505)
This commit adds a note about the possibility of erroneously
mistaking named and default exports to an existing error message.
2017-11-09 18:28:35 +00:00
Brian Vaughn
ac0e670545 Release script tweaks (#11504)
* Added missing params object to execUnlessDry call

* Public package names are no longer hard-coded

* Added "v" prefix to git tag

* Show more accurate in-progress duration

* Properly bucket-bridage params

* Prettier

* Publish command logs stack with error
2017-11-09 16:29:51 +00:00
Clement Hoang
dc48cc38ea Enable createRoot API in www (#11501) 2017-11-09 15:33:49 +00:00
Dan Abramov
c3a529325f Fix the release script 2017-11-09 15:16:24 +00:00
Dan Abramov
1d3d791ca5 Updating CHANGELOG.md for 16.1.0 release 2017-11-09 15:04:27 +00:00
883 changed files with 114054 additions and 42803 deletions

View File

@@ -18,8 +18,6 @@
["transform-es2015-spread", { "loose": true }],
"transform-es2015-parameters",
["transform-es2015-destructuring", { "loose": true }],
["transform-es2015-block-scoping", { "throwIfClosureRequired": true }],
"transform-es3-member-expression-literals",
"transform-es3-property-literals"
["transform-es2015-block-scoping", { "throwIfClosureRequired": true }]
]
}

42
.circleci/config.yml Normal file
View File

@@ -0,0 +1,42 @@
version: 2
jobs:
build:
docker:
- image: circleci/openjdk:8-jdk-node-browsers
environment:
TZ: /usr/share/zoneinfo/America/Los_Angeles
TRAVIS_REPO_SLUG: facebook/react
parallelism: 4
steps:
- checkout
- run: echo $CIRCLE_COMPARE_URL | cut -d/ -f7
- restore_cache:
name: Restore node_modules cache
keys:
- v1-node-{{ arch }}-{{ .Branch }}-{{ checksum "yarn.lock" }}
- v1-node-{{ arch }}-{{ .Branch }}-
- v1-node-{{ arch }}-
- run:
name: Nodejs Version
command: node --version
- run:
name: Install Packages
command: yarn install --frozen-lockfile
- run:
name: Test Packages
command: ./scripts/circleci/test_entry_point.sh
- save_cache:
name: Save node_modules cache
key: v1-node-{{ arch }}-{{ .Branch }}-{{ checksum "yarn.lock" }}
paths:
- node_modules

View File

@@ -6,7 +6,12 @@ const ERROR = 2;
module.exports = {
extends: 'fbjs',
// Stop ESLint from looking for a configuration file in parent folders
'root': true,
plugins: [
'jest',
'no-for-of-loops',
'react',
'react-internal',
],
@@ -32,10 +37,12 @@ module.exports = {
'no-shadow': ERROR,
'no-unused-expressions': ERROR,
'no-unused-vars': [ERROR, {args: 'none'}],
'no-use-before-define': [ERROR, {functions: false, variables: false}],
'no-useless-concat': OFF,
'quotes': [ERROR, 'single', {avoidEscape: true, allowTemplateLiterals: true }],
'space-before-blocks': ERROR,
'space-before-function-paren': OFF,
'valid-typeof': [ERROR, {requireStringLiterals: true}],
// React & JSX
// Our transforms set this automatically
@@ -52,13 +59,32 @@ module.exports = {
// We don't care to do this
'react/jsx-wrap-multilines': [ERROR, {declaration: false, assignment: false}],
// Prevent for...of loops because they require a Symbol polyfill.
// You can disable this rule for code that isn't shipped (e.g. build scripts and tests).
'no-for-of-loops/no-for-of-loops': ERROR,
// CUSTOM RULES
// the second argument of warning/invariant should be a literal string
'react-internal/warning-and-invariant-args': ERROR,
'react-internal/no-primitive-constructors': ERROR,
'react-internal/no-to-warn-dev-within-to-throw': ERROR,
'react-internal/warning-and-invariant-args': ERROR,
},
overrides: [
{
files: ['**/__tests__/*.js'],
rules: {
// https://github.com/jest-community/eslint-plugin-jest
'jest/no-focused-tests': ERROR,
}
}
],
globals: {
expectDev: true,
spyOnDev: true,
spyOnDevAndProd: true,
spyOnProd: true,
__PROFILE__: true,
__UMD__: true,
},
};

View File

@@ -1,45 +0,0 @@
[ignore]
<PROJECT_ROOT>/fixtures/.*
<PROJECT_ROOT>/build/.*
<PROJECT_ROOT>/scripts/bench/.*
# These shims are copied into external projects:
<PROJECT_ROOT>/scripts/rollup/shims/facebook-www/.*
<PROJECT_ROOT>/scripts/rollup/shims/react-native/.*
# Note: intentionally *don't* ignore /scripts/rollup/shims/rollup/
# because it is part of the build and isn't external.
<PROJECT_ROOT>/.*/node_modules/y18n/.*
<PROJECT_ROOT>/node_modules/chrome-devtools-frontend/.*
<PROJECT_ROOT>/node_modules/devtools-timeline-model/.*
<PROJECT_ROOT>/node_modules/create-react-class/.*
<PROJECT_ROOT>/.*/__mocks__/.*
<PROJECT_ROOT>/.*/__tests__/.*
[include]
[libs]
./node_modules/fbjs/flow/lib/dev.js
./scripts/flow
[options]
esproposal.class_static_fields=enable
esproposal.class_instance_fields=enable
unsafe.enable_getters_and_setters=true
munge_underscores=false
suppress_type=$FlowIssue
suppress_type=$FlowFixMe
suppress_type=$FixMe
suppress_type=$FlowExpectedError
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-3]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*www[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-3]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*www[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
[version]
^0.53.1

View File

@@ -7,7 +7,7 @@
**What is the current behavior?**
**If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://jsfiddle.net or similar (template for React 16: https://jsfiddle.net/Luktwrdm/, template for React 15: https://jsfiddle.net/hmbg7e9w/).**
**If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your JSFiddle (https://jsfiddle.net/Luktwrdm/) or CodeSandbox (https://codesandbox.io/s/new) example below:**
**What is the expected behavior?**

View File

@@ -4,9 +4,11 @@
2. Run `yarn` in the repository root.
3. If you've fixed a bug or added code that should be tested, add tests!
4. Ensure the test suite passes (`yarn test`). Tip: `yarn test --watch TestName` is helpful in development.
5. Format your code with [prettier](https://github.com/prettier/prettier) (`yarn prettier`).
6. Make sure your code lints (`yarn lint`). Tip: `yarn linc` to only check changed files.
7. Run the [Flow](https://flowtype.org/) typechecks (`yarn flow`).
8. If you haven't already, complete the CLA.
5. Run `yarn test-prod` to test in the production environment. It supports the same options as `yarn test`.
6. If you need a debugger, run `yarn debug-test --watch TestName`, open `chrome://inspect`, and press "Inspect".
7. Format your code with [prettier](https://github.com/prettier/prettier) (`yarn prettier`).
8. Make sure your code lints (`yarn lint`). Tip: `yarn linc` to only check changed files.
9. Run the [Flow](https://flowtype.org/) typechecks (`yarn flow`).
10. If you haven't already, complete the CLA.
**Learn more about contributing:** https://reactjs.org/docs/how-to-contribute.html

1
.gitignore vendored
View File

@@ -1,5 +1,6 @@
.DS_STORE
node_modules
scripts/flow/*/.flowconfig
*~
*.pyc
.grunt

19
.prettierrc.js Normal file
View File

@@ -0,0 +1,19 @@
const {esNextPaths} = require('./scripts/shared/pathsByLanguageVersion');
module.exports = {
bracketSpacing: false,
singleQuote: true,
jsxBracketSameLine: true,
trailingComma: 'es5',
printWidth: 80,
parser: 'babylon',
overrides: [
{
files: esNextPaths,
options: {
trailingComma: 'all',
},
},
],
};

0
.watchmanconfig Normal file
View File

View File

@@ -5,6 +5,349 @@
Click to see more.
</summary>
</details>
## 16.5.2 (September 18, 2018)
### React DOM
* Fixed a recent `<iframe>` regression ([@JSteunou](https://github.com/JSteunou) in [#13650](https://github.com/facebook/react/pull/13650))
* Fix `updateWrapper` so that `<textarea>`s no longer re-render when data is unchanged ([@joelbarbosa](https://github.com/joelbarbosa) in [#13643](https://github.com/facebook/react/pull/13643))
### Schedule (Experimental)
* Renaming "tracking" API to "tracing" ([@bvaughn](https://github.com/bvaughn) in [#13641](https://github.com/facebook/react/pull/13641))
* Add UMD production+profiling entry points ([@bvaughn](https://github.com/bvaughn) in [#13642](https://github.com/facebook/react/pull/13642))
* Refactored `schedule` to remove some React-isms and improve performance for when deferred updates time out ([@acdlite](https://github.com/acdlite) in [#13582](https://github.com/facebook/react/pull/13582))
## 16.5.1 (September 13, 2018)
### React
* Improve the warning when `React.forwardRef` receives an unexpected number of arguments. ([@andresroberto](https://github.com/andresroberto) in [#13636](https://github.com/facebook/react/issues/13636))
### React DOM
* Fix a regression in unstable exports used by React Native Web. ([@aweary](https://github.com/aweary) in [#13598](https://github.com/facebook/react/issues/13598))
* Fix a crash when component defines a method called `isReactComponent`. ([@gaearon](https://github.com/gaearon) in [#13608](https://github.com/facebook/react/issues/13608))
* Fix a crash in development mode in IE9 when printing a warning. ([@link-alex](https://github.com/link-alex) in [#13620](https://github.com/facebook/react/issues/13620))
* Provide a better error message when running `react-dom/profiling` with `schedule/tracking`. ([@bvaughn](https://github.com/bvaughn) in [#13605](https://github.com/facebook/react/issues/13605))
* If a `ForwardRef` component defines a `displayName`, use it in warnings. ([@probablyup](https://github.com/probablyup) in [#13615](https://github.com/facebook/react/issues/13615))
### Schedule (Experimental)
* Add a separate profiling entry point at `schedule/tracking-profiling`. ([@bvaughn](https://github.com/bvaughn) in [#13605](https://github.com/facebook/react/issues/13605))
## 16.5.0 (September 5, 2018)
### React
* Add a warning if `React.forwardRef` render function doesn't take exactly two arguments ([@bvaughn](https://github.com/bvaughn) in [#13168](https://github.com/facebook/react/issues/13168))
* Improve the error message when passing an element to `createElement` by mistake ([@DCtheTall](https://github.com/DCtheTall) in [#13131](https://github.com/facebook/react/issues/13131))
* Don't call profiler `onRender` until after mutations ([@bvaughn](https://github.com/bvaughn) in [#13572](https://github.com/facebook/react/issues/13572))
### React DOM
* Add support for React DevTools Profiler ([@bvaughn](https://github.com/bvaughn) in [#13058](https://github.com/facebook/react/issues/13058))
* Add `react-dom/profiling` entry point alias for profiling in production ([@bvaughn](https://github.com/bvaughn) in [#13570](https://github.com/facebook/react/issues/13570))
* Add `onAuxClick` event for browsers that support it ([@jquense](https://github.com/jquense) in [#11571](https://github.com/facebook/react/issues/11571))
* Add `movementX` and `movementY` fields to mouse events ([@jasonwilliams](https://github.com/jasonwilliams) in [#9018](https://github.com/facebook/react/issues/9018))
* Add `tangentialPressure` and `twist` fields to pointer events ([@motiz88](https://github.com/motiz88) in [#13374](https://github.com/facebook/react/issues/13374))
* Minimally support iframes (nested browsing contexts) in selection event handling ([@acusti](https://github.com/acusti) in [#12037](https://github.com/facebook/react/issues/12037))
* Support passing booleans to the `focusable` SVG attribute ([@gaearon](https://github.com/gaearon) in [#13339](https://github.com/facebook/react/issues/13339))
* Ignore `<noscript>` on the client when hydrating ([@Ephem](https://github.com/Ephem) in [#13537](https://github.com/facebook/react/issues/13537))
* Fix `gridArea` to be treated as a unitless CSS property ([@mgol](https://github.com/mgol) in [#13550](https://github.com/facebook/react/issues/13550))
* Fix incorrect data in `compositionend` event when typing Korean on IE11 ([@crux153](https://github.com/crux153) in [#12563](https://github.com/facebook/react/issues/12563))
* Fix a crash when using dynamic `children` in the `<option>` tag ([@Slowyn](https://github.com/Slowyn) in [#13261](https://github.com/facebook/react/issues/13261), [@gaearon](https://github.com/gaearon) in [#13465](https://github.com/facebook/react/pull/13465))
* Fix the `checked` attribute not getting initially set on the `input` ([@dilidili](https://github.com/dilidili) in [#13114](https://github.com/facebook/react/issues/13114))
* Fix hydration of `dangerouslySetInnerHTML` when `__html` is not a string ([@gaearon](https://github.com/gaearon) in [#13353](https://github.com/facebook/react/issues/13353))
* Fix a warning about missing controlled `onChange` to fire on falsy values too ([@nicolevy](https://github.com/nicolevy) in [#12628](https://github.com/facebook/react/issues/12628))
* Fix `submit` and `reset` buttons getting an empty label ([@ellsclytn](https://github.com/ellsclytn) in [#12780](https://github.com/facebook/react/issues/12780))
* Fix the `onSelect` event not being triggered after drag and drop ([@gaearon](https://github.com/gaearon) in [#13422](https://github.com/facebook/react/issues/13422))
* Fix the `onClick` event not working inside a portal on iOS ([@aweary](https://github.com/aweary) in [#11927](https://github.com/facebook/react/issues/11927))
* Fix a performance issue when thousands of roots are re-rendered ([@gaearon](https://github.com/gaearon) in [#13335](https://github.com/facebook/react/issues/13335))
* Fix a performance regression that also caused `onChange` to not fire in some cases ([@gaearon](https://github.com/gaearon) in [#13423](https://github.com/facebook/react/issues/13423))
* Handle errors in more edge cases gracefully ([@gaearon](https://github.com/gaearon) in [#13237](https://github.com/facebook/react/issues/13237) and [@acdlite](https://github.com/acdlite) in [#13269](https://github.com/facebook/react/issues/13269))
* Don't use proxies for synthetic events in development ([@gaearon](https://github.com/gaearon) in [#12171](https://github.com/facebook/react/issues/12171))
* Warn when `"false"` or `"true"` is the value of a boolean DOM prop ([@motiz88](https://github.com/motiz88) in [#13372](https://github.com/facebook/react/issues/13372))
* Warn when `this.state` is initialized to `props` ([@veekas](https://github.com/veekas) in [#11658](https://github.com/facebook/react/issues/11658))
* Don't compare `style` on hydration in IE due to noisy false positives ([@mgol](https://github.com/mgol) in [#13534](https://github.com/facebook/react/issues/13534))
* Include `StrictMode` in the component stack ([@gaearon](https://github.com/gaearon) in [#13240](https://github.com/facebook/react/issues/13240))
* Don't overwrite `window.event` in IE ([@ConradIrwin](https://github.com/ConradIrwin) in [#11696](https://github.com/facebook/react/issues/11696))
* Improve component stack for the `folder/index.js` naming convention ([@gaearon](https://github.com/gaearon) in [#12059](https://github.com/facebook/react/issues/12059))
* Improve a warning when using `getDerivedStateFromProps` without initialized state ([@flxwu](https://github.com/flxwu) in [#13317](https://github.com/facebook/react/issues/13317))
* Improve a warning about invalid textarea usage ([@raunofreiberg](https://github.com/raunofreiberg) in [#13361](https://github.com/facebook/react/issues/13361))
* Treat invalid Symbol and function values more consistently ([@raunofreiberg](https://github.com/raunofreiberg) in [#13362](https://github.com/facebook/react/issues/13362) and [#13389](https://github.com/facebook/react/issues/13389))
* Allow Electron `<webview>` tag without warnings ([@philipp-spiess](https://github.com/philipp-spiess) in [#13301](https://github.com/facebook/react/issues/13301))
* Don't show the uncaught error addendum if `e.preventDefault()` was called ([@gaearon](https://github.com/gaearon) in [#13384](https://github.com/facebook/react/issues/13384))
* Warn about rendering Generators ([@gaearon](https://github.com/gaearon) in [#13312](https://github.com/facebook/react/issues/13312))
* Remove irrelevant suggestion of a legacy method from a warning ([@zx6658](https://github.com/zx6658) in [#13169](https://github.com/facebook/react/issues/13169))
* Remove `unstable_deferredUpdates` in favor of `unstable_scheduleWork` from `schedule` ([@gaearon](https://github.com/gaearon) in [#13488](https://github.com/facebook/react/issues/13488))
* Fix unstable asynchronous mode from doing unnecessary work when an update takes too long ([@acdlite](https://github.com/acdlite) in [#13503](https://github.com/facebook/react/issues/13503))
### React DOM Server
* Fix crash with nullish children when using `dangerouslySetInnerHtml` in a selected `<option>` ([@mridgway](https://github.com/mridgway) in [#13078](https://github.com/facebook/react/issues/13078))
* Fix crash when `setTimeout` is missing ([@dustinsoftware](https://github.com/dustinsoftware) in [#13088](https://github.com/facebook/react/issues/13088))
### React Test Renderer and Test Utils
* Fix `this` in a functional component for shallow renderer to be `undefined` ([@koba04](https://github.com/koba04) in [#13144](https://github.com/facebook/react/issues/13144))
* Deprecate a Jest-specific `ReactTestUtils.mockComponent()` helper ([@bvaughn](https://github.com/bvaughn) in [#13193](https://github.com/facebook/react/issues/13193))
* Warn about `ReactDOM.createPortal` usage within the test renderer ([@bvaughn](https://github.com/bvaughn) in [#12895](https://github.com/facebook/react/issues/12895))
* Improve a confusing error message ([@gaearon](https://github.com/gaearon) in [#13351](https://github.com/facebook/react/issues/13351))
### React ART
* Add support for DevTools ([@yunchancho](https://github.com/yunchancho) in [#13173](https://github.com/facebook/react/issues/13173))
### Schedule (Experimental)
* New package for cooperatively scheduling work in a browser environment. It's used by React internally, but its public API is not finalized yet. ([@flarnie](https://github.com/flarnie) in [#12624](https://github.com/facebook/react/pull/12624))
## 16.4.2 (August 1, 2018)
### React DOM Server
* Fix a [potential XSS vulnerability when the attacker controls an attribute name](https://reactjs.org/blog/2018/08/01/react-v-16-4-2.html) (`CVE-2018-6341`). This fix is available in the latest `react-dom@16.4.2`, as well as in previous affected minor versions: `react-dom@16.0.1`, `react-dom@16.1.2`, `react-dom@16.2.1`, and `react-dom@16.3.3`. ([@gaearon](https://github.com/gaearon) in [#13302](https://github.com/facebook/react/pull/13302))
* Fix a crash in the server renderer when an attribute is called `hasOwnProperty`. This fix is only available in `react-dom@16.4.2`. ([@gaearon](https://github.com/gaearon) in [#13303](https://github.com/facebook/react/pull/13303))
## 16.4.1 (June 13, 2018)
### React
* You can now assign `propTypes` to components returned by `React.ForwardRef`. ([@bvaughn](https://github.com/bvaughn) in [#12911](https://github.com/facebook/react/pull/12911))
### React DOM
* Fix a crash when the input `type` changes from some other types to `text`. ([@spirosikmd](https://github.com/spirosikmd) in [#12135](https://github.com/facebook/react/pull/12135))
* Fix a crash in IE11 when restoring focus to an SVG element. ([@ThaddeusJiang](https://github.com/ThaddeusJiang) in [#12996](https://github.com/facebook/react/pull/12996))
* Fix a range input not updating in some cases. ([@Illu](https://github.com/Illu) in [#12939](https://github.com/facebook/react/pull/12939))
* Fix input validation triggering unnecessarily in Firefox. ([@nhunzaker](https://github.com/nhunzaker) in [#12925](https://github.com/facebook/react/pull/12925))
* Fix an incorrect `event.target` value for the `onChange` event in IE9. ([@nhunzaker](https://github.com/nhunzaker) in [#12976](https://github.com/facebook/react/pull/12976))
* Fix a false positive error when returning an empty `<React.Fragment />` from a component. ([@philipp-spiess](https://github.com/philipp-spiess) in [#12966](https://github.com/facebook/react/pull/12966))
### React DOM Server
* Fix an incorrect value being provided by new context API. ([@ericsoderberghp](https://github.com/ericsoderberghp) in [#12985](https://github.com/facebook/react/pull/12985), [@gaearon](https://github.com/gaearon) in [#13019](https://github.com/facebook/react/pull/13019))
### React Test Renderer
* Allow multiple root children in test renderer traversal API. ([@gaearon](https://github.com/gaearon) in [#13017](https://github.com/facebook/react/pull/13017))
* Fix `getDerivedStateFromProps()` in the shallow renderer to not discard the pending state. ([@fatfisz](https://github.com/fatfisz) in [#13030](https://github.com/facebook/react/pull/13030))
## 16.4.0 (May 23, 2018)
### React
* Add a new [experimental](https://github.com/reactjs/rfcs/pull/51) `React.unstable_Profiler` component for measuring performance. ([@bvaughn](https://github.com/bvaughn) in [#12745](https://github.com/facebook/react/pull/12745))
### React DOM
* Add support for the Pointer Events specification. ([@philipp-spiess](https://github.com/philipp-spiess) in [#12507](https://github.com/facebook/react/pull/12507))
* Properly call `getDerivedStateFromProps()` regardless of the reason for re-rendering. ([@acdlite](https://github.com/acdlite) in [#12600](https://github.com/facebook/react/pull/12600) and [#12802](https://github.com/facebook/react/pull/12802))
* Fix a bug that prevented context propagation in some cases. ([@gaearon](https://github.com/gaearon) in [#12708](https://github.com/facebook/react/pull/12708))
* Fix re-rendering of components using `forwardRef()` on a deeper `setState()`. ([@gaearon](https://github.com/gaearon) in [#12690](https://github.com/facebook/react/pull/12690))
* Fix some attributes incorrectly getting removed from custom element nodes. ([@airamrguez](https://github.com/airamrguez) in [#12702](https://github.com/facebook/react/pull/12702))
* Fix context providers to not bail out on children if there's a legacy context provider above. ([@gaearon](https://github.com/gaearon) in [#12586](https://github.com/facebook/react/pull/12586))
* Add the ability to specify `propTypes` on a context provider component. ([@nicolevy](https://github.com/nicolevy) in [#12658](https://github.com/facebook/react/pull/12658))
* Fix a false positive warning when using `react-lifecycles-compat` in `<StrictMode>`. ([@bvaughn](https://github.com/bvaughn) in [#12644](https://github.com/facebook/react/pull/12644))
* Warn when the `forwardRef()` render function has `propTypes` or `defaultProps`. ([@bvaughn](https://github.com/bvaughn) in [#12644](https://github.com/facebook/react/pull/12644))
* Improve how `forwardRef()` and context consumers are displayed in the component stack. ([@sophiebits](https://github.com/sophiebits) in [#12777](https://github.com/facebook/react/pull/12777))
* Change internal event names. This can break third-party packages that rely on React internals in unsupported ways. ([@philipp-spiess](https://github.com/philipp-spiess) in [#12629](https://github.com/facebook/react/pull/12629))
### React Test Renderer
* Fix the `getDerivedStateFromProps()` support to match the new React DOM behavior. ([@koba04](https://github.com/koba04) in [#12676](https://github.com/facebook/react/pull/12676))
* Fix a `testInstance.parent` crash when the parent is a fragment or another special node. ([@gaearon](https://github.com/gaearon) in [#12813](https://github.com/facebook/react/pull/12813))
* `forwardRef()` components are now discoverable by the test renderer traversal methods. ([@gaearon](https://github.com/gaearon) in [#12725](https://github.com/facebook/react/pull/12725))
* Shallow renderer now ignores `setState()` updaters that return `null` or `undefined`. ([@koba04](https://github.com/koba04) in [#12756](https://github.com/facebook/react/pull/12756))
### React ART
* Fix reading context provided from the tree managed by React DOM. ([@acdlite](https://github.com/acdlite) in [#12779](https://github.com/facebook/react/pull/12779))
### React Call Return (Experimental)
* This experiment was deleted because it was affecting the bundle size and the API wasn't good enough. It's likely to come back in the future in some other form. ([@gaearon](https://github.com/gaearon) in [#12820](https://github.com/facebook/react/pull/12820))
### React Reconciler (Experimental)
* The [new host config shape](https://github.com/facebook/react/blob/c601f7a64640290af85c9f0e33c78480656b46bc/packages/react-noop-renderer/src/createReactNoop.js#L82-L285) is flat and doesn't use nested objects. ([@gaearon](https://github.com/gaearon) in [#12792](https://github.com/facebook/react/pull/12792))
## 16.3.3 (August 1, 2018)
### React DOM Server
* Fix a [potential XSS vulnerability when the attacker controls an attribute name](https://reactjs.org/blog/2018/08/01/react-v-16-4-2.html) (`CVE-2018-6341`). This fix is available in the latest `react-dom@16.4.2`, as well as in previous affected minor versions: `react-dom@16.0.1`, `react-dom@16.1.2`, `react-dom@16.2.1`, and `react-dom@16.3.3`. ([@gaearon](https://github.com/gaearon) in [#13302](https://github.com/facebook/react/pull/13302))
## 16.3.2 (April 16, 2018)
### React
* Improve the error message when passing `null` or `undefined` to `React.cloneElement`. ([@nicolevy](https://github.com/nicolevy) in [#12534](https://github.com/facebook/react/pull/12534))
### React DOM
* Fix an IE crash in development when using `<StrictMode>`. ([@bvaughn](https://github.com/bvaughn) in [#12546](https://github.com/facebook/react/pull/12546))
* Fix labels in User Timing measurements for new component types. ([@bvaughn](https://github.com/bvaughn) in [#12609](https://github.com/facebook/react/pull/12609))
* Improve the warning about wrong component type casing. ([@nicolevy](https://github.com/nicolevy) in [#12533](https://github.com/facebook/react/pull/12533))
* Improve general performance in development mode. ([@gaearon](https://github.com/gaearon) in [#12537](https://github.com/facebook/react/pull/12537))
* Improve performance of the experimental `unstable_observedBits` API with nesting. ([@gaearon](https://github.com/gaearon) in [#12543](https://github.com/facebook/react/pull/12543))
### React Test Renderer
* Add a UMD build. ([@bvaughn](https://github.com/bvaughn) in [#12594](https://github.com/facebook/react/pull/12594))
## 16.3.1 (April 3, 2018)
### React
* Fix a false positive warning in IE11 when using `Fragment`. ([@heikkilamarko](https://github.com/heikkilamarko) in [#12504](https://github.com/facebook/react/pull/12504))
* Prefix a private API. ([@Andarist](https://github.com/Andarist) in [#12501](https://github.com/facebook/react/pull/12501))
* Improve the warning when calling `setState()` in constructor. ([@gaearon](https://github.com/gaearon) in [#12532](https://github.com/facebook/react/pull/12532))
### React DOM
* Fix `getDerivedStateFromProps()` not getting applied in some cases. ([@acdlite](https://github.com/acdlite) in [#12528](https://github.com/facebook/react/pull/12528))
* Fix a performance regression in development mode. ([@gaearon](https://github.com/gaearon) in [#12510](https://github.com/facebook/react/pull/12510))
* Fix error handling bugs in development mode. ([@gaearon](https://github.com/gaearon) and [@acdlite](https://github.com/acdlite) in [#12508](https://github.com/facebook/react/pull/12508))
* Improve user timing API messages for profiling. ([@flarnie](https://github.com/flarnie) in [#12384](https://github.com/facebook/react/pull/12384))
### Create Subscription
* Set the package version to be in sync with React releases. ([@bvaughn](https://github.com/bvaughn) in [#12526](https://github.com/facebook/react/pull/12526))
* Add a peer dependency on React 16.3+. ([@NMinhNguyen](https://github.com/NMinhNguyen) in [#12496](https://github.com/facebook/react/pull/12496))
## 16.3.0 (March 29, 2018)
### React
* Add a new officially supported context API. ([@acdlite](https://github.com/acdlite) in [#11818](https://github.com/facebook/react/pull/11818))
* Add a new `React.createRef()` API as an ergonomic alternative to callback refs. ([@trueadm](https://github.com/trueadm) in [#12162](https://github.com/facebook/react/pull/12162))
* Add a new `React.forwardRef()` API to let components forward their refs to a child. ([@bvaughn](https://github.com/bvaughn) in [#12346](https://github.com/facebook/react/pull/12346))
* Fix a false positive warning in IE11 when using `React.Fragment`. ([@XaveScor](https://github.com/XaveScor) in [#11823](https://github.com/facebook/react/pull/11823))
* Replace `React.unstable_AsyncComponent` with `React.unstable_AsyncMode`. ([@acdlite](https://github.com/acdlite) in [#12117](https://github.com/facebook/react/pull/12117))
* Improve the error message when calling `setState()` on an unmounted component. ([@sophiebits](https://github.com/sophiebits) in [#12347](https://github.com/facebook/react/pull/12347))
### React DOM
* Add a new `getDerivedStateFromProps()` lifecycle and `UNSAFE_` aliases for the legacy lifecycles. ([@bvaughn](https://github.com/bvaughn) in [#12028](https://github.com/facebook/react/pull/12028))
* Add a new `getSnapshotBeforeUpdate()` lifecycle. ([@bvaughn](https://github.com/bvaughn) in [#12404](https://github.com/facebook/react/pull/12404))
* Add a new `<React.StrictMode>` wrapper to help prepare apps for async rendering. ([@bvaughn](https://github.com/bvaughn) in [#12083](https://github.com/facebook/react/pull/12083))
* Add support for `onLoad` and `onError` events on the `<link>` tag. ([@roderickhsiao](https://github.com/roderickhsiao) in [#11825](https://github.com/facebook/react/pull/11825))
* Add support for `noModule` boolean attribute on the `<script>` tag. ([@aweary](https://github.com/aweary) in [#11900](https://github.com/facebook/react/pull/11900))
* Fix minor DOM input bugs in IE and Safari. ([@nhunzaker](https://github.com/nhunzaker) in [#11534](https://github.com/facebook/react/pull/11534))
* Correctly detect Ctrl + Enter in `onKeyPress` in more browsers. ([@nstraub](https://github.com/nstraub) in [#10514](https://github.com/facebook/react/pull/10514))
* Fix containing elements getting focused on SSR markup mismatch. ([@koba04](https://github.com/koba04) in [#11737](https://github.com/facebook/react/pull/11737))
* Fix `value` and `defaultValue` to ignore Symbol values. ([@nhunzaker](https://github.com/nhunzaker) in [#11741](https://github.com/facebook/react/pull/11741))
* Fix refs to class components not getting cleaned up when the attribute is removed. ([@bvaughn](https://github.com/bvaughn) in [#12178](https://github.com/facebook/react/pull/12178))
* Fix an IE/Edge issue when rendering inputs into a different window. ([@M-ZubairAhmed](https://github.com/M-ZubairAhmed) in [#11870](https://github.com/facebook/react/pull/11870))
* Throw with a meaningful message if the component runs after jsdom has been destroyed. ([@gaearon](https://github.com/gaearon) in [#11677](https://github.com/facebook/react/pull/11677))
* Don't crash if there is a global variable called `opera` with a `null` value. [@alisherdavronov](https://github.com/alisherdavronov) in [#11854](https://github.com/facebook/react/pull/11854))
* Don't check for old versions of Opera. ([@skiritsis](https://github.com/skiritsis) in [#11921](https://github.com/facebook/react/pull/11921))
* Deduplicate warning messages about `<option selected>`. ([@watadarkstar](https://github.com/watadarkstar) in [#11821](https://github.com/facebook/react/pull/11821))
* Deduplicate warning messages about invalid callback. ([@yenshih](https://github.com/yenshih) in [#11833](https://github.com/facebook/react/pull/11833))
* Deprecate `ReactDOM.unstable_createPortal()` in favor of `ReactDOM.createPortal()`. ([@prometheansacrifice](https://github.com/prometheansacrifice) in [#11747](https://github.com/facebook/react/pull/11747))
* Don't emit User Timing entries for context types. ([@abhaynikam](https://github.com/abhaynikam) in [#12250](https://github.com/facebook/react/pull/12250))
* Improve the error message when context consumer child isn't a function. ([@raunofreiberg](https://github.com/raunofreiberg) in [#12267](https://github.com/facebook/react/pull/12267))
* Improve the error message when adding a ref to a functional component. ([@skiritsis](https://github.com/skiritsis) in [#11782](https://github.com/facebook/react/pull/11782))
### React DOM Server
* Prevent an infinite loop when attempting to render portals with SSR. ([@gaearon](https://github.com/gaearon) in [#11709](https://github.com/facebook/react/pull/11709))
* Warn if a class doesn't extend `React.Component`. ([@wyze](https://github.com/wyze) in [#11993](https://github.com/facebook/react/pull/11993))
* Fix an issue with `this.state` of different components getting mixed up. ([@sophiebits](https://github.com/sophiebits) in [#12323](https://github.com/facebook/react/pull/12323))
* Provide a better message when component type is undefined. ([@HeroProtagonist](https://github.com/HeroProtagonist) in [#11966](https://github.com/facebook/react/pull/11966))
## React Test Renderer
* Fix handling of fragments in `toTree()`. ([@maciej-ka](https://github.com/maciej-ka) in [#12107](https://github.com/facebook/react/pull/12107) and [@gaearon](https://github.com/gaearon) in [#12154](https://github.com/facebook/react/pull/12154))
* Shallow renderer should assign state to `null` for components that don't set it. ([@jwbay](https://github.com/jwbay) in [#11965](https://github.com/facebook/react/pull/11965))
* Shallow renderer should filter legacy context according to `contextTypes`. ([@koba04](https://github.com/koba04) in [#11922](https://github.com/facebook/react/pull/11922))
* Add an unstable API for testing asynchronous rendering. ([@acdlite](https://github.com/acdlite) in [#12478](https://github.com/facebook/react/pull/12478))
### React Is (New)
* First release of the [new package](https://github.com/facebook/react/tree/master/packages/react-is) that libraries can use to detect different React node types. ([@bvaughn](https://github.com/bvaughn) in [#12199](https://github.com/facebook/react/pull/12199))
* Add `ReactIs.isValidElementType()` to help higher-order components validate their inputs. ([@jamesreggio](https://github.com/jamesreggio) in [#12483](https://github.com/facebook/react/pull/12483))
### React Lifecycles Compat (New)
* First release of the [new package](https://github.com/reactjs/react-lifecycles-compat) to help library developers target multiple versions of React. ([@bvaughn](https://github.com/bvaughn) in [#12105](https://github.com/facebook/react/pull/12105))
### Create Subscription (New)
* First release of the [new package](https://github.com/facebook/react/tree/master/packages/create-subscription) to subscribe to external data sources safely for async rendering. ([@bvaughn](https://github.com/bvaughn) in [#12325](https://github.com/facebook/react/pull/12325))
### React Reconciler (Experimental)
* Expose `react-reconciler/persistent` for building renderers that use persistent data structures. ([@gaearon](https://github.com/gaearon) in [#12156](https://github.com/facebook/react/pull/12156))
* Pass host context to `finalizeInitialChildren()`. ([@jquense](https://github.com/jquense) in [#11970](https://github.com/facebook/react/pull/11970))
* Remove `useSyncScheduling` from the host config. ([@acdlite](https://github.com/acdlite) in [#11771](https://github.com/facebook/react/pull/11771))
### React Call Return (Experimental)
* Fix a crash on updates. ([@rmhartog](https://github.com/rmhartog) in [#11955](https://github.com/facebook/react/pull/11955))
## 16.2.1 (August 1, 2018)
### React DOM Server
* Fix a [potential XSS vulnerability when the attacker controls an attribute name](https://reactjs.org/blog/2018/08/01/react-v-16-4-2.html) (`CVE-2018-6341`). This fix is available in the latest `react-dom@16.4.2`, as well as in previous affected minor versions: `react-dom@16.0.1`, `react-dom@16.1.2`, `react-dom@16.2.1`, and `react-dom@16.3.3`. ([@gaearon](https://github.com/gaearon) in [#13302](https://github.com/facebook/react/pull/13302))
## 16.2.0 (November 28, 2017)
### React
* Add `Fragment` as named export to React. ([@clemmy](https://github.com/clemmy) in [#10783](https://github.com/facebook/react/pull/10783))
* Support experimental Call/Return types in `React.Children` utilities. ([@MatteoVH](https://github.com/MatteoVH) in [#11422](https://github.com/facebook/react/pull/11422))
### React DOM
* Fix radio buttons not getting checked when using multiple lists of radios. ([@landvibe](https://github.com/landvibe) in [#11227](https://github.com/facebook/react/pull/11227))
* Fix radio buttons not receiving the `onChange` event in some cases. ([@jquense](https://github.com/jquense) in [#11028](https://github.com/facebook/react/pull/11028))
### React Test Renderer
* Fix `setState()` callback firing too early when called from `componentWillMount`. ([@accordeiro](https://github.com/accordeiro) in [#11507](https://github.com/facebook/react/pull/11507))
### React Reconciler
* Expose `react-reconciler/reflection` with utilities useful to custom renderers. ([@rivenhk](https://github.com/rivenhk) in [#11683](https://github.com/facebook/react/pull/11683))
### Internal Changes
* Many tests were rewritten against the public API. Big thanks to [everyone who contributed](https://github.com/facebook/react/issues/11299)!
## 16.1.2 (August 1, 2018)
### React DOM Server
* Fix a [potential XSS vulnerability when the attacker controls an attribute name](https://reactjs.org/blog/2018/08/01/react-v-16-4-2.html) (`CVE-2018-6341`). This fix is available in the latest `react-dom@16.4.2`, as well as in previous affected minor versions: `react-dom@16.0.1`, `react-dom@16.1.2`, `react-dom@16.2.1`, and `react-dom@16.3.3`. ([@gaearon](https://github.com/gaearon) in [#13302](https://github.com/facebook/react/pull/13302))
## 16.1.1 (November 13, 2017)
### React
* Improve the warning about undefined component type. ([@selbekk](https://github.com/selbekk) in [#11505](https://github.com/facebook/react/pull/11505))
### React DOM
* Support string values for the `capture` attribute. ([@maxschmeling](https://github.com/maxschmeling) in [#11424](https://github.com/facebook/react/pull/11424))
### React DOM Server
* Don't freeze the `ReactDOMServer` public API. ([@travi](https://github.com/travi) in [#11531](https://github.com/facebook/react/pull/11531))
* Don't emit `autoFocus={false}` attribute on the server. ([@gaearon](https://github.com/gaearon) in [#11543](https://github.com/facebook/react/pull/11543))
### React Reconciler
* Change the hydration API for better Flow typing. ([@sebmarkbage](https://github.com/sebmarkbage) in [#11493](https://github.com/facebook/react/pull/11493))
## 16.1.0 (November 9, 2017)
### Discontinuing Bower Releases
Starting with 16.1.0, we will no longer be publishing new releases on Bower. You can continue using Bower for old releases, or point your Bower configs to the [React UMD builds hosted on unpkg](https://reactjs.org/docs/installation.html#using-a-cdn) that mirror npm releases and will continue to be updated.
@@ -25,14 +368,14 @@ Starting with 16.1.0, we will no longer be publishing new releases on Bower. You
* Fix `onMouseEnter` and `onMouseLeave` firing on wrong elements. ([@gaearon](https://github.com/gaearon) in [#11164](https://github.com/facebook/react/pull/11164))
* Fix `null` showing up in a warning instead of the component stack. ([@gaearon](https://github.com/gaearon) in [#10915](https://github.com/facebook/react/pull/10915))
* Fix IE11 crash in development mode. ([@leidegre](https://github.com/leidegre) in [#10921](https://github.com/facebook/react/pull/10921))
* Fix `tabIndex` not getting applied to SVG elements. ([@gaearon](http://github.com/gaearon) in [#11034](https://github.com/facebook/react/pull/11034))
* Fix `tabIndex` not getting applied to SVG elements. ([@gaearon](https://github.com/gaearon) in [#11034](https://github.com/facebook/react/pull/11034))
* Fix SVG children not getting cleaned up on `dangerouslySetInnerHTML` in IE. ([@OriR](https://github.com/OriR) in [#11108](https://github.com/facebook/react/pull/11108))
* Fix false positive text mismatch warning caused by newline normalization. ([@gaearon](http://github.com/gaearon) in [#11119](https://github.com/facebook/react/pull/11119))
* Fix false positive text mismatch warning caused by newline normalization. ([@gaearon](https://github.com/gaearon) in [#11119](https://github.com/facebook/react/pull/11119))
* Fix `form.reset()` to respect `defaultValue` on uncontrolled `<select>`. ([@aweary](https://github.com/aweary) in [#11057](https://github.com/facebook/react/pull/11057))
* Fix `<textarea>` placeholder not rendering on IE11. ([@gaearon](https://github.com/gaearon) in [#11177](https://github.com/facebook/react/pull/11177))
* Fix a crash rendering into shadow root. ([@gaearon](https://github.com/gaearon) in [#11037](https://github.com/facebook/react/pull/11037))
* Fix false positive warning about hydrating mixed case SVG tags. ([@gaearon](http://github.com/gaearon) in [#11174](https://github.com/facebook/react/pull/11174))
* Suppress the new unknown tag warning for `<dialog>` element. ([@gaearon](http://github.com/gaearon) in [#11035](https://github.com/facebook/react/pull/11035))
* Fix false positive warning about hydrating mixed case SVG tags. ([@gaearon](https://github.com/gaearon) in [#11174](https://github.com/facebook/react/pull/11174))
* Suppress the new unknown tag warning for `<dialog>` element. ([@gaearon](https://github.com/gaearon) in [#11035](https://github.com/facebook/react/pull/11035))
* Warn when defining a non-existent `componentDidReceiveProps` method. ([@iamtommcc](https://github.com/iamtommcc) in [#11479](https://github.com/facebook/react/pull/11479))
* Warn about function child no more than once. ([@andreysaleba](https://github.com/andreysaleba) in [#11120](https://github.com/facebook/react/pull/11120))
* Warn about nested updates no more than once. ([@anushreesubramani](https://github.com/anushreesubramani) in [#11113](https://github.com/facebook/react/pull/11113))
@@ -41,15 +384,16 @@ Starting with 16.1.0, we will no longer be publishing new releases on Bower. You
* Improve the warning about booleans passed to event handlers. ([@NicBonetto](https://github.com/NicBonetto) in [#11308](https://github.com/facebook/react/pull/11308))
* Improve the warning when a multiple `select` gets null `value`. ([@Hendeca](https://github.com/Hendeca) in [#11141](https://github.com/facebook/react/pull/11141))
* Move link in the warning message to avoid redirect. ([@marciovicente](https://github.com/marciovicente) in [#11400](https://github.com/facebook/react/pull/11400))
* Add a way to suppress the React DevTools installation prompt. ([@gaearon](http://github.com/gaearon) in [#11448](https://github.com/facebook/react/pull/11448))
* Add a way to suppress the React DevTools installation prompt. ([@gaearon](https://github.com/gaearon) in [#11448](https://github.com/facebook/react/pull/11448))
* 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))
### React DOM Server
* Fix markup generation when components return strings. ([@gaearon](http://github.com/gaearon) in [#11109](https://github.com/facebook/react/pull/11109))
* Add a new `suppressHydrationWarning` attribute for intentional client/server text mismatches. ([@sebmarkbage](https://github.com/sebmarkbage) in [#11126](https://github.com/facebook/react/pull/11126))
* Fix markup generation when components return strings. ([@gaearon](https://github.com/gaearon) in [#11109](https://github.com/facebook/react/pull/11109))
* Fix obscure error message when passing an invalid style value. ([@iamdustan](https://github.com/iamdustan) in [#11173](https://github.com/facebook/react/pull/11173))
* Include the `autoFocus` attribute into SSR markup. ([@gaearon](http://github.com/gaearon) in [#11192](https://github.com/facebook/react/pull/11192))
* Include the component stack into more warnings. ([@gaearon](http://github.com/gaearon) in [#11284](https://github.com/facebook/react/pull/11284))
* Include the `autoFocus` attribute into SSR markup. ([@gaearon](https://github.com/gaearon) in [#11192](https://github.com/facebook/react/pull/11192))
* Include the component stack into more warnings. ([@gaearon](https://github.com/gaearon) in [#11284](https://github.com/facebook/react/pull/11284))
### React Test Renderer and Test Utils
@@ -73,7 +417,11 @@ Starting with 16.1.0, we will no longer be publishing new releases on Bower. You
* First release of the [new experimental package](https://github.com/facebook/react/tree/master/packages/react-call-return) for parent-child communication. ([@gaearon](https://github.com/gaearon) in [#11364](https://github.com/facebook/react/pull/11364))
</details>
## 16.0.1 (August 1, 2018)
### React DOM Server
* Fix a [potential XSS vulnerability when the attacker controls an attribute name](https://reactjs.org/blog/2018/08/01/react-v-16-4-2.html) (`CVE-2018-6341`). This fix is available in the latest `react-dom@16.4.2`, as well as in previous affected minor versions: `react-dom@16.0.1`, `react-dom@16.1.2`, `react-dom@16.2.1`, and `react-dom@16.3.3`. ([@gaearon](https://github.com/gaearon) in [#13302](https://github.com/facebook/react/pull/13302))
## 16.0.0 (September 26, 2017)
@@ -552,7 +900,7 @@ Each of these changes will continue to work as before with a new warning until t
- React DOM now correctly handles `borderImageOutset`, `borderImageWidth`, `borderImageSlice`, `floodOpacity`, `strokeDasharray`, and `strokeMiterlimit` as unitless CSS properties. ([@rofrischmann](https://github.com/rofrischmann) in [#6210](https://github.com/facebook/react/pull/6210) and [#6270](https://github.com/facebook/react/pull/6270))
- React DOM now supports the `onAnimationStart`, `onAnimationEnd`, `onAnimationIteration`, `onTransitionEnd`, and `onInvalid` events. Support for `onLoad` has been added to `object` elements. ([@tomduncalf](https://github.com/tomduncalf) in [#5187](https://github.com/facebook/react/pull/5187), [@milesj](https://github.com/milesj) in [#6005](https://github.com/facebook/react/pull/6005), and [@ara4n](https://github.com/ara4n) in [#5781](https://github.com/facebook/react/pull/5781))
- React DOM now defaults to using DOM attributes instead of properties, which fixes a few edge case bugs. Additionally the nullification of values (ex: `href={null}`) now results in the forceful removal, no longer trying to set to the default value used by browsers in the absence of a value. ([@syranide](https://github.com/syranide) in [#1510](https://github.com/facebook/react/pull/1510))
- React DOM does not mistakingly coerce `children` to strings for Web Components. ([@jimfb](https://github.com/jimfb) in [#5093](https://github.com/facebook/react/pull/5093))
- React DOM does not mistakenly coerce `children` to strings for Web Components. ([@jimfb](https://github.com/jimfb) in [#5093](https://github.com/facebook/react/pull/5093))
- React DOM now correctly normalizes SVG `<use>` events. ([@edmellum](https://github.com/edmellum) in [#5720](https://github.com/facebook/react/pull/5720))
- React DOM does not throw if a `<select>` is unmounted while its `onChange` handler is executing. ([@sambev](https://github.com/sambev) in [#6028](https://github.com/facebook/react/pull/6028))
- React DOM does not throw in Windows 8 apps. ([@Andrew8xx8](https://github.com/Andrew8xx8) in [#6063](https://github.com/facebook/react/pull/6063))
@@ -561,7 +909,7 @@ Each of these changes will continue to work as before with a new warning until t
- `Object.is` is used in a number of places to compare values, which leads to fewer false positives, especially involving `NaN`. In particular, this affects the `shallowCompare` add-on. ([@chicoxyzzy](https://github.com/chicoxyzzy) in [#6132](https://github.com/facebook/react/pull/6132))
- Add-Ons: ReactPerf no longer instruments adding or removing an event listener because they dont really touch the DOM due to event delegation. ([@antoaravinth](https://github.com/antoaravinth) in [#5209](https://github.com/facebook/react/pull/5209))
### Other improvements
### Other improvements
- React now uses `loose-envify` instead of `envify` so it installs fewer transitive dependencies. ([@qerub](https://github.com/qerub) in [#6303](https://github.com/facebook/react/pull/6303))
- Shallow renderer now exposes `getMountedInstance()`. ([@glenjamin](https://github.com/glenjamin) in [#4918](https://github.com/facebook/react/pull/4918))
@@ -689,7 +1037,7 @@ Each of these changes will continue to work as before with a new warning until t
- Added `React.Children.toArray` which takes a nested children object and returns a flat array with keys assigned to each child. This helper makes it easier to manipulate collections of children in your `render` methods, especially if you want to reorder or slice `this.props.children` before passing it down. In addition, `React.Children.map` now returns plain arrays too.
- React uses `console.error` instead of `console.warn` for warnings so that browsers show a full stack trace in the console. (Our warnings appear when you use patterns that will break in future releases and for code that is likely to behave unexpectedly, so we do consider our warnings to be “must-fix” errors.)
- Previously, including untrusted objects as React children [could result in an XSS security vulnerability](http://danlec.com/blog/xss-via-a-spoofed-react-element). This problem should be avoided by properly validating input at the application layer and by never passing untrusted objects around your application code. As an additional layer of protection, [React now tags elements](https://github.com/facebook/react/pull/4832) with a specific [ES2015 (ES6) `Symbol`](http://www.2ality.com/2014/12/es6-symbols.html) in browsers that support it, in order to ensure that React never considers untrusted JSON to be a valid element. If this extra security protection is important to you, you should add a `Symbol` polyfill for older browsers, such as the one included by [Babels polyfill](http://babeljs.io/docs/usage/polyfill/).
- Previously, including untrusted objects as React children [could result in an XSS security vulnerability](http://danlec.com/blog/xss-via-a-spoofed-react-element). This problem should be avoided by properly validating input at the application layer and by never passing untrusted objects around your application code. As an additional layer of protection, [React now tags elements](https://github.com/facebook/react/pull/4832) with a specific [ES2015 (ES6) `Symbol`](http://www.2ality.com/2014/12/es6-symbols.html) in browsers that support it, in order to ensure that React never considers untrusted JSON to be a valid element. If this extra security protection is important to you, you should add a `Symbol` polyfill for older browsers, such as the one included by [Babels polyfill](https://babeljs.io/docs/usage/polyfill/).
- When possible, React DOM now generates XHTML-compatible markup.
- React DOM now supports these standard HTML attributes: `capture`, `challenge`, `inputMode`, `is`, `keyParams`, `keyType`, `minLength`, `summary`, `wrap`. It also now supports these non-standard attributes: `autoSave`, `results`, `security`.
- React DOM now supports these SVG attributes, which render into namespaced attributes: `xlinkActuate`, `xlinkArcrole`, `xlinkHref`, `xlinkRole`, `xlinkShow`, `xlinkTitle`, `xlinkType`, `xmlBase`, `xmlLang`, `xmlSpace`.
@@ -723,7 +1071,7 @@ Each of these changes will continue to work as before with a new warning until t
#### Breaking Changes
- The `react-tools` package and `JSXTransformer.js` browser file [have been deprecated](https://reactjs.org/blog/2015/06/12/deprecating-jstransform-and-react-tools.html). You can continue using version `0.13.3` of both, but we no longer support them and recommend migrating to [Babel](http://babeljs.io/), which has built-in support for React and JSX.
- The `react-tools` package and `JSXTransformer.js` browser file [have been deprecated](https://reactjs.org/blog/2015/06/12/deprecating-jstransform-and-react-tools.html). You can continue using version `0.13.3` of both, but we no longer support them and recommend migrating to [Babel](https://babeljs.io), which has built-in support for React and JSX.
#### New Features

3
CODE_OF_CONDUCT.md Normal file
View File

@@ -0,0 +1,3 @@
# Code of Conduct
Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please [read the full text](https://code.fb.com/codeofconduct/) so that you can understand what actions will and will not be tolerated.

View File

@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2013-present, Facebook, Inc.
Copyright (c) Facebook, Inc. and its affiliates.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -8,15 +8,28 @@ React is a JavaScript library for building user interfaces.
[Learn how to use React in your own project](https://reactjs.org/docs/getting-started.html).
## Installation
React has been designed for gradual adoption from the start, and **you can use as little or as much React as you need**:
* Use [Online Playgrounds](https://reactjs.org/docs/getting-started.html#online-playgrounds) to get a taste of React.
* [Add React to a Website](https://reactjs.org/docs/add-react-to-a-website.html) as a `<script>` tag in one minute.
* [Create a New React App](https://reactjs.org/docs/create-a-new-react-app.html) if you're looking for a powerful JavaScript toolchain.
You can use React as a `<script>` tag from a [CDN](https://reactjs.org/docs/cdn-links.html), or as a `react` package on [npm](https://www.npmjs.com/).
## Documentation
You can find the React documentation [on the website](https://reactjs.org/docs).
It is divided into several sections:
* [Quick Start](https://reactjs.org/docs/hello-world.html)
Check out the [Getting Started](https://reactjs.org/docs/getting-started.html) page for a quick overview.
The documentation is divided into several sections:
* [Tutorial](https://reactjs.org/tutorial/tutorial.html)
* [Main Concepts](https://reactjs.org/docs/hello-world.html)
* [Advanced Guides](https://reactjs.org/docs/jsx-in-depth.html)
* [API Reference](https://reactjs.org/docs/react-api.html)
* [Tutorial](https://reactjs.org/tutorial/tutorial.html)
* [Where to Get Support](https://reactjs.org/community/support.html)
* [Contributing Guide](https://reactjs.org/docs/how-to-contribute.html)
@@ -34,26 +47,14 @@ class HelloMessage extends React.Component {
}
ReactDOM.render(
<HelloMessage name="John" />,
<HelloMessage name="Taylor" />,
document.getElementById('container')
);
```
This example will render "Hello John" into a container on the page.
This example will render "Hello Taylor" into a container on the page.
You'll notice that we used an HTML-like syntax; [we call it JSX](https://reactjs.org/docs/introducing-jsx.html). JSX is not required to use React, but it makes code more readable, and writing it feels like writing HTML. We recommend using [Babel](https://babeljs.io/) with a [React preset](https://babeljs.io/docs/plugins/preset-react/) to convert JSX into native JavaScript for browsers to digest.
## Installation
React is available as the `react` package on [npm](https://www.npmjs.com/). It is also available on a [CDN](https://reactjs.org/docs/installation.html#using-a-cdn).
React is flexible and can be used in a variety of projects. You can create new apps with it, but you can also gradually introduce it into an existing codebase without doing a rewrite.
The recommended way to install React depends on your project. Here you can find short guides for the most common scenarios:
* [Trying Out React](https://reactjs.org/docs/installation.html#trying-out-react)
* [Creating a New Application](https://reactjs.org/docs/installation.html#creating-a-new-application)
* [Adding React to an Existing Application](https://reactjs.org/docs/installation.html#adding-react-to-an-existing-application)
You'll notice that we used an HTML-like syntax; [we call it JSX](https://reactjs.org/docs/introducing-jsx.html). JSX is not required to use React, but it makes code more readable, and writing it feels like writing HTML. If you're using React as a `<script>` tag, read [this section](https://reactjs.org/docs/add-react-to-a-website.html#optional-try-react-with-jsx) on integrating JSX; otherwise, the [recommended JavaScript toolchains](https://reactjs.org/docs/create-a-new-react-app.html) handle it automatically.
## Contributing

41
appveyor.yml Normal file
View File

@@ -0,0 +1,41 @@
image: Visual Studio 2017
# Fix line endings in Windows. (runs before repo cloning)
init:
- git config --global core.autocrlf input
environment:
JAVA_HOME: C:\Program Files\Java\jdk1.8.0
matrix:
- nodejs_version: 10
# Finish on first failed build
matrix:
fast_finish: true
platform:
- x64
branches:
only:
- master
# Disable Visual Studio build and deploy
build: off
deploy: off
install:
- ps: Install-Product node $env:nodejs_version $env:platform
- yarn install --frozen-lockfile
test_script:
- node --version
- yarn lint
# - yarn flow-ci
- yarn build
- yarn test
- yarn prettier
cache:
- node_modules
- "%LOCALAPPDATA%/Yarn"

View File

@@ -1,40 +0,0 @@
---
machine:
timezone: America/Los_Angeles
node:
version: 8
ruby:
version: 2.2.3
environment:
TRAVIS_REPO_SLUG: facebook/react
YARN_VERSION: 1.2.1
PATH: "${PATH}:${HOME}/.yarn/bin"
dependencies:
pre:
# This is equivalent to $TRAVIS_COMMIT_RANGE
- echo $CIRCLE_COMPARE_URL | cut -d/ -f7
# install yarn if it's not already installed
- |
if [[ ! -e ~/.yarn/bin/yarn || $(yarn --version) != "${YARN_VERSION}" ]]; then
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version $YARN_VERSION
fi
override:
- yarn install
- scripts/circleci/set_up_github_keys.sh
post:
# - npm ls --depth=0
cache_directories:
- ~/.yarn
- ~/.yarn-cache
test:
override:
- ./scripts/circleci/test_entry_point.sh:
parallel: true
deployment:
staging:
branch: /.*/
commands:
- ./scripts/circleci/upload_build.sh

217
dangerfile.js Normal file
View File

@@ -0,0 +1,217 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';
// Hi, if this is your first time editing/reading a Dangerfile, here's a summary:
// It's a JS runtime which helps you provide continuous feedback inside GitHub.
//
// You can see the docs here: http://danger.systems/js/
//
// If you want to test changes Danger, I'd recommend checking out an existing PR
// and then running the `danger pr` command.
//
// You'll need a GitHub token, you can re-use this one:
//
// e622517d9f1136ea8900 07c6373666312cdfaa69
//
// (Just remove the space)
//
// So, for example:
//
// `DANGER_GITHUB_API_TOKEN=[ENV_ABOVE] yarn danger pr https://github.com/facebook/react/pull/11865
const {markdown, danger} = require('danger');
const fetch = require('node-fetch');
const {generateResultsArray} = require('./scripts/rollup/stats');
const {readFileSync} = require('fs');
const {exec} = require('child_process');
const currentBuildResults = JSON.parse(
readFileSync('./scripts/rollup/results.json')
);
/**
* Generates a Markdown table
* @param {string[]} headers
* @param {string[][]} body
*/
function generateMDTable(headers, body) {
const tableHeaders = [
headers.join(' | '),
headers.map(() => ' --- ').join(' | '),
];
const tablebody = body.map(r => r.join(' | '));
return tableHeaders.join('\n') + '\n' + tablebody.join('\n');
}
/**
* Generates a user-readable string from a percentage change
* @param {number} change
* @param {boolean} includeEmoji
*/
function addPercent(change, includeEmoji) {
if (!isFinite(change)) {
// When a new package is created
return 'n/a';
}
const formatted = (change * 100).toFixed(1);
if (/^-|^0(?:\.0+)$/.test(formatted)) {
return `${formatted}%`;
} else {
if (includeEmoji) {
return `:small_red_triangle:+${formatted}%`;
} else {
return `+${formatted}%`;
}
}
}
function setBoldness(row, isBold) {
if (isBold) {
return row.map(element => `**${element}**`);
} else {
return row;
}
}
/**
* Gets the commit that represents the merge between the current branch
* and master.
*/
function git(args) {
return new Promise(res => {
exec('git ' + args, (err, stdout, stderr) => {
if (err) {
throw err;
} else {
res(stdout.trim());
}
});
});
}
(async function() {
// Use git locally to grab the commit which represents the place
// where the branches differ
const upstreamRepo = danger.github.pr.base.repo.full_name;
const upstreamRef = danger.github.pr.base.ref;
await git(`remote add upstream https://github.com/${upstreamRepo}.git`);
await git('fetch upstream');
const mergeBaseCommit = await git(`merge-base HEAD upstream/${upstreamRef}`);
const commitURL = sha =>
`http://react.zpao.com/builds/master/_commits/${sha}/results.json`;
const response = await fetch(commitURL(mergeBaseCommit));
// Take the JSON of the build response and
// make an array comparing the results for printing
const previousBuildResults = await response.json();
const results = generateResultsArray(
currentBuildResults,
previousBuildResults
);
const packagesToShow = results
.filter(
r =>
Math.abs(r.prevFileSizeAbsoluteChange) >= 300 || // bytes
Math.abs(r.prevGzipSizeAbsoluteChange) >= 100 // bytes
)
.map(r => r.packageName);
if (packagesToShow.length) {
let allTables = [];
// Highlight React and React DOM changes inline
// e.g. react: `react.production.min.js`: -3%, `react.development.js`: +4%
if (packagesToShow.includes('react')) {
const reactProd = results.find(
r => r.bundleType === 'UMD_PROD' && r.packageName === 'react'
);
if (
reactProd.prevFileSizeChange !== 0 ||
reactProd.prevGzipSizeChange !== 0
) {
const changeSize = addPercent(reactProd.prevFileSizeChange, true);
const changeGzip = addPercent(reactProd.prevGzipSizeChange, true);
markdown(`React: size: ${changeSize}, gzip: ${changeGzip}`);
}
}
if (packagesToShow.includes('react-dom')) {
const reactDOMProd = results.find(
r => r.bundleType === 'UMD_PROD' && r.packageName === 'react-dom'
);
if (
reactDOMProd.prevFileSizeChange !== 0 ||
reactDOMProd.prevGzipSizeChange !== 0
) {
const changeSize = addPercent(reactDOMProd.prevFileSizeChange, true);
const changeGzip = addPercent(reactDOMProd.prevGzipSizeChange, true);
markdown(`ReactDOM: size: ${changeSize}, gzip: ${changeGzip}`);
}
}
// Show a hidden summary table for all diffs
// eslint-disable-next-line no-var,no-for-of-loops/no-for-of-loops
for (var name of new Set(packagesToShow)) {
const thisBundleResults = results.filter(r => r.packageName === name);
const changedFiles = thisBundleResults.filter(
r => r.prevFileSizeChange !== 0 || r.prevGzipSizeChange !== 0
);
const mdHeaders = [
'File',
'Filesize Diff',
'Gzip Diff',
'Prev Size',
'Current Size',
'Prev Gzip',
'Current Gzip',
'ENV',
];
const mdRows = changedFiles.map(r => {
const isProd = r.bundleType.includes('PROD');
return setBoldness(
[
r.filename,
addPercent(r.prevFileSizeChange, isProd),
addPercent(r.prevGzipSizeChange, isProd),
r.prevSize,
r.prevFileSize,
r.prevGzip,
r.prevGzipSize,
r.bundleType,
],
isProd
);
});
allTables.push(`\n## ${name}`);
allTables.push(generateMDTable(mdHeaders, mdRows));
}
const summary = `
<details>
<summary>Details of bundled changes.</summary>
<p>Comparing: ${mergeBaseCommit}...${danger.github.pr.head.sha}</p>
${allTables.join('\n')}
</details>
`;
markdown(summary);
}
})();

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.

View File

@@ -5,9 +5,9 @@
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-preset-es2015": "^6.6.0",
"babel-preset-react": "^6.5.0",
"react": "file:../../build/packages/react",
"react-art": "file:../../build/packages/react-art",
"react-dom": "file:../../build/packages/react-dom",
"react": "link:../../build/node_modules/react",
"react-art": "link:../../build/node_modules/react-art/",
"react-dom": "link:../../build/node_modules/react-dom",
"webpack": "^1.14.0"
},
"scripts": {

View File

@@ -1742,31 +1742,17 @@ rc@^1.1.7:
minimist "^1.2.0"
strip-json-comments "~2.0.1"
"react-art@file:../../build/packages/react-art":
version "16.0.0"
dependencies:
art "^0.10.1"
create-react-class "^15.6.2"
fbjs "^0.8.16"
loose-envify "^1.1.0"
object-assign "^4.1.1"
prop-types "^15.6.0"
"react-art@link:../../build/node_modules/react-art":
version "0.0.0"
uid ""
"react-dom@file:../../build/packages/react-dom":
version "16.0.0"
dependencies:
fbjs "^0.8.16"
loose-envify "^1.1.0"
object-assign "^4.1.1"
prop-types "^15.6.0"
"react-dom@link:../../build/node_modules/react-dom":
version "0.0.0"
uid ""
"react@file:../../build/packages/react":
version "16.0.0"
dependencies:
fbjs "^0.8.16"
loose-envify "^1.1.0"
object-assign "^4.1.1"
prop-types "^15.6.0"
"react@link:../../build/node_modules/react":
version "0.0.0"
uid ""
"readable-stream@^2.0.0 || ^1.1.13", readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.5, readable-stream@^2.1.4, readable-stream@^2.2.6:
version "2.2.6"

File diff suppressed because it is too large Load Diff

View File

@@ -20,7 +20,7 @@ The left box shows the property (or attribute) assigned by React 15.\*, and the
right box shows the property (or attribute) assigned by the latest version of
React 16.
Right now we use a purple outline to call out cases where the assigned property
Right now, we use a purple outline to call out cases where the assigned property
(or attribute) has changed between React 15 and 16.
---

View File

@@ -11,7 +11,8 @@
"react-virtualized": "^9.9.0"
},
"scripts": {
"prestart": "cp ../../build/dist/{react,react-dom,react-dom-server.browser}.development.js public/",
"prestart":
"cp ../../build/dist/react.development.js public/ && cp ../../build/dist/react-dom.development.js public/ && cp ../../build/dist/react-dom-server.browser.development.js public/",
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",

View File

@@ -1222,6 +1222,7 @@ const attributes = [
tagName: 'color-profile',
read: getSVGAttribute('color-profile'),
},
{name: 'noModule', tagName: 'script'},
{name: 'nonce', read: getAttribute('nonce')},
{name: 'noValidate', tagName: 'form'},
{

View File

@@ -10,6 +10,7 @@ coverage
build
public/react.development.js
public/react-dom.development.js
public/react-dom-server.browser.development.js
# misc
.DS_Store

View File

@@ -6,17 +6,19 @@
"react-scripts": "^1.0.11"
},
"dependencies": {
"@babel/standalone": "^7.0.0",
"classnames": "^2.2.5",
"codemirror": "^5.40.0",
"core-js": "^2.4.1",
"prop-types": "^15.6.0",
"query-string": "^4.2.3",
"react": "^15.4.1",
"react-dom": "^15.4.1",
"semver": "^5.3.0"
"semver": "^5.5.0"
},
"scripts": {
"start": "react-scripts start",
"prestart": "cp ../../build/dist/{react,react-dom}.development.js public/",
"prestart": "cp ../../build/dist/react.development.js ../../build/dist/react-dom.development.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"

View File

@@ -0,0 +1 @@
<svg data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 23 20.46348"><title>logo</title><path d="M18.91 6.633q-.367-.126-.74-.234.062-.252.115-.506c.56-2.72.194-4.912-1.058-5.634-1.2-.692-3.162.03-5.144 1.755q-.293.255-.572.525-.187-.18-.38-.352C9.053.344 6.97-.432 5.72.29 4.523.984 4.168 3.045 4.67 5.623q.077.383.17.762c-.293.084-.578.173-.85.268-2.435.85-3.99 2.18-3.99 3.56 0 1.425 1.67 2.855 4.206 3.72q.308.106.622.196-.102.407-.18.82c-.482 2.533-.106 4.545 1.09 5.235 1.234.712 3.306-.02 5.325-1.784q.24-.208.48-.442.302.293.62.568c1.956 1.682 3.886 2.36 5.08 1.67 1.235-.715 1.636-2.876 1.115-5.505q-.06-.3-.138-.614.218-.064.428-.133C21.285 13.07 23 11.657 23 10.213c0-1.386-1.605-2.725-4.09-3.58zM12.73 2.756c1.698-1.478 3.285-2.06 4.01-1.644.77.444 1.068 2.235.584 4.584q-.047.23-.103.457a23.538 23.538 0 0 0-3.076-.486A23.08 23.08 0 0 0 12.2 3.24q.258-.248.528-.484zM6.79 11.39q.313.604.653 1.19.347.6.722 1.183a20.922 20.922 0 0 1-2.12-.34c.204-.657.454-1.34.746-2.032zm0-2.31c-.286-.678-.53-1.345-.73-1.99.655-.147 1.355-.267 2.084-.358q-.366.57-.705 1.16-.34.586-.65 1.188zm.522 1.156q.454-.945.98-1.854.522-.91 1.114-1.775c.684-.052 1.385-.08 2.094-.08.712 0 1.414.028 2.098.08q.585.865 1.108 1.77.526.906.992 1.845-.46.948-.988 1.862-.523.908-1.104 1.78c-.682.05-1.387.074-2.106.074-.716 0-1.412-.022-2.082-.066q-.596-.87-1.124-1.783-.526-.91-.982-1.854zm8.25 2.34q.346-.603.666-1.22A20.867 20.867 0 0 1 17 13.38a20.852 20.852 0 0 1-2.145.365q.364-.578.706-1.17zm.656-3.495q-.318-.604-.66-1.196-.338-.582-.7-1.15c.733.093 1.436.216 2.097.367a20.96 20.96 0 0 1-.737 1.98zM11.51 3.945a21.013 21.013 0 0 1 1.354 1.634q-1.358-.065-2.718 0c.447-.59.905-1.138 1.365-1.634zM6.214 1.14c.77-.445 2.47.19 4.264 1.783.115.102.23.208.345.318a23.545 23.545 0 0 0-1.96 2.426 24.008 24.008 0 0 0-3.068.477q-.088-.352-.158-.71v.002c-.433-2.21-.146-3.876.577-4.294zM5.09 13.183q-.285-.082-.566-.177A8.324 8.324 0 0 1 1.84 11.58a2.03 2.03 0 0 1-.857-1.368c0-.837 1.248-1.905 3.33-2.63q.393-.138.792-.25a23.565 23.565 0 0 0 1.12 2.904 23.922 23.922 0 0 0-1.134 2.946zm5.326 4.48a8.322 8.322 0 0 1-2.575 1.61 2.03 2.03 0 0 1-1.612.062c-.725-.42-1.027-2.034-.616-4.2q.074-.385.168-.764a23.104 23.104 0 0 0 3.1.448 23.91 23.91 0 0 0 1.974 2.44q-.214.207-.438.403zm1.122-1.112c-.466-.502-.93-1.058-1.384-1.656q.66.026 1.346.026.703 0 1.388-.03a20.894 20.894 0 0 1-1.35 1.66zm5.967 1.367a2.03 2.03 0 0 1-.753 1.428c-.725.42-2.275-.126-3.947-1.564q-.287-.246-.578-.526a23.09 23.09 0 0 0 1.928-2.448 22.936 22.936 0 0 0 3.115-.48q.07.284.124.556a8.32 8.32 0 0 1 .11 3.035zm.834-4.907c-.127.042-.256.082-.388.12a23.06 23.06 0 0 0-1.164-2.913 23.05 23.05 0 0 0 1.12-2.87c.234.067.463.14.683.215 2.13.732 3.428 1.816 3.428 2.65 0 .89-1.403 2.044-3.68 2.798z" fill="#61dafb"/><path d="M11.5 8.159a2.054 2.054 0 1 1-2.054 2.052A2.054 2.054 0 0 1 11.5 8.16" fill="#61dafb"/></svg>

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@@ -0,0 +1,86 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Renderer</title>
<style>
*,
*:before,
*:after {
box-sizing: border-box;
}
html,
body {
font-family: sans-serif;
margin: 0;
height: 100%;
}
body {
padding-top: 32px;
}
#status {
font-size: 12px;
left: 8px;
letter-spacing: 0.05em;
line-height: 16px;
margin: -8px 0 0;
max-width: 50%;
overflow: hidden;
position: absolute;
text-align: left;
text-overflow: ellipsis;
top: 50%;
white-space: nowrap;
width: 100%;
}
#output {
margin: 16px;
}
.header {
background: white;
border-bottom: 1px solid #d9d9d9;
padding: 4px;
top: 0;
left: 0;
position: fixed;
width: 100%;
text-align: right;
}
.controls {
display: inline-block;
margin: 0;
}
.button {
background: #eee;
border-radius: 2px;
border: 1px solid #aaa;
font-size: 11px;
padding: 4px 6px;
text-transform: uppercase;
}
</style>
</head>
<body>
<header class="header">
<p id="status">Loading</p>
<menu class="controls">
<button class="button" id="hydrate">Hydrate</button>
<button class="button" id="reload">Reload</button>
</menu>
</header>
<div id="output"></div>
<script src="https://cdn.polyfill.io/v2/polyfill.min.js"></script>
<script src="renderer.js"></script>
</body>
</html>

View File

@@ -0,0 +1,141 @@
/**
* Supports render.html, a piece of the hydration fixture. See /hydration
*/
'use strict';
(function() {
var Fixture = null;
var output = document.getElementById('output');
var status = document.getElementById('status');
var hydrate = document.getElementById('hydrate');
var reload = document.getElementById('reload');
var renders = 0;
var failed = false;
function getQueryParam(key) {
var pattern = new RegExp(key + '=([^&]+)(&|$)');
var matches = window.location.search.match(pattern);
if (matches) {
return decodeURIComponent(matches[1]);
}
handleError(new Error('No key found for' + key));
}
function getBooleanQueryParam(key) {
return getQueryParam(key) === 'true';
}
function setStatus(label) {
status.innerHTML = label;
}
function prerender() {
setStatus('Generating markup');
output.innerHTML = ReactDOMServer.renderToString(
React.createElement(Fixture)
);
setStatus('Markup only (No React)');
}
function render() {
setStatus('Hydrating');
if (ReactDOM.hydrate) {
ReactDOM.hydrate(React.createElement(Fixture), output);
} else {
ReactDOM.render(React.createElement(Fixture), output);
}
setStatus(renders > 0 ? 'Re-rendered (' + renders + 'x)' : 'Hydrated');
renders += 1;
hydrate.innerHTML = 'Re-render';
}
function handleError(error) {
console.log(error);
failed = true;
setStatus('Javascript Error');
output.innerHTML = error;
}
function loadScript(src) {
return new Promise(function(resolve, reject) {
var script = document.createElement('script');
script.async = true;
script.src = src;
script.onload = resolve;
script.onerror = function(error) {
reject(new Error('Unable to load ' + src));
};
document.body.appendChild(script);
});
}
function injectFixture(src) {
Fixture = new Function(src + '\nreturn Fixture;')();
if (typeof Fixture === 'undefined') {
setStatus('Failed');
output.innerHTML = 'Please name your root component "Fixture"';
} else {
prerender();
if (getBooleanQueryParam('hydrate')) {
render();
}
}
}
function reloadFixture(code) {
renders = 0;
ReactDOM.unmountComponentAtNode(output);
injectFixture(code);
}
window.onerror = handleError;
reload.onclick = function() {
window.location.reload();
};
hydrate.onclick = render;
loadScript(getQueryParam('reactPath'))
.then(function() {
return getBooleanQueryParam('needsReactDOM')
? loadScript(getQueryParam('reactDOMPath'))
: null;
})
.then(function() {
return loadScript(getQueryParam('reactDOMServerPath'));
})
.then(function() {
if (failed) {
return;
}
window.addEventListener('message', function(event) {
var data = JSON.parse(event.data);
switch (data.type) {
case 'code':
reloadFixture(data.payload);
break;
default:
throw new Error(
'Renderer Error: Unrecognized message "' + data.type + '"'
);
}
});
window.parent.postMessage(JSON.stringify({type: 'ready'}), '*');
})
.catch(handleError);
})();

Binary file not shown.

View File

@@ -8,9 +8,7 @@ function App() {
return (
<div>
<Header />
<div className="container">
<Fixtures />
</div>
<Fixtures />
</div>
);
}

View File

@@ -1,4 +1,4 @@
const PropTypes = window.PropTypes;
import PropTypes from 'prop-types';
const React = window.React;
const propTypes = {

View File

@@ -1,9 +1,9 @@
import React from 'react';
import PropTypes from 'prop-types';
const React = window.React;
const propTypes = {
title: PropTypes.node.isRequired,
description: PropTypes.node.isRequired,
description: PropTypes.node,
};
class FixtureSet extends React.Component {
@@ -11,7 +11,7 @@ class FixtureSet extends React.Component {
const {title, description, children} = this.props;
return (
<div>
<div className="container">
<h1>{title}</h1>
{description && <p>{description}</p>}

View File

@@ -34,12 +34,12 @@ class Header extends React.Component {
<div className="header__inner">
<span className="header__logo">
<img
src="https://reactjs.org/img/logo.svg"
alt=""
width="32"
height="32"
src={process.env.PUBLIC_URL + '/react-logo.svg'}
alt="React"
width="20"
height="20"
/>
React Sandbox (v{React.version})
<a href="/">DOM Test Fixtures (v{React.version})</a>
</span>
<div className="header-controls">
@@ -48,7 +48,8 @@ class Header extends React.Component {
<select
value={window.location.pathname}
onChange={this.handleFixtureChange}>
<option value="/">Select a Fixture</option>
<option value="/">Home</option>
<option value="/hydration">Hydration</option>
<option value="/range-inputs">Range Inputs</option>
<option value="/text-inputs">Text Inputs</option>
<option value="/number-inputs">Number Input</option>
@@ -63,6 +64,11 @@ class Header extends React.Component {
<option value="/error-handling">Error Handling</option>
<option value="/event-pooling">Event Pooling</option>
<option value="/custom-elements">Custom Elements</option>
<option value="/media-events">Media Events</option>
<option value="/pointer-events">Pointer Events</option>
<option value="/mouse-events">Mouse Events</option>
<option value="/selection-events">Selection Events</option>
<option value="/suspense">Suspense</option>
</select>
</label>
<label htmlFor="react_version">

View File

@@ -0,0 +1,58 @@
const React = window.React;
const ReactDOM = window.ReactDOM;
class IframePortal extends React.Component {
iframeRef = null;
handleRef = ref => {
if (ref !== this.iframeRef) {
this.iframeRef = ref;
if (ref) {
if (ref.contentDocument && this.props.head) {
ref.contentDocument.head.innerHTML = this.props.head;
}
// Re-render must take place in the next tick (Firefox)
setTimeout(() => {
this.forceUpdate();
});
}
}
};
render() {
const ref = this.iframeRef;
let portal = null;
if (ref && ref.contentDocument) {
portal = ReactDOM.createPortal(
this.props.children,
ref.contentDocument.body
);
}
return (
<div>
<iframe
title="Iframe portal"
style={{border: 'none', height: this.props.height}}
ref={this.handleRef}
/>
{portal}
</div>
);
}
}
class IframeSubtree extends React.Component {
warned = false;
render() {
if (!this.warned) {
console.error(
`IFrame has not yet been implemented for React v${React.version}`
);
this.warned = true;
}
return <div>{this.props.children}</div>;
}
}
export default (ReactDOM.createPortal ? IframePortal : IframeSubtree);

View File

@@ -10,7 +10,7 @@ function onButtonClick() {
export default class ButtonTestCases extends React.Component {
render() {
return (
<FixtureSet title="Buttons" description="">
<FixtureSet title="Buttons">
<TestCase
title="onClick with disabled buttons"
description="The onClick event handler should not be invoked when clicking on a disabled buyaton">

View File

@@ -8,7 +8,7 @@ const React = window.React;
class DateInputFixtures extends React.Component {
render() {
return (
<FixtureSet title="Dates" description="">
<FixtureSet title="Dates">
<TestCase title="Switching between date and datetime-local">
<TestCase.Steps>
<li>Type a date into the date picker</li>

View File

@@ -7,9 +7,21 @@ const ReactDOM = window.ReactDOM;
function BadRender(props) {
props.doThrow();
}
class BadDidMount extends React.Component {
componentDidMount() {
this.props.doThrow();
}
render() {
return null;
}
}
class ErrorBoundary extends React.Component {
static defaultProps = {
buttonText: 'Trigger error',
badChildType: BadRender,
};
state = {
shouldThrow: false,
@@ -33,7 +45,8 @@ class ErrorBoundary extends React.Component {
}
}
if (this.state.shouldThrow) {
return <BadRender doThrow={this.props.doThrow} />;
const BadChild = this.props.badChildType;
return <BadChild doThrow={this.props.doThrow} />;
}
return <button onClick={this.triggerError}>{this.props.buttonText}</button>;
}
@@ -84,10 +97,154 @@ class TriggerErrorAndCatch extends React.Component {
}
}
function silenceWindowError(event) {
event.preventDefault();
}
class SilenceErrors extends React.Component {
state = {
silenceErrors: false,
};
componentDidMount() {
if (this.state.silenceErrors) {
window.addEventListener('error', silenceWindowError);
}
}
componentDidUpdate(prevProps, prevState) {
if (!prevState.silenceErrors && this.state.silenceErrors) {
window.addEventListener('error', silenceWindowError);
} else if (prevState.silenceErrors && !this.state.silenceErrors) {
window.removeEventListener('error', silenceWindowError);
}
}
componentWillUnmount() {
if (this.state.silenceErrors) {
window.removeEventListener('error', silenceWindowError);
}
}
render() {
return (
<div>
<label>
<input
type="checkbox"
value={this.state.silenceErrors}
onChange={() =>
this.setState(state => ({
silenceErrors: !state.silenceErrors,
}))
}
/>
Silence errors
</label>
{this.state.silenceErrors && (
<div>
{this.props.children}
<br />
<hr />
<b style={{color: 'red'}}>
Don't forget to uncheck "Silence errors" when you're done with
this test!
</b>
</div>
)}
</div>
);
}
}
class GetEventTypeDuringUpdate extends React.Component {
state = {};
onClick = () => {
this.expectUpdate = true;
this.forceUpdate();
};
componentDidUpdate() {
if (this.expectUpdate) {
this.expectUpdate = false;
this.setState({eventType: window.event.type});
setTimeout(() => {
this.setState({cleared: !window.event});
});
}
}
render() {
return (
<div className="test-fixture">
<button onClick={this.onClick}>Trigger callback in event.</button>
{this.state.eventType ? (
<p>
Got <b>{this.state.eventType}</b> event.
</p>
) : (
<p>Got no event</p>
)}
{this.state.cleared ? (
<p>Event cleared correctly.</p>
) : (
<p>Event failed to clear.</p>
)}
</div>
);
}
}
class SilenceRecoverableError extends React.Component {
render() {
return (
<SilenceErrors>
<ErrorBoundary
badChildType={BadRender}
buttonText={'Throw (render phase)'}
doThrow={() => {
throw new Error('Silenced error (render phase)');
}}
/>
<ErrorBoundary
badChildType={BadDidMount}
buttonText={'Throw (commit phase)'}
doThrow={() => {
throw new Error('Silenced error (commit phase)');
}}
/>
</SilenceErrors>
);
}
}
class TrySilenceFatalError extends React.Component {
container = document.createElement('div');
triggerErrorAndCatch = () => {
try {
ReactDOM.flushSync(() => {
ReactDOM.render(
<BadRender
doThrow={() => {
throw new Error('Caught error');
}}
/>,
this.container
);
});
} catch (e) {}
};
render() {
return (
<SilenceErrors>
<button onClick={this.triggerErrorAndCatch}>Throw fatal error</button>
</SilenceErrors>
);
}
}
export default class ErrorHandlingTestCases extends React.Component {
render() {
return (
<FixtureSet title="Error handling" description="">
<FixtureSet title="Error handling">
<TestCase
title="Break on uncaught exceptions"
description="In DEV, errors should be treated as uncaught, even though React catches them internally">
@@ -103,6 +260,12 @@ export default class ErrorHandlingTestCases extends React.Component {
the BadRender component. After resuming, the "Trigger error" button
should be replaced with "Captured an error: Oops!" Clicking reset
should reset the test case.
<br />
<br />
In the console, you should see <b>two</b> messages: the actual error
("Oops") printed natively by the browser with its JavaScript stack,
and our addendum ("The above error occurred in BadRender component")
with a React component stack.
</TestCase.ExpectedResult>
<Example
doThrow={() => {
@@ -155,10 +318,59 @@ export default class ErrorHandlingTestCases extends React.Component {
</TestCase.Steps>
<TestCase.ExpectedResult>
Open the console. "Uncaught Error: Caught error" should have been
logged by the browser.
logged by the browser. You should also see our addendum ("The above
error...").
</TestCase.ExpectedResult>
<TriggerErrorAndCatch />
</TestCase>
<TestCase
title="Recoverable errors can be silenced with preventDefault (development mode only)"
description="">
<TestCase.Steps>
<li>Check the "Silence errors" checkbox below</li>
<li>Click the "Throw (render phase)" button</li>
<li>Click the "Throw (commit phase)" button</li>
<li>Uncheck the "Silence errors" checkbox</li>
</TestCase.Steps>
<TestCase.ExpectedResult>
Open the console. You shouldn't see <b>any</b> messages in the
console: neither the browser error, nor our "The above error"
addendum, from either of the buttons. The buttons themselves should
get replaced by two labels: "Captured an error: Silenced error
(render phase)" and "Captured an error: Silenced error (commit
phase)".
</TestCase.ExpectedResult>
<SilenceRecoverableError />
</TestCase>
<TestCase
title="Fatal errors cannot be silenced with preventDefault (development mode only)"
description="">
<TestCase.Steps>
<li>Check the "Silence errors" checkbox below</li>
<li>Click the "Throw fatal error" button</li>
<li>Uncheck the "Silence errors" checkbox</li>
</TestCase.Steps>
<TestCase.ExpectedResult>
Open the console. "Error: Caught error" should have been logged by
React. You should also see our addendum ("The above error...").
</TestCase.ExpectedResult>
<TrySilenceFatalError />
</TestCase>
{window.hasOwnProperty('event') ? (
<TestCase
title="Error handling does not interfere with window.event"
description="">
<TestCase.Steps>
<li>Click the "Trigger callback in event" button</li>
</TestCase.Steps>
<TestCase.ExpectedResult>
You should see "Got <b>click</b> event" and "Event cleared
successfully" below.
</TestCase.ExpectedResult>
<GetEventTypeDuringUpdate />
</TestCase>
) : null}
</FixtureSet>
);
}

View File

@@ -7,7 +7,7 @@ const React = window.React;
class EventPooling extends React.Component {
render() {
return (
<FixtureSet title="Event Pooling" description="">
<FixtureSet title="Event Pooling">
<MouseMove />
<Persistence />
</FixtureSet>

View File

@@ -0,0 +1,117 @@
const React = window.React;
export default function Home() {
return (
<main className="container">
<h1>DOM Test Fixtures</h1>
<p>
Use this site to test browser quirks and other behavior that can not be
captured through unit tests.
</p>
<section>
<h2>Tested Browsers</h2>
<table>
<thead>
<tr>
<th>Browser</th>
<th>Versions</th>
</tr>
</thead>
<tbody>
<tr>
<td>Chrome - Desktop</td>
<td>
49<sup>*</sup>, Latest
</td>
</tr>
<tr>
<td>Chrome - Android</td>
<td>Latest</td>
</tr>
<tr>
<td>Firefox Desktop</td>
<td>
<a href="https://www.mozilla.org/en-US/firefox/organizations/">
ESR<sup></sup>
</a>, Latest
</td>
</tr>
<tr>
<td>Internet Explorer</td>
<td>9, 10, 11</td>
</tr>
<tr>
<td>Microsoft Edge</td>
<td>14, Latest</td>
</tr>
<tr>
<td>Safari - Desktop</td>
<td>7, Latest</td>
</tr>
<tr>
<td>Safari - iOS</td>
<td>7, Latest</td>
</tr>
</tbody>
</table>
<footer>
<small>* Chrome 49 is the last release for Windows XP.</small>
<br />
<small>
Firefox Extended Support Release (ESR) is used by many
institutions.
</small>
</footer>
</section>
<section>
<h2>How do I test browsers I don't have access to?</h2>
<p>
Getting test coverage across all of these browsers can be difficult,
particularly for older versions of evergreen browsers. Fortunately
there are a handful of tools that make browser testing easy.
</p>
<section>
<h3>Paid services</h3>
<ul>
<li>
<a href="https://browserstack.com">BrowserStack</a>
</li>
<li>
<a href="https://saucelabs.com">Sauce Labs</a>
</li>
<li>
<a href="https://crossbrowsertesting.com/">CrossBrowserTesting</a>
</li>
</ul>
<p>
These services provide access to all browsers we test, however they
cost money. There is no obligation to pay for them. Maintainers have
access to a BrowserStack subscription; feel free to contact a
maintainer or mention browsers where extra testing is required.
</p>
</section>
<section>
<h3>Browser downloads</h3>
<p>A handful of browsers are available for download directly:</p>
<ul>
<li>
<a href="https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/">
Internet Explorer (9-11) and MS Edge virtual machines
</a>
</li>
<li>
<a href="https://www.chromium.org/getting-involved/download-chromium#TOC-Downloading-old-builds-of-Chrome-Chromium">
Chromium snapshots (for older versions of Chrome)
</a>
</li>
<li>
<a href="https://www.mozilla.org/en-US/firefox/organizations/">
Firefox Extended Support Release (ESR)
</a>
</li>
</ul>
</section>
</section>
</main>
);
}

View File

@@ -0,0 +1,85 @@
const React = window.React;
export class CodeEditor extends React.Component {
shouldComponentUpdate() {
return false;
}
componentDidMount() {
// Important: CodeMirror incorrectly lays out the editor
// if it executes before CSS has loaded
// https://github.com/graphql/graphiql/issues/33#issuecomment-318188555
Promise.all([
import('codemirror'),
import('codemirror/mode/jsx/jsx'),
import('codemirror/lib/codemirror.css'),
import('./codemirror-paraiso-dark.css'),
]).then(([CodeMirror]) => this.install(CodeMirror));
}
install(CodeMirror) {
if (!this.textarea) {
return;
}
const {onChange} = this.props;
this.editor = CodeMirror.fromTextArea(this.textarea, {
mode: 'jsx',
theme: 'paraiso-dark',
lineNumbers: true,
});
this.editor.on('change', function(doc) {
onChange(doc.getValue());
});
}
componentWillUnmount() {
if (this.editor) {
this.editor.toTextArea();
}
}
render() {
return (
<textarea
ref={ref => (this.textarea = ref)}
defaultValue={this.props.code}
autoComplete="off"
hidden={true}
/>
);
}
}
/**
* Prevent IE9 from raising an error on an unrecognized element:
* See https://github.com/facebook/react/issues/13610
*/
const supportsDetails = !(
document.createElement('details') instanceof HTMLUnknownElement
);
export class CodeError extends React.Component {
render() {
const {error, className} = this.props;
if (!error) {
return null;
}
if (supportsDetails) {
const [summary, ...body] = error.message.split(/\n+/g);
return (
<details className={className}>
<summary>{summary}</summary>
{body.join('\n')}
</details>
);
}
return <div className={className}>{error.message}</div>;
}
}

View File

@@ -0,0 +1,18 @@
/**
* Babel works across all browsers, however it requires many polyfills.
*/
import 'core-js/es6/weak-map';
import 'core-js/es6/weak-set';
import 'core-js/es6/number';
import 'core-js/es6/string';
import 'core-js/es6/array';
import 'core-js/modules/es6.object.set-prototype-of';
import {transform} from '@babel/standalone';
const presets = ['es2015', 'stage-3', 'react'];
export function compile(raw) {
return transform(raw, {presets}).code;
}

View File

@@ -0,0 +1,38 @@
/**
* Name: Paraíso (Dark)
* Author: Jan T. Sott
* License: Creative Commons Attribution-ShareAlike 4.0 Unported License.
* https://creativecommons.org/licenses/by-sa/4.0/deed.en_US
*
* Color scheme by Jan T. Sott (https://github.com/idleberg/Paraiso-CodeMirror)
* Inspired by the art of Rubens LP (http://www.rubenslp.com.br)
*/
.cm-s-paraiso-dark.CodeMirror { background: #2f1e2e; color: #b9b6b0; }
.cm-s-paraiso-dark div.CodeMirror-selected { background: #41323f; }
.cm-s-paraiso-dark .CodeMirror-line::selection, .cm-s-paraiso-dark .CodeMirror-line > span::selection, .cm-s-paraiso-dark .CodeMirror-line > span > span::selection { background: rgba(65, 50, 63, .99); }
.cm-s-paraiso-dark .CodeMirror-line::-moz-selection, .cm-s-paraiso-dark .CodeMirror-line > span::-moz-selection, .cm-s-paraiso-dark .CodeMirror-line > span > span::-moz-selection { background: rgba(65, 50, 63, .99); }
.cm-s-paraiso-dark .CodeMirror-gutters { background: #2f1e2e; border-right: 0px; }
.cm-s-paraiso-dark .CodeMirror-guttermarker { color: #ef6155; }
.cm-s-paraiso-dark .CodeMirror-guttermarker-subtle { color: #776e71; }
.cm-s-paraiso-dark .CodeMirror-linenumber { color: #776e71; }
.cm-s-paraiso-dark .CodeMirror-cursor { border-left: 1px solid #8d8687; }
.cm-s-paraiso-dark span.cm-comment { color: #e96ba8; }
.cm-s-paraiso-dark span.cm-atom { color: #815ba4; }
.cm-s-paraiso-dark span.cm-number { color: #815ba4; }
.cm-s-paraiso-dark span.cm-property, .cm-s-paraiso-dark span.cm-attribute { color: #48b685; }
.cm-s-paraiso-dark span.cm-keyword { color: #ef6155; }
.cm-s-paraiso-dark span.cm-string { color: #fec418; }
.cm-s-paraiso-dark span.cm-variable { color: #48b685; }
.cm-s-paraiso-dark span.cm-variable-2 { color: #06b6ef; }
.cm-s-paraiso-dark span.cm-def { color: #f99b15; }
.cm-s-paraiso-dark span.cm-bracket { color: #b9b6b0; }
.cm-s-paraiso-dark span.cm-tag { color: #ef6155; }
.cm-s-paraiso-dark span.cm-link { color: #815ba4; }
.cm-s-paraiso-dark span.cm-error { background: #ef6155; color: #8d8687; }
.cm-s-paraiso-dark .CodeMirror-activeline-background { background: #4D344A; }
.cm-s-paraiso-dark .CodeMirror-matchingbracket { text-decoration: underline; color: white !important; }

View File

@@ -0,0 +1,22 @@
export const SAMPLE_CODE = `
class Fixture extends React.Component {
state = {
value: 'asdf'
}
onChange(event) {
this.setState({ value: event.target.value });
}
render() {
const { value } = this.state;
return (
<form>
<input value={value} onChange={this.onChange.bind(this)} />
<p>Value: {value}</p>
</form>
);
}
}
`.trim();

View File

@@ -0,0 +1,68 @@
.hydration {
background: #2f1e2e;
margin: 0;
position: relative;
height: calc(100vh - 40px); /* height of header */
overflow: auto;
padding-top: 32px;
}
.hydration-options {
background: #171717;
border-top: 1px dashed rgba(215, 235, 255, 0.12);
color: #def5ff;
height: 32px;
line-height: 28px;
padding: 0 8px;
width: 100%;
position: absolute;
top: 0;
left: 0;
}
.hydration-options label {
font-size: 13px;
}
.hydration-options input[type=checkbox] {
display: inline-block;
margin-right: 4px;
vertical-align: middle;
}
.hydration .CodeMirror {
font-size: 13px;
padding-top: 8px;
padding-bottom: 68px;
height: calc(100vh - 72px);
width: 55%;
}
.hydration-sandbox {
background: white;
border-radius: 2px;
border: 0;
box-shadow: 0 1px 6px rgba(0, 0, 0, 0.54);
height: calc(100% - 34px);
position: absolute;
right: 16px;
top: 16px;
width: calc(45% - 24px);
}
.hydration-code-error {
background: #df3f3f;
border-radius: 2px;
bottom: 18px;
color: white;
font-family: monospace;
font-size: 13px;
left: 16px;
line-height: 1.25;
overflow: auto;
padding: 12px;
position: fixed;
white-space: pre;
max-width: calc(55% - 26px);
z-index: 10;
}

View File

@@ -0,0 +1,109 @@
import './hydration.css';
import {SAMPLE_CODE} from './data';
import {CodeEditor, CodeError} from './Code';
import {compile} from './code-transformer';
import {reactPaths} from '../../../react-loader';
import qs from 'query-string';
const React = window.React;
class Hydration extends React.Component {
state = {
error: null,
code: SAMPLE_CODE,
hydrate: true,
};
ready = false;
componentDidMount() {
window.addEventListener('message', this.handleMessage);
}
componentWillUnmount() {
window.removeEventListener('message', this.handleMessage);
}
handleMessage = event => {
var data = JSON.parse(event.data);
switch (data.type) {
case 'ready':
this.ready = true;
this.injectCode();
break;
default:
throw new Error(
'Editor Error: Unrecognized message "' + data.type + '"'
);
}
};
injectCode = () => {
try {
this.send({
type: 'code',
payload: compile(this.state.code),
});
this.setState({error: null});
} catch (error) {
this.setState({error});
}
};
send = message => {
if (this.ready) {
this.frame.contentWindow.postMessage(JSON.stringify(message), '*');
}
};
setFrame = frame => {
this.frame = frame;
};
setCode = code => {
this.setState({code}, this.injectCode);
};
setCheckbox = event => {
this.setState({
[event.target.name]: event.target.checked,
});
};
render() {
const {code, error, hydrate} = this.state;
const src = '/renderer.html?' + qs.stringify({hydrate, ...reactPaths()});
return (
<div className="hydration">
<header className="hydration-options">
<label htmlFor="hydrate">
<input
id="hydrate"
name="hydrate"
type="checkbox"
checked={hydrate}
onChange={this.setCheckbox}
/>
Auto-Hydrate
</label>
</header>
<CodeEditor code={code} onChange={this.setCode} />
<CodeError error={error} className="hydration-code-error" />
<iframe
ref={this.setFrame}
className="hydration-sandbox"
title="Hydration Preview"
src={src}
/>
</div>
);
}
}
export default Hydration;

View File

@@ -1,51 +1,62 @@
import RangeInputFixtures from './range-inputs';
import TextInputFixtures from './text-inputs';
import SelectFixtures from './selects';
import TextAreaFixtures from './textareas';
import InputChangeEvents from './input-change-events';
import NumberInputFixtures from './number-inputs';
import PasswordInputFixtures from './password-inputs';
import ButtonFixtures from './buttons';
import DateInputFixtures from './date-inputs';
import ErrorHandling from './error-handling';
import EventPooling from './event-pooling';
import CustomElementFixtures from './custom-elements';
const React = window.React;
const fixturePath = window.location.pathname;
/**
* A simple routing component that renders the appropriate
* fixture based on the location pathname.
*/
function FixturesPage() {
switch (window.location.pathname) {
case '/text-inputs':
return <TextInputFixtures />;
case '/range-inputs':
return <RangeInputFixtures />;
case '/selects':
return <SelectFixtures />;
case '/textareas':
return <TextAreaFixtures />;
case '/input-change-events':
return <InputChangeEvents />;
case '/number-inputs':
return <NumberInputFixtures />;
case '/password-inputs':
return <PasswordInputFixtures />;
case '/buttons':
return <ButtonFixtures />;
case '/date-inputs':
return <DateInputFixtures />;
case '/error-handling':
return <ErrorHandling />;
case '/event-pooling':
return <EventPooling />;
case '/custom-elements':
return <CustomElementFixtures />;
default:
return <p>Please select a test fixture.</p>;
class FixturesPage extends React.Component {
static defaultProps = {
fixturePath: fixturePath === '/' ? '/home' : fixturePath,
};
state = {
isLoading: true,
error: null,
Fixture: null,
};
componentDidMount() {
this.loadFixture();
}
async loadFixture() {
const {fixturePath} = this.props;
try {
const module = await import(`.${fixturePath}`);
this.setState({Fixture: module.default});
} catch (error) {
console.error(error);
this.setState({error});
} finally {
this.setState({isLoading: false});
}
}
render() {
const {Fixture, error, isLoading} = this.state;
if (isLoading) {
return null;
}
if (error) {
return <FixtureError error={error} />;
}
return <Fixture />;
}
}
function FixtureError({error}) {
return (
<section>
<h2>Error loading fixture</h2>
<p>{error.message}</p>
</section>
);
}
export default FixturesPage;

View File

@@ -1,6 +1,5 @@
import React from 'react';
import Fixture from '../../Fixture';
const React = window.React;
class InputPlaceholderFixture extends React.Component {
constructor(props, context) {

View File

@@ -1,6 +1,5 @@
import React from 'react';
import Fixture from '../../Fixture';
const React = window.React;
class RadioClickFixture extends React.Component {
constructor(props, context) {

View File

@@ -1,6 +1,5 @@
import React from 'react';
import Fixture from '../../Fixture';
const React = window.React;
class RadioGroupFixture extends React.Component {
constructor(props, context) {
@@ -27,7 +26,7 @@ class RadioGroupFixture extends React.Component {
render() {
const {changeCount} = this.state;
const color = changeCount === 2 ? 'green' : 'red';
const color = changeCount >= 3 ? 'green' : 'red';
return (
<Fixture>

View File

@@ -0,0 +1,48 @@
const React = window.React;
const noop = n => n;
class RadioNameChangeFixture extends React.Component {
state = {
updated: false,
};
onClick = () => {
this.setState(state => {
return {updated: !state.updated};
});
};
render() {
const {updated} = this.state;
const radioName = updated ? 'firstName' : 'secondName';
return (
<div>
<label>
<input
type="radio"
name={radioName}
onChange={noop}
checked={updated === true}
/>
First Radio
</label>
<label>
<input
type="radio"
name={radioName}
onChange={noop}
checked={updated === false}
/>
Second Radio
</label>
<div>
<button type="button" onClick={this.onClick}>
Toggle
</button>
</div>
</div>
);
}
}
export default RadioNameChangeFixture;

View File

@@ -1,6 +1,5 @@
import React from 'react';
import Fixture from '../../Fixture';
const React = window.React;
class RangeKeyboardFixture extends React.Component {
constructor(props, context) {

View File

@@ -1,11 +1,11 @@
import React from 'react';
import FixtureSet from '../../FixtureSet';
import TestCase from '../../TestCase';
import RangeKeyboardFixture from './RangeKeyboardFixture';
import RadioClickFixture from './RadioClickFixture';
import RadioGroupFixture from './RadioGroupFixture';
import RadioNameChangeFixture from './RadioNameChangeFixture';
import InputPlaceholderFixture from './InputPlaceholderFixture';
const React = window.React;
class InputChangeEvents extends React.Component {
render() {
@@ -58,10 +58,12 @@ class InputChangeEvents extends React.Component {
<TestCase.Steps>
<li>Click on the "Radio 2"</li>
<li>Click back to "Radio 1"</li>
<li>Click back to "Radio 2"</li>
</TestCase.Steps>
<TestCase.ExpectedResult>
The <code>onChange</code> call count should equal 2
The <code>onChange</code> call count increment on each value change
(at least 3+)
</TestCase.ExpectedResult>
<RadioGroupFixture />
@@ -87,6 +89,25 @@ class InputChangeEvents extends React.Component {
<InputPlaceholderFixture />
</TestCase>
<TestCase
title="Radio button groups with name changes"
description={`
A radio button group should have correct checked value when
the names changes
`}
resolvedBy="#11227"
affectedBrowsers="IE9+">
<TestCase.Steps>
<li>Click the toggle button</li>
</TestCase.Steps>
<TestCase.ExpectedResult>
The checked radio button should switch between the first and second
radio button
</TestCase.ExpectedResult>
<RadioNameChangeFixture />
</TestCase>
</FixtureSet>
);
}

View File

@@ -0,0 +1,121 @@
import FixtureSet from '../../FixtureSet';
import TestCase from '../../TestCase';
const React = window.React;
export default class MediaEvents extends React.Component {
state = {
playbackRate: 2,
events: {
onCanPlay: false,
onCanPlayThrough: false,
onDurationChange: false,
onEmptied: false,
onEnded: false,
onError: false,
onLoadedData: false,
onLoadedMetadata: false,
onLoadStart: false,
onPause: false,
onPlay: false,
onPlaying: false,
onProgress: false,
onRateChange: false,
onSeeked: false,
onSeeking: false,
onSuspend: false,
onTimeUpdate: false,
onVolumeChange: false,
onWaiting: false,
},
};
updatePlaybackRate = () => {
this.video.playbackRate = 2;
};
setVideo = el => {
this.video = el;
};
eventDidFire(event) {
this.setState({
events: Object.assign({}, this.state.events, {[event]: true}),
});
}
getProgress() {
const events = Object.keys(this.state.events);
const total = events.length;
const fired = events.filter(type => this.state.events[type]).length;
return fired / total;
}
render() {
const events = Object.keys(this.state.events);
const handlers = events.reduce((events, event) => {
events[event] = this.eventDidFire.bind(this, event);
return events;
}, {});
return (
<FixtureSet title="Media Events">
<TestCase
title="Event bubbling"
description="Media events should synthetically bubble">
<TestCase.Steps>
<li>Play the loaded video</li>
<li>Pause the loaded video</li>
<li>Play the failing video</li>
<li>Drag the track bar</li>
<li>Toggle the volume button</li>
<li>
<button onClick={this.updatePlaybackRate}>
Click this button to increase playback rate
</button>
</li>
</TestCase.Steps>
<p className="footnote">
Note: This test does not confirm <code>onStalled</code>,{' '}
<code>onAbort</code>, or <code>onEncrypted</code>
</p>
<TestCase.ExpectedResult>
All events in the table below should be marked as "true".
</TestCase.ExpectedResult>
<section {...handlers}>
<video src="/test.mp4" width="300" controls ref={this.setVideo} />
<video src="/missing.mp4" width="300" controls />
<p className="footnote">
Note: The second video will not load. This is intentional.
</p>
</section>
<hr />
<section>
<h3>Events</h3>
<p>The following events should bubble:</p>
<table>
<tbody>{events.map(this.renderOutcome, this)}</tbody>
</table>
</section>
</TestCase>
</FixtureSet>
);
}
renderOutcome(event) {
let fired = this.state.events[event];
return (
<tr key={event}>
<td>
<b>{event}</b>
</td>
<td style={{color: fired ? null : 'red'}}>{`${fired}`}</td>
</tr>
);
}
}

View File

@@ -0,0 +1,16 @@
import FixtureSet from '../../FixtureSet';
import MouseMovement from './mouse-movement';
const React = window.React;
class MouseEvents extends React.Component {
render() {
return (
<FixtureSet title="Mouse Events">
<MouseMovement />
</FixtureSet>
);
}
}
export default MouseEvents;

View File

@@ -0,0 +1,48 @@
import TestCase from '../../TestCase';
const React = window.React;
class MouseMovement extends React.Component {
state = {
movement: {x: 0, y: 0},
};
onMove = event => {
this.setState({x: event.movementX, y: event.movementY});
};
render() {
const {x, y} = this.state;
const boxStyle = {
padding: '10px 20px',
border: '1px solid #d9d9d9',
margin: '10px 0 20px',
};
return (
<TestCase
title="Mouse Movement"
description="We polyfill the movementX and movementY fields."
affectedBrowsers="IE, Safari">
<TestCase.Steps>
<li>Mouse over the box below</li>
</TestCase.Steps>
<TestCase.ExpectedResult>
The reported values should equal the pixel (integer) difference
between mouse movements positions.
</TestCase.ExpectedResult>
<div style={boxStyle} onMouseMove={this.onMove}>
<p>Trace your mouse over this box.</p>
<p>
Last movement: {x},{y}
</p>
</div>
</TestCase>
);
}
}
export default MouseMovement;

View File

@@ -27,9 +27,9 @@ function NumberInputs() {
<NumberTestCase />
<p className="footnote">
<b>Notes:</b> Chrome and Safari clear trailing decimals on blur. React
makes this concession so that the value attribute remains in sync with
the value property.
<b>Notes:</b> Modern Chrome and Safari {'<='} 6 clear trailing
decimals on blur. React makes this concession so that the value
attribute remains in sync with the value property.
</p>
</TestCase>

View File

@@ -6,7 +6,7 @@ const React = window.React;
function NumberInputs() {
return (
<FixtureSet title="Password inputs" description="">
<FixtureSet title="Password inputs">
<TestCase
title="The show password icon"
description={`
@@ -15,7 +15,7 @@ function NumberInputs() {
`}
affectedBrowsers="IE Edge, IE 11">
<TestCase.Steps>
<li>Type any string (not an actual password</li>
<li>Type any string (not an actual password)</li>
</TestCase.Steps>
<TestCase.ExpectedResult>

View File

@@ -0,0 +1,90 @@
const React = window.React;
const CIRCLE_SIZE = 80;
class DragBox extends React.Component {
state = {
hasCapture: false,
circleLeft: 80,
circleTop: 80,
};
isDragging = false;
previousLeft = 0;
previousTop = 0;
onDown = event => {
this.isDragging = true;
event.target.setPointerCapture(event.pointerId);
// We store the initial coordinates to be able to calculate the changes
// later on.
this.extractPositionDelta(event);
};
onMove = event => {
if (!this.isDragging) {
return;
}
const {left, top} = this.extractPositionDelta(event);
this.setState(({circleLeft, circleTop}) => ({
circleLeft: circleLeft + left,
circleTop: circleTop + top,
}));
};
onUp = event => (this.isDragging = false);
onGotCapture = event => this.setState({hasCapture: true});
onLostCapture = event => this.setState({hasCapture: false});
extractPositionDelta = event => {
const left = event.pageX;
const top = event.pageY;
const delta = {
left: left - this.previousLeft,
top: top - this.previousTop,
};
this.previousLeft = left;
this.previousTop = top;
return delta;
};
render() {
const {hasCapture, circleLeft, circleTop} = this.state;
const boxStyle = {
border: '1px solid #d9d9d9',
margin: '10px 0 20px',
minHeight: 400,
width: '100%',
position: 'relative',
};
const circleStyle = {
width: CIRCLE_SIZE,
height: CIRCLE_SIZE,
borderRadius: CIRCLE_SIZE / 2,
position: 'absolute',
left: circleLeft,
top: circleTop,
backgroundColor: hasCapture ? 'blue' : 'green',
touchAction: 'none',
};
return (
<div style={boxStyle}>
<div
style={circleStyle}
onPointerDown={this.onDown}
onPointerMove={this.onMove}
onPointerUp={this.onUp}
onPointerCancel={this.onUp}
onGotPointerCapture={this.onGotCapture}
onLostPointerCapture={this.onLostCapture}
/>
</div>
);
}
}
export default DragBox;

View File

@@ -0,0 +1,25 @@
import TestCase from '../../TestCase';
import DragBox from './drag-box';
const React = window.React;
class Drag extends React.Component {
render() {
return (
<TestCase title="Drag" description="">
<TestCase.Steps>
<li>Drag the circle below with any pointer tool</li>
</TestCase.Steps>
<TestCase.ExpectedResult>
While dragging, the circle must have turn blue to indicate that a
pointer capture was received.
</TestCase.ExpectedResult>
<DragBox />
</TestCase>
);
}
}
export default Drag;

View File

@@ -0,0 +1,34 @@
const React = window.React;
class DrawBox extends React.Component {
render() {
const boxStyle = {
border: '1px solid #d9d9d9',
margin: '10px 0 20px',
padding: '20px 20px',
touchAction: 'none',
};
const obstacleStyle = {
border: '1px solid #d9d9d9',
width: '25%',
height: '200px',
margin: '12.5%',
display: 'inline-block',
};
return (
<div
style={boxStyle}
onPointerOver={this.props.onOver}
onPointerOut={this.props.onOut}
onPointerEnter={this.props.onEnter}
onPointerLeave={this.props.onLeave}>
<div style={obstacleStyle} />
<div style={obstacleStyle} />
</div>
);
}
}
export default DrawBox;

View File

@@ -0,0 +1,51 @@
import TestCase from '../../TestCase';
import HoverBox from './hover-box';
const React = window.React;
class Hover extends React.Component {
state = {
overs: 0,
outs: 0,
enters: 0,
leaves: 0,
};
onOver = () => this.setState({overs: this.state.overs + 1});
onOut = () => this.setState({outs: this.state.outs + 1});
onEnter = () => this.setState({enters: this.state.enters + 1});
onLeave = () => this.setState({leaves: this.state.leaves + 1});
render() {
const {overs, outs, enters, leaves} = this.state;
return (
<TestCase title="Hover" description="">
<TestCase.Steps>
<li>Hover over the above box and the obstacles</li>
</TestCase.Steps>
<TestCase.ExpectedResult>
Overs and outs should increase when moving over the obstacles but
enters and leaves should not.
</TestCase.ExpectedResult>
<HoverBox
onOver={this.onOver}
onOut={this.onOut}
onEnter={this.onEnter}
onLeave={this.onLeave}
/>
<p>
Pointer Overs: <b>{overs}</b> <br />
Pointer Outs: <b>{outs}</b> <br />
Pointer Enters: <b>{enters}</b> <br />
Pointer Leaves: <b>{leaves}</b> <br />
</p>
</TestCase>
);
}
}
export default Hover;

View File

@@ -0,0 +1,20 @@
import FixtureSet from '../../FixtureSet';
import Drag from './drag';
import Hover from './hover';
const React = window.React;
class PointerEvents extends React.Component {
render() {
return (
<FixtureSet
title="Pointer Events"
description="Pointer Events are not supported in every browser. The examples below might not work in every browser. To test pointer events, make sure to use Google Chrome, Firefox, Internet Explorer, or Edge.">
<Drag />
<Hover />
</FixtureSet>
);
}
}
export default PointerEvents;

View File

@@ -1,3 +1,5 @@
import FixtureSet from '../../FixtureSet';
const React = window.React;
class RangeInputs extends React.Component {
@@ -7,22 +9,26 @@ class RangeInputs extends React.Component {
};
render() {
return (
<form>
<fieldset>
<legend>Controlled</legend>
<input
type="range"
value={this.state.value}
onChange={this.onChange}
/>
<span className="hint">Value: {this.state.value}</span>
</fieldset>
<FixtureSet
title="Range Inputs"
description="Note: Range inputs are not supported in IE9.">
<form>
<fieldset>
<legend>Controlled</legend>
<input
type="range"
value={this.state.value}
onChange={this.onChange}
/>
<span className="hint">Value: {this.state.value}</span>
</fieldset>
<fieldset>
<legend>Uncontrolled</legend>
<input type="range" defaultValue={0.5} />
</fieldset>
</form>
<fieldset>
<legend>Uncontrolled</legend>
<input type="range" defaultValue={0.5} />
</fieldset>
</form>
</FixtureSet>
);
}
}

View File

@@ -0,0 +1,50 @@
import TestCase from '../../TestCase';
import Iframe from '../../Iframe';
const React = window.React;
class OnSelectIframe extends React.Component {
state = {count: 0, value: 'Select Me!'};
_onSelect = event => {
this.setState(({count}) => ({count: count + 1}));
};
_onChange = event => {
this.setState({value: event.target.value});
};
render() {
const {count, value} = this.state;
return (
<Iframe height={60}>
Selection Event Count: {count}
<input
type="text"
onSelect={this._onSelect}
value={value}
onChange={this._onChange}
/>
</Iframe>
);
}
}
export default class OnSelectEventTestCase extends React.Component {
render() {
return (
<TestCase
title="onSelect events within iframes"
description="onSelect events should fire for elements rendered inside iframes">
<TestCase.Steps>
<li>Highlight some of the text in the input below</li>
<li>Move the cursor around using the arrow keys</li>
</TestCase.Steps>
<TestCase.ExpectedResult>
The displayed count should increase as you highlight or move the
cursor
</TestCase.ExpectedResult>
<OnSelectIframe />
</TestCase>
);
}
}

View File

@@ -0,0 +1,44 @@
import TestCase from '../../TestCase';
import Iframe from '../../Iframe';
const React = window.React;
export default class ReorderedInputsTestCase extends React.Component {
state = {count: 0};
componentDidMount() {
this.interval = setInterval(() => {
this.setState({count: this.state.count + 1});
}, 2000);
}
componentWillUnmount() {
clearInterval(this.interval);
}
renderInputs() {
const inputs = [
<input key={1} defaultValue="Foo" />,
<input key={2} defaultValue="Bar" />,
];
if (this.state.count % 2 === 0) {
inputs.reverse();
}
return inputs;
}
render() {
return (
<TestCase title="Reordered input elements in iframes" description="">
<TestCase.Steps>
<li>The two inputs below swap positions every two seconds</li>
<li>Select the text in either of them</li>
<li>Wait for the swap to occur</li>
</TestCase.Steps>
<TestCase.ExpectedResult>
The selection you made should be maintained
</TestCase.ExpectedResult>
<Iframe height={50}>{this.renderInputs()}</Iframe>
</TestCase>
);
}
}

View File

@@ -0,0 +1,19 @@
import FixtureSet from '../../FixtureSet';
import ReorderedInputsTestCase from './ReorderedInputsTestCase';
import OnSelectEventTestCase from './OnSelectEventTestCase';
const React = window.React;
export default function SelectionEvents() {
return (
<FixtureSet
title="Selection Restoration"
description="
When React commits changes it may perform operations which cause existing
selection state to be lost. This is manually managed by reading the
selection state before commits and then restoring it afterwards.
">
<ReorderedInputsTestCase />
<OnSelectEventTestCase />
</FixtureSet>
);
}

View File

@@ -46,7 +46,7 @@ class SelectFixture extends React.Component {
render() {
return (
<FixtureSet title="Selects" description="">
<FixtureSet title="Selects">
<form className="field-group">
<fieldset>
<legend>Controlled</legend>
@@ -123,7 +123,7 @@ class SelectFixture extends React.Component {
<li>Click the "Reset" button</li>
</TestCase.Steps>
<TestCase.ExpectedResult>
The select should be reset to the inital value, "bar"
The select should be reset to the initial value, "bar"
</TestCase.ExpectedResult>
<div className="test-fixture">
@@ -158,6 +158,50 @@ class SelectFixture extends React.Component {
</form>
</div>
</TestCase>
<TestCase title="A multiple select being scrolled to first selected option">
<TestCase.ExpectedResult>
First selected option should be visible
</TestCase.ExpectedResult>
<div className="test-fixture">
<form>
<select multiple defaultValue={['tiger']}>
<option value="gorilla">gorilla</option>
<option value="giraffe">giraffe</option>
<option value="monkey">monkey</option>
<option value="lion">lion</option>
<option value="mongoose">mongoose</option>
<option value="tiger">tiget</option>
</select>
</form>
</div>
</TestCase>
<TestCase
title="An option which contains conditional render fails"
relatedIssues="11911">
<TestCase.Steps>
<li>Select any option</li>
</TestCase.Steps>
<TestCase.ExpectedResult>
Option should be set
</TestCase.ExpectedResult>
<div className="test-fixture">
<select value={this.state.value} onChange={this.onChange}>
<option value="red">
red {this.state.value === 'red' && 'is chosen '} TextNode
</option>
<option value="blue">
blue {this.state.value === 'blue' && 'is chosen '} TextNode
</option>
<option value="green">
green {this.state.value === 'green' && 'is chosen '} TextNode
</option>
</select>
</div>
</TestCase>
</FixtureSet>
);
}

View File

@@ -0,0 +1,321 @@
import Fixture from '../../Fixture';
import FixtureSet from '../../FixtureSet';
import TestCase from '../../TestCase';
const React = window.React;
const ReactDOM = window.ReactDOM;
const Suspense = React.unstable_Suspense;
let cache = new Set();
function AsyncStep({text, ms}) {
if (!cache.has(text)) {
throw new Promise(resolve =>
setTimeout(() => {
cache.add(text);
resolve();
}, ms)
);
}
return null;
}
let suspendyTreeIdCounter = 0;
class SuspendyTreeChild extends React.Component {
id = suspendyTreeIdCounter++;
state = {
step: 1,
isHidden: false,
};
increment = () => this.setState(s => ({step: s.step + 1}));
componentDidMount() {
document.addEventListener('keydown', this.onKeydown);
}
componentWillUnmount() {
document.removeEventListener('keydown', this.onKeydown);
}
onKeydown = event => {
if (event.metaKey && event.key === 'Enter') {
this.increment();
}
};
render() {
return (
<React.Fragment>
<Suspense fallback={<div>(display: none)</div>}>
<div>
<AsyncStep text={`${this.state.step} + ${this.id}`} ms={500} />
{this.props.children}
</div>
</Suspense>
<button onClick={this.increment}>Hide</button>
</React.Fragment>
);
}
}
class SuspendyTree extends React.Component {
parentContainer = React.createRef(null);
container = React.createRef(null);
componentDidMount() {
this.setState({});
document.addEventListener('keydown', this.onKeydown);
}
componentWillUnmount() {
document.removeEventListener('keydown', this.onKeydown);
}
onKeydown = event => {
if (event.metaKey && event.key === '/') {
this.removeAndRestore();
}
};
removeAndRestore = () => {
const parentContainer = this.parentContainer.current;
const container = this.container.current;
parentContainer.removeChild(container);
parentContainer.textContent = '(removed from DOM)';
setTimeout(() => {
parentContainer.textContent = '';
parentContainer.appendChild(container);
}, 500);
};
render() {
return (
<React.Fragment>
<div ref={this.parentContainer}>
<div ref={this.container} />
</div>
<div>
{this.container.current !== null
? ReactDOM.createPortal(
<React.Fragment>
<SuspendyTreeChild>{this.props.children}</SuspendyTreeChild>
<button onClick={this.removeAndRestore}>Remove</button>
</React.Fragment>,
this.container.current
)
: null}
</div>
</React.Fragment>
);
}
}
class TextInputFixtures extends React.Component {
render() {
return (
<FixtureSet
title="Suspense"
description="Preserving the state of timed-out children">
<p>
Clicking "Hide" will hide the fixture context using{' '}
<code>display: none</code> for 0.5 seconds, then restore. This is the
built-in behavior for timed-out children. Each fixture tests whether
the state of the DOM is preserved. Clicking "Remove" will remove the
fixture content from the DOM for 0.5 seconds, then restore. This is{' '}
<strong>not</strong> how timed-out children are hidden, but is
included for comparison purposes.
</p>
<div className="footnote">
As a shortcut, you can use Command + Enter (or Control + Enter on
Windows, Linux) to "Hide" all the fixtures, or Command + / to "Remove"
them.
</div>
<TestCase title="Text selection where entire range times out">
<TestCase.Steps>
<li>Use your cursor to select the text below.</li>
<li>Click "Hide" or "Remove".</li>
</TestCase.Steps>
<TestCase.ExpectedResult>
Text selection is preserved when hiding, but not when removing.
</TestCase.ExpectedResult>
<Fixture>
<SuspendyTree>
Select this entire sentence (and only this sentence).
</SuspendyTree>
</Fixture>
</TestCase>
<TestCase title="Text selection that extends outside timed-out subtree">
<TestCase.Steps>
<li>
Use your cursor to select a range that includes both the text and
the "Go" button.
</li>
<li>Click "Hide" or "Remove".</li>
</TestCase.Steps>
<TestCase.ExpectedResult>
Text selection is preserved when hiding, but not when removing.
</TestCase.ExpectedResult>
<Fixture>
<SuspendyTree>
Select a range that includes both this sentence and the "Go"
button.
</SuspendyTree>
</Fixture>
</TestCase>
<TestCase title="Focus">
<TestCase.Steps>
<li>
Use your cursor to select a range that includes both the text and
the "Go" button.
</li>
<li>
Intead of clicking "Go", which switches focus, press Command +
Enter (or Control + Enter on Windows, Linux).
</li>
</TestCase.Steps>
<TestCase.ExpectedResult>
The ideal behavior is that the focus would not be lost, but
currently it is (both when hiding and removing).
</TestCase.ExpectedResult>
<Fixture>
<SuspendyTree>
<button>Focus me</button>
</SuspendyTree>
</Fixture>
</TestCase>
<TestCase title="Uncontrolled form input">
<TestCase.Steps>
<li>Type something ("Hello") into the text input.</li>
<li>Click "Hide" or "Remove".</li>
</TestCase.Steps>
<TestCase.ExpectedResult>
Input is preserved when hiding, but not when removing.
</TestCase.ExpectedResult>
<Fixture>
<SuspendyTree>
<input type="text" />
</SuspendyTree>
</Fixture>
</TestCase>
<TestCase title="Image flicker">
<TestCase.Steps>
<li>Click "Hide" or "Remove".</li>
</TestCase.Steps>
<TestCase.ExpectedResult>
The image should reappear without flickering. The text should not
reflow.
</TestCase.ExpectedResult>
<Fixture>
<SuspendyTree>
<img src="https://upload.wikimedia.org/wikipedia/commons/e/ee/Atom_%282%29.png" />React
is cool
</SuspendyTree>
</Fixture>
</TestCase>
<TestCase title="Iframe">
<TestCase.Steps>
<li>
The iframe shows a nested version of this fixtures app. Navigate
to the "Text inputs" page.
</li>
<li>Select one of the checkboxes.</li>
<li>Click "Hide" or "Remove".</li>
</TestCase.Steps>
<TestCase.ExpectedResult>
When removing, the iframe is reloaded. When hiding, the iframe
should still be on the "Text inputs" page. The checkbox should still
be checked. (Unfortunately, scroll position is lost.)
</TestCase.ExpectedResult>
<Fixture>
<SuspendyTree>
<iframe width="500" height="300" src="/" />
</SuspendyTree>
</Fixture>
</TestCase>
<TestCase title="Video playback">
<TestCase.Steps>
<li>Start playing the video, or seek to a specific position.</li>
<li>Click "Hide" or "Remove".</li>
</TestCase.Steps>
<TestCase.ExpectedResult>
The playback position should stay the same. When hiding, the video
plays in the background for the entire duration. When removing, the
video stops playing, but the position is not lost.
</TestCase.ExpectedResult>
<Fixture>
<SuspendyTree>
<video controls>
<source
src="http://techslides.com/demos/sample-videos/small.webm"
type="video/webm"
/>
<source
src="http://techslides.com/demos/sample-videos/small.ogv"
type="video/ogg"
/>
<source
src="http://techslides.com/demos/sample-videos/small.mp4"
type="video/mp4"
/>
<source
src="http://techslides.com/demos/sample-videos/small.3gp"
type="video/3gp"
/>
</video>
</SuspendyTree>
</Fixture>
</TestCase>
<TestCase title="Audio playback">
<TestCase.Steps>
<li>Start playing the audio, or seek to a specific position.</li>
<li>Click "Hide" or "Remove".</li>
</TestCase.Steps>
<TestCase.ExpectedResult>
The playback position should stay the same. When hiding, the audio
plays in the background for the entire duration. When removing, the
audio stops playing, but the position is not lost.
</TestCase.ExpectedResult>
<Fixture>
<SuspendyTree>
<audio controls={true}>
<source src="https://upload.wikimedia.org/wikipedia/commons/e/ec/Mozart_K448.ogg" />
</audio>
</SuspendyTree>
</Fixture>
</TestCase>
<TestCase title="Scroll position">
<TestCase.Steps>
<li>Scroll to a position in the list.</li>
<li>Click "Hide" or "Remove".</li>
</TestCase.Steps>
<TestCase.ExpectedResult>
Scroll position is preserved when hiding, but not when removing.
</TestCase.ExpectedResult>
<Fixture>
<SuspendyTree>
<div style={{height: 200, overflow: 'scroll'}}>
{Array(20)
.fill()
.map((_, i) => <h2 key={i}>{i + 1}</h2>)}
</div>
</SuspendyTree>
</Fixture>
</TestCase>
</FixtureSet>
);
}
}
export default TextInputFixtures;

View File

@@ -0,0 +1,40 @@
import Fixture from '../../Fixture';
const React = window.React;
class ReplaceEmailInput extends React.Component {
state = {
formSubmitted: false,
};
onReset = () => {
this.setState({formSubmitted: false});
};
onSubmit = event => {
event.preventDefault();
this.setState({formSubmitted: true});
};
render() {
return (
<Fixture>
<form className="control-box" onSubmit={this.onSubmit}>
<fieldset>
<legend>Email</legend>
{!this.state.formSubmitted ? (
<input type="email" />
) : (
<input type="text" disabled={true} />
)}
</fieldset>
</form>
<button type="button" onClick={this.onReset}>
Reset
</button>
</Fixture>
);
}
}
export default ReplaceEmailInput;

View File

@@ -2,6 +2,7 @@ import Fixture from '../../Fixture';
import FixtureSet from '../../FixtureSet';
import TestCase from '../../TestCase';
import InputTestCase from './InputTestCase';
import ReplaceEmailInput from './ReplaceEmailInput';
const React = window.React;
@@ -42,6 +43,61 @@ class TextInputFixtures extends React.Component {
</p>
</TestCase>
<TestCase
title="Required Inputs"
affectedBrowsers="Firefox"
relatedIssues="8395">
<TestCase.Steps>
<li>View this test in Firefox</li>
</TestCase.Steps>
<TestCase.ExpectedResult>
You should{' '}
<b>
<i>not</i>
</b>{' '}
see a red aura, indicating the input is invalid.
<br />
This aura looks roughly like:
<input style={{boxShadow: '0 0 1px 1px red', marginLeft: 8}} />
</TestCase.ExpectedResult>
<Fixture>
<form className="control-box">
<fieldset>
<legend>Empty value prop string</legend>
<input value="" required={true} />
</fieldset>
<fieldset>
<legend>No value prop</legend>
<input required={true} />
</fieldset>
<fieldset>
<legend>Empty defaultValue prop string</legend>
<input required={true} defaultValue="" />
</fieldset>
<fieldset>
<legend>No value prop date input</legend>
<input type="date" required={true} />
</fieldset>
<fieldset>
<legend>Empty value prop date input</legend>
<input type="date" value="" required={true} />
</fieldset>
</form>
</Fixture>
<p className="footnote">
Checking the date type is also important because of a prior fix for
iOS Safari that involved assigning over value/defaultValue
properties of the input to prevent a display bug. This also triggers
input validation.
</p>
<p className="footnote">
The date inputs should be blank in iOS. This is not a bug.
</p>
</TestCase>
<TestCase title="Cursor when editing email inputs">
<TestCase.Steps>
<li>Type "user@example.com"</li>
@@ -70,6 +126,21 @@ class TextInputFixtures extends React.Component {
<InputTestCase type="url" defaultValue="" />
</TestCase>
<TestCase
title="Replacing email input with text disabled input"
relatedIssues="12062">
<TestCase.Steps>
<li>Type "test@test.com"</li>
<li>Press enter</li>
</TestCase.Steps>
<TestCase.ExpectedResult>
There should be no selection-related error in the console.
</TestCase.ExpectedResult>
<ReplaceEmailInput />
</TestCase>
<TestCase title="All inputs" description="General test of all inputs">
<InputTestCase type="text" defaultValue="Text" />
<InputTestCase type="email" defaultValue="user@example.com" />

View File

@@ -1,3 +1,4 @@
import 'core-js/es6/symbol';
import 'core-js/es6/promise';
import 'core-js/es6/set';
import 'core-js/es6/map';

View File

@@ -1,3 +1,5 @@
import semver from 'semver';
/**
* Take a version from the window query string and load a specific
* version of React.
@@ -34,36 +36,51 @@ function loadScript(src) {
});
}
export default function loadReact() {
let REACT_PATH = 'react.development.js';
let DOM_PATH = 'react-dom.development.js';
export function reactPaths() {
let reactPath = 'react.development.js';
let reactDOMPath = 'react-dom.development.js';
let reactDOMServerPath = 'react-dom-server.browser.development.js';
let query = parseQuery(window.location.search);
let version = query.version || 'local';
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 (parseInt(version, 10) >= 16 && version.indexOf('alpha') < 0) {
REACT_PATH =
if (major >= 16 && !(minor === 0 && preReleaseStage === 'alpha')) {
reactPath =
'https://unpkg.com/react@' + version + '/umd/react.development.js';
DOM_PATH =
reactDOMPath =
'https://unpkg.com/react-dom@' +
version +
'/umd/react-dom.development.js';
reactDOMServerPath =
'https://unpkg.com/react-dom@' +
version +
'/umd/react-dom-server.browser.development';
} else {
REACT_PATH = 'https://unpkg.com/react@' + version + '/dist/react.js';
DOM_PATH =
reactPath = 'https://unpkg.com/react@' + version + '/dist/react.js';
reactDOMPath =
'https://unpkg.com/react-dom@' + version + '/dist/react-dom.js';
reactDOMServerPath =
'https://unpkg.com/react-dom@' + version + '/dist/react-dom-server.js';
}
}
const needsReactDOM = version === 'local' || parseFloat(version, 10) > 0.13;
let request = loadScript(REACT_PATH);
return {reactPath, reactDOMPath, reactDOMServerPath, needsReactDOM};
}
export default function loadReact() {
const {reactPath, reactDOMPath, needsReactDOM} = reactPaths();
let request = loadScript(reactPath);
if (needsReactDOM) {
request = request.then(() => loadScript(DOM_PATH));
request = request.then(() => loadScript(reactDOMPath));
} else {
// Aliasing React to ReactDOM for compatibility.
request = request.then(() => {

View File

@@ -4,14 +4,13 @@
box-sizing: border-box;
}
html {
font-size: 10px;
}
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
color: #333;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Arimo", "Roboto", "Oxygen",
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
sans-serif;
font-size: 1.4rem;
font-size: 15px;
line-height: 24px;
margin: 0;
padding: 0;
}
@@ -26,23 +25,82 @@ button {
padding: 6px 8px;
}
h1,
h2,
h3,
h4,
h5,
h6 {
color: #171717;
font-weight: 600;
}
h1 {
font-size: 32px;
margin: 24px 0;
}
h2 {
font-size: 24px;
margin: 24px 0 16px;
}
h3 {
font-size: 18px;
margin: 8px 0 16px;
}
h4, h4, h5, h6 {
font-size: 16px;
margin: 0 0 16px;
}
code {
font-size: 90%;
}
a {
text-decoration: none;
}
a:link:hover,
a:link:focus {
text-decoration: underline;
}
textarea {
border-radius: 2px;
border: 1px solid #d9d9d9;
font-size: 12px;
min-height: 100px;
min-width: 300px;
padding: 8px;
}
.header {
background: #222;
box-shadow: inset 0 -1px 3px #000;
font-size: 1.6rem;
line-height: 3.2rem;
background: #171717;
overflow: hidden;
padding: .8rem 1.6rem;
padding: 8px;
}
.header a {
text-decoration: none;
color: white;
}
.header a:hover,
.header a:focus{
text-decoration: underline;
}
.header select {
width: 12rem;
margin-left: 8px;
max-width: 150px;
}
.header__inner {
display: table;
margin: 0 auto;
max-width: 1000px;
overflow: hidden;
text-align: center;
width: 100%;
@@ -108,11 +166,11 @@ fieldset {
ul,
ol {
margin: 0 0 2rem 0;
margin: 0 0 16px 0;
}
li {
margin-bottom: 0.4rem;
p {
margin: 16px 0;
}
.type-subheading {
@@ -130,11 +188,10 @@ li {
.footnote {
border-left: 4px solid #aaa;
color: #444;
font-size: 14px;
font-style: italic;
line-height: 1.5;
margin-bottom: 2.4rem;
margin-left: 0.4rem;
padding-left: 1.6rem;
margin-left: 8px;
padding-left: 16px;
}
.test-case {
@@ -158,7 +215,7 @@ li {
}
.test-case__body {
padding: 0 15px;
padding: 10px;
}
.test-case__desc {
@@ -222,3 +279,24 @@ li {
.field-group {
overflow: hidden;
}
table {
border: 1px solid #d9d9d9;
border-width: 1px 1px 1px 0;
border-collapse: collapse;
margin: 16px 0;
font-size: 14px;
line-height: 20px;
width: 100%;
}
td,
th {
text-align: left;
border: 1px solid #d9d9d9;
padding: 6px;
}
tbody tr:nth-child(even) {
background: #f0f0f0;
}

View File

@@ -52,7 +52,9 @@ export default function getVersionTags() {
cachedTags = JSON.parse(cachedTags);
resolve(cachedTags);
} else {
fetch('https://api.github.com/repos/facebook/react/tags', {mode: 'cors'})
fetch('https://api.github.com/repos/facebook/react/tags?per_page=1000', {
mode: 'cors',
})
.then(res => res.json())
.then(tags => {
// A message property indicates an error was sent from the API

View File

@@ -2,6 +2,10 @@
# yarn lockfile v1
"@babel/standalone@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/@babel/standalone/-/standalone-7.0.0.tgz#856446641620c1c5f0ca775621d478324ebd1f52"
abab@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/abab/-/abab-1.0.3.tgz#b81de5f7274ec4e756d797cd834f303642724e5d"
@@ -1556,6 +1560,10 @@ code-point-at@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77"
codemirror@^5.40.0:
version "5.40.0"
resolved "https://registry.yarnpkg.com/codemirror/-/codemirror-5.40.0.tgz#2f5ed47366e514f41349ba0fe34daaa39be4e257"
color-convert@^1.3.0:
version "1.8.2"
resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.8.2.tgz#be868184d7c8631766d54e7078e2672d7c7e3339"
@@ -5878,6 +5886,10 @@ semver@^5.0.3:
version "5.4.1"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.4.1.tgz#e059c09d8571f0540823733433505d3a2f00b18e"
semver@^5.5.0:
version "5.5.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.0.tgz#dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab"
send@0.14.1:
version "0.14.1"
resolved "https://registry.yarnpkg.com/send/-/send-0.14.1.tgz#a954984325392f51532a7760760e459598c89f7a"

24
fixtures/expiration/.gitignore vendored Normal file
View File

@@ -0,0 +1,24 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.
# dependencies
/node_modules
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*
public/react.development.js
public/react-dom.development.js

View File

@@ -0,0 +1,18 @@
{
"name": "expiration-2",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.1.1",
"react-dom": "^16.1.1",
"react-scripts": "1.0.17"
},
"scripts": {
"prestart":
"cp ../../build/dist/react.development.js public/ && cp ../../build/dist/react-dom.development.js public/",
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}

View File

@@ -0,0 +1,51 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<!--
manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<script src="/react.development.js"></script>
<script src="/react-dom.development.js"></script>
<title>Expiration Example</title>
</head>
<body>
<h1>Expiration Example</h1>
<p>This fixture demonstrates expiration using the
<code>timeout</code> option of
<code>requestIdleCallback</code>. If it's working correctly, you should see below a number that increments approximately once every second (the expiration
time of a low priority update.) If there is no counter, or if it increases too slowly or quickly, something is broken.
</p>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>

View File

@@ -0,0 +1,34 @@
const React = global.React;
const ReactDOM = global.ReactDOM;
class Counter extends React.unstable_AsyncComponent {
state = {counter: 0};
onCommit() {
setImmediate(() => {
this.setState(state => ({
counter: state.counter + 1,
}));
});
}
componentDidMount() {
this.onCommit();
}
componentDidUpdate() {
this.onCommit();
}
render() {
return <h1>{this.state.counter}</h1>;
}
}
const interval = 200;
function block() {
const endTime = performance.now() + interval;
while (performance.now() < endTime) {}
}
setInterval(block, interval);
// Should render a counter that increments approximately every second (the
// expiration time of a low priority update).
ReactDOM.render(<Counter />, document.getElementById('root'));
block();

File diff suppressed because it is too large Load Diff

View File

@@ -2,11 +2,10 @@
"private": true,
"name": "browserify-dev-fixture",
"dependencies": {
"browserify": "^13.3.0",
"react": "file:../../../../build/packages/react",
"react-dom": "file:../../../../build/packages/react-dom"
"browserify": "^13.3.0"
},
"scripts": {
"build": "rm -f output.js && browserify ./input.js -o output.js"
"build": "rm -f output.js && browserify ./input.js -o output.js",
"prebuild": "cp -r ../../../../build/node_modules/* ./node_modules/"
}
}

View File

@@ -25,10 +25,6 @@ array-reduce@~0.0.0:
version "0.0.0"
resolved "https://registry.yarnpkg.com/array-reduce/-/array-reduce-0.0.0.tgz#173899d3ffd1c7d9383e4479525dbe278cab5f2b"
asap@~2.0.3:
version "2.0.6"
resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46"
asn1.js@^4.0.0:
version "4.9.1"
resolved "https://registry.yarnpkg.com/asn1.js/-/asn1.js-4.9.1.tgz#48ba240b45a9280e94748990ba597d216617fd40"
@@ -254,10 +250,6 @@ convert-source-map@~1.1.0:
version "1.1.3"
resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.1.3.tgz#4829c877e9fe49b3161f3bf3673888e204699860"
core-js@^1.0.0:
version "1.2.7"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-1.2.7.tgz#652294c14651db28fa93bd2d5ff2983a4f08c636"
core-util-is@~1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
@@ -365,12 +357,6 @@ elliptic@^6.0.0:
minimalistic-assert "^1.0.0"
minimalistic-crypto-utils "^1.0.0"
encoding@^0.1.11:
version "0.1.12"
resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.12.tgz#538b66f3ee62cd1ab51ec323829d1f9480c74beb"
dependencies:
iconv-lite "~0.4.13"
events@~1.1.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/events/-/events-1.1.1.tgz#9ebdb7635ad099c70dcc4c2a1f5004288e8bd924"
@@ -382,18 +368,6 @@ evp_bytestokey@^1.0.0, evp_bytestokey@^1.0.3:
md5.js "^1.3.4"
safe-buffer "^5.1.1"
fbjs@^0.8.16:
version "0.8.16"
resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.16.tgz#5e67432f550dc41b572bf55847b8aca64e5337db"
dependencies:
core-js "^1.0.0"
isomorphic-fetch "^2.1.1"
loose-envify "^1.0.0"
object-assign "^4.1.0"
promise "^7.1.1"
setimmediate "^1.0.5"
ua-parser-js "^0.7.9"
fs.realpath@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
@@ -455,10 +429,6 @@ https-browserify@~0.0.0:
version "0.0.1"
resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-0.0.1.tgz#3f91365cabe60b77ed0ebba24b454e3e09d95a82"
iconv-lite@~0.4.13:
version "0.4.19"
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b"
ieee754@^1.1.4:
version "1.1.8"
resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.8.tgz#be33d40ac10ef1926701f6f08a2d86fbfd1ad3e4"
@@ -505,10 +475,6 @@ is-buffer@^1.1.0:
version "1.1.5"
resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.5.tgz#1f3b26ef613b214b88cbca23cc6c01d87961eecc"
is-stream@^1.0.1:
version "1.1.0"
resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44"
isarray@^1.0.0, isarray@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11"
@@ -517,17 +483,6 @@ isarray@~0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf"
isomorphic-fetch@^2.1.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz#611ae1acf14f5e81f729507472819fe9733558a9"
dependencies:
node-fetch "^1.0.1"
whatwg-fetch ">=0.10.0"
js-tokens@^3.0.0:
version "3.0.2"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"
json-stable-stringify@~0.0.0:
version "0.0.1"
resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-0.0.1.tgz#611c23e814db375527df851193db59dd2af27f45"
@@ -560,12 +515,6 @@ lodash.memoize@~3.0.3:
version "3.0.4"
resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-3.0.4.tgz#2dcbd2c287cbc0a55cc42328bd0c736150d53e3f"
loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.3.1:
version "1.3.1"
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.1.tgz#d1a8ad33fa9ce0e713d65fdd0ac8b748d478c848"
dependencies:
js-tokens "^3.0.0"
md5.js@^1.3.4:
version "1.3.4"
resolved "https://registry.yarnpkg.com/md5.js/-/md5.js-1.3.4.tgz#e9bdbde94a20a5ac18b04340fc5764d5b09d901d"
@@ -618,17 +567,6 @@ module-deps@^4.0.8:
through2 "^2.0.0"
xtend "^4.0.0"
node-fetch@^1.0.1:
version "1.7.3"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.3.tgz#980f6f72d85211a5347c6b2bc18c5b84c3eb47ef"
dependencies:
encoding "^0.1.11"
is-stream "^1.0.1"
object-assign@^4.1.0, object-assign@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
once@^1.3.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
@@ -693,20 +631,6 @@ process@~0.11.0:
version "0.11.10"
resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182"
promise@^7.1.1:
version "7.3.1"
resolved "https://registry.yarnpkg.com/promise/-/promise-7.3.1.tgz#064b72602b18f90f29192b8b1bc418ffd1ebd3bf"
dependencies:
asap "~2.0.3"
prop-types@^15.6.0:
version "15.6.0"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.0.tgz#ceaf083022fc46b4a35f69e13ef75aed0d639856"
dependencies:
fbjs "^0.8.16"
loose-envify "^1.3.1"
object-assign "^4.1.1"
public-encrypt@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/public-encrypt/-/public-encrypt-4.0.0.tgz#39f699f3a46560dd5ebacbca693caf7c65c18cc6"
@@ -739,22 +663,6 @@ randombytes@^2.0.0, randombytes@^2.0.1:
dependencies:
safe-buffer "^5.1.0"
"react-dom@file:../../../../build/packages/react-dom":
version "16.0.0"
dependencies:
fbjs "^0.8.16"
loose-envify "^1.1.0"
object-assign "^4.1.1"
prop-types "^15.6.0"
"react@file:../../../../build/packages/react":
version "16.0.0"
dependencies:
fbjs "^0.8.16"
loose-envify "^1.1.0"
object-assign "^4.1.1"
prop-types "^15.6.0"
read-only-stream@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/read-only-stream/-/read-only-stream-2.0.0.tgz#2724fd6a8113d73764ac288d4386270c1dbf17f0"
@@ -805,10 +713,6 @@ safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@~5.1.0,
version "5.1.1"
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853"
setimmediate@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285"
sha.js@^2.4.0, sha.js@^2.4.8, sha.js@~2.4.4:
version "2.4.9"
resolved "https://registry.yarnpkg.com/sha.js/-/sha.js-2.4.9.tgz#98f64880474b74f4a38b8da9d3c0f2d104633e7d"
@@ -918,10 +822,6 @@ typedarray@~0.0.5:
version "0.0.6"
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
ua-parser-js@^0.7.9:
version "0.7.17"
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.17.tgz#e9ec5f9498b9ec910e7ae3ac626a805c4d09ecac"
umd@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/umd/-/umd-3.0.1.tgz#8ae556e11011f63c2596708a8837259f01b3d60e"
@@ -949,10 +849,6 @@ vm-browserify@~0.0.1:
dependencies:
indexof "0.0.1"
whatwg-fetch@>=0.10.0:
version "2.0.3"
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.3.tgz#9c84ec2dcf68187ff00bc64e1274b442176e1c84"
wrappy@1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"

View File

@@ -2,12 +2,11 @@
"private": true,
"name": "browserify-prod-fixture",
"dependencies": {
"browserify": "^13.3.0",
"react": "file:../../../../build/packages/react",
"react-dom": "file:../../../../build/packages/react-dom"
"browserify": "^13.3.0"
},
"scripts": {
"build": "rm -f output.js && browserify ./input.js -g [envify --NODE_ENV 'production'] -o output.js"
"build": "rm -f output.js && browserify ./input.js -g [envify --NODE_ENV 'production'] -o output.js",
"prebuild": "cp -r ../../../../build/node_modules/* ./node_modules/"
},
"devDependencies": {
"envify": "^4.0.0"

View File

@@ -25,10 +25,6 @@ array-reduce@~0.0.0:
version "0.0.0"
resolved "https://registry.yarnpkg.com/array-reduce/-/array-reduce-0.0.0.tgz#173899d3ffd1c7d9383e4479525dbe278cab5f2b"
asap@~2.0.3:
version "2.0.6"
resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46"
asn1.js@^4.0.0:
version "4.9.1"
resolved "https://registry.yarnpkg.com/asn1.js/-/asn1.js-4.9.1.tgz#48ba240b45a9280e94748990ba597d216617fd40"
@@ -254,10 +250,6 @@ convert-source-map@~1.1.0:
version "1.1.3"
resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.1.3.tgz#4829c877e9fe49b3161f3bf3673888e204699860"
core-js@^1.0.0:
version "1.2.7"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-1.2.7.tgz#652294c14651db28fa93bd2d5ff2983a4f08c636"
core-util-is@~1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
@@ -365,12 +357,6 @@ elliptic@^6.0.0:
minimalistic-assert "^1.0.0"
minimalistic-crypto-utils "^1.0.0"
encoding@^0.1.11:
version "0.1.12"
resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.12.tgz#538b66f3ee62cd1ab51ec323829d1f9480c74beb"
dependencies:
iconv-lite "~0.4.13"
envify@^4.0.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/envify/-/envify-4.1.0.tgz#f39ad3db9d6801b4e6b478b61028d3f0b6819f7e"
@@ -393,18 +379,6 @@ evp_bytestokey@^1.0.0, evp_bytestokey@^1.0.3:
md5.js "^1.3.4"
safe-buffer "^5.1.1"
fbjs@^0.8.16:
version "0.8.16"
resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.16.tgz#5e67432f550dc41b572bf55847b8aca64e5337db"
dependencies:
core-js "^1.0.0"
isomorphic-fetch "^2.1.1"
loose-envify "^1.0.0"
object-assign "^4.1.0"
promise "^7.1.1"
setimmediate "^1.0.5"
ua-parser-js "^0.7.9"
fs.realpath@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
@@ -466,10 +440,6 @@ https-browserify@~0.0.0:
version "0.0.1"
resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-0.0.1.tgz#3f91365cabe60b77ed0ebba24b454e3e09d95a82"
iconv-lite@~0.4.13:
version "0.4.19"
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b"
ieee754@^1.1.4:
version "1.1.8"
resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.8.tgz#be33d40ac10ef1926701f6f08a2d86fbfd1ad3e4"
@@ -516,10 +486,6 @@ is-buffer@^1.1.0:
version "1.1.5"
resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.5.tgz#1f3b26ef613b214b88cbca23cc6c01d87961eecc"
is-stream@^1.0.1:
version "1.1.0"
resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44"
isarray@^1.0.0, isarray@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11"
@@ -528,17 +494,6 @@ isarray@~0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf"
isomorphic-fetch@^2.1.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz#611ae1acf14f5e81f729507472819fe9733558a9"
dependencies:
node-fetch "^1.0.1"
whatwg-fetch ">=0.10.0"
js-tokens@^3.0.0:
version "3.0.2"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"
json-stable-stringify@~0.0.0:
version "0.0.1"
resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-0.0.1.tgz#611c23e814db375527df851193db59dd2af27f45"
@@ -571,12 +526,6 @@ lodash.memoize@~3.0.3:
version "3.0.4"
resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-3.0.4.tgz#2dcbd2c287cbc0a55cc42328bd0c736150d53e3f"
loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.3.1:
version "1.3.1"
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.1.tgz#d1a8ad33fa9ce0e713d65fdd0ac8b748d478c848"
dependencies:
js-tokens "^3.0.0"
md5.js@^1.3.4:
version "1.3.4"
resolved "https://registry.yarnpkg.com/md5.js/-/md5.js-1.3.4.tgz#e9bdbde94a20a5ac18b04340fc5764d5b09d901d"
@@ -629,17 +578,6 @@ module-deps@^4.0.8:
through2 "^2.0.0"
xtend "^4.0.0"
node-fetch@^1.0.1:
version "1.7.3"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.3.tgz#980f6f72d85211a5347c6b2bc18c5b84c3eb47ef"
dependencies:
encoding "^0.1.11"
is-stream "^1.0.1"
object-assign@^4.1.0, object-assign@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
once@^1.3.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
@@ -704,20 +642,6 @@ process@~0.11.0:
version "0.11.10"
resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182"
promise@^7.1.1:
version "7.3.1"
resolved "https://registry.yarnpkg.com/promise/-/promise-7.3.1.tgz#064b72602b18f90f29192b8b1bc418ffd1ebd3bf"
dependencies:
asap "~2.0.3"
prop-types@^15.6.0:
version "15.6.0"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.0.tgz#ceaf083022fc46b4a35f69e13ef75aed0d639856"
dependencies:
fbjs "^0.8.16"
loose-envify "^1.3.1"
object-assign "^4.1.1"
public-encrypt@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/public-encrypt/-/public-encrypt-4.0.0.tgz#39f699f3a46560dd5ebacbca693caf7c65c18cc6"
@@ -750,22 +674,6 @@ randombytes@^2.0.0, randombytes@^2.0.1:
dependencies:
safe-buffer "^5.1.0"
"react-dom@file:../../../../build/packages/react-dom":
version "16.0.0"
dependencies:
fbjs "^0.8.16"
loose-envify "^1.1.0"
object-assign "^4.1.1"
prop-types "^15.6.0"
"react@file:../../../../build/packages/react":
version "16.0.0"
dependencies:
fbjs "^0.8.16"
loose-envify "^1.1.0"
object-assign "^4.1.1"
prop-types "^15.6.0"
read-only-stream@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/read-only-stream/-/read-only-stream-2.0.0.tgz#2724fd6a8113d73764ac288d4386270c1dbf17f0"
@@ -816,10 +724,6 @@ safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@~5.1.0,
version "5.1.1"
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853"
setimmediate@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285"
sha.js@^2.4.0, sha.js@^2.4.8, sha.js@~2.4.4:
version "2.4.9"
resolved "https://registry.yarnpkg.com/sha.js/-/sha.js-2.4.9.tgz#98f64880474b74f4a38b8da9d3c0f2d104633e7d"
@@ -929,10 +833,6 @@ typedarray@~0.0.5:
version "0.0.6"
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
ua-parser-js@^0.7.9:
version "0.7.17"
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.17.tgz#e9ec5f9498b9ec910e7ae3ac626a805c4d09ecac"
umd@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/umd/-/umd-3.0.1.tgz#8ae556e11011f63c2596708a8837259f01b3d60e"
@@ -960,10 +860,6 @@ vm-browserify@~0.0.1:
dependencies:
indexof "0.0.1"
whatwg-fetch@>=0.10.0:
version "2.0.3"
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.3.tgz#9c84ec2dcf68187ff00bc64e1274b442176e1c84"
wrappy@1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"

View File

@@ -3,11 +3,10 @@
"name": "brunch-dev-fixture",
"devDependencies": {
"brunch": "^2.9.1",
"javascript-brunch": "^2.0.0",
"react": "file:../../../../build/packages/react",
"react-dom": "file:../../../../build/packages/react-dom"
"javascript-brunch": "^2.0.0"
},
"scripts": {
"build": "rm -rf public && brunch build"
"build": "rm -rf public && brunch build",
"prebuild": "cp -r ../../../../build/node_modules/* ./node_modules/"
}
}
}

View File

@@ -78,10 +78,6 @@ array-unique@^0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.2.1.tgz#a1d97ccafcbc2625cc70fadceb36a50c58b01a53"
asap@~2.0.3:
version "2.0.6"
resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46"
asn1.js@^4.0.0:
version "4.9.1"
resolved "https://registry.yarnpkg.com/asn1.js/-/asn1.js-4.9.1.tgz#48ba240b45a9280e94748990ba597d216617fd40"
@@ -413,10 +409,6 @@ cookie@0.3.1:
version "0.3.1"
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.3.1.tgz#e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb"
core-js@^1.0.0:
version "1.2.7"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-1.2.7.tgz#652294c14651db28fa93bd2d5ff2983a4f08c636"
core-util-is@1.0.2, core-util-is@~1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
@@ -604,12 +596,6 @@ encodeurl@~1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.1.tgz#79e3d58655346909fe6f0f45a5de68103b294d20"
encoding@^0.1.11:
version "0.1.12"
resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.12.tgz#538b66f3ee62cd1ab51ec323829d1f9480c74beb"
dependencies:
iconv-lite "~0.4.13"
es-abstract@^1.6.1:
version "1.9.0"
resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.9.0.tgz#690829a07cae36b222e7fd9b75c0d0573eb25227"
@@ -726,18 +712,6 @@ fast-levenshtein@^1.1.3:
version "1.1.4"
resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-1.1.4.tgz#e6a754cc8f15e58987aa9cbd27af66fd6f4e5af9"
fbjs@^0.8.16:
version "0.8.16"
resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.16.tgz#5e67432f550dc41b572bf55847b8aca64e5337db"
dependencies:
core-js "^1.0.0"
isomorphic-fetch "^2.1.1"
loose-envify "^1.0.0"
object-assign "^4.1.0"
promise "^7.1.1"
setimmediate "^1.0.5"
ua-parser-js "^0.7.9"
fcache@~0.3:
version "0.3.0"
resolved "https://registry.yarnpkg.com/fcache/-/fcache-0.3.0.tgz#d45f2f908642b91b798e88195ec47881a51c3d44"
@@ -1027,7 +1001,7 @@ https-browserify@~0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-0.0.1.tgz#3f91365cabe60b77ed0ebba24b454e3e09d95a82"
iconv-lite@0.4.19, iconv-lite@~0.4.13:
iconv-lite@0.4.19:
version "0.4.19"
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b"
@@ -1152,10 +1126,6 @@ is-regex@^1.0.4:
dependencies:
has "^1.0.1"
is-stream@^1.0.1:
version "1.1.0"
resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44"
is-symbol@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.1.tgz#3cc59f00025194b6ab2e38dbae6689256b660572"
@@ -1182,13 +1152,6 @@ isobject@^2.0.0:
dependencies:
isarray "1.0.0"
isomorphic-fetch@^2.1.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz#611ae1acf14f5e81f729507472819fe9733558a9"
dependencies:
node-fetch "^1.0.1"
whatwg-fetch ">=0.10.0"
isstream@~0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a"
@@ -1199,10 +1162,6 @@ javascript-brunch@^2.0.0:
dependencies:
esprima "~3.0.0"
js-tokens@^3.0.0:
version "3.0.2"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"
jsbn@~0.1.0:
version "0.1.1"
resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513"
@@ -1264,12 +1223,6 @@ loggy@~0.3.0:
ansicolors "~0.3.2"
growl "~1.8.1"
loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.3.1:
version "1.3.1"
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.1.tgz#d1a8ad33fa9ce0e713d65fdd0ac8b748d478c848"
dependencies:
js-tokens "^3.0.0"
md5.js@^1.3.4:
version "1.3.4"
resolved "https://registry.yarnpkg.com/md5.js/-/md5.js-1.3.4.tgz#e9bdbde94a20a5ac18b04340fc5764d5b09d901d"
@@ -1423,13 +1376,6 @@ node-browser-modules@^0.1.0:
util "~0.10.3"
vm-browserify "~0.0.4"
node-fetch@^1.0.1:
version "1.7.3"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.3.tgz#980f6f72d85211a5347c6b2bc18c5b84c3eb47ef"
dependencies:
encoding "^0.1.11"
is-stream "^1.0.1"
node-pre-gyp@^0.6.36:
version "0.6.38"
resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.6.38.tgz#e92a20f83416415bb4086f6d1fb78b3da73d113d"
@@ -1479,7 +1425,7 @@ oauth-sign@~0.8.1:
version "0.8.2"
resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.8.2.tgz#46a6ab7f0aead8deae9ec0565780b7d4efeb9d43"
object-assign@^4.1.0, object-assign@^4.1.1:
object-assign@^4.1.0:
version "4.1.1"
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
@@ -1605,20 +1551,6 @@ promise.prototype.finally@^2:
es-abstract "^1.6.1"
function-bind "^1.1.0"
promise@^7.1.1:
version "7.3.1"
resolved "https://registry.yarnpkg.com/promise/-/promise-7.3.1.tgz#064b72602b18f90f29192b8b1bc418ffd1ebd3bf"
dependencies:
asap "~2.0.3"
prop-types@^15.6.0:
version "15.6.0"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.0.tgz#ceaf083022fc46b4a35f69e13ef75aed0d639856"
dependencies:
fbjs "^0.8.16"
loose-envify "^1.3.1"
object-assign "^4.1.1"
proxy-addr@~2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.2.tgz#6571504f47bb988ec8180253f85dd7e14952bdec"
@@ -1704,22 +1636,6 @@ rc@^1.1.7:
minimist "^1.2.0"
strip-json-comments "~2.0.1"
"react-dom@file:../../../../build/packages/react-dom":
version "16.0.0"
dependencies:
fbjs "^0.8.16"
loose-envify "^1.1.0"
object-assign "^4.1.1"
prop-types "^15.6.0"
"react@file:../../../../build/packages/react":
version "16.0.0"
dependencies:
fbjs "^0.8.16"
loose-envify "^1.1.0"
object-assign "^4.1.1"
prop-types "^15.6.0"
read-components@~0.7:
version "0.7.0"
resolved "https://registry.yarnpkg.com/read-components/-/read-components-0.7.0.tgz#77dce7adcb72a514240c47a675b9bcf7a3509dd9"
@@ -1878,10 +1794,6 @@ set-immediate-shim@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz#4b2b1b27eb808a9f8dcc481a58e5e56f599f3f61"
setimmediate@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285"
setprototypeof@1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.0.3.tgz#66567e37043eeb4f04d91bd658c0cbefb55b8e04"
@@ -2061,10 +1973,6 @@ type-is@~1.6.15:
media-typer "0.3.0"
mime-types "~2.1.15"
ua-parser-js@^0.7.9:
version "0.7.17"
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.17.tgz#e9ec5f9498b9ec910e7ae3ac626a805c4d09ecac"
uid-number@^0.0.6:
version "0.0.6"
resolved "https://registry.yarnpkg.com/uid-number/-/uid-number-0.0.6.tgz#0ea10e8035e8eb5b8e4449f06da1c730663baa81"
@@ -2126,10 +2034,6 @@ vm-browserify@~0.0.4:
dependencies:
indexof "0.0.1"
whatwg-fetch@>=0.10.0:
version "2.0.3"
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.3.tgz#9c84ec2dcf68187ff00bc64e1274b442176e1c84"
which@^1.2.12:
version "1.3.0"
resolved "https://registry.yarnpkg.com/which/-/which-1.3.0.tgz#ff04bdfc010ee547d780bec38e1ac1c2777d253a"

View File

@@ -3,11 +3,10 @@
"name": "brunch-prod-fixture",
"devDependencies": {
"brunch": "^2.9.1",
"javascript-brunch": "^2.0.0",
"react": "file:../../../../build/packages/react",
"react-dom": "file:../../../../build/packages/react-dom"
"javascript-brunch": "^2.0.0"
},
"scripts": {
"build": "rm -rf public && brunch build -p"
"build": "rm -rf public && brunch build -p",
"prebuild": "cp -r ../../../../build/node_modules/* ./node_modules/"
}
}
}

View File

@@ -78,10 +78,6 @@ array-unique@^0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.2.1.tgz#a1d97ccafcbc2625cc70fadceb36a50c58b01a53"
asap@~2.0.3:
version "2.0.6"
resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46"
asn1.js@^4.0.0:
version "4.9.1"
resolved "https://registry.yarnpkg.com/asn1.js/-/asn1.js-4.9.1.tgz#48ba240b45a9280e94748990ba597d216617fd40"
@@ -413,10 +409,6 @@ cookie@0.3.1:
version "0.3.1"
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.3.1.tgz#e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb"
core-js@^1.0.0:
version "1.2.7"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-1.2.7.tgz#652294c14651db28fa93bd2d5ff2983a4f08c636"
core-util-is@1.0.2, core-util-is@~1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
@@ -604,12 +596,6 @@ encodeurl@~1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.1.tgz#79e3d58655346909fe6f0f45a5de68103b294d20"
encoding@^0.1.11:
version "0.1.12"
resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.12.tgz#538b66f3ee62cd1ab51ec323829d1f9480c74beb"
dependencies:
iconv-lite "~0.4.13"
es-abstract@^1.6.1:
version "1.9.0"
resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.9.0.tgz#690829a07cae36b222e7fd9b75c0d0573eb25227"
@@ -726,18 +712,6 @@ fast-levenshtein@^1.1.3:
version "1.1.4"
resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-1.1.4.tgz#e6a754cc8f15e58987aa9cbd27af66fd6f4e5af9"
fbjs@^0.8.16:
version "0.8.16"
resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.16.tgz#5e67432f550dc41b572bf55847b8aca64e5337db"
dependencies:
core-js "^1.0.0"
isomorphic-fetch "^2.1.1"
loose-envify "^1.0.0"
object-assign "^4.1.0"
promise "^7.1.1"
setimmediate "^1.0.5"
ua-parser-js "^0.7.9"
fcache@~0.3:
version "0.3.0"
resolved "https://registry.yarnpkg.com/fcache/-/fcache-0.3.0.tgz#d45f2f908642b91b798e88195ec47881a51c3d44"
@@ -1027,7 +1001,7 @@ https-browserify@~0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-0.0.1.tgz#3f91365cabe60b77ed0ebba24b454e3e09d95a82"
iconv-lite@0.4.19, iconv-lite@~0.4.13:
iconv-lite@0.4.19:
version "0.4.19"
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b"
@@ -1152,10 +1126,6 @@ is-regex@^1.0.4:
dependencies:
has "^1.0.1"
is-stream@^1.0.1:
version "1.1.0"
resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44"
is-symbol@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.1.tgz#3cc59f00025194b6ab2e38dbae6689256b660572"
@@ -1182,13 +1152,6 @@ isobject@^2.0.0:
dependencies:
isarray "1.0.0"
isomorphic-fetch@^2.1.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz#611ae1acf14f5e81f729507472819fe9733558a9"
dependencies:
node-fetch "^1.0.1"
whatwg-fetch ">=0.10.0"
isstream@~0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a"
@@ -1199,10 +1162,6 @@ javascript-brunch@^2.0.0:
dependencies:
esprima "~3.0.0"
js-tokens@^3.0.0:
version "3.0.2"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"
jsbn@~0.1.0:
version "0.1.1"
resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513"
@@ -1264,12 +1223,6 @@ loggy@~0.3.0:
ansicolors "~0.3.2"
growl "~1.8.1"
loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.3.1:
version "1.3.1"
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.1.tgz#d1a8ad33fa9ce0e713d65fdd0ac8b748d478c848"
dependencies:
js-tokens "^3.0.0"
md5.js@^1.3.4:
version "1.3.4"
resolved "https://registry.yarnpkg.com/md5.js/-/md5.js-1.3.4.tgz#e9bdbde94a20a5ac18b04340fc5764d5b09d901d"
@@ -1423,13 +1376,6 @@ node-browser-modules@^0.1.0:
util "~0.10.3"
vm-browserify "~0.0.4"
node-fetch@^1.0.1:
version "1.7.3"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.3.tgz#980f6f72d85211a5347c6b2bc18c5b84c3eb47ef"
dependencies:
encoding "^0.1.11"
is-stream "^1.0.1"
node-pre-gyp@^0.6.36:
version "0.6.38"
resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.6.38.tgz#e92a20f83416415bb4086f6d1fb78b3da73d113d"
@@ -1479,7 +1425,7 @@ oauth-sign@~0.8.1:
version "0.8.2"
resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.8.2.tgz#46a6ab7f0aead8deae9ec0565780b7d4efeb9d43"
object-assign@^4.1.0, object-assign@^4.1.1:
object-assign@^4.1.0:
version "4.1.1"
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
@@ -1605,20 +1551,6 @@ promise.prototype.finally@^2:
es-abstract "^1.6.1"
function-bind "^1.1.0"
promise@^7.1.1:
version "7.3.1"
resolved "https://registry.yarnpkg.com/promise/-/promise-7.3.1.tgz#064b72602b18f90f29192b8b1bc418ffd1ebd3bf"
dependencies:
asap "~2.0.3"
prop-types@^15.6.0:
version "15.6.0"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.0.tgz#ceaf083022fc46b4a35f69e13ef75aed0d639856"
dependencies:
fbjs "^0.8.16"
loose-envify "^1.3.1"
object-assign "^4.1.1"
proxy-addr@~2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.2.tgz#6571504f47bb988ec8180253f85dd7e14952bdec"
@@ -1704,22 +1636,6 @@ rc@^1.1.7:
minimist "^1.2.0"
strip-json-comments "~2.0.1"
"react-dom@file:../../../../build/packages/react-dom":
version "16.0.0"
dependencies:
fbjs "^0.8.16"
loose-envify "^1.1.0"
object-assign "^4.1.1"
prop-types "^15.6.0"
"react@file:../../../../build/packages/react":
version "16.0.0"
dependencies:
fbjs "^0.8.16"
loose-envify "^1.1.0"
object-assign "^4.1.1"
prop-types "^15.6.0"
read-components@~0.7:
version "0.7.0"
resolved "https://registry.yarnpkg.com/read-components/-/read-components-0.7.0.tgz#77dce7adcb72a514240c47a675b9bcf7a3509dd9"
@@ -1878,10 +1794,6 @@ set-immediate-shim@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz#4b2b1b27eb808a9f8dcc481a58e5e56f599f3f61"
setimmediate@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285"
setprototypeof@1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.0.3.tgz#66567e37043eeb4f04d91bd658c0cbefb55b8e04"
@@ -2061,10 +1973,6 @@ type-is@~1.6.15:
media-typer "0.3.0"
mime-types "~2.1.15"
ua-parser-js@^0.7.9:
version "0.7.17"
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.17.tgz#e9ec5f9498b9ec910e7ae3ac626a805c4d09ecac"
uid-number@^0.0.6:
version "0.0.6"
resolved "https://registry.yarnpkg.com/uid-number/-/uid-number-0.0.6.tgz#0ea10e8035e8eb5b8e4449f06da1c730663baa81"
@@ -2126,10 +2034,6 @@ vm-browserify@~0.0.4:
dependencies:
indexof "0.0.1"
whatwg-fetch@>=0.10.0:
version "2.0.3"
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.3.tgz#9c84ec2dcf68187ff00bc64e1274b442176e1c84"
which@^1.2.12:
version "1.3.0"
resolved "https://registry.yarnpkg.com/which/-/which-1.3.0.tgz#ff04bdfc010ee547d780bec38e1ac1c2777d253a"

View File

@@ -42,51 +42,51 @@
</div>
<div class="frame">
<h2>browserify (dev)</h2>
<iframe src="/fixtures/packaging/browserify/dev/index.html"></iframe>
<iframe src="/fixtures/packaging/browserify/dev/"></iframe>
</div>
<div class="frame">
<h2>browserify (prod)</h2>
<iframe src="/fixtures/packaging/browserify/prod/index.html"></iframe>
<iframe src="/fixtures/packaging/browserify/prod/"></iframe>
</div>
<div class="frame">
<h2>brunch (dev)</h2>
<iframe src="/fixtures/packaging/brunch/dev/index.html"></iframe>
<iframe src="/fixtures/packaging/brunch/dev/"></iframe>
</div>
<div class="frame">
<h2>brunch (prod)</h2>
<iframe src="/fixtures/packaging/brunch/prod/index.html"></iframe>
<iframe src="/fixtures/packaging/brunch/prod/"></iframe>
</div>
<div class="frame">
<h2>rjs (dev)</h2>
<iframe src="/fixtures/packaging/rjs/dev/index.html"></iframe>
<iframe src="/fixtures/packaging/rjs/dev/"></iframe>
</div>
<div class="frame">
<h2>rjs (prod)</h2>
<iframe src="/fixtures/packaging/rjs/prod/index.html"></iframe>
<iframe src="/fixtures/packaging/rjs/prod/"></iframe>
</div>
<div class="frame">
<h2>systemjs-builder (dev)</h2>
<iframe src="/fixtures/packaging/systemjs-builder/dev/index.html"></iframe>
<iframe src="/fixtures/packaging/systemjs-builder/dev/"></iframe>
</div>
<div class="frame">
<h2>systemjs-builder (prod)</h2>
<iframe src="/fixtures/packaging/systemjs-builder/prod/index.html"></iframe>
<iframe src="/fixtures/packaging/systemjs-builder/prod/"></iframe>
</div>
<div class="frame">
<h2>webpack (dev)</h2>
<iframe src="/fixtures/packaging/webpack/dev/index.html"></iframe>
<iframe src="/fixtures/packaging/webpack/dev/"></iframe>
</div>
<div class="frame">
<h2>webpack (prod)</h2>
<iframe src="/fixtures/packaging/webpack/prod/index.html"></iframe>
<iframe src="/fixtures/packaging/webpack/prod/"></iframe>
</div>
<div class="frame">
<h2>webpack-alias (dev)</h2>
<iframe src="/fixtures/packaging/webpack-alias/dev/index.html"></iframe>
<iframe src="/fixtures/packaging/webpack-alias/dev/"></iframe>
</div>
<div class="frame">
<h2>webpack-alias (prod)</h2>
<iframe src="/fixtures/packaging/webpack-alias/prod/index.html"></iframe>
<iframe src="/fixtures/packaging/webpack-alias/prod/"></iframe>
</div>
</body>
</html>

View File

@@ -6,5 +6,6 @@ module.exports = {
paths: {
react: '../../../../build/dist/react.development',
'react-dom': '../../../../build/dist/react-dom.development',
schedule: '../../../../build/dist/schedule.development',
},
};

View File

@@ -6,5 +6,6 @@ module.exports = {
paths: {
react: '../../../../build/dist/react.production.min',
'react-dom': '../../../../build/dist/react-dom.production.min',
schedule: '../../../../build/dist/schedule.development',
},
};

View File

@@ -2,5 +2,6 @@ System.config({
paths: {
react: '../../../../build/dist/react.development.js',
'react-dom': '../../../../build/dist/react-dom.development.js',
schedule: '../../../../build/dist/schedule.development',
},
});

View File

@@ -2,5 +2,6 @@ System.config({
paths: {
react: '../../../../build/dist/react.production.min.js',
'react-dom': '../../../../build/dist/react-dom.production.min.js',
schedule: '../../../../build/dist/schedule.development',
},
});

View File

@@ -6,7 +6,7 @@ module.exports = {
filename: 'output.js',
},
resolve: {
root: path.resolve('../../../../build/packages'),
root: path.resolve('../../../../build/node_modules'),
alias: {
react: 'react/umd/react.development',
'react-dom': 'react-dom/umd/react-dom.development',

View File

@@ -6,7 +6,7 @@ module.exports = {
filename: 'output.js',
},
resolve: {
root: path.resolve('../../../../build/packages'),
root: path.resolve('../../../../build/node_modules'),
alias: {
react: 'react/umd/react.production.min',
'react-dom': 'react-dom/umd/react-dom.production.min',

View File

@@ -6,6 +6,6 @@ module.exports = {
filename: 'output.js',
},
resolve: {
root: path.resolve('../../../../build/packages/'),
root: path.resolve('../../../../build/node_modules/'),
},
};

View File

@@ -7,7 +7,7 @@ module.exports = {
filename: 'output.js',
},
resolve: {
root: path.resolve('../../../../build/packages/'),
root: path.resolve('../../../../build/node_modules/'),
},
plugins: [
new webpack.DefinePlugin({

View File

@@ -1,14 +0,0 @@
# React Reconciler Test Fixture
This folder exists for **React contributors** only.
If you use React you don't need to worry about it.
These fixtures are a smoke-screen verification that the built React Reconciler distribution works.
To test, from the project root:
* `yarn build`
* `cd fixtures/reconciler`
* `yarn`
* `yarn test`
They should run as part of the CI check.

View File

@@ -1,371 +0,0 @@
/**
* This is a renderer of React that doesn't have a render target output.
* It is used to test that the react-reconciler package doesn't blow up.
*
* @flow
*/
'use strict';
var React = require('react');
var assert = require('assert');
var ReactFiberReconciler = require('react-reconciler');
var emptyObject = require('fbjs/lib/emptyObject');
var assert = require('assert');
const UPDATE_SIGNAL = {};
var scheduledCallback = null;
type Container = {rootID: string, children: Array<Instance | TextInstance>};
type Props = {prop: any, hidden?: boolean};
type Instance = {|
type: string,
id: number,
children: Array<Instance | TextInstance>,
prop: any,
|};
type TextInstance = {|text: string, id: number|};
var instanceCounter = 0;
function appendChild(
parentInstance: Instance | Container,
child: Instance | TextInstance
): void {
const index = parentInstance.children.indexOf(child);
if (index !== -1) {
parentInstance.children.splice(index, 1);
}
parentInstance.children.push(child);
}
function insertBefore(
parentInstance: Instance | Container,
child: Instance | TextInstance,
beforeChild: Instance | TextInstance
): void {
const index = parentInstance.children.indexOf(child);
if (index !== -1) {
parentInstance.children.splice(index, 1);
}
const beforeIndex = parentInstance.children.indexOf(beforeChild);
if (beforeIndex === -1) {
throw new Error('This child does not exist.');
}
parentInstance.children.splice(beforeIndex, 0, child);
}
function removeChild(
parentInstance: Instance | Container,
child: Instance | TextInstance
): void {
const index = parentInstance.children.indexOf(child);
if (index === -1) {
throw new Error('This child does not exist.');
}
parentInstance.children.splice(index, 1);
}
var NoopRenderer = ReactFiberReconciler({
getRootHostContext() {
return emptyObject;
},
getChildHostContext() {
return emptyObject;
},
getPublicInstance(instance) {
return instance;
},
createInstance(type: string, props: Props): Instance {
const inst = {
id: instanceCounter++,
type: type,
children: [],
prop: props.prop,
};
// Hide from unit tests
Object.defineProperty(inst, 'id', {value: inst.id, enumerable: false});
return inst;
},
appendInitialChild(
parentInstance: Instance,
child: Instance | TextInstance
): void {
parentInstance.children.push(child);
},
finalizeInitialChildren(
domElement: Instance,
type: string,
props: Props
): boolean {
return false;
},
prepareUpdate(
instance: Instance,
type: string,
oldProps: Props,
newProps: Props
): null | {} {
return UPDATE_SIGNAL;
},
shouldSetTextContent(type: string, props: Props): boolean {
return (
typeof props.children === 'string' || typeof props.children === 'number'
);
},
shouldDeprioritizeSubtree(type: string, props: Props): boolean {
return !!props.hidden;
},
now: Date.now,
createTextInstance(
text: string,
rootContainerInstance: Container,
hostContext: Object,
internalInstanceHandle: Object
): TextInstance {
var inst = {text: text, id: instanceCounter++};
// Hide from unit tests
Object.defineProperty(inst, 'id', {value: inst.id, enumerable: false});
return inst;
},
scheduleDeferredCallback(callback) {
if (scheduledCallback) {
throw new Error(
'Scheduling a callback twice is excessive. Instead, keep track of ' +
'whether the callback has already been scheduled.'
);
}
scheduledCallback = callback;
},
prepareForCommit(): void {},
resetAfterCommit(): void {},
mutation: {
commitMount(instance: Instance, type: string, newProps: Props): void {
// Noop
},
commitUpdate(
instance: Instance,
updatePayload: Object,
type: string,
oldProps: Props,
newProps: Props
): void {
instance.prop = newProps.prop;
},
commitTextUpdate(
textInstance: TextInstance,
oldText: string,
newText: string
): void {
textInstance.text = newText;
},
appendChild: appendChild,
appendChildToContainer: appendChild,
insertBefore: insertBefore,
insertInContainerBefore: insertBefore,
removeChild: removeChild,
removeChildFromContainer: removeChild,
resetTextContent(instance: Instance): void {},
},
});
var rootContainers = new Map();
var roots = new Map();
var DEFAULT_ROOT_ID = '<default>';
let yieldedValues = null;
function* flushUnitsOfWork(n: number): Generator<Array<mixed>, void, void> {
var didStop = false;
while (!didStop && scheduledCallback !== null) {
var cb = scheduledCallback;
scheduledCallback = null;
yieldedValues = null;
var unitsRemaining = n;
cb({
timeRemaining() {
if (yieldedValues !== null) {
return 0;
}
if (unitsRemaining-- > 0) {
return 999;
}
didStop = true;
return 0;
},
});
if (yieldedValues !== null) {
const values = yieldedValues;
yieldedValues = null;
yield values;
}
}
}
var Noop = {
getChildren(rootID: string = DEFAULT_ROOT_ID) {
const container = rootContainers.get(rootID);
if (container) {
return container.children;
} else {
return null;
}
},
// Shortcut for testing a single root
render(element: React$Element<any>, callback: ?Function) {
Noop.renderToRootWithID(element, DEFAULT_ROOT_ID, callback);
},
renderToRootWithID(
element: React$Element<any>,
rootID: string,
callback: ?Function
) {
let root = roots.get(rootID);
if (!root) {
const container = {rootID: rootID, children: []};
rootContainers.set(rootID, container);
root = NoopRenderer.createContainer(container);
roots.set(rootID, root);
}
NoopRenderer.updateContainer(element, root, null, callback);
},
flush(): Array<mixed> {
return Noop.flushUnitsOfWork(Infinity);
},
flushUnitsOfWork(n: number): Array<mixed> {
let values = [];
for (const value of flushUnitsOfWork(n)) {
values.push(...value);
}
return values;
},
batchedUpdates: NoopRenderer.batchedUpdates,
deferredUpdates: NoopRenderer.deferredUpdates,
unbatchedUpdates: NoopRenderer.unbatchedUpdates,
flushSync: NoopRenderer.flushSync,
};
type TestProps = {|
active: boolean,
|};
type TestState = {|
counter: number,
|};
let instance = null;
class Test extends React.Component<TestProps, TestState> {
state = {counter: 0};
increment() {
this.setState(({counter}) => ({
counter: counter + 1,
}));
}
render() {
return [this.props.active ? 'Active' : 'Inactive', this.state.counter];
}
}
const Children = props => props.children;
Noop.render(
<main>
<div>Hello</div>
<Children>
Hello world
<span>
{'Number '}
{42}
</span>
<Test active={true} ref={t => (instance = t)} />
</Children>
</main>
);
Noop.flush();
const actual1 = Noop.getChildren();
const expected1 = [
{
type: 'main',
children: [
{type: 'div', children: [], prop: undefined},
{text: 'Hello world'},
{
type: 'span',
children: [{text: 'Number '}, {text: '42'}],
prop: undefined,
},
{text: 'Active'},
{text: '0'},
],
prop: undefined,
},
];
assert.deepEqual(
actual1,
expected1,
'Error. Noop.getChildren() returned unexpected value.\nExpected: ' +
JSON.stringify(expected1, null, 2) +
'\n\nActual:\n ' +
JSON.stringify(actual1, null, 2)
);
if (instance === null) {
throw new Error('Expected instance to exist.');
}
instance.increment();
Noop.flush();
const actual2 = Noop.getChildren();
const expected2 = [
{
type: 'main',
children: [
{type: 'div', children: [], prop: undefined},
{text: 'Hello world'},
{
type: 'span',
children: [{text: 'Number '}, {text: '42'}],
prop: undefined,
},
{text: 'Active'},
{text: '1'},
],
prop: undefined,
},
];
assert.deepEqual(
actual2,
expected2,
'Error. Noop.getChildren() returned unexpected value.\nExpected: ' +
JSON.stringify(expected2, null, 2) +
'\n\nActual:\n ' +
JSON.stringify(actual2, null, 2)
);
const beginGreen = '\u001b[32m';
const endGreen = '\u001b[39m';
console.log(beginGreen + 'Reconciler package is OK!' + endGreen);

View File

@@ -1,14 +0,0 @@
{
"name": "react-fixtures",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "file:../../build/packages/react",
"react-reconciler": "file:../../build/packages/react-reconciler"
},
"scripts": {
"test:dev": "../../node_modules/.bin/babel-node ./index",
"test:prod": "NODE_ENV=production ../../node_modules/.bin/babel-node ./index",
"test": "npm run test:dev && npm run test:prod"
}
}

Some files were not shown because too many files have changed in this diff Show More