Compare commits

..

4044 Commits

Author SHA1 Message Date
Andrew Clark
0c756fb33f Update error codes 2018-11-12 17:59:06 -08:00
Sebastian Markbage
6c22b6cad9 fix typo 2018-11-12 17:51:02 -08:00
Sebastian Markbåge
b545546ccb Use unique thread ID for each partial render to access Context (#14182)
* BUG: ReactPartialRenderer / New Context polutes mutable global state

The new context API stores the provided values on the shared context instance. When used in a synchronous context, this is not an issue. However when used in an concurrent context this can cause a "push provider" from one react render to have an effect on an unrelated concurrent react render.

I've encountered this bug in production when using renderToNodeStream, which asks ReactPartialRenderer for bytes up to a high water mark before yielding. If two Node Streams are created and read from in parallel, the state of one can polute the other.

I wrote a failing test to illustrate the conditions under which this happens.

I'm also concerned that the experimental concurrent/async React rendering on the client could suffer from the same issue.

* Use unique thread ID for each partial render to access Context

This first adds an allocator that keeps track of a unique ThreadID index
for each currently executing partial renderer. IDs are not just growing
but are reused as streams are destroyed.

This ensures that IDs are kept nice and compact.

This lets us use an "array" for each Context object to store the current
values. The look up for these are fast because they're just looking up
an offset in a tightly packed "array".

I don't use an actual Array object to store the values. Instead, I rely
on that VMs (notably V8) treat storage of numeric index property access
as a separate "elements" allocation.

This lets us avoid an extra indirection.

However, we must ensure that these arrays are not holey to preserve this
feature.

To do that I store the _threadCount on each context (effectively it takes
the place of the .length property on an array).

This lets us first validate that the context has enough slots before we
access the slot. If not, we fill in the slots with the default value.
2018-11-12 17:50:46 -08:00
Brian Vaughn
d5e1bf07d0 Renamed outdated schedule/tracing referecnes (#14177) 2018-11-09 12:37:03 -08:00
Andrew Clark
2dd4ba11e0 ESlint -> ESLint 2018-11-09 10:22:18 -08:00
Sophie Alpert
9cc631a539 Don't run danger on bad build (#14143)
sizebot comments can be confusing when not based on reality.

If results.json doesn't exist, danger will fail. This is what we want.
2018-11-09 10:21:39 -08:00
Heaven
1034e26fe5 Fix typos (#14124) 2018-11-09 10:17:49 -08:00
Bartosz Gordon
5618da49d8 Fix comment typo (#14156) 2018-11-09 10:17:19 -08:00
Andrew Clark
9fb9199455 Add global to ESLint plugin bundle config 2018-11-08 18:49:03 -08:00
Andrew Clark
c174f85924 Add fb build of ESLint plugin (#14165) 2018-11-08 18:44:08 -08:00
Alex Taylor
02e4848e3a Improved suspense support in ReactDOMServer (#14161) 2018-11-08 18:15:06 -08:00
Andrew Clark
4b163fee1c Remove errant return assignment (#14164)
Oopsie!

This could have been avoided if our types were modeled correctly with
Flow (using a disjoint union).

Fuzz tester didn't catch it because it does not generate cases where
a Suspense component mounts with no children. I'll update it.
2018-11-08 18:13:42 -08:00
Andrew Clark
e58ecda9a2 Suspense fuzz tester (#14147)
* Don't warn if an unmounted component is pinged

* Suspense fuzz tester

The fuzzer works by generating a random tree of React elements. The tree
two types of custom components:

- A Text component suspends rendering on initial mount for a fuzzy
  duration of time. It may update a fuzzy number of times; each update
  supsends for a fuzzy duration of time.
- A Container component wraps some children. It may remount its children
  a fuzzy number of times, by updating its key.

The tree may also include nested Suspense components.

After this tree is generated, the tester sets a flag to temporarily
disable Text components from suspending. The tree is rendered
synchronously. The output of this render is the expected output.

Then the tester flips the flag back to enable suspending. It renders the
tree again. This time the Text components will suspend for the amount of
time configured by the props. The tester waits until everything has
resolved. The resolved output is then compared to the expected output
generated in the previous step.

Finally, we render once more, but this time in concurrent mode. Once
again, the resolved output is compared to the expected output.

I tested by commenting out various parts of the Suspense implementation
to see if broke in the expected way. I also confirmed that it would have
caught #14133, a recent bug related to deletions.

* When a generated test case fails, log its input

* Moar fuzziness

Adds more fuzziness to the generated tests. Specifcally, introduces
nested Suspense cases, where the fallback of a Suspense component
also suspends.

This flushed out a bug (yay!) whose test case I've hard coded.

* Use seeded random number generator

So if there's a failure, we can bisect.
2018-11-08 17:26:43 -08:00
Andrew Clark
7fd1661f80 Don't warn if an unmounted component is pinged (#14158)
* Add failing test for ping on unmounted component

We had a test for this, but not outside of concurrent mode :)

* Don't warn if an unmounted component is pinged
2018-11-08 17:24:32 -08:00
Andrew Clark
f9e9913f0e [Synchronous Suspense] Don't delete children of suspended component (#14157)
Vestigial behavior that should have been removed in #13823.

Found using the Suspense fuzz tester in #14147.
2018-11-08 11:38:38 -08:00
Nathan Schloss
7c560131bf Adding logger pri (#14155) 2018-11-08 11:30:38 -08:00
Minh Nguyen
3d8bda70e5 Refactor ESLint configuration to enable better IDE integration (#13914)
* Refactor ESLint configuration to enable better IDE integration

* Minor tweaks
2018-11-08 17:56:35 +00:00
Sebastian Markbåge
051272f201 Use Entry in yarn build ... Instead of Label (#14148)
* Parse build script type and package names

This ensures that `yarn build core dom` includes DOM.

It also ensures that spaces like `yarn build "core, dom"` doesn't build EVERYTHING.

* Get rid of label in bundles config

Instead we just use the name from entry using fuzzy search.

There is one special case. If you put in `/index` or `/index.js`.

That allows to build things like `react/index` to only build isomorphic
where as `react` would build everything. Or `react-dom/index` to exclude
the server renderers.

* Instead of matching `/index.js` just append it to the search string

That way things like `yarn build react/` works too.
2018-11-07 20:46:41 -08:00
Brian Vaughn
3ff2c7ccd4 Invalid actualDuration+treeBaseDuration for hidden+suspended trees (#14065)
* Fixed `treeBaseDuration` by propagating its value from the suspended tree to the Fragment React temporarily wraps around it when showing the fallback UI.
* Fixed `actualDuration` by recording elapsed profiler time in the event of an error.
* Fixed `actualDuration` in concurrent mode by propagating the time spent rendering the suspending component to its parent.

Also updated ReactSuspensePlaceholder-test.internal to cover these new cases.
2018-11-07 15:46:30 -08:00
Brian Vaughn
5afa1c4eda Tag MemoComponent with PerformedWork effectTag for DevTools Profiler (#14141) 2018-11-07 13:56:12 -08:00
Brian Vaughn
be63473004 Release script supports interleaved stable and alpha releases (#14138) 2018-11-07 12:33:13 -08:00
Andrew Clark
e27720d7f5 [Synchronous Suspense] Reuse deletions from primary tree (#14133)
Fixes a bug where deletion effects in the primary tree were dropped
before entering the second render pass.

Because we no longer reset the effect list after the first render pass,
I've also moved the deletion of the fallback children to the complete
phase, after the tree successfully renders without suspending.

Will need to revisit this heuristic when we implement resuming.
2018-11-07 10:56:57 -08:00
Dominic Gannaway
aa1ffe4e77 Show deprecated context object warnings usage in ReactDOM server (#14033)
* Applies context object warnings to ReactDOM server
2018-11-07 17:19:38 +00:00
Andrew Clark
e3a7b96455 Make react-debug-tools a private package 2018-11-06 18:45:30 -08:00
Andrew Clark
ff29de4029 Updating CHANGELOG.md for 16.6.1 release 2018-11-06 18:32:29 -08:00
Andrew Clark
ba19844236 Update bundle sizes for 16.6.1 release 2018-11-06 18:28:50 -08:00
Andrew Clark
a24d510287 Update error codes for 16.6.1 release 2018-11-06 18:28:50 -08:00
Andrew Clark
b50e63ef53 Updating package versions for release 16.6.1 2018-11-06 18:19:57 -08:00
Andrew Clark
fd4527dbcd Updating yarn.lock file for 16.6.1 release 2018-11-06 18:16:23 -08:00
Andrew Clark
bd5a6d3914 Update changelog with unreleased features 2018-11-06 17:38:19 -08:00
Andrew Clark
8f2c89e963 Make react-debug-tools a private package 2018-11-06 17:37:52 -08:00
locknono
2aecbcd6f1 "functional component" -> "function component" (#14123) 2018-11-06 17:33:26 -08:00
Nadav Kaner
b4608dd24c Remove unused simulated flag parameter (#14127) 2018-11-06 17:33:01 -08:00
Dan Abramov
3c69a18814 Recover from errors with a boundary in completion phase (#14104)
* Recover from errors with a boundary in completion phase

* Use a separate field for completing unit of work

* Use a simpler fix with one boolean

* Reoder conditions

* Clarify which paths are DEV-only

* Move duplicated line out

* Make it clearer this code is DEV-only
2018-11-06 23:38:12 +00:00
Andrew Clark
b020fb1148 Check correct commit phase props in fuzz tester (#14129)
Adds a check to the existing fuzz tester to confirm that the props are
set to the latest values in the commit phase. Only checks
componentDidUpdate; we already have unit tests for the other lifecycles,
so I think this is good enough. This is only a redundancy.
2018-11-06 15:01:18 -08:00
Dan Abramov
b67c1a2ee1 Add DEV-only checks for assumption about instance properties (#14128) 2018-11-06 22:28:50 +00:00
Dan Abramov
f777d196e0 Fix lazy() with defaultProps (#14112)
* Resolve defaultProps for Lazy components

* Make test fail again

* Undo the partial fix

* Make test output more compact

* Add a separate failing test for sync mode

* Clean up tests

* Add another update to both tests

* Resolve props for commit phase lifecycles

* Resolve prevProps for begin phase lifecycles

* Resolve prevProps for pre-commit lifecycles

* Only resolve props if element type differs

* Fix Flow

* Don't set instance.props/state during commit phase

This is an optimization. I'm not sure it's entirely safe. It's probably worth running internal tests and see if we can ever trigger a case where they're different.

This can mess with resuming.

* Keep setting instance.props/state before unmounting

This reverts part of the previous commit. It broke a test that verifies we use current props in componentWillUnmount if the fiber unmounts due to an error.
2018-11-06 19:54:14 +00:00
Sophie Alpert
e4512991c9 Fix unhiding in IE11 (#14126)
Setting to null isn't correct; setting to '' is. I opted to use dangerousStyleValue for consistency with the main path that we set things.

Fixes #14114.

Test Plan:
Verified setting to '' works in Chrome and IE11. (Setting to null works in Chrome but not in IE11.)
2018-11-06 11:24:44 -08:00
Andrew Clark
affb2b50ca Enable hooks in www test renderer, too 2018-11-05 18:50:00 -08:00
Andrew Clark
0a0f503d57 Enable hooks in www build (#14116)
The `enableHooks` feature flag used to only control whether the API
was exposed on the React package. But now it also determines if the
dispatcher and implementation are included in the bundle.

We're using hooks in www, so I've switched the feature flag to `true`
in the www build.

(Alternatively, we could have two feature flags: one for the
implementation and dispatcher, and one for exposing the API on the
React package.)
2018-11-05 17:48:54 -08:00
Dan Abramov
600651e68e Restore the Hooks dispatcher after using SSR (#14105) 2018-11-06 01:15:11 +00:00
Andrew Clark
e9a2ec9156 [suspense] Avoid double commit by re-rendering immediately and reusing primary children (#14083)
* Avoid double commit by re-rendering immediately and reusing children

To support Suspense outside of concurrent mode, any component that
starts rendering must commit synchronously without being interrupted.
This means normal path, where we unwind the stack and try again from the
nearest Suspense boundary, won't work.

We used to have a special case where we commit the suspended tree in an
incomplete state. Then, in a subsequent commit, we re-render using the
fallback.

The first part — committing an incomplete tree — hasn't changed with
this PR. But I've changed the second part — now we render the fallback
children immediately, within the same commit.

* Add a failing test for remounting fallback in sync mode

* Add failing test for stuck Suspense fallback

* Toggle visibility of Suspense children in mutation phase, not layout

If parent reads visibility of children in a lifecycle, they should have
already updated.
2018-11-05 16:32:50 -08:00
Sophie Alpert
9d47143e85 Implement {,un}hideInstance on RN renderer (#14115)
This is required to use lazy.

Test Plan:
* Verified lazy works on a real world use case (shows spinner, shows real content).
* Verified that if I change the primary content's styles to have `display: 'none'` then it never appears (i.e., the code in `unhide` reads the styles successfully)
2018-11-05 15:33:25 -08:00
Sophie Alpert
ebdb47d2c1 DCE hooks code when flag is off (#14111) 2018-11-05 13:04:57 -08:00
Sophie Alpert
8b87ebf5b0 Rename .internal tests that aren't using internals (#14109) 2018-11-05 11:12:28 -08:00
Sophie Alpert
da04058a91 Use Function.prototype.apply in warningWithoutStack (#14107)
console.error.apply() fails in IE9, but I verified this works (and it works everywhere else too). :)
2018-11-05 11:11:33 -08:00
Sebastian Markbåge
fd1256a561 Add Debug Tools Package for Introspection of Hooks (#14085)
* Add debug tools package

* Add basic implementation

* Implement inspection of the current state of hooks using the fiber tree

* Support useContext hooks inspection by backtracking from the Fiber

I'm not sure this is safe because the return fibers may not be current
but close enough and it's fast.

We use this to set up the current values of the providers.

* rm copypasta

* Use lastIndexOf

Just in case. I don't know of any scenario where this can happen.

* Support ForwardRef

* Add test for memo and custom hooks

* Support defaultProps resolution
2018-11-05 10:02:59 -08:00
Tiago Nunes
b305c4e034 fix(react-dom): Fix crash during server render (#14103)
Check for existence of `setTimeout` and `clearTimeout` in the runtime
before using them, to ensure runtimes without them (like .NET ClearScript)
do not crash just by importing `react-dom`.
2018-11-05 17:08:07 +00:00
Keyan Zhang
ce90ffd045 update the benchmark script (#13994) 2018-11-05 15:55:46 +00:00
Marcelo Jorge Vieira
d34d1c3bae react-reconciler: Update README.md (#13953)
Replaced 'var' with 'const'
2018-11-05 15:55:23 +00:00
einarq
6c404d82aa Bugfix: Add back early return in setOffsets which was removed between 16.4.2 and 16.5.0. Fails in Edge in some scenarios. (#14095) 2018-11-05 15:19:50 +00:00
Simen Bekkhus
8eca0eff87 chore(tests): don't rely on jest fake timers scheduling real timers (#14003)
* chore: don't rely on jest fake timers scheduling real timers

* re-add one part not working with Jest 23
2018-11-02 16:54:23 -05:00
Sophie Alpert
293fed8993 Warn for bad useEffect return value (#14069)
Mostly to catch this:

```js
useEffect(async () => {
  // ...
  return cleanup;
});
```

Is this too restrictive? Not sure if you would want to do like

```js
useEffect(() => ref.current.style.color = 'red');
```

which would give a false positive here. We can always relax it to only warn on Promises if people complain.
2018-11-02 14:43:45 -07:00
Mateusz Burzyński
ae196e84b6 Rename inputsAreEqual to areHookInputsEqual & move it to shared (#14036) 2018-11-02 12:50:23 -07:00
Sophie Alpert
c898020e01 Warn for forwardRef(memo(...)) (#14070)
People are probably gonna do this all the time.
2018-11-02 12:32:44 -07:00
Sophie Alpert
c84b9bf828 Tweak error message for missing fallback (#14068) 2018-11-01 22:45:23 -07:00
Chris Bianca
595b4f945b Remove duplicate import declarations (#14062) 2018-11-01 13:31:46 +00:00
Maksim Markelov
d5d10d140e Simplify imports in react reconciler (#13718)
* Simplify imports in ReactChildFiber
* Import type first in ReactCurrentFiber
* Simplify imports in ReactFiberBeginWork
* Simplify imports in ReactFiberScheduler
* Simplify import in ReactFiberTreeReflection
* Simplify import in ReactFiberUnwindWork
* Remove repeated import
* Fix imports from ReactFiberExpirationTime
* Master imports in ReactFiberBeginWork
2018-10-31 21:12:51 -07:00
Jordan Harband
cdbfa6b5dd [react-is] add back proper AsyncMode symbol, for back compat (#13959)
- Partial revert of #13732
 - Fixes #13958.
2018-10-31 19:03:50 +00:00
Brian Vaughn
1ae3f29c20 Fix react-cache UMD build (#14047) 2018-10-31 11:16:03 -07:00
Sophie Alpert
3db8b80e15 Don't lint against Hooks after conditional throw (#14040)
Seems like this should be OK. Fixes #14038.

Now when tracking paths, we completely ignore segments that end in a throw.
2018-10-30 17:13:24 -07:00
Sophie Alpert
169f935f78 Flip expiration times (#13912)
See https://github.com/facebook/react/pull/13912 commit messages for how this was done.
2018-10-30 15:26:20 -07:00
Andrew Clark
bf9fadfcf4 [Hooks] Remove dispatch callbacks (#14037)
Removes the `enableDispatchCallback` feature flag and deletes the
associated code. An earlier version of the Hooks proposal included this
feature but we've since decided to remove it.
2018-10-30 14:14:20 -07:00
Andrew Clark
8c67bbf183 [scheduler] Deadline object -> shouldYield (#14025)
* [scheduler] Deadline object -> shouldYield

Instead of using a requestIdleCallback-style deadline object, expose a
method Scheduler.shouldYield that returns true if there's a higher
priority event in the queue.

* Nits
2018-10-30 13:47:51 -07:00
Andrew Clark
e02086bfcc Warn about variable number of dependencies
We don't check this in prod, since best practice is to always pass
these inline. But we should still warn in dev.
2018-10-29 13:51:43 -07:00
Andrew Clark
b92cdef641 Rename ReactHooks test suite
New tests should use React Test Renderer. We'll put existing tests in
this module and new tests in a new module.
2018-10-29 13:36:41 -07:00
Sophie Alpert
6efbbe0685 Prettier 2018-10-29 12:29:41 -07:00
Andrew Clark
5045763064 Swap order of function member in hook union types 2018-10-29 11:42:41 -07:00
Caleb Meredith
ddbfe2ed50 Add ESLint rule for React Hooks 2018-10-29 11:26:54 -07:00
Andrew Clark
acb4899637 Clear effect tags from a fiber that suspends in non-concurrent mode
Even though we commit the fiber in an incomplete state, we shouldn't
fire any lifecycles or effects.

We already did this for classes, but now with useEffect, the same is
needed for other types of work, too.
2018-10-29 11:26:54 -07:00
Andrew Clark
933b64710a Disable hook update callback (2nd arg to setState/dispatch)
I put the feature behind a feature flag, along with a warning, so
we can phase it out in www.
2018-10-29 11:26:54 -07:00
Sophie Alpert
5fc84efacc Skip updating effect tag when skipping effect
For example, if you have `useEffect(..., [])`, there's no need to set .effectTag to `Update | Passive` on updates.
2018-10-29 11:26:54 -07:00
Alex Taylor
9f34eb79a3 Add readContext to ReactPartialRendererHooks 2018-10-29 11:26:54 -07:00
Dan Abramov
f7cb9d2b22 Warn about useContext(Consumer|Provider) 2018-10-29 11:26:54 -07:00
Dan Abramov
63cc7d2b31 Test useContext in pure, forwardRef, and PureComponent 2018-10-29 11:26:54 -07:00
Sophie Alpert
3a7c6da8d4 Make effects actually work with memo
Bug fix.
2018-10-29 11:26:54 -07:00
Sophie Alpert
75a1c2e72a The Lost Effect, chapter 3
wow, writing code is hard
2018-10-29 11:26:54 -07:00
Sophie Alpert
55a4b1f377 memo supports Hooks 2018-10-29 11:26:53 -07:00
Sophie Alpert
30aa4ad554 The Lost Effect, chapter 2
Previously, flushPassiveEffects (called by scheduling work) would overwrite rootWithPendingPassiveEffects before we had a chance to schedule the work.
2018-10-29 11:26:53 -07:00
Sebastian Markbåge
b772e0e26b "functional component" -> "function component" in hooks error messages 2018-10-29 11:26:53 -07:00
Sophie Alpert
9e9e3970e4 Warn for Hook set-state on unmounted component 2018-10-29 11:26:53 -07:00
Sophie Alpert
6514697f0c Make sure deletions don't stop passive effects
Before the fix, the passive effect in the test is never executed.

We were previously waiting until the next commit phase to run effects. Now, we run them before scheduling work.
2018-10-29 11:26:53 -07:00
Alex Taylor
dd019d34db Add support for hooks to ReactDOMServer
Co-authored-by: Alex Taylor <alexmckenley@gmail.com>
Co-authored-by: Andrew Clark <acdlite@fb.com>
2018-10-29 11:26:53 -07:00
Andrew Clark
11d0781eea Defer useEffect until after paint
Effects scheduled by useEffect should not fire until after the browser
has had a chance to paint. However, they should be fired before any
subsequent mutations.

Also adds useMutationEffect and useLayoutEffect. useMutationEffect fires
during the host update phase. useLayoutEffect fires during the post-
update phase (the same phase as componentDidMount
and componentDidUpdate).
2018-10-29 11:26:53 -07:00
Andrew Clark
105f2de545 Put hooks behind feature flag 2018-10-29 11:26:53 -07:00
Andrew Clark
7bee9fbdd4 Initial hooks implementation
Includes:
- useState
- useContext
- useEffect
- useRef
- useReducer
- useCallback
- useMemo
- useAPI
2018-10-29 11:26:53 -07:00
Rauno Freiberg
37c7fe0a5f Update createRoot warning message based on enableStableConcurrentModeAPIs (#14017) 2018-10-29 11:25:24 -07:00
Jeffrey Zhang
ae4f3f07e5 Remove extraneous CSS selector (#13996) 2018-10-27 10:01:25 -07:00
Joseph
95f98a1873 fix typo (#13955) 2018-10-27 09:59:00 -07:00
Patrick
e217f2f1ac Updated comment for getEventModifierState (#13918) 2018-10-27 09:52:01 -07:00
Brian Vaughn
275e76e83b Enable stable concurrent APIs flag for 16.7 alpha (#13928)
* Add enableStableConcurrentModeAPIs feature flag

* Conditionally name concurrent API based on enableStableConcurrentModeAPIs flag
2018-10-24 13:45:07 -07:00
Dan Abramov
b5539ad628 It's Concurrent 2018-10-23 19:26:00 -07:00
Dan Abramov
0cc50b675a Fix scheduler fixture 2018-10-23 16:35:07 -07:00
Dan Abramov
8b97a9c36f Update bundle sizes for 16.6.0 release 2018-10-23 16:29:35 -07:00
Dan Abramov
c8ade996e9 Update error codes for 16.6.0 release 2018-10-23 16:29:35 -07:00
Dan Abramov
6c29eabf78 Updating package versions for release 16.6.0 2018-10-23 16:23:41 -07:00
Dan Abramov
d520b358d6 Revert all package versions to 16.5.2 state
Our release script is getting really confused so I'm resetting to last working state.
2018-10-23 16:18:28 -07:00
Dan Abramov
8f1ec7649e Bump versions to beta.0 2018-10-23 16:01:57 -07:00
Dan Abramov
5055a83fa4 Revert "Revert "Updating dependencies for react-noop-renderer""
This reverts commit 3e8b4a5b8b.
2018-10-23 15:59:36 -07:00
Brian Vaughn
3e8b4a5b8b Revert "Updating dependencies for react-noop-renderer"
This reverts commit 1a57dc6689.
2018-10-23 15:36:31 -07:00
Brian Vaughn
ff5efb0390 Prettier 2018-10-23 15:06:58 -07:00
Brian Vaughn
f4488bee51 Add skipCI flag to release script (#13933) 2018-10-23 15:05:14 -07:00
Dan Abramov
d42ed60026 Fix Suspense fixture (#13932) 2018-10-23 18:03:22 -04:00
Andrew Clark
d8e03de4aa [react-cache] Remove cache as argument to read (#13865)
* [react-cache] Remove `cache` as argument to `read`

Updated is API is `Resource.read(key)` instead of
`Resource.read(cache, key)`.

The cache is read from context using `readContext`.

This also removes cache invalidation entirely (other than the default
LRU mechanism), as well as the ability to have multiple caches. We'll
add it back once `Context.write` lands and we can implement it the
right way.

Since there's now only a single cache (the global one), we don't
actually need to use context yet, but I've added a dummy context
anyway so the user gets an error if they attempt to read outside the
render phase.

* nits

* Add test for thenables that resolve multiple times
2018-10-23 14:38:51 -07:00
Andrew Clark
fefa1269e2 Revert accidentally committed existence check (#13931) 2018-10-23 14:27:04 -07:00
Brian Vaughn
80a0c05ce3 Removed react-cache from the bundle list for now (#13930)
* Removed react-cache from the bundle list for now

* Re-add react-cache bundle, but mark as private to avoid NPM publishing
2018-10-23 13:55:52 -07:00
Brian Vaughn
915e4eab53 Add "unstable_" prefix to react-cache and jest-react (#13929)
* Add "unstable_" prefix to react-cache createResource and jest-react matchers
* Reverted accidental change to error-codes JSON
* Remove unstable_ prefix from internal React tests for jest-test
2018-10-23 13:55:37 -07:00
Dan Abramov
508b5fba0e Fix Markdown 2018-10-23 12:16:13 -07:00
Dan Abramov
c285ea2700 Tweak changelog credits 2018-10-23 12:15:57 -07:00
Dan Abramov
eac092ecac Add 16.6.0 changelog (#13927)
* Add 16.6.0 changelog

* Update CHANGELOG.md
2018-10-23 15:08:08 -04:00
Andrew Clark
cbbc2b6c4d [Synchronous Suspense] Suspending a class outside concurrent mode (#13926)
* [Synchronous Suspense] Suspending a class outside concurrent mode

When a class component suspends during mount outside concurrent mode,
change the tag so it's not mistaken for a completed component. For
example, we should not call componentWillUnmount if it is deleted.

* PR nits
2018-10-23 11:36:56 -07:00
Sebastian Markbåge
4947fcd762 Fix lint (#13923) 2018-10-22 22:47:39 -07:00
Sebastian Markbåge
d75c69e0cf Remove unstable_ prefix from Suspense (#13922)
We are using it with lazy and the combination Suspense + lazy seems pretty
stable. maxDuration is not but that's only enabled when you're in
ConcurrentMode which is still unstable.
2018-10-22 22:40:05 -07:00
John Lin
c8ef2feda9 Remove redundant word "the" (#13919) 2018-10-22 22:39:23 -07:00
Andrew Clark
55444a6f49 Try rendering again if a timed out tree receives an update (#13921)
Found a bug related to suspending inside an already mounted tree. While
investigating this I noticed we really don't have much coverage of
suspended updates. I think this would greatly benefit from some fuzz
testing; still haven't thought of a good test case, though.
2018-10-22 22:37:15 -07:00
yongningfu
04c4f2fcea [reconciler] ReactFiberNewContext import maxSigned31BitInt twice (#13857)
* [reconciler] ReactFiberNewContext import maxSigned31BitInt twice

* rename maxSigned31BitInt to MAX_SIGNED_31_BIT_INT
2018-10-22 10:24:44 -05:00
Abdul Rauf
409e472fca Add flow types in ReactControlledComponent (#13669) 2018-10-21 14:35:35 -05:00
Abdul Rauf
663835a43a Add flow types in getEventModifierState (#13909) 2018-10-21 13:20:50 -05:00
Abdul Rauf
82710097f6 Add flow types in getNodeForCharacterOffset (#13908) 2018-10-21 13:18:32 -05:00
shawn wang
7ebd90c2c3 [minor bugfix] fix minor bug with handleReset in suspense fixture (#13843)
* fix minor bug with handleReset in suspense fixture

otherwise resetting the cache in debugger throws an error 

reported here
https://www.reddit.com/r/reactjs/comments/9n9nfo/react_166_canary/

* fix singlequote/doublequote

* switch to performance.now()
2018-10-21 13:16:44 -05:00
Abdul Rauf
420001cb4e Fix babel-preset-fbjs configure link in comment (#13666) 2018-10-21 12:23:24 -05:00
Andrew Clark
b753f76a74 Fix failing async tests in Node 10
Dunno why they happened to work in Node 8 but whatever. Tested on both.
2018-10-20 16:06:23 -07:00
ZYSzys
d37f595595 Add use strict to .prettierrc.js (#13787) 2018-10-20 17:42:11 -04:00
Dan Abramov
b5c0852fdd Bump version to 16.6.0-beta.0 (#13906)
* Bump version to 16.6.0-beta.0

* Root too
2018-10-20 13:03:15 -04:00
Dan Abramov
769b1f270e pure -> memo (#13905) 2018-10-20 12:46:23 -04:00
Alex Taylor
8ecd4bd4f0 Add support for React.pure in ReactDOMServer (#13855)
* Add support for React.pure in ReactDOMServer

* Unwrap pure wrappers by creating an additional element as a single child

This is very slow but meh. We're rewriting this whole thing anyway.
2018-10-20 00:42:33 -07:00
Sebastian Markbåge
15b11d23f9 Allow arbitrary types to be wrapped in pure (#13903)
* Allow arbitrary types to be wrapped in pure

This creates an outer fiber that container the pure check and an inner
fiber that represents which ever type of component.

* Add optimized fast path for simple pure function components

Special cased when there are no defaultProps and it's a simple function
component instead of class. This doesn't require an extra fiber.

We could make it so that this also works with custom comparer but that
means we have to go through one extra indirection to get to it.
Maybe it's worth it, donno.
2018-10-20 00:32:16 -07:00
Andrew Clark
e770af7a3a Add back accidentally deleted break to prevent fallthrough 2018-10-19 22:47:37 -07:00
Sebastian Markbåge
95a313ec0b Unfork Lazy Component Branches (#13902)
* Introduce elementType field

This will be used to store the wrapped type of an element. E.g. pure and
lazy.

The existing type field will be used for the unwrapped type within them.

* Store the unwrapped type on the type field of lazy components

* Use the raw tags for lazy components

Instead, we check if the elementType and type are equal to test if
we need to resolve props. This is slightly slower in the normal case
but will yield less code and branching.

* Clean up lazy branches

* Collapse work tag numbering

* Split IndeterminateComponent out from Lazy

This way we don't have to check the type in a hacky way in the
indeterminate path. Also, lets us deal with lazy that resolves to
indeterminate and such.

* Missing clean up in rebase
2018-10-19 22:22:45 -07:00
Andrew Clark
e16cdd5b17 Always bail out timed out children even if they receive an update (#13901)
* Always bail out timed out children even if they receive an update

The fragment that wraps timed-out children should always have an
expiration time of NoWork.

* Don't need to set expirationTime, only childExpirationTime
2018-10-19 20:31:44 -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
Dan Abramov
7d9b4ba35a Update bundle sizes for 16.1.0 release 2017-11-09 14:55:57 +00:00
Dan Abramov
7e8b0c5800 Updating package versions for release 16.1.0 2017-11-09 14:53:27 +00:00
Dan Abramov
17aa4d4682 Update bundle sizes for 16.1.0-rc release 2017-11-08 22:59:38 +00:00
Dan Abramov
2437e2c3da Updating package versions for release 16.1.0-rc 2017-11-08 22:54:10 +00:00
Dan Abramov
c83596df65 Consolidate build process with GCC (#11483)
* Consolidate build process with GCC

* Record sizes

* Refactor header and footer wrapping

It is easier to understand if we just explicitly type them out.
2017-11-08 22:37:11 +00:00
Mitermayer Reis
e88f292041 Fixing typo on test (#11495)
- As ironicaly as it sounds the tests was checking for misspelling
2017-11-08 21:23:46 +00:00
Brian Vaughn
8a0285fb43 Release script follow-up (#11482)
* Add a timeout before querying npm right after publish

* Conditionally log some post publish steps

* Print ready-to-paste 'yarn add' instructions for CRA prerelease testing
2017-11-08 19:59:26 +00:00
Haroen Viaene
a2ec771360 docs(readme): correct link for "your first PR" (#11489)
This info is now on the website and not in CONTRIBUTING.md
2017-11-08 18:48:19 +00:00
Dan Abramov
c932885e79 Fix React.createFactory() crash (#11484)
* Add a failing test for createFactory in production

* Fix createFactory() in production

* Add more prod-only tests

* Fix prettier

* Run prettier 1.8.1
2017-11-08 00:02:07 +00:00
Clement Hoang
94f44aeba7 Update prettier to 1.8.1 (#10785)
* Change prettier dependency in package.json version 1.8.1

* Update yarn.lock

* Apply prettier changes

* Fix ReactDOMServerIntegration-test.js

* Fix test for ReactDOMComponent-test.js
2017-11-07 18:09:33 +00:00
Andrew Clark
05f3ecc3ea Performance tool: Warn when interrupting an in-progress tree (#11480)
* Performance tool: Warn when interrupting an in-progress tree

* Include the name of the component that caused the interruption
2017-11-07 16:52:48 +00:00
Dan Abramov
de48ad1646 Add react-call-return to publish list 2017-11-07 16:16:46 +00:00
Dan Abramov
0bd2c2bb3d Fix error reporting in release script 2017-11-07 15:03:08 +00:00
Dan Abramov
a653f910f8 Update bundle sizes for 16.1.0-beta.1 release 2017-11-07 14:53:31 +00:00
Dan Abramov
0acde04377 Update error codes for 16.1.0-beta.1 release 2017-11-07 14:53:31 +00:00
Dan Abramov
97a7c5f0d4 Updating package versions for release 16.1.0-beta.1 2017-11-07 14:51:36 +00:00
Dan Abramov
b2ff29d38c Add missing "files" field to react-call-return package 2017-11-07 14:07:37 +00:00
Dan Abramov
cbd6d43417 Amend changelog 2017-11-07 14:02:15 +00:00
Tom
48012ef839 Add warning for componentDidReceiveProps() (#11479)
* Add warning for componentDidReceiveProps()

* Adjust message for componentDidReceiveProps() warning
2017-11-07 14:00:31 +00:00
Kiho · Cham
acb268c577 minor typo (#11477)
concurently --> concurrently
2017-11-07 09:39:15 +00:00
Dan Abramov
2c228f15a0 Correctly replace shims using relative requires (#11472) 2017-11-06 16:53:13 +00:00
Dan Abramov
4480f75ff9 Amend changelog 2017-11-06 16:19:35 +00:00
Dan Abramov
96914c98df Split static and dynamic www feature flags (#11471) 2017-11-06 16:17:43 +00:00
Dan Abramov
3b27160f82 Put perf integration behind a feature flag (#11455)
* Enable User Timing API integration with a feature flag

* Expose a way to toggle user timing flag in www

* Update ReactNativeCSFeatureFlags.js

* Update ReactFeatureFlags.js
2017-11-06 16:07:08 +00:00
Dan Abramov
699496164d Record sizes 2017-11-06 15:34:42 +00:00
Dan Abramov
46f7b0d945 Fix dead code elimination for feature flags (#11453)
* Fix dead code elimination for feature flags

Turning flags into named exports fixes dead code elimination.

This required some restructuring of how we verify that flag types match up. I used the Check<> trick combined with import typeof, as suggested by @calebmer.

For www, we can no longer re-export `require('ReactFeatureFlags')` directly, and instead destructure it. This means flags have to be known at init time. This is already the case so it's not a problem. In fact it may be better since it removes extra property access in tight paths.

For things that we *want* to be dynamic on www (currently, only performance flag) we can export a function to toggle it, and then put it on the secret exports. In fact this is better than just letting everyone mutate the flag at arbitrary times since we can provide, e.g., a ref counting interface to it.

* Record sizes
2017-11-06 14:14:48 +00:00
Dan Abramov
b6a7beefe4 Use Rollup legacy mode for www builds (#11469) 2017-11-06 13:57:15 +00:00
Dan Abramov
8e7cb85788 Expose injectIntoDevTools() to renderers (#11463) 2017-11-06 13:09:02 +00:00
Raphael Amorim
bb3c22c66f Use const/let in more places (#11467)
* Convert ReactDOM to const/let
* Convert ReactDOMComponentTree to const/let
* Convert ReactDOMComponentTree to const/let
* Convert getNodeForCharacterOffset to const/let
* Convert getTextContentAccessor to const/let
* Convert inputValueTracking to const/let
* Convert setInnerHTML to const/let
* Convert setTextContent to const/let
* Convert validateDOMNesting to const/let
2017-11-06 11:30:03 +00:00
Joe Lim
1d1f7038ec Handle prettier error (#11466)
* handle prettier error

* error if prettier fail
2017-11-06 11:17:51 +00:00
Joe Lim
40fbed5721 Use prettier api (#11458)
* use prettier-api

* fix string to boolean

* fix eslint

* fix typo

* cleanup

* use object assign
2017-11-05 21:06:08 +00:00
Joe Lim
e2e7fcce7e switch ordering of logical and (#11462) 2017-11-05 14:46:46 +00:00
Dan Abramov
92b7b172cc Use named exports in more places (#11457)
* Convert EventPlugin{Hub,Registry} to named exports

* Convert EventPluginUtils to named exports

* Convert EventPropagators to named exports

* Convert ReactControlledComponent to named exports

* Convert ReactGenericBatching to named exports

* Convert ReactDOMComponentTree to named exports

* Convert ReactNativeComponentTree to named exports

* Convert ReactNativeRTComponentTree to named exports

* Convert FallbackCompositionState to named exports

* Convert ReactEventEmitterMixin to named exports

* Convert ReactBrowserEventEmitter to named exports

* Convert ReactNativeEventEmitter to named exports

* Convert ReactDOMEventListener to named exports

* Convert DOMMarkupOperations to named exports

* Convert DOMProperty to named exports

* Add suppression for existing Flow violation

Flow didn't see it before.

* Update sizes
2017-11-05 11:58:36 +00:00
Joe Lim
7432013872 make linc script cross platform (#11447)
* make linc script cross platform

* fix typo

* attempt to fix long command error

* use eslint node api

* Update linc.js
2017-11-04 18:09:28 +00:00
Jonathan Silvestri
366600d0b2 Rewrite setInnerHTML tests to use Public API. (#11385)
* Rewrite setInnerHTML tests to use Public API.

* Rename variables and drop unnecessary variable assignments.

* Rename testfile to dangerouslySetInnerHTML-test.js

* Properly prettify test file.

* Rewrite SVG tests to verify we recover from missing innerHTML
2017-11-04 18:04:13 +00:00
Mike Wilcox
51c101fc48 Update getEventKey tests to use public API (#11299) (#11317)
* Add flow annotation to getEventKey.

* Remove Simulate and SimulateNative for native events.

* Style nits

* Oops
2017-11-04 17:11:49 +00:00
Dan Abramov
646781b0b4 Tweak the bundle validation script
Exit on error, and minor nits.
2017-11-04 13:00:49 +00:00
Soo Jae Hwang
da86a4553b Validate built bundles exists (#11452) 2017-11-04 12:57:48 +00:00
Dan Abramov
028691b43d Update changelog 2017-11-04 00:26:29 +00:00
Dan Abramov
8de8be07a8 Add a way to suppress DevTools logs and warnings (#11448) 2017-11-04 00:21:12 +00:00
Iacami Gevaerd
bfa269008a Use only public api for ReactDOMEventListener-test.js (#11327)
* Use only public api for ReactDOMEventListener-test.js

* Use less confusing naming

There was no need to extract React elements into separate variables.

* Replace the "disappearance" test

I could not get it to fail on master so it was probably testing something specific to Stack implementation details. It was also already broken because it didn't look at the right argument and never actually called `unmountComponentAtNode`.

Instead I replaced it with original repro case from https://github.com/facebook/react/issues/1105 which is when it was introduced.

* Tweak naming and add comments

* Missed this one
2017-11-03 20:43:56 +00:00
Brian Vaughn
af08b5cbca Release script follow-up work after 16.1.0-beta release (#11437)
* Build script creates git tag

* Build script post instructions print better relative paths

* Pre-release (<1.0) version numbers also include pre-release suffix (eg '-beta.0')

* Post-NPM-publish step properly handles minor rev comparison check

* Release script also updates @next tag when publishing @latest

* Fixed a typo. Improved inline comment.
2017-11-03 13:19:32 -07:00
Alex Cordeiro
43a1e0d084 Use only public API for EnterLeaveEventPlugin Tests (#11316)
* Use only public API for EnterLeaveEventPlugin Tests (#11299)

* Trigger native event to test EnterLeaveEventPlugin (#11299)

* Rewrite EnterLeaveEventPlugin tests to use dispatchEvent

* Update EnterLeaveEventPlugin test to use OnMouseLeave event

* Add coverage for onMouseEnter too
2017-11-03 19:18:23 +00:00
Dan Abramov
221aa954fb Refer people to "good first issue"
This tag is highlighted by GH. We can still tag them with difficulty.
2017-11-03 18:35:36 +00:00
Dan Abramov
61d35ce1f3 Record sizes and fix bundle lint 2017-11-03 18:01:53 +00:00
Dan Abramov
fd47129ce6 Remove support for passing badly typed elements to shallow renderer (#11442) 2017-11-03 16:16:56 +00:00
Toru Kobayashi
e8a382343a Fix to reset the forceUpdate flag after the update (#11440)
* Fix to reset the forceUpdate flag after the update

* Add support for PureComponent and mirror real behavior closer
2017-11-03 14:29:14 +00:00
Michał Matyas
779d23f72e Fix ReactShallowRenderer not rerendering when calling forceUpdate() (#11439)
* Fix ReactShallowRenderer not rerendering when calling forceUpdate()

* Style nit
2017-11-03 11:03:06 +00:00
Dan Abramov
c2b68dae64 Fix typo 2017-11-03 01:17:51 +00:00
Dan Abramov
6ad203630b Add a link to RCR explanation 2017-11-03 00:47:54 +00:00
Dan Abramov
73bb99626f Update changelog 2017-11-03 00:45:22 +00:00
Brian Vaughn
1298e15f84 Update bundle sizes for 16.1.0-beta release 2017-11-02 15:34:31 -07:00
Brian Vaughn
8306553301 Update error codes for 16.1.0-beta release 2017-11-02 15:34:31 -07:00
Brian Vaughn
00e27eaf1e Updating package versions for release 16.1.0-beta 2017-11-02 15:32:36 -07:00
Brian Vaughn
c5c48b51b4 Updating yarn.lock file for 16.1.0-beta release 2017-11-02 15:31:08 -07:00
Brian Vaughn
a181ba8707 Auto-install (or update) release script Yarn deps before running (#11434) 2017-11-02 15:21:28 -07:00
Clement Hoang
1e35f2b282 Put createRoot export under a feature flag (#11426) 2017-11-02 15:21:06 -07:00
Dan Abramov
45c1ff348e Remove unnecessary 'use strict' in the source (#11433)
* Remove use strict from ES modules

* Delete unused file

This was unused since Stack.
2017-11-02 20:32:48 +00:00
Dan Abramov
c0ee8df26c Record sizes 2017-11-02 19:54:58 +00:00
Dan Abramov
21d0c11523 Convert the Source to ES Modules (#11389)
* Update transforms to handle ES modules

* Update Jest to handle ES modules

* Convert react package to ES modules

* Convert react-art package to ES Modules

* Convert react-call-return package to ES Modules

* Convert react-test-renderer package to ES Modules

* Convert react-cs-renderer package to ES Modules

* Convert react-rt-renderer package to ES Modules

* Convert react-noop-renderer package to ES Modules

* Convert react-dom/server to ES modules

* Convert react-dom/{client,events,test-utils} to ES modules

* Convert react-dom/shared to ES modules

* Convert react-native-renderer to ES modules

* Convert react-reconciler to ES modules

* Convert events to ES modules

* Convert shared to ES modules

* Remove CommonJS support from transforms

* Move ReactDOMFB entry point code into react-dom/src

This is clearer because we can use ES imports in it.

* Fix Rollup shim configuration to work with ESM

* Fix incorrect comment

* Exclude external imports without side effects

* Fix ReactDOM FB build

* Remove TODOs I don’t intend to fix yet
2017-11-02 19:50:03 +00:00
Dan Abramov
fbf617a263 Update Rollup (#11427)
* Update Rollup

* Strip "use strict" in individual modules

* Record sizes
2017-11-02 16:56:12 +00:00
Dan Abramov
f302a6a334 Record sizes 2017-11-02 16:26:54 +00:00
Dan Abramov
4008f6d37d Validate built bundles with a few ESLint rules (#11432) 2017-11-02 15:50:25 +00:00
Dan Abramov
b98313f176 Fix lint issues 2017-11-02 14:07:20 +00:00
Dan Abramov
c97c92061b Undo fbjs/lib/EventListener inlining (#11431) 2017-11-02 13:43:28 +00:00
Dan Abramov
983ec90764 Always run React.Fragment tests (#11430) 2017-11-02 13:31:17 +00:00
Dean Brophy
787c2ad2d9 Constructor error message (#11395)
* Constructor test and fix complete

* Linters and prettier run

* Remove unnecessary checks

* Update error message

* Updat unit test

* prettier

* Tweak the check to be more specific

* Move tests to ReactCompositeComponent-test

* add error call count and remove line
2017-11-01 21:01:24 +00:00
Dan Abramov
9d75a62d14 Depend on prop-types/checkPropTypes, not prop-types itself (#11420)
* Remove prop-types/checkPropTypes reimplementation

* Remove renderer dependency on top-level PropTypes

This annotation is unnecessary because we already warn for bad event listener types.

* Record sizes
2017-11-01 10:57:24 +00:00
Clement Hoang
0e15ff5669 Put React.Fragment under a feature flag (#11421)
* Put React.Fragment under a feature flag

* Don't export undefined Fragment
2017-10-31 17:43:55 -07:00
Dan Abramov
dd1b7afc14 Use warning() over console.error() direct call (#11418) 2017-11-01 00:41:02 +00:00
Dan Abramov
9f2b15909a Record sizes 2017-10-31 22:14:22 +00:00
Sebastian Markbåge
2c1ac9fe1d Inline fbjs/lib/EventListener dependency (#11402)
* Drop fbjs/lib/EventListener from tests

Assert on the underlying native event listener instead.

This test file still needs to be rewritten in terms of public APIs.

* Inline fbjs/lib/EventListener dependency

We explicitly don't want to shim this and we don't use the return value.

We can probably even drop the IE path now since we don't support it.
Not sure if that'll be a true breaking change though.

* Wrap event listeners and the callback passed to requestIdleCallback

This is a FBism.

This uses the injection model in ReactErrorUtils. This isn't technically
going to used for errors but close enough.

This really wants to be eager but we can't because of dynamic injection.
2017-10-31 11:23:03 -07:00
Matteo Vesprini-Heidrich
0752a63f59 add Portal support to React.Children calls (#11378) 2017-10-31 14:59:27 +00:00
zombieJ
2b3592331e Pass pendingProps as argument in createWorkInProgress (#11296)
* move to pendingProps to args

* update userFiber in ReactChildFiber

* prettier it

* prettier it

* move expirationTime to the last

* move expirationTime to the last on userFiber

* Move assignment
2017-10-31 13:46:17 +00:00
Nic Bonetto
544d5c7208 Fixed invalid prop types error message to be more specific (#11308)
* Modified tests and corrected error message. #3

* Fixed syntax issues. #3

* Modified test. #3

* Prettified. #3

* Changed warning message to handle true and false boolean values. #3

* Changed test to contain undefined instead of value. #3

* Simplified branch structure. #3

* Refactored branching logic. #3

* Refactored falsy warning message and tests. #3

* Changed condition to attribute name. #3

* Refactored falsy and truthy warning messages with tests updated. #3

* Added missing character. #3

* Fixed warning message. #3

* Cleared extra whitespace. #3

* Refactored warning messages to be clear. #3

* Prettified. #3

* Grammar fix

* Tweak unrelated warning

The message didn't make sense because it appears for *any* attributes, not just numeric ones.

* Tweak the message for more clarity

* Add a special message for false event handlers

* Add missing whitespace

* Revert size changes
2017-10-31 13:02:41 +00:00
Anushree Subramani
3f1f3dc12e Deduplicated many warnings (#11140) (#11216)
*  Deduplicated many warnings (#11140)

*  Deduplicated the following warnings:

1.  Can only update a mounted or mounting component.
    This usually means you called setState, replaceState,
    or forceUpdate on an unmounted component. This is a no-op

2.  %s.componentWillReceiveProps(): Assigning directly to
    this.state is deprecated (except inside a component's
    constructor). Use setState instead.'

3.  An update (setState, replaceState, or forceUpdate) was scheduled
    from inside an update function. Update functions should be pure,
    with zero side-effects. Consider using componentDidUpdate or a
    callback.

4.  setState(...): Cannot call setState() inside getChildContext()

* Code review changes made for #11140

* Minor style fix

* Test deduplication for noop updates in server renderer

* Test deduplication for cWRP warning

* Test deduplication for cWM setState warning

* Test deduplication for unnmounted setState warning

* Fix existing Flow typing

* Test deduplication for invalid updates

* Test deduplication of update-in-updater warning
2017-10-31 12:35:28 +00:00
shawn wang
7f10fae4c1 Warn if class has a render() method but doesn't extend React.Component (#11168)
Warn if class has a render() method but doesn't extend React.Component
2017-10-31 12:02:55 +00:00
Neal Wright
4a43cf6eac Changed the error message displayed when a select element has props.multiple set to true and value set to null (#11141)
* Corrects error message for select with props.multiple set to true and a null value.

* Don't bother deduplicating based on type

* Make the code a bit simpler (and more verbose)
2017-10-31 11:47:59 +00:00
Clement Hoang
4ce5da7aee Add Fragment as a named export to React (#10783)
* Add Fragment as a named export to React

* Remove extra tests for Fragment

* Change React.Fragment export to be a string '#fragment'

* Fix fragment special case to work with 1 child

* Add single child test for fragment export

* Move fragment definition to ReactEntry.js and render components for key warning tests

* Inline createFiberFromElementType into createFiberFromElement

* Update reconciliation to special case fragments

* Use same semantics as implicit childsets for ReactFragment

* Add more fragment state preservation tests

* Export symbol instead of string for fragments

* Fix rebase breakages

* Re-apply prettier at 1.2.2

* Merge branches in updateElement

* Remove unnecessary check

* Re-use createFiberFromFragment for fragment case

* Simplyify branches by adding type field to fragment fiber

* Move branching logic for fragments to broader methods when possible.

* Add more tests for fragments

* Address Dan's feedback

* Move REACT_FRAGMENT_TYPE into __DEV__ block for DCE

* Change hex representation of REACT_FRAGMENT_TYPE to follow convention

* Remove unnecessary branching and isArray checks

* Update test for preserving children state when keys are same

* Fix updateSlot bug and add more tests

* Make fragment tests more robust by using ops pattern

* Update jsx element validator to allow numbers and symbols

* Remove type field from fragment fiber

* Fork reconcileChildFibers instead of recursing

* Use ternary if condition

* Revamp fragment test suite:

- Add more coverage to fragment tests
- Use better names
- Remove useless Fragment component inside tests
- Remove useless tests so that tests are more concise

* Check output of renderer in fragment tests to ensure no silly business despite states being preserved

* Finish implementation of fragment reconciliation with desired behavior

* Add reverse render direction for fragment tests

* Remove unneeded fragment branch in updateElement

* Add more test cases for ReactFragment

* Handle childless fragment in reconciler

* Support fragment flattening in SSR

* Clean up ReactPartialRenderer

* Warn when non-key and children props are passed to fragments

* Add non-null key check back to updateSlot's array's case

* Add test for positional reconciliation in fragments

* Add warning for refs in fragments with stack trace
2017-10-30 17:52:40 -07:00
Márcio Vicente
d61af82390 Removing dot to avoid redirect to facebook.com (#11400)
* Removing dot to avoid redirect to facebook.com

* Changing phrase instead of using

* Tweak test

* Reset unrelated file
2017-10-30 14:16:18 +00:00
Dan Abramov
177cd85253 Reorder badges by colors 2017-10-28 18:57:19 +01:00
Aleem
84a2891b14 Added MIT license badge along with other existing badges. (#11391) 2017-10-28 12:36:23 +01:00
Sebastian Markbåge
696908f496 [CS] Implement Some Stuff (#11390)
* Implement CS first take

This is using a pure JS API. This should probably switch to native hooks
at some later point but I'll start ironing out issues at this level first.

* Use async scheduling by default

The scheduled callback gets called immediately in render with infinite
time for now. Later this will be per root and abortable.

* Fix up the type signature of the ReactNativeCSType export

* Add escape hatch for special cased children

Working around the fact that we can't map arbitrary children slots. Just
the "children" prop.

* Readd providesModule for ReactNativeCSTypes

* Fix lint

* Fix ReactNativeTypes providesModule and CI check

* Special case a parent instance that doesn't have a props object

CSCustom can be anything here. Ugly but whatevs.

* Don't forget to store stateUpdater so that we can trigger updates

* Fix test
2017-10-27 20:05:34 -07:00
Dan Abramov
cc54b6f48a Add a shim for React 16.0.0 future compatibility (#11388) 2017-10-27 17:38:59 +01:00
Lucas Lentz
55b3172f1d Rewrite ReactDOMInput-test depending on internal API (#11299) (#11309)
* Rewrite tests depending on internal API

* Remove focus being called when there was no blur event function before

* Remove triggering function and just let ReactTestUtils take care

* Use native events

* Remove duplicate

* Simulate native event when changing value on reentrant

* Change wasn't being called

* Use Simulate only

* Use React event handlers on test

* Move commentary

* Lint commit

* Use native event

* Comment native event dispatching

* Prettier

* add setUntrackedValue

* Prettier-all

* Use dispatchEvent instead of ReactTestUtils Simulates;

* Prettier

* Fix lint

* Remove useless arg

* Wrap event dispatcher into function

* Remove deprecated Event

* Remove unused change event dispatcher

* Fix merge

* Prettier

* Add missing focus/blur calls

They are necessary to cover for the fix in #8240.
2017-10-26 19:22:10 +01:00
Andrew Clark
f751bd8877 Fuzz test across multiple roots (#11376)
While refactoring root scheduler, I noticed we have few tests that
cover updates across multiple roots. To address, I've added multiple
root cases to the fuzz tester.

Includes a hard-coded test case that was failing before #11307 landed.
2017-10-26 11:03:40 -07:00
Dan Abramov
5f6159fa84 Coverage works again 2017-10-26 18:57:30 +01:00
Thiago Galvani
dee4cc2cb3 Documentation on README (#11368)
* Adding the Documentation to the README

* Updating the Documentation to the README

* Tweaks
2017-10-26 18:06:25 +01:00
Dustan Kasten
80849fd1c6 Flow-ify ReactPartialRenderer (#11251)
* flow ReactPartialRenderer

* prettier

* moving flow type around;

* Move anys to DEV-only code path and keep it typechecked

* Increase Flow coverage
2017-10-26 17:59:29 +01:00
Matteo Vesprini-Heidrich
b0bb1b46aa reference yarn instead of npm in dom fixtures README (#11374)
* reference yarn instead of npm in dom fixtures README

* Update README.md
2017-10-26 17:51:58 +01:00
Matteo Vesprini-Heidrich
bd3a00b326 make yarn lock file current (#11375) 2017-10-26 17:51:33 +01:00
Dustan Kasten
399029444f maybe proactively redirect some doc site issues (#11235)
* maybe proactively redirect some doc site issuesg

* Update ISSUE_TEMPLATE.md
2017-10-26 15:27:16 +01:00
Dan Abramov
8f4ccc2bd3 Fix stray absolute imports 2017-10-26 15:18:34 +01:00
Dan Abramov
707ca7f492 Update Jest and remove hacks (#11372)
* Update Jest

* Remove hacks for Jest + Workspace integration

They were fixed by https://github.com/facebook/jest/pull/4761.

* Use relative requires in tests relying on private APIs

I changed them to absolute to work around a Jest bug.
The bug has been fixed so I can revert my past changes now.
2017-10-26 15:15:24 +01:00
Andrew Clark
3addf205bf Remove Task priority (#11307)
* Remove Task priority

The concept of Task priority was originally added as a way to avoid
reentrancy. Sync priority is for work that flushes synchronously, and
Task is for work that flushes at the end of the event loop.

But it turns out that in most cases, it's simpler to model Task and
Sync as the same priority level. For example, it's never correct to
flush Sync work from the update queue without flushing Task. Doing so
can lead to infinite update loops.

And using a separate priority level is not necessary to avoid
reentrancy. We already track when work is being rendered, and exit
before entering the render cycle again. That alone is sufficient.

This commit removes Task priority from the codebase. Now we use the
same level for both truly synchronous work and work that is deferred
until the end of the event loop.

This also enables us to remove DOM-specific legacy cases from the 
reconciler and lift them to the renderer.

* Remove isUnbatched from FiberRoot

Simpler to render unbatched roots immediately.

* Use a cyclic linked list for root schedule

Avoids the need for a separate `isScheduled` field.
2017-10-25 16:51:45 -07:00
Brian Vaughn
c86ae4b46f Added naive scheduleDeferredCallback implementation for RN (#11362)
* Added naive scheduleDeferredCallback implementation for RN

* Fixed ReactNative shim's expected @provideModule
2017-10-25 14:13:34 -07:00
Dan Abramov
396eb8698b Add disclaimer 2017-10-25 20:47:47 +01:00
Dan Abramov
2c0a8fb99e Add react-call-return package (#11364) 2017-10-25 22:23:55 +03:00
Dan Abramov
8e1f7f76fb Temporarily hide broken coverage reporting 2017-10-25 19:12:13 +01:00
Dan Abramov
087c48bb36 Reorder imports (#11359)
* Reorder imports

* Record sizes
2017-10-25 21:07:54 +03:00
Dan Abramov
f1c6488f1b Forbid adding new files with @providesModule (#11361)
* Forbid adding new files with @providesModule

* Turn off Haste mode in Flow config

* chmod a+x

* Try to fix bash

* Try to fix bash again
2017-10-25 19:50:34 +03:00
Brian Vaughn
72ba8db504 Added unit test that would have caught the recent error code transform regression (#11356)
* Added an automated test that would have caught the recent error code transform bug

* Renamed dev-expression-with-codes test to replace-invariant-error-codes

* Formatting nit
2017-10-25 08:21:55 -07:00
Dan Abramov
3ad5bd803f Expose TapEventPlugin on the www bundle (#11360) 2017-10-25 17:37:49 +03:00
Dan Abramov
96ed55ff80 Remove accidental art peerDep from react-art
Probably a rebase issue.
2017-10-25 14:52:06 +01:00
Dan Abramov
1eed302d34 Drop Haste (#11303)
* Use relative paths in packages/react

* Use relative paths in packages/react-art

* Use relative paths in packages/react-cs

* Use relative paths in other packages

* Fix as many issues as I can

This uncovered an interesting problem where ./b from package/src/a would resolve to a different instantiation of package/src/b in Jest.

Either this is a showstopper or we can solve it by completely fobbidding remaining /src/.

* Fix all tests

It seems we can't use relative requires in tests anymore. Otherwise Jest becomes confused between real file and symlink.
https://github.com/facebook/jest/issues/3830

This seems bad... Except that we already *don't* want people to create tests that import individual source files.
All existing cases of us doing so are actually TODOs waiting to be fixed.

So perhaps this requirement isn't too bad because it makes bad code looks bad.

Of course, if we go with this, we'll have to lint against relative requires in tests.
It also makes moving things more painful.

* Prettier

* Remove @providesModule

* Fix remaining Haste imports I missed earlier

* Fix up paths to reflect new flat structure

* Fix Flow

* Fix CJS and UMD builds

* Fix FB bundles

* Fix RN bundles

* Prettier

* Fix lint

* Fix warning printing and error codes

* Fix buggy return

* Fix lint and Flow

* Use Yarn on CI

* Unbreak Jest

* Fix lint

* Fix aliased originals getting included in DEV

Shouldn't affect correctness (they were ignored) but fixes DEV size regression.

* Record sizes

* Fix weird version in package.json

* Tweak bundle labels

* Get rid of output option by introducing react-dom/server.node

* Reconciler should depend on prop-types

* Update sizes last time
2017-10-25 02:55:00 +03:00
Dan Abramov
37baacb096 Update CI environment (Node 8, Yarn 1.2.1) (#11355) 2017-10-24 22:32:26 +03:00
Dan Abramov
d20af23598 Add item to changelog 2017-10-24 19:53:35 +01:00
Dan Abramov
793a28d698 Use simple invariant in case of missing error codes (#11350) 2017-10-24 09:11:03 -07:00
Dan Abramov
d5f26b041e Rename Haste modules (#11349) 2017-10-24 17:26:07 +03:00
Dan Abramov
f6c60dcbcd Expose react-art/{Circle,Rectange/Wedge} on npm (#11343)
* Include ART shapes into npm package

* Fix the fixture

* Prettier oops
2017-10-23 21:18:11 +03:00
Dan Abramov
0ebcbd4f1e Update changelog 2017-10-23 18:35:02 +01:00
Dan Abramov
c148e5415e Make "art" a dependency of "react-art" (#11341)
* Make "art" a dependency of "react-art"

* Add it back to root devDeps
2017-10-23 19:00:41 +03:00
Dan Abramov
faf3697e03 Add "prop-types" to dependencies of "react-test-renderer" (#11340) 2017-10-23 18:14:33 +03:00
Dan Abramov
4ceb5a4aa0 Record sizes 2017-10-23 15:06:36 +01:00
Vladimir Tsibizow
a30d01ad04 [React Children][Flow] Removed useless typechecking, because this file have`t flow comment (#11323) 2017-10-22 14:14:13 +01:00
Brian Vaughn
2d7c754f3b Delete unused code in ReactDOMFrameScheduling (#11301) 2017-10-21 08:54:45 -07:00
Leo Selig
69fcc81ce4 Fix renderer example links in README of react-reconciler (#11312)
Fixes facebook/react/issues/#11310
2017-10-21 15:13:54 +01:00
Dan Abramov
97776fb6d2 Move DOM-specific event files to the right folder (#11305) 2017-10-20 21:36:53 +01:00
Andrew Clark
2e4663f616 Split performWork into renderRoot and commitRoot (#11264)
* Split performWork into renderRoot and commitRoot

It turns out that the scheduler is too coupled to how the DOM renderer
works. Specifically, the requestIdleCallback model, and how roots are
committed immediately after completing. Other renderers have different
constraints for when to yield and when to commit work.

We're moving towards a model where the scheduler only works on a single
root at a time, and the render phase and commit phase are split into
distinct entry points. This gives the renderer more control over when
roots are committed, coordinating multiple roots, deferring the commit
phase, batching updates, when to yield execution, and so on.

In this initial commit, I've left the renderers alone and only changed
the scheduler. Mostly, this involved extracting logic related to
multiple roots and moving it into its own section at the bottom of the
file. The idea is that this section can be lifted pretty much as-is
into the renderers. I'll do that next.

* Remove FiberRoot scheduleAt

Isn't actually used anywhere

* Make the root schedule a linked list again

Since this still lives inside the renderer, let's just use the
FiberRoot type. The FiberRoot concept will likely be lifted out
eventually, anyway.

* commitRoot should accept a HostRoot

This way it's less reliant on the alternate model

* Unify branches

* Remove dead branch

onUncaughtError is only called while we're working on a root.

* remainingWork -> remainingExpirationTime

I was wary of leaking NoWork but mixing numbers and null is worse so
let's just do it until we think of something better.

* Rename stuff
2017-10-20 13:22:29 -07:00
Brian Vaughn
c7d28a0136 Fix build/sync script for RN/CS/RT (#11302)
While testing some changes to RN, I noticed that the '--sync-fbsource' flag had been broken recently by things being moved around and the newly-added CS renderer. Fixed it up.
2017-10-20 12:58:53 -07:00
Dan Abramov
e779c39dfe Flatten everything (#11304)
* Flatten everything

* Fix ReactDOMServerNode build

* Fix native builds
2017-10-20 20:14:52 +01:00
Dan Abramov
cc1ff874e5 Remove outdated TODO 2017-10-20 17:34:16 +01:00
Brian Vaughn
fa5adb3bc4 Release script no longer auto-updates peerDependencies react version (#11292)
* Release script ensures peer dep matches release major version, but otherwise no longer auto-updates them to exactly match the release version.
* f
2017-10-20 08:53:15 -07:00
Brian Vaughn
845b1afdc5 Rollup script can now extract error codes and build in a single pass (#11291)
* Rollup build scripts can now extract error codes while building

* I can't spell ternary
2017-10-20 08:35:33 -07:00
Dan Abramov
2de3702d93 Rename shared/event/eventPlugins -> shared/event/plugins
Forgot this as part of my last PR.
Mirrors new ReactDOM structure.
2017-10-20 13:58:42 +01:00
Dan Abramov
ab853e6f3e Group event code together and forbid cross-client/server imports (#11298)
* react-dom/src/syntheticEvents => events, and put plugins into it

* Flatten react-dom/src/shared

* Split react-dom/src/client/utils into event/ and root client folder

Makes it clearer what is used by what.

* Strictly separate modules that can be imported by client and server
2017-10-20 13:51:50 +01:00
Dan Abramov
c080537a7b Flatten the shared/ folder (#11297)
* shared/src -> shared

It's not a real package and doesn't even have package.json.
This will also make importing less weird if we drop Haste.

* Get rid of shared/utils

Moved event-specific into shared/event.
Moved rest to the root since distinction has always been pretty arbitrary.

* Fix references to old shared/src paths
2017-10-20 12:59:57 +01:00
Dan Abramov
08ff3d749d Move files in react package (#11294)
* Move files in react package

* Move test-only TypeScript definitions into tests subfolder
2017-10-20 11:26:37 +01:00
David Gilbertson
73527237e6 Fix typos in comments (#11295) 2017-10-20 11:15:17 +01:00
Dan Abramov
313611572b Reorganize code structure (#11288)
* Move files and tests to more meaningful places

* Fix the build

Now that we import reconciler via react-reconciler, I needed to make a few tweaks.

* Update sizes

* Move @preventMunge directive to FB header

* Revert unintentional change

* Fix Flow coverage

I forgot to @flow-ify those files. This uncovered some issues.

* Prettier, I love you but you're bringing me down
Prettier, I love you but you're bringing me down

Like a rat in a cage
Pulling minimum wage
Prettier, I love you but you're bringing me down

Prettier, you're safer and you're wasting my time
Our records all show you were filthy but fine
But they shuttered your stores
When you opened the doors
To the cops who were bored once they'd run out of crime

Prettier, you're perfect, oh, please don't change a thing
Your mild billionaire mayor's now convinced he's a king
So the boring collect
I mean all disrespect
In the neighborhood bars I'd once dreamt I would drink

Prettier, I love you but you're freaking me out
There's a ton of the twist but we're fresh out of shout
Like a death in the hall
That you hear through your wall
Prettier, I love you but you're freaking me out

Prettier, I love you but you're bringing me down
Prettier, I love you but you're bringing me down
Like a death of the heart
Jesus, where do I start?
But you're still the one pool where I'd happily drown

And oh! Take me off your mailing list
For kids who think it still exists
Yes, for those who think it still exists
Maybe I'm wrong and maybe you're right
Maybe I'm wrong and maybe you're right
Maybe you're right, maybe I'm wrong
And just maybe you're right

And oh! Maybe mother told you true
And there'll always be somebody there for you
And you'll never be alone
But maybe she's wrong and maybe I'm right
And just maybe she's wrong
Maybe she's wrong and maybe I'm right
And if so, here's this song!
2017-10-19 19:50:24 +01:00
Dan Abramov
1740f30d5c Fix production crash (#11286)
* Fix production crash

* Add regression test
2017-10-19 19:12:07 +01:00
Dan Abramov
1a81be4625 Include component stack in more places, including SSR (#11284)
* Include component stack in more places, including SSR

* Forbid including reconciler code into the server bundle

* Tighten up the Flow annotation

* Fix lint

* Gosh Prettier
2017-10-19 17:43:40 +01:00
Dan Abramov
f56ca479be Add component stack to invalid style warnings (#11282) 2017-10-19 16:46:39 +01:00
Dan Abramov
c625b868f5 Only renderers should depend on reconciler code (#11281)
* Only renderers should depend on reconciler code

* Remove react-art dependency on react-dom modules

They share ReactDOMFrameScheduling so I moved it to shared.
2017-10-19 15:52:45 +01:00
Sebastian Markbåge
b52a5624e9 [CS] Persistent Updates (#11260)
* Update build size

* [CS] Clone container instead of new root concept

The extra "root" concept is kind of unnecessary. Instead of having a
mutable container even in the persistent mode, I'll instead make the
container be immutable too and be cloned. Then the "commit" just becomes
swapping the previous container for the new one.

* Change the signature or persistence again

We may need to clone without any updates, e.g. when the children are changed.

Passing in the previous node is not enough to recycle since it won't have the
up-to-date props and children. It's really only useful to for allocation pooling.

* Implement persistent updates

This forks the update path for host fibers. For mutation mode we mark
them as having an effect. For persistence mode, we clone the stateNode with
new props/children.

Next I'll do HostRoot and HostPortal.

* Refine protocol into a complete and commit phase

finalizeContainerChildren will get called at the complete phase.
replaceContainer will get called at commit.

Also, drop the keepChildren flag. We'll never keep children as we'll never
update a container if none of the children has changed.

* Implement persistent updates of roots and portals

These are both "containers". Normally we rely on placement/deletion effects
to deal with insertions into the containers. In the persistent mode we need
to clone the container and append all the changed children to it.

I needed somewhere to store these new containers before they're committed
so I added another field.

* Commit persistent work at the end by swapping out the container

* Unify cloneOrRecycle

Originally I tried to make the recyclable instance nullable but Flow didn't
like that and it's kind of sketchy since the instance type might not be
nullable.

However, the real difference which one we call is depending on whether they
are equal. We can just offload that to the renderer. Most of them won't
need to know about this at all since they'll always clone or just create
new.

The ones that do know now have to be careful to compare them so they don't
reuse an existing instance but that's probably fine to simplify the
implementation and API.

* Add persistent noop renderer for testing

* Add basic persistent tree test

* Test bail out

This adds a test for bailouts. This revealed a subtle bug. We don't set the
return pointer when stepping into newly created fibers because there
can only be one. However, since I'm reusing this mechanism for persistent
updates, I'll need to set the return pointer because a bailed out tree
won't have the right return pointer.

* Test persistent text nodes

Found another bug.

* Add persistent portal test

This creates a bit of an unfortunate feature testing in the unmount
branch.

That's because we want to trigger nested host deletions in portals in the
mutation mode.

* Don't consider container when determining portal identity

Basically, we can't use the container to determine if we should keep
identity and update an existing portal instead of recreate it. Because
for persistent containers, there is no permanent identity.

This makes it kind of strange to even use portals in this mode. It's
probably more ideal to have another concept that has permanent identity
rather than trying to swap out containers.

* Clear portals when the portal is deleted

When a portal gets deleted we need to create a new empty container and
replace the current one with the empty one.

* Add renderer mode flags for dead code elimination

* Simplify ReactNoop fix

* Add new type to the host config for persistent configs

We need container to stay as the persistent identity of the root atom.
So that we can refer to portals over time.

Instead, I'll introduce a new type just to temporarily hold the children
of a container until they're ready to be committed into the permanent
container. Essentially, this is just a fancy array that is not an array
so that the host can choose data structure/allocation for it.

* Implement new hooks

Now containers are singletons and instead their children swap. That way
portals can use the container as part of their identity again.

* Update build size and error codes

* Address comment

* Move new files to new location
2017-10-18 18:28:23 -07:00
Dan Abramov
4af2a24f00 Update contribution instructions (#11276) 2017-10-19 01:03:55 +01:00
Dan Abramov
338036fa50 Delete unnecessary typing from the website 2017-10-19 00:45:48 +01:00
Dan Abramov
d9c1dbd617 Use Yarn Workspaces (#11252)
* Enable Yarn workspaces for packages/*

* Move src/isomorphic/* into packages/react/src/*

* Create index.js stubs for all packages in packages/*

This makes the test pass again, but breaks the build because npm/ folders aren't used yet.
I'm not sure if we'll keep this structure--I'll just keep working and fix the build after it settles down.

* Put FB entry point for react-dom into packages/*

* Move src/renderers/testing/* into packages/react-test-renderer/src/*

Note that this is currently broken because Jest ignores node_modules,
and so Yarn linking makes Jest skip React source when transforming.

* Remove src/node_modules

It is now unnecessary. Some tests fail though.

* Add a hacky workaround for Jest/Workspaces issue

Jest sees node_modules and thinks it's third party code.

This is a hacky way to teach Jest to still transform anything in node_modules/react*
if it resolves outside of node_modules (such as to our packages/*) folder.

I'm not very happy with this and we should revisit.

* Add a fake react-native package

* Move src/renderers/art/* into packages/react-art/src/*

* Move src/renderers/noop/* into packages/react-noop-renderer/src/*

* Move src/renderers/dom/* into packages/react-dom/src/*

* Move src/renderers/shared/fiber/* into packages/react-reconciler/src/*

* Move DOM/reconciler tests I previously forgot to move

* Move src/renderers/native-*/* into packages/react-native-*/src/*

* Move shared code into packages/shared

It's not super clear how to organize this properly yet.

* Add back files that somehow got lost

* Fix the build

* Prettier

* Add missing license headers

* Fix an issue that caused mocks to get included into build

* Update other references to src/

* Re-run Prettier

* Fix lint

* Fix weird Flow violation

I didn't change this file but Flow started complaining.
Caleb said this annotation was unnecessarily using $Abstract though so I removed it.

* Update sizes

* Fix stats script

* Fix packaging fixtures

Use file: instead of NODE_PATH since NODE_PATH.
NODE_PATH trick only worked because we had no react/react-dom in root node_modules, but now we do.

file: dependency only works as I expect in Yarn, so I moved the packaging fixtures to use Yarn and committed lockfiles.
Verified that the page shows up.

* Fix art fixture

* Fix reconciler fixture

* Fix SSR fixture

* Rename native packages
2017-10-19 00:22:21 +01:00
Andrew Clark
76659c418f Use sigil instead of comparing baseState to null 2017-10-18 15:39:58 -07:00
Andrew Clark
d9647282e6 Better fix for base state bug (#11273) 2017-10-18 15:11:47 -07:00
Andrew Clark
8707755676 Render-phase setState bugfix (#11272)
Fixes a bug surfaced by www unit test.

I'm not yet sure the best way to test this; in the interest of landing
this fix quickly, I'll save the test for a follow-up.
2017-10-18 14:32:31 -07:00
Dan Abramov
dee604dbe2 Add static injection for feature flags (#11269)
* Replace ReactDOMFeatureFlags with ReactFeatureFlags

* Add static injection for feature flags
2017-10-18 18:40:52 +01:00
Flarnie Marchan
101934646f Add note to 'unreleased' CHANGELOG about deprecating Bower (#11262)
* Add note to 'unreleased' CHANGELOG about deprecating Bower

**what is the change?:**
We will no longer release new versions of React to Bower, and we should
announce that as part of our CHANGELOG.

**why make this change?:**
We decided on this as a team.

**test plan:**
Visual inspection and spell check. :)

**issue:**
Just follow-up for https://github.com/facebook/react/pull/11223

* Improve messaging/formatting

* Move bower deprecation notice to top of changelog
2017-10-18 08:42:22 -07:00
243083df
4b7c562bba Remove unnecessary comparison; (#11215) 2017-10-18 15:00:56 +01:00
Dan Abramov
d7c271e5ed Update rolling changelog 2017-10-18 14:58:34 +01:00
Michał Matyas
03a3934e0e Fix forceUpdate in shallow test renderer (#11239) 2017-10-18 14:54:06 +01:00
Dan Abramov
c539be0515 Remove unused bundle flag (#11267) 2017-10-18 14:00:44 +01:00
Ethan Arrowood
a3a10db22c Added component stack to contentEditable warning (#11208)
* Added component stack to contentEditable warning

* Added component stack to contentEditable warning
2017-10-18 13:59:43 +01:00
Dan Abramov
066f02281b Put NativeCS bundles into their own directory (#11266) 2017-10-18 13:56:07 +01:00
Dan Abramov
ce335f7021 Delete .netlify (#11261) 2017-10-17 23:37:11 +01:00
Dan Abramov
daf75f0671 Record sizes 2017-10-17 22:54:11 +01:00
Brian Vaughn
90370f28ff Removed test utils dependency on test renderer from bundle config (#11259) 2017-10-17 14:31:12 -07:00
Dan Abramov
0e5767824f Don't mark portals for updates (#11255) 2017-10-17 20:53:15 +01:00
Dustan Kasten
94e8e9d88e isPortal() is not referenced anywhere (#11256) 2017-10-17 20:27:54 +01:00
Dan Abramov
56e5288b04 Remove broken links from React ART readme 2017-10-17 14:20:48 +01:00
Dan Abramov
1ef250d881 Move Flow environment into scripts/flow (#11249)
* Move flow environment into scripts/flow

* Run Prettier
2017-10-17 14:20:00 +01:00
Dan Abramov
979fce8b72 Delete adler32 implementation (#11250) 2017-10-17 14:19:47 +01:00
Dan Abramov
5be6a1a6d1 Drop name and commonerConfig from package.json (#11244) 2017-10-17 13:34:01 +01:00
Dan Abramov
043d369210 Simplify Jest-specific tests (#11243)
* Delete tests that only mattered during createElement transition

They were added after #2576, but were only important when React.createElement was introduced as a migration path.
Now that elements are used consistently, these tests shouldn't be necessary.

I created a separate test specifically for scryRenderedComponentsWithType() though because that was the only one.

* Simplify mocking test setup

Today, the only remaining special behavior for Jest mocks is we let them render undefined.

We don't plan to introduce any other special behavior for them in the future.
(In fact, we already decided against replicating this special behavior for functional components.)

Therefore, we can remove dependency on Jest automocking mechanism in these tests completely,
and just explicitly mock the render method which is the only one for which we have special behavior.

For clarity, we add an explicit test for mockComponent() API (whose naming is a bit of a lie).
2017-10-17 13:05:44 +01:00
Dan Abramov
49d4381c67 Simplify Jest config a little bit (#11242)
* Inline getTestDocument into test cases

* Remove mention of mock file we do not use

* Remove unused configuration entries

* Move eslint-rules package into the scripts/ folder
2017-10-16 23:17:00 +01:00
Brian Vaughn
9ed78ad277 Tweaked wording of release script README 2017-10-16 15:02:41 -07:00
Brian Vaughn
c371c152ab Release script (#11223)
* First chunk of new release script

* Re-ordered build steps to combine error codes and releases

* Reorganized build files; added stub publish script

* First pass at publis script. Also collect and print dry-run commits/publish commands.

* Deleted old react-release-manager scripts

* Cleaned up release package.json

* Basic README instructions

* Removed unnecessary 'async' keyword from a method

* Wordsmithing

* Tweaked README

* Renamed build -> build-commands and publish -> publish-commands to avoid conflict with .gitignore

* Bump pre-release package versions differently

* Prettier

* Improved CircleCI API token setup instructions message

* Lint fix

* Typofix
2017-10-16 15:01:14 -07:00
Dan Abramov
b5a2a1349d Bump Jest version (#11241) 2017-10-16 21:38:34 +01:00
Dan Abramov
f8134966c9 Record sizes 2017-10-16 20:51:36 +01:00
Clark Du
b623bf43a0 Use value on <select> instead of setting selected on <option> (#11206) 2017-10-16 07:46:24 -04:00
Fatos Morina
17de6a35cf Fix typos (#11204)
* Use an MVP rather than a MVP

* Use the capital letter for React and highlight eslint-plugin

* Fix typos
2017-10-14 16:26:10 -04:00
Andrew Clark
7687962249 ReactDOM.createRoot (#11225)
* ReactDOM.createRoot

Introduce new API for creating roots. Only root.render and root.unmount
are implemented. Later we'll add root.prerender, and support for lazy
roots (roots with DOM containers that resolve lazily).

* Add hydrate option to createRoot
2017-10-13 20:08:36 -07:00
Andrew Clark
3ffb5d0876 Deterministic updates (#10715)
* Deterministic updates

High priority updates typically require less work to render than
low priority ones. It's beneficial to flush those first, in their own
batch, before working on more expensive low priority ones. We do this
even if a high priority is scheduled after a low priority one.

However, we don't want this reordering of updates to affect the terminal
state. State should be deterministic: once all work has been flushed,
the final state should be the same regardless of how they were
scheduled.

To get both properties, we store updates on the queue in insertion
order instead of priority order (always append). Then, when processing
the queue, we skip over updates with insufficient priority. Instead of
removing updates from the queue right after processing them, we only
remove them if there are no unprocessed updates before it in the list.

This means that updates may be processed more than once.

As a bonus, the new implementation is simpler and requires less code.

* Fix ceiling function

Mixed up the operators.

* Remove addUpdate, addReplaceState, et al

These functions don't really do anything. Simpler to use a single
insertUpdateIntoFiber function.

Also splits scheduleUpdate into two functions:

- scheduleWork traverses a fiber's ancestor path and updates their
  expiration times.
- scheduleUpdate inserts an update into a fiber's update queue, then
  calls scheduleWork.

* Remove getExpirationTime

The last remaining use for getExpirationTime was for top-level async
updates. I moved that check to scheduleUpdate instead.

* Move UpdateQueue insertions back to class module

Moves UpdateQueue related functions out of the scheduler and back into
the class component module. It's a bit awkward that now we need to pass
around createUpdateExpirationForFiber, too. But we can still do without
addUpdate, replaceUpdate, et al.

* Store callbacks as an array of Updates

Simpler this way.

Also moves commitCallbacks back to UpdateQueue module.

* beginUpdateQueue -> processUpdateQueue

* Updates should never have an expiration of NoWork

* Rename expiration related functions

* Fix update queue Flow types

Gets rid of an unneccessary null check
2017-10-13 17:21:25 -07:00
Sebastian Markbåge
36a2afccc5 [CS] Split Host Config Out into a Mutable or Immutable Mode (#11213)
* CS renderer

Because we didn't have enough RN experiments. I want to add one more.

* Split out hydration from the host config object

This makes it easier to do feature detection on the configuration.

* Move mutation host config to separate optional object

* Refs and life-cycles should happen even in immutable mode

* Unmount components even in non-mutation mode

This is the same as committing deletions but instead of finding host
components to delete, it only invokes componentWillUnmount and detaching
of refs.

* Add persistent updates API

This mode will use a clone based API instead of mutating host instances.

Needs implementation still.

It's awkward that there can be more than one child inserted into the root.
So we need a new API to create a "root" instance so that we can update it
atomically. Alternatively we could keep the mutable API for containers
and assume that most use cases would only have a single root.

* Package up CS renderer

* Fix reconciler package fixture
2017-10-13 14:29:59 -07:00
Andrew Clark
339d6cb32b Sync setStates inside willUpdate and didUpdate should flush at same time (#11212)
In sync mode, we downgrade sync priority work to task work when we're in
the commit phase, but not in the render phase. That means if you
schedule updates in both phases, the render phase update will flush
first, and the commit phase update will flush after that. What should
really happen is that both updates flush at the same time.

To solve this, updates in the commit phase are now given sync priority.
The distinction between task and sync really only exists to account for
a historical quirk in the behavior of top-level mounts. (Refer to the
test case titled "initial mount is sync inside batchedUpdates".)

Ideally, there would only be one priority for both sync and task. This
gets us closer to that model, while still accounting for
top-level mounts.
2017-10-12 21:05:58 -07:00
Haroen Viaene
0c5a455ecb chore(syntheticEvent): remove IE8 code (#11178)
* chore(syntheticEvent): remove IE8 code

Since IE8 has been deprecated for a while, I thought it might be useful to remove some IE8-only code

If this is not something you want to focus on yet, or is too much work to test, feel free to close this PR

* Update SyntheticUIEvent.js

* Update SyntheticUIEvent.js

* remove unused require

* completely remove UIEvent

* augment with noop

everything breaks otherwise

* comment back

* spacing
2017-10-12 17:30:47 -04:00
Nathan Hunzaker
19043236be Add exception for 16.alpha when loading React in DOM Fixtures (#11200)
The file structure was updated in 16. This wasn't the case for
alphas. We need to load the old module location for anything less than
16 RC.
2017-10-12 17:30:03 -04:00
Andrew Clark
8ac9600574 Remove priority coalescing and PriorityLevel module (#11187)
Coalescing is the only feature that depends on PriorityLevel. Since
we're not sure if coalescing is even valuable, we'll remove it for
now. If it turns out we need it, we can add it back later.
2017-10-11 14:48:44 -07:00
Dustan Kasten
111731dedd React reconciler package (#10758)
* Initial commit of react-reconciler bundle

* I think it’s working 🙀

* React reconciler: slightly better description and README

* Drop react-reconciler version to an unstable release number

* Convert to moduleType enum and fix packaging

* eslint

* s/Renderer/Reconciler in docs

* yarn prettier

* change names of things in the react-reconciler readme

* change predicate

* rollup: flip object-assign shimming check

* copy noop renderer into react-reconciler fixture

* Change reconciler fixture test

* prettier

* Remove a bunch of Noop test renderer

* Delete a bunch of stuff we don’t care about for reconciler teesting. Add flow pragmas for future flow pragma testing

* Remove PATENTS

* Update Reconciler fixture docs

* ReactDOMUnstableNativeDependencies should be ISOMORPHIC

* Inline fixture renderer

* Make it "RENDERER"

* There is no UMD build. It also doesn't need propTypes.

* Tweak how the reconciler is built

* Record sizes

* Update README.md
2017-10-11 19:29:26 +01:00
Dan Abramov
fb0199b73c Add to changelog 2017-10-11 19:08:25 +01:00
Dan Abramov
6c592deac9 Record sizes 2017-10-11 19:06:43 +01:00
Dan Abramov
2228f497f3 Keep autoFocus attribute in the DOM (#11192)
* Keep autoFocus attribute in the DOM

* Don't emit autoFocus attribute on the client

* Test that hydration doesn't call focus

* Add autoFocus to SSR fixture
2017-10-11 18:52:12 +01:00
Dan Abramov
b75be6a363 Move loop init variable assignment (#11182) 2017-10-11 11:46:15 +01:00
Dan Abramov
4a26b90cfa Fix DOM fixture for 16.0.0 2017-10-11 10:50:00 +01:00
Brian Vaughn
8b3ad851fd Update build scripts to put RN-RT files in the right places (#11183) 2017-10-10 13:44:43 -07:00
Dan Abramov
e5db5302ac Fix false positive <noscript> rehydration text difference warning in React 16 (#11157)
* Add <noscript> with HTML in it to SSR fixture

* Wrap <noscript> into a <div> to get its "client HTML"

* Revert "Wrap <noscript> into a <div> to get its "client HTML""

This reverts commit 27a42503e2790a0d5cf0b90451a664fc6ab9d862.

* Always use parent.ownerDocument
2017-10-10 19:35:43 +01:00
Dan Abramov
f42dfcdb94 Fix false positive SVG hydration warning for mixed case tags (#11174)
* Add a failing test for <feMorphology> SSR

It causes a false positive warning on hydration.

* Make hydration tag comparison case insensitive
2017-10-10 19:34:37 +01:00
Dan Abramov
18f408fb6b Update changelog 2017-10-10 17:57:45 +01:00
Dan Abramov
309fa6c871 Don't set empty placeholder to work around IE11 bug (#11177)
* Don't set empty placeholder to work around IE11 bug

* Add fixture for textarea placeholders
2017-10-10 17:49:59 +01:00
Dan Abramov
10320a5331 Update changelog 2017-10-10 16:58:19 +01:00
Dustan Kasten
9b4e4e1759 Fix obscure error message when passing an invalid style value for SSR (#11173)
* Add failing iframe test

* Possible fix by returning null ownerName in SSR

* prettier

* eslolint

* gah c’mon really?

* emptyFunction.thatReturnsNull

* One less property access
2017-10-10 16:57:25 +01:00
Shirshak Bajgain
45c05c7097 Remove broken link from licence (#11176) 2017-10-10 16:57:00 +01:00
Dan Abramov
09cafa6e40 Changelog 2017-10-10 16:56:42 +01:00
Brandon Dail
5c6cb597f9 Fix form reset for uncontrolled select elements (#11057)
* Set defaultSelected on option element from select's defaultValue

* Add form reset fixture for selects

* Pass explicit value for setDefaultSelected
2017-10-10 16:54:59 +01:00
Dan Abramov
b2101cb328 Record sizes 2017-10-10 16:06:05 +01:00
Dan Abramov
20471d693d Update changelog 2017-10-10 12:35:24 +01:00
Filipp Riabchun
2264e3d044 Shallow renderer: support multiple setState invocation (#11167) 2017-10-10 12:33:57 +01:00
Dan Abramov
44c795c45f Update rolling changelog 2017-10-10 11:59:29 +01:00
Ori Riner
6ad6dcd112 Clear previous children when SVG node doesn't have innerHTML (#11108)
* clear previous children when SVG node doesn't have innerHTML

* remove 'get' handler for appendChild in test node proxy
2017-10-10 11:54:47 +01:00
Andrew Clark
3019210df2 Expiration times (#10426)
* [Work-in-progress] Assign expiration times to updates

An expiration time represents a time in the future by which an update
should flush. The priority of the update is related to the difference
between the current clock time and the expiration time. This has the
effect of increasing the priority of updates as time progresses, to
prevent starvation.

This lays the initial groundwork for expiration times without changing
any behavior. Future commits will replace work priority with
expiration times.

* Replace pendingWorkPriority with expiration times

Instead of a priority, a fiber has an expiration time that represents
a point in the future by which it should render.

Pending updates still have priorities so that they can be coalesced.

We use a host config method to read the current time. This commit
implements everything except that method, which currently returns a
constant value. So this just proves that expiration times work the same
as priorities when time is frozen. Subsequent commits will show the
effect of advancing time.

* Triangle Demo should use a class

shouldComponentUpdate was removed from functional components.

Running the demo shows, now that expiration is enabled, the demo does
not starve. (Still won't run smoothly until we add back the ability to
resume interrupted work.)

* Use a magic value for task expiration time

There are a few cases related to sync mode where we need to distinguish
between work that is scheduled as task and work that is treated like
task because it expires. For example, batchedUpdates. We don't want to
perform any work until the end of the batch, regardless of how much
time has elapsed.

* Use current time to calculate expiration time

* Add unit tests for expiration and coalescing

* Delete unnecessary abstraction

* Move performance.now polyfill to ReactDOMFrameScheduling

* Add expiration to fuzz tester

* Expiration nits

- Rename Done -> NoWork
- Use max int32 instead of max safe int
- Use bitwise operations instead of Math functions
2017-10-09 18:39:53 -07:00
Georgios Giannoutsos Barkas
65b16b1c7e Allow custom attribute named on to be passed on to elements (#11153)
* Allow single `on` property for custom elements

* Remove test from ReactDOMComponent-test

* Allow custom attribute named 'on' to be passed

* Check property length instead of comparing strings
2017-10-09 17:31:24 -07:00
Dan Abramov
80596c2c92 Fix incorrect calculation of onMouseEnter/Leave component path (#11164)
* Add a regression test for #10906

* Turn while conditions into breaks without changing the logic

This will be easier to follow when we add more code there.

* var => const/let

So that I can add a block scoped variable.

* Check alternates when comparing to the common ancestor

This is the actual bugfix.
2017-10-09 20:30:03 +01:00
Dustan Kasten
08cbc257bd Bump peer deps of react to ^16.0.0 (#11156) 2017-10-09 16:00:50 +01:00
Sebastian Markbåge
4131af3e4b Ignore SSR warning using explicit suppressHydrationWarning option (#11126)
* Pass parent type and props to insert/delete hydration warning hooks

For this to work, we need to split the API into a container and normal
version. Since the root doesn't have a type nor props.

* Ignore SSR warning using explicit suppressHydrationWarning option

This lets you ignore the warning on a single element and its direct child
content. This is useful for simple fields that you're expecting to fail
such as time stamps.

Note that this still won't patch up such content so it'll remain
inconsistent. It's also not suitable for nested complex content that may
change.

* Suppress warning of inserted/deleted direct children

* Add fixture testing hydration warning

Also fixing the render->hydrate API change in the fixture

* Add hooks when text hydration doesn't match up

The purpose of these hooks is to pass the parent context to them. I don't
want to do that in the normal hydrateTextInstance hooks since this is
only used in DEV. This is also in line with what happens if there is no
text instance at all and we invoke didNotFindHydratableTextInstance.

* Move mismatch text hydration warning to the new hooks

This lets us ignore this call when we have parent props available and
the suppression flag is set.
2017-10-06 19:50:01 -07:00
Sebastian Markbåge
5744571140 [RT] More predictable things (#11139)
* Inject the right event emitter

Previously this was injecting the ReactNativeEventEmitter even though
we want the ReactNativeRTEventEmitter.

RCTEventEmitter is also just an abstraction around BatchedBridge that
registers a single name. We can't register more than one with it. Removed
that abstraction for now so we don't have to add it back into the RN repo.

* Unify appendChildToDetachedParent and appendChild, separate root

Merge appendChildToDetachedParent and appendChild. We don't need the distinction.

We do however need a separate notion for the root container.
Calling this `appendChildToContext` since Context has a meaning here.

* Add a simple shallow comparison so that we don't send updates for equal props

This still sends all props if any differs. Not sure we'll want that but I
think so.

* Add BatchedBridge to bundle externals

* Lint
2017-10-06 19:08:22 -07:00
Dan Abramov
190a1141cc Add an item to changelog 2017-10-06 23:08:25 +01:00
Anushree Subramani
e8629667ab Deduplication of warning messages in nested updates (#11081) (#11113) 2017-10-06 23:04:18 +01:00
Dan Abramov
c75eed29c6 Add more items to the rolling changelog 2017-10-06 21:47:49 +01:00
andreysaleba
12144517f9 Added check to deduplicate function type warning calls on each compon… (#11120)
* Added check to deduplicate function type warning calls on each component type

* Added test to check that 'function type as React child' warning is deduplicated correctly by component type

* Ran prettier on added code

* Modified test checking deduplication of 'Functions are not valid as a React child' warning so it will check against rerendering component now
2017-10-06 21:40:45 +01:00
Brian Vaughn
ebb1d316bd Delete documentation and website source (#11137)
* Deleted docs folder

* Deleted www folder

* Remove Netlify website build command

* Removed refs to docs and www from ESlint config

* Removed refs to www/docs from Flow config

* Removed unnecessary .gitignore config

* Updated license check to remove refs to docs

* Removed gh-pages specific portions of Circle build scripts
There may be more that we can remove (eg set_up_github_keys.sh) but I'm not positive

* Removed docs specific license
2017-10-06 10:18:05 -07:00
Nathan Hunzaker
09ed79a942 Add focus helper to range test, update button styles (#11134)
When testing range input change events, clicking the knob would cause
it to move if the click region wasn't precisely on the center of the
knob.

This is annoying! This commit adds a button to focus the range input
knob and takes a small pass at styling buttons.

A label would work here too, however it does not generate a focus ring
in all browsers.
2017-10-06 12:58:10 -04:00
Nathan Hunzaker
ea507f163b Use indexOf instead of includes in RangeKeyboardFixture (#11133)
Allows the DOM Fixture change test case to work in older browsers.
2017-10-06 10:45:57 -04:00
Sebastian Markbåge
7ec46e0fb0 [RT] Minor clean up (#11122)
* Rename rootNodeID -> tag

* Process RT props before forwarding them along

This is needed because the children prop can't be serialized.

Also, some minor placeholder for events.
2017-10-05 18:32:07 -04:00
Dan Abramov
44c32fc268 Ignore CR/LF differences when warning about markup mismatch (#11119)
* Add regression test for CR-insensitive hydration

* Normalize CR when comparing server HTML to DOM

* Move tests in the file

* Add a failing test for comparing attributes

* Normalize CR for attributes too

* Add a test case for CR in dangerouslySetInnerHTML

* Undo the fix per feedback

* Change the fix to be DEV-only and still patch up LF -> CR

* Remove the dangerouslySetInnerHTML test

It's always going to "pass" because we normalize HTML anyway.

Except that it won't pass because we intentionally don't patch up dangerouslyInnerHTML.

* Fix issue that Flow failed to catch

* Add null character tests

* Normalize both client and server value for the warning

* Fix the bug

* Normalize replacement character away as well

* Fix outdated comment
2017-10-05 20:59:43 +01:00
Dan Abramov
32ec797274 Adjacent text nodes in SSR should have comments between them despite components (#11109)
* Add a failing test for text nodes within components

* Reset the text node flag only when emitting tags

This ensures we don't reset it when we exit components that return strings.

* Add a failing test for a more complex tree

* Also reset text flag when emitting a footer

This fixes the {'a'}</div>{'b'} case and prevents an unnecessary comment before 'b'.
2017-10-05 20:05:00 +01:00
Dan Abramov
7d3b44bf37 Add production bundles for Test and Shallow renderers (#11112)
* Add production bundles for Test and Shallow renderers

* Remove unused/broken file from test renderer

* Add production bundle for TestUtils
2017-10-05 15:26:52 +01:00
Shi Yan
fa7461e25b Fix SyntheticEvent constructor comments (#11011) 2017-10-05 00:45:39 +01:00
Dan Abramov
a2efa51b92 Tweak wording based on @landermkerbey's suggestion in #10433#issuecomment-324488168 2017-10-04 21:44:12 +01:00
Sophie Alpert
dffb206a04 Remove references to PATENTS that crept in (#11091) 2017-10-04 12:40:41 -07:00
Yangshun Tay
2b0ef3c1bb Fix blog issues that resulted from migration (#11089) 2017-10-04 19:35:29 +01:00
Gustavo Gard
81b368cf97 Correct logo url (#11090) 2017-10-04 19:33:39 +01:00
Dominic Gannaway
e0b802fc4e Fixes example in Web Components docs (#11039)
* fixes docs on webcomponent

* Update web-components.md
2017-10-04 17:12:36 +01:00
Sophie Alpert
1ba7dfcf04 Rewrite ReactDOMSelection to use fewer ranges (#9992)
We heard from Chrome engineers that creating too many Range objects slows down Chrome because it needs to keep track of all of them for the case that anchor/focus nodes get removed from the document. We can just implement this calculation without ranges anyway.

jsdom doesn't support Range objects, but I copied the fuzz test code into my browser and manually compared it against our old implementation https://gist.github.com/sophiebits/2e6d571f4f10f33b62ea138a6e9c265c; with 200,000 trials no differences were found.
2017-10-03 18:48:30 -07:00
Sebastian Markbåge
761decb352 Fork React Native render into an "RT" renderer (#11072)
This is an experimental new protocol for some experiments we want to play
with. To make that easier, I'm just going to fork it.

This experiment won't use the event system so I by-pass it and just invoke
functions on the props object for now.

I also fork the UIManager into a new RTManager.
2017-10-03 18:48:23 -04:00
Brian Vaughn
53c1b8b0d7 Live code editor ignores tab key for improved a11y (#10992) 2017-10-03 11:15:00 -07:00
Fernando Poumian
25dbf03e66 [website] Add RSS Feed to website (#11056) 2017-10-03 11:06:30 -07:00
Haroen Viaene
e367a44789 style(docsearch): add cursor + logo (#11032)
* style(docsearch): add cursor + logo

fixes #10965

Not completely convinced about the cursor colour, but I couldn't really find a better one, cc @joecritch

* fix margin

* style(docsearch): add cursor + logo

fixes #10965

Not completely convinced about the cursor colour, but I couldn't really find a better one, cc @joecritch

* padding
2017-10-03 10:39:14 -07:00
Brandon Dail
f6a79d1f16 Only define MyElement when needed (#11069) 2017-10-03 10:23:59 -07:00
Dan Abramov
589c0a25df Update button labels 2017-10-03 17:03:18 +01:00
Yangshun Tay
4d60346fc4 Fix all GitHub issues and PRs query params (#11066) 2017-10-03 16:58:26 +01:00
pyitphyoaung
85b59d2fc9 Replace hyperlink tag with button tag in tic-tac-toe tutorial and update related references in the tutorial document (#11045) 2017-10-03 08:48:06 -07:00
Bernard Lin
07dba67ae0 Update conferences (#10781)
* Update conferences

* Update conferences.md
2017-10-03 15:45:30 +01:00
Brandon Dail
5f93ee6f6c Add test for mounting into a document fragment (#11047) 2017-10-03 14:55:32 +01:00
matej
c32b4cd275 Fixing how to contribute beginner friendly issues GitHub link (#11063)
* Fixing how to contribute beginner friendly issues GitHub link

* Fixing again url for how to contribute beginner friendly issues GitHub link
2017-10-03 13:38:28 +01:00
Brian Vaughn
07b1da8964 Removed PooledClass (and tests) (#11053) 2017-10-02 16:54:40 -07:00
Brandon Dail
ad1709a394 Only run custom element fixture in browsers that support it (#11052) 2017-10-02 16:50:46 -07:00
Flarnie Marchan
96134a0ea1 [Website] Add titles and labels to iframes and images on Community pages (#11041)
* [Website] Add titles and labels to iframes and images on Community pages

**what is the change?:**
- add titles to all iframes
- add alt tags to images
- add `aria-label` to some links which only have images as contents.

**why make this change?:**
Based on warnings thrown by aXe a11y audit of those pages

**test plan:**
Manual testing

**issue:**
None

* remove redundant alt tags
2017-10-02 16:41:05 -07:00
Ricky Reusser
fb7bab6c27 Remove bundle-collapser browserify recommendation (#11051)
* Move bundle-collapser browserify plugin recommendation to a note.

* Remove bundle-collapser note entirely
2017-10-03 00:17:49 +01:00
Brian Vaughn
75ad1a9cd6 Refactored Installation page to no longer use tabs (#11050) 2017-10-02 15:45:48 -07:00
Orjiewuru Kingdom Isaac
4caa888bf9 Update react summit Nigeria title (#11046) 2017-10-02 23:15:07 +01:00
Vicky Chijwani
465ffd10c6 Docs: add link to DOM Level 3 spec for possible values of key prop (#11042) 2017-10-02 23:13:23 +01:00
Brandon Dail
e7a2ac959a Update JSFiddle templates for React 16 (#11040)
These were broken after 16 was tagged as `latest` on npm. This fixes that problem, and also adds two template options: one for React 16 and one for React 15. I figure we should provide both for now, since there's still a lot of 15.x users.
2017-10-02 14:11:29 -07:00
Dan Abramov
d8faa70b64 Add changelog entry 2017-10-02 20:51:13 +01:00
Dan Abramov
8b4ec79d4f Fix rendering into shadow root (#11037)
* Replace skipped unit test with a fixture

* Fix crash for custom elements
2017-10-02 20:50:14 +01:00
Dan Abramov
bbb272f3aa Fix 404 for warning URLs (#11038) 2017-10-02 20:12:32 +01:00
Dan Abramov
4c8d248757 Add note to changelog 2017-10-02 19:01:20 +01:00
Dan Abramov
223396ad0a Whitelist <dialog> from unknown tag warning (#11035) 2017-10-02 18:59:37 +01:00
Dan Abramov
9d4c2dfaac Update the changelog 2017-10-02 18:54:45 +01:00
Dan Abramov
fbd6b9ded6 Fix tabIndex attribute for SVG (#11033)
* Fix tabIndex attribute for SVG

* Update the attribute table
2017-10-02 18:52:26 +01:00
Dan Abramov
fbdd43fd70 Fix lint 2017-10-02 18:51:15 +01:00
Dan Abramov
da681e0699 Add <svg tabIndex> to the attribute table (#11034) 2017-10-02 18:44:48 +01:00
Brian Vaughn
5cb17c421d Fix lint error in master 2017-10-02 10:05:37 -07:00
Yangshun Tay
5e8d124754 Ensure all external links have consistent behavior (#11012) 2017-10-02 09:52:39 -07:00
Cole Turner
bd915caaf7 Clarify implementation of tick() in Lifecycle docs (#11002)
This documentation change clarifies how the method `tick()` relates to the example given in the State and Lifecycle documentation. Why this change is necessary is because it may be confusing for beginners who may mistake `tick()` to be a lifecycle API hook.  To clarify, the verbiage is changed so that it becomes more clear that the method is specific to the component and not the API.
2017-10-02 09:37:05 -07:00
Romello Goodman
a88738d7ae issue 10986. [website] Buttons in Live Code sections have bad styling (#11009) 2017-10-02 09:34:26 -07:00
Nic Bonetto
61a1adbda1 Fixed: [website] Handling Events shows wrong 'current' highlight (#10998) 2017-10-02 08:56:41 -07:00
Dan Abramov
2fdb84d999 Add legacy JSFiddle files (#11030)
* Add legacy JSFiddle files

* Exclude from Prettier
2017-10-02 16:48:59 +01:00
Dan Abramov
641ade94bd Stop exposing DOMProperty for the www build (#11029) 2017-10-02 15:55:48 +01:00
Dan Abramov
12d5231c2a Clarify the IRC channel confusion 2017-10-02 15:30:19 +01:00
Dan Abramov
e3a1c6616f Update sizes 2017-10-02 14:31:39 +01:00
Dan Abramov
c1ea3cda30 Delete DOMProperty www shim
It's unused
2017-10-02 13:49:53 +01:00
John Darryl Pelingo
f444937bd8 Combine rendered Note section (#11026) 2017-10-02 13:47:40 +01:00
Dan Abramov
5c13e2ee58 Remove Stack (part 4: remove Stack-only branches and types) (#10798)
* Remove findDOMNode injection and inline it

* Remove Stack-only code in ReactGenericBatching

* Remove Stack-only code branches
2017-10-02 13:43:45 +01:00
Dan Abramov
df445270a6 Disambiguate #react and #reactjs IRC channels (#11025) 2017-10-02 13:32:25 +01:00
Goffert van Gool
4c855cce0b Update web-component docs to current standard (#11020)
The documentation example for Web Components uses deprecated Custom Element and Shadow DOM APIs [0]. This change updates the example to the v1 APIs, which are the current standard.

[0] https://developers.google.com/web/fundamentals/web-components/customelements#historysupport
2017-10-02 11:44:57 +01:00
Dan Abramov
745c4ab0af Remove Stack-only DEV code (#10797) 2017-10-02 11:42:07 +01:00
Josh Hawkins
18d574a086 Improve docs for select multiple (#9539)
* Readd original select multiple note

* Update forms.md
2017-10-02 00:18:08 +01:00
Fernando Poumian
860190da77 [website] Fix Layout Footer in Contribuiting pages. (#11014)
* Fix layout footer in contribuiting pages.

* Run prettier-all
2017-10-01 22:34:21 +01:00
Greg Myers
766db4d342 Update Reference-readme to remove React.DOM (#10999)
`React.DOM` is now Undefined in React 16 so `React.DOM.div` or `React.DOM.button` are no longer possible.
2017-10-01 11:53:00 +01:00
Jason O'Neil
e3d710e60a Fix createPortal link in API docs (#11000)
The anchor name is lower case
2017-10-01 11:52:22 +01:00
Dan Abramov
c8af9c4645 Fix HTML file download link 2017-09-30 21:10:01 +01:00
Neo
ca77e34436 tweak search style (#10985) 2017-09-30 08:26:52 -07:00
Pooya Parsa
2e2dc6708f fix(examples/todo): don't submit empty values (#10979) 2017-09-30 08:20:01 -07:00
Dave Garwacke
f2568605a7 chore(docs) Remove extra style tag curly braces (#10973)
Removed an extra quoted set of curly braces..
2017-09-30 08:11:55 -07:00
Joe Critchley
7ae5ed0e7b [Gatsby] Darkened line-highlight to increase contrast (#10931)
* Darkened line-highlight to increase contrast

* added current line to line highlight

* removed blue line
2017-09-30 07:54:20 -07:00
Joe Critchley
b43574067e [Gatsby] Installation tabs design (#10989) 2017-09-30 07:53:08 -07:00
Joe Critchley
839b7fb901 [Gatsby] Removed Typekit in favour of system fonts (#10988) 2017-09-30 07:48:04 -07:00
Eugene Zhlobo
81cf21c6d1 Fix anchor links in reference-react documentation (#10975) 2017-09-29 18:44:45 -07:00
skratchdot
0344f7ad55 [Gatsby] "https://facebook.github.io/react/" -> "https://reactjs.org/" (#10970) 2017-09-29 18:43:22 -07:00
Toru Kobayashi
ed4174511a Fix og:url on SSR (#10902) 2017-09-29 18:38:01 -07:00
Dan Abramov
c22e4202d3 Fix note formatting (#10966) 2017-09-29 18:37:35 +01:00
Joe Critchley
03725199cc [Gatsby] Updated og-image location (#10942) 2017-09-29 08:27:41 -07:00
Dan Abramov
7bdf93b17a Add changelog for unreleased commits 2017-09-29 14:04:16 +01:00
watadarkstar
2494a25ee9 Added unstable_batchedUpdates as breaking change to v16 post (#10954)
* Add breaking change

ReactDOM.unstable_batchedUpdates now only takes one argument.

* Reword

* Update CHANGELOG.md
2017-09-29 13:08:20 +01:00
Dan Abramov
366c4bb5cb Don't let UMD create extraneous global variables (#10935) 2017-09-29 12:48:33 +01:00
Joshua
3a4c2a661f Use ES6 module instead of commonJS (#10953)
* Use ES6 module instead of commonJS

As far as I know, we're using ES6 modules throughout the docs. For the sake of consistency :)

* Convert all CommonJS requires to ES6 module
2017-09-29 12:24:10 +01:00
Dan Abramov
29f1aedb08 Don't include warning in production (#10946)
Fixes a size regression I introduced in #10802.
2017-09-29 08:24:06 +01:00
Joe Critchley
e271e13809 [Gatsby] README.md instructions (#10945)
* Padded out README.md instructions

* fixed markdown links and added reloading notes

* added more yarn instructions

* removed html.js instruction
2017-09-29 00:47:06 +01:00
Dan Abramov
d87804abc2 Tweaks to "Introducing JSX" (#10944)
* Tweaks to "Introducing JSX"

* Update introducing-jsx.md

* Update introducing-jsx.md

* Update introducing-jsx.md
2017-09-29 00:32:25 +01:00
BJR Matos
473327a469 remove note about license for example (#10943)
removing the old mention of license for examples. since there is no examples in the repository and also the license for them was deleted [here](#10890)
2017-09-28 23:27:52 +01:00
Orjiewuru Kingdom Isaac
25b48c8b03 Add React Summit Nigeria to the list of conferences. (#10939) 2017-09-28 23:04:59 +01:00
Flarnie Marchan
ca7bea802f [website] a11y fixes (#10927)
* [Gatsby docs a11y] Add `aria-label` to search input

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

**why make this change?:**
There was no label on this input, and screen readers might not have been
able to identify it's purpose.
[The `placeholder` doesn't count as a label.](http://a11yproject.com/posts/placeholder-input-elements/)

**test plan:**
Manually inspected the HTML in the devtools, and ran the aXe a11y audit
tool, and the warning generated by aXe was gone.

**issue:**
Checklist item on list of docs a11y issues -
https://github.com/bvaughn/react/wiki/Gatsby-A11y-Fixes

* [Gatsby Docs a11y] Increase contrast of 'installation' page tabs

**what is the change?:**
Change the dark blue used for the text/background of the tabs on the
'installation' page to a slightly darker blue, which we were already
using for the 'focus' style of the tabs. It looked a bit weird before,
imo, when the 'focus' was darker.

Now the 'focus' style just lightens the border to the new signature
blue.

**why make this change?:**

To add enough contrast that folks who see colors differently can still
decipher the writing on the tabs on this page.

We plan to refactor this page and remove the tabs soon, so not too
worried about making this fix perfect.

**test plan:**
Manual testing - loaded the page and it looks ok, and ran aXe a11y
audit, no more warnings about contrast. :)

(Flarnie will insert a screenshot)

**issue:**
checklist item on https://github.com/bvaughn/react/wiki/Gatsby-A11y-Fixes
2017-09-28 13:57:34 -07:00
Dan Abramov
83a536e622 Fix "null" instead of the component stack in a warning (#10915)
* Add a failing test that prints "null" in the warning instead of the stack

* Don't reset the current fiber during reconciliation

It should only be reset when we stop doing work.
Otherwise, any warnings after the reset will lose the component stack.

The reset in getMaskedContext() was completely unnecessary.
It is always called with the same fiber as the current work in progress.
Therefore, I add a DEV-only warning assertion to ensure we don't regress, and remove the reset.

The reset in processChildContext() is necessary because it can be called outside of reconciliation.
Unfortunately, we have to keep this hack in until we can remove unstable_renderSubtreeIntoContainer().
To work around it, I restore the previous fiber instead of resetting.

* Decouple setting the current fiber and phase

These are two distinct actions.
This helps make it clearer when we're actually changing the current pointer.

I'm also removing an overengineered hack I previously added for unstable_renderSubtreeIntoContainer. It's not necessary now that we don't null the pointer all the time.
This makes the code more straightforward.

* Centralize the pointer updates in the scheduler
2017-09-28 20:40:26 +01:00
Brian Vaughn
47a6ac525d Gatsby markdown cleanup (#10926)
* Removed unnecessary <script> tags from index.md

* Added gatsby-plugin-twitter rather than embedding <script> tags to load platform.twitter.com
2017-09-28 12:08:40 -07:00
Joe Critchley
43bab3f537 [Gatsby] Paragraph line-height / margin follow-up (#10928)
* removed old paragraph line-height

* reduced paragraph margins
2017-09-28 19:41:13 +01:00
John Leidegren
857ed18b06 Fix for createHTMLDocument API specific to IE11 (#10921)
* Fix for createHTMLDocument API specific to IE11

The createHTMLDocument API title parameter is not optional in IE while other browsers don't care IE11 will throw if an argument is not passed. This only impacts react.dom.development not react.dom.production.

* Tweak
2017-09-28 18:34:33 +01:00
Brian Vaughn
96fde8a09a Add new docs website (#10896)
Adds a new docs website, built with Gatsby JS, to replace the old Jekyll site. Source code for the new site lives in /www (although markdown and YML data still comes from the legacy /docs folder).

Changes to either markdown or website source code can be previewed on Netlify. The react-js bot should automatically add comments to each PR with preview links. (This preview is generated by running the newly-added yarn build:docs command in the root package.json.)

The majority of the changes in this PR are contained within the new /www directory. However some minor modifications have been made to existing content in the /docs directory:

* Modified frontmatter author block to always be an array
* Small markdown formatting tweaks
2017-09-28 10:18:04 -07:00
Matias Larsson
803b493314 Add ReactEurope 2018 Conference (#10914) 2017-09-28 14:19:58 +01:00
Nathan Hunzaker
4472442708 Remove allow transparency (#10823)
* Remove allowTransparency attribute

`allowtransparency` is an Internet Explorer-only attribute that
controls the background transparency of an iFrame. When set to true,
it respects the background color of the iFrame. When set to false, it
sets the background color to that of the document.

This feature was removed in IE9 - falling out of React's support
commitment.

Developers that have somehow figured out how to get IE8 to work with
React 16.x can still use `allowtransparency="true"`, since React now
supports unrecognized attributes.

* Use correct attribute script location

* Use new UMD bundles in attribute fixtures

* Update attribute snapshot

* Blank for CI
2017-09-28 12:53:59 +01:00
Spencer Miskoviak
a58e99371d Remove apostrophe (#10807)
* Remove apostrophe

* Update printInclusive default documentation
2017-09-27 23:05:52 +01:00
Dan Abramov
18506240c6 Delete LICENSE-examples (#10890)
We don’t have `examples` folder anymore (or any other folder with examples).
I think we can delete this?
2017-09-27 19:29:11 +01:00
Ivan Babak
9f6f7b3520 Fix fragments docs example JSX typo (#10885)
Fixes https://github.com/facebook/react/issues/10883
2017-09-27 19:28:04 +01:00
Dan Abramov
a947d3f92f Remove usage of ReactDOMFeatureFlags.useFiber, assuming true (#10796) 2017-09-27 17:14:27 +01:00
Syed Fazle Rahman
f50ff7e5d1 Add link to React community on Hashnode (#10874)
* Add link to React community on Hashnode

React community on Hashnode has more than 10K followers. It'd be nice if we can point developers to this place.

* Consistency in heading + remove the sales pitch-y bit
2017-09-27 17:06:46 +01:00
Cody Wall
7811677a49 Minor update to portals docs "child" language (#10870)
* Update portals docs "child" language

This commit changes the portals docs so that the language of the Parent
no longer feels like it is missing a word with "is not a child the div
with onClick handler" and replaces that with "is not a direct child of
the div with the onClick handler".

closes #10868

* Update portals.md
2017-09-27 17:04:11 +01:00
Dan Abramov
aad0970192 Remove Stack (part 1, safe: unused files and tests) (#10794)
* Remove Fiber Jest project

* Remove Stack reconciler and ReactDOMStack code

* Fix tests depending on Stack internals

* Fix Flow
2017-09-27 15:15:20 +01:00
Mario Schüttel
6955414465 "Write Code in Your Editor": Split step 5 into 2 steps (#10832)
* "Write Code in Your Editor": Split step 5 into 2 steps

To me it wasn't clear (enough) that I had to copy the file's content from [here](https://codepen.io/gaearon/pen/oWWQNa?editors=0010) *and* add the three lines to the top.

* Update tutorial.md
2017-09-27 13:17:23 +01:00
Dan Abramov
c0a87b2b8d Remove unnecessary event whitelist in production (#10802)
* Remove unnecessary top level event type whitelist

* Record sizes
2017-09-27 13:01:25 +01:00
Dan Abramov
2566b2420b Remove IE8 property expansion workaround (#10803)
* Remove IE8 property expansion workaround

* Edit from a plane ✈️
2017-09-27 12:59:59 +01:00
Leslie
ccb2f82a83 Fix a few typos (#10860) 2017-09-27 11:13:21 +01:00
Toru Kobayashi
7c78a38182 Add a note about deprecating react-addons-perf (#10743)
* Add a note about deprecating react-addons-perf

* Update addons-perf.md
2017-09-27 11:12:39 +01:00
Youngchan Je
1c77d4c0ff Fix typo on docs for React 16 (#10862) 2017-09-27 10:48:20 +01:00
Arthur Gunn
31eb1ba7c6 Update authors for v16 (#10861) 2017-09-27 10:24:16 +01:00
Dan Abramov
9ce135f863 Minor doc edit 2017-09-26 22:23:20 +01:00
Dan Abramov
138634f7da Update docs for React 16 (#10846) 2017-09-26 22:12:40 +01:00
Andrew Clark
706d2f4f9c Fix portal link (#10845) 2017-09-26 21:26:38 +01:00
Karl Horky
8b39991819 Update name of property initializer proposal (#10812)
The proposal for property initializers is called [Public Class Fields](https://tc39.github.io/proposal-class-public-fields/) now (part of the combined [Class Fields](https://github.com/tc39/proposal-class-fields) proposal).
2017-09-26 19:48:23 +01:00
Samuel
04799590fc Update Portals Documentation (#10840)
* Update Portals Documentation

Correct some grammar to be more explicit and clear. Update example CodePen to better match code found in documentation. Update code example styles to match other code examples (ie. 'State and Lifecycle', 'Handling Events').

* Clean up comment to be accurate to example

There was a small comment overlooked when reviewing the documentation. This fixes it to be accurate to the example as well as grammatically correct.

* Update portals.md

* More fixes
2017-09-26 19:45:48 +01:00
Kaylee Knowles
ba1396fb03 React.createPortal is not a function (#10843) 2017-09-26 19:41:30 +01:00
Dan Abramov
26cf268541 Fix note formatting 2017-09-26 19:01:38 +01:00
Samuel Reed
5120bf897c Doc change for prevContext removal in CDU (#10836)
* Doc change for prevContext removal in CDU

Ref: https://github.com/facebook/react/issues/8631

* Minor rewording
2017-09-26 18:29:35 +01:00
Dan Abramov
893919f6a7 Fix React links on the website (#10837)
* Fix React links on the website

* Fix code editor

* Fix code editor, attempt 2
2017-09-26 18:20:41 +01:00
Andrew Clark
5f6326f356 Doc updates for React 16 + blog post (#10824)
* Doc updates for React 16 + blog post

* Add link to Sophie's post
2017-09-26 09:04:14 -07:00
Andrew Clark
5c6ef40446 v16.0.0 2017-09-26 08:50:33 -07:00
Andrew Clark
b62d315950 Update CHANGELOG for React 16 2017-09-26 08:45:53 -07:00
Andrew Clark
7ccfbfc25d Update error codes 2017-09-26 08:44:21 -07:00
Andrew Clark
1fcdc020eb Flow should ignore node_modules/create-react-class 2017-09-26 08:41:07 -07:00
Andrew Clark
ec75ad1488 Bump object-assign patch range to match main package.json 2017-09-26 08:33:29 -07:00
Dan Abramov
4de45cfbec Add Nate to authors on master 2017-09-26 11:41:02 +01:00
Dan Abramov
9f8387a15f Add 15.6.2 blog post to master 2017-09-26 11:40:07 +01:00
Dan Abramov
e858ed5b14 Add changelog for 15.6.2 2017-09-26 11:37:12 +01:00
Toru Kobayashi
b9d55695e1 Add ReactTestRenderer documentations (#10692)
* Add ReactTestRenderer documentations

* Add TestRenderer documentations

* TestRenderer is not experiment

* Add a link for jsdom

* Use ES Modules syntax

* Twaek

* Add a Link component

* Use Jest assertions

* Move a documentation for createNodeMock to Idea section

* Renamed

* Tweak

* Rename

* More explicit

* Add a usecase for createNodeMock
2017-09-26 00:30:56 -07:00
Sophie Alpert
e932ad68be Version bumps to use MIT license 2017-09-25 18:17:44 -07:00
Sophie Alpert
b765fb25eb Change license and remove references to PATENTS
Only remaining references:

```
docs/_posts/2014-10-28-react-v0.12.md
51:You can read the full text of the [LICENSE](https://github.com/facebook/react/blob/master/LICENSE) and [`PATENTS`](https://github.com/facebook/react/blob/master/PATENTS) files on GitHub.

docs/_posts/2015-04-17-react-native-v0.4.md
20:* **Patent Grant**: Many of you had concerns and questions around the PATENTS file. We pushed [a new version of the grant](https://code.facebook.com/posts/1639473982937255/updating-our-open-source-patent-grant/).

src/__mocks__/vendor/third_party/WebComponents.js
8: * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
```
2017-09-25 18:17:44 -07:00
Sophie Alpert
d63249d034 Update license headers BSD+Patents -> MIT
Did find and replace in TextMate.

```
find: (?:( \*)( ))?Copyright (?:\(c\) )?(\d{4})\b.+Facebook[\s\S]+(?:this source tree|the same directory)\.$
replace: $1$2Copyright (c) $3-present, Facebook, Inc.\n$1\n$1$2This source code is licensed under the MIT license found in the\n$1$2LICENSE file in the root directory of this source tree.
```
2017-09-25 18:17:44 -07:00
Dan Abramov
b24d23d3e8 Update DOM warning wording and link (#10819)
* Update DOM warning wording and link

* Consistently use "Invalid" for known misspellings
2017-09-26 00:28:28 +01:00
Dan Abramov
6e8c09c363 Include tag name into the table snapshot (#10818) 2017-09-25 21:03:44 +01:00
Joe Critchley
f9bfd08a02 Markdown fixs on "DOM Attributes in React 16" post (#10816) 2017-09-25 18:57:42 +02:00
Toru Kobayashi
7b2101e352 Add a changelog for elements having the same key (#10811)
*  Add a changelog for elements having the same key

* Reword
2017-09-25 11:57:14 +02:00
Dan Abramov
4c45058355 Record sizes 2017-09-24 17:44:13 +02:00
Kenneth Chau
a160f3ecfa Fixes #9667: Updated createTextInstance to create the text node on correct document (#10723) 2017-09-22 16:08:19 -07:00
Flarnie Marchan
cdfbe6bb04 Update changelog for unreleased 16.0 changes (#10730)
* First shot at updating changelog for 16.0

**what is the change?:**
Added an 'unreleased' section to the changelog with info from https://github.com/facebook/react/issues/10294

**why make this change?:**
To get things set for the 16.0 release.

**test plan:**
Visual inspection

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

* Fix typos and formatting errors in changelog

* Add requestAnimationFrame and remove "New helpful warnings"

**what is the change?:**
In response to helpful code review -
- Add mention of dependency on `requestAnimationFrame` and need to
  polyfill that as well as `Map` and `Set`
- Remove "New helpful warnings" section; it was incomplete, and there
  are so many new and updated warnings that it might not be reasonable
  to cover them in the changelog.

**why make this change?:**
Accuracy

**test plan:**
Visual inspection

**issue:**
issue #8854

* Improve wording

* Improve wording and fix missing links

* Add backticks to file names & code; wording tweak

* Break "Major Changes" into "New Feature" and "Breaking Changes"

* Add server side render changes to 16.0 changelog

* Change gist link from mine to gaearons

* Add note about returning fragments

* fix misc nits

* Misc. formatting/wording fixes to changelog

**what is the change?:**
Thanks to the kind code review comments of @gaearon and @nhunzaker we
have
- removed the non-deterministic bold styling on some bullet points
- improved wording of the bullet points for portals, attribute whitelist
  changes, and server rendering changes
- Add note about error boundaries including a breaking change to error
  handling behavior.
- punctuation and capitalization fixes

**why make this change?:**
Clarity and correctness

**test plan:**
Visual inspection

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

* fix broken link
2017-09-22 15:22:39 -07:00
Robert Haritonov
dd00b47e1f Add React Amsterdam 2018 Conference (#10734) 2017-09-19 11:23:28 -07:00
Andrew Clark
b5ac963fb7 Push host root context when bailing out on low priority (#10712)
Prevents a push/pop mismatch when bailing out on HostRoots. This is
currently unobservable, because HostRoots never bail out on low
priority, but this does happen with prerendering.

I found this when rebasing #10624 on top of master.
2017-09-14 15:23:55 -07:00
Brian Vaughn
836d1c5d0c ReactNativeBridgeEventPlugin supports lazily-registered event types (#10679)
* ReactNativeBridgeEventPlugin supports lazily-registered event types
This accompanies changes on the native side to now specify which event types each view manager supports as part of its view config. Ultimately the goal is to lazily initialize view managers on the native side as well.
* Bubbling and direct attributes are optional on view config
This should help ease transition for pre-existing JS-only components.
2017-09-14 14:55:32 -07:00
Anuja Ware
3c98b2e0b0 Small typo fixed (#10701) 2017-09-14 14:39:17 -07:00
Clement Hoang
7caa035be5 Fix bug with toTree on rendered array #10616 (#10652)
* Fix bug with toTree on rendered array #10616

* Preserve previous behaviour of rendered being a node unless it's for rendering an array
2017-09-14 22:15:43 +01:00
Dan Abramov
c043c1e7d9 Remove View.propTypes RN deprecation workaround (#10683) 2017-09-14 19:46:24 +01:00
Dan Abramov
03443a2e23 Record sizes 2017-09-14 14:04:11 +01:00
Dan Abramov
b741916d37 16.0.0-rc.3 2017-09-14 13:59:29 +01:00
Dan Abramov
07f129bec2 Update error codes 2017-09-14 13:37:26 +01:00
Dan Abramov
d5d46df270 Update fbjs in lockfile 2017-09-14 13:32:23 +01:00
Dan Abramov
bacaf60e15 Update sizes 2017-09-14 13:27:27 +01:00
Dan Abramov
af36a05d5a Fix FB isomorphic build (#10704)
* Freeze bundle configs before the build

This ensures we don't accidentally mutate it.

* Fix config mutation during the build uncovered by freeze

* Fix FB isomorphic build by marking object-assign as an external

* Bye bye redundant check
2017-09-14 01:24:31 +01:00
Dan Abramov
aebd7f5454 Report bad dead code elimination to React DevTools (#10702)
* Report bad dead code elimination to React DevTools

* Fix lint
2017-09-13 23:51:42 +01:00
Dan Abramov
c99bad9483 Warn against custom non-lowercase attributes (#10699)
* Warn against custom non-lowercase attributes

* Update attribute table

* Grammar tweaks
2017-09-13 18:13:13 +01:00
Dan Abramov
c55ffb37f1 Fix false positive hydration warning for SVG attributes (#10676)
* Fix false positive hydration warning for SVG attributes

* Undo the generic fix

* Pass namespace through and use it to determine sensitivity
2017-09-13 16:31:40 +01:00
Dan Abramov
65b9ad94aa Fix context memory leak (#10680)
* Fix context memory leak

* Fix Flow
2017-09-12 21:47:09 +01:00
Dan Abramov
43dae749aa Stop exposing shallow renderer from TestUtils (#10682)
* Stop exposing ShallowRenderer from TestUtils

* Record sizes

* Lint
2017-09-12 19:29:28 +01:00
Dan Abramov
18d6cb5ebe Remove undocumented TestUtils methods (#10681) 2017-09-12 16:50:41 +01:00
Dan Abramov
89508f20d4 Make ReactDOM.createPortal() official (#10675)
* Validate portal container early

* Add ReactDOM.createPortal but leave unstable_ alias usable
2017-09-11 22:23:54 +01:00
Dan Abramov
f74981beee Share Object.assign polyfill between UMD builds (#10671) 2017-09-11 19:22:59 +01:00
Dan Abramov
61282d38d5 Remove toString-based minification check (#10673) 2017-09-11 19:22:41 +01:00
Dan Abramov
6552519a21 Update sizes 2017-09-11 16:51:58 +01:00
Thibaut Rizzi
af312ce006 Remove react proptypes references (#9759) 2017-09-10 17:37:22 -07:00
Matthew Shotton
b80e3ad1f5 Fix hint wording in tutorial.md (#9867)
The tutorial hints that a change can be made that allows you to go back
in time then click in the board to create a new entry, but the change is
already present in the example code.

This fix removes the hint and re-words the explanation of the change the
example code is making.
2017-09-10 17:28:32 -07:00
François Chalifour
83b63e5ff8 Fix test names in ReactDOMComponent-test (#10113)
* Fix test names in ReactDOMComponent-test

* Run record-tests script for Fiber
2017-09-10 14:52:09 -07:00
Brian Emil Hartz
6d37c05dd7 More explicit class method for ref doc (#10228)
After realizing this was the second time I've visited this exact page within a year and second guessing myself that the `textInput` ref isn't actually the `<input />` element. I decided to attempt to make this a little more explicit; you are actually accessing the method on the child class and not the `focus` method on the dom input element. Having them named the same caused some confusion.
2017-09-10 14:48:39 -07:00
zhangs
0440157608 the order of withRouter and connect is reset (#10658)
per [this link](https://github.com/ReactTraining/react-router/blob/master/packages/react-router/docs/api/withRouter.md) becasue ` If you are using withRouter to prevent updates from being blocked by shouldComponentUpdate, it is important that withRouter wraps the component that implements shouldComponentUpdate. `
2017-09-10 12:56:22 -07:00
Nikoloz Buligini
c294b0995a adds missing else clause (#10660) 2017-09-10 12:42:53 -07:00
Taegon Kim
f76467e8e5 Add React Seoul 2017 to the conferences list (#10661) 2017-09-10 12:41:03 -07:00
Jane Manchun Wong
1b72ef396e Update Sophie's name on various files (#10655) 2017-09-08 17:10:48 -07:00
Héliton Nordt
617f8810ba Improve displayName documentation (#10451)
* Improve displayName documentation

* displayName docs: higher-order component lowercased to stay consistent with the rest of the docs

* Rephrase displayName reference docs
2017-09-08 16:45:25 -07:00
Clement Hoang
11a1543b9e Reset effectTag to NoEffect instead of NoWork (#10653) 2017-09-08 16:00:35 -07:00
Sophie Alpert
2aa4988379 Update my name in most places 2017-09-08 15:45:55 -07:00
Sophie Alpert
8db2e11d97 Bump versions for 16.0.0-rc.2 (pick)
NOTE: This commit is not exactly what went out as RC2 because I forgot to push. See tag v16.0.0-rc.2 (d06680ea9e) instead. Bumping the version here so we're at the right place though.
2017-09-08 15:44:56 -07:00
Dan Abramov
5b5a0bd36c Blog post: DOM Attributes in React 16 (#10650)
* Blog post: DOM Attributes in React 16

* Testing the RC
2017-09-08 20:25:36 +01:00
Clement Hoang
7d77d795c2 Remove performWithPriority from scheduler (#10638) 2017-09-07 17:35:06 -07:00
guoyong yi
8b7082eced Add license headers on build bundles (#10490)
* Add license headers on build bundles

* Add the filename IMO to header

* Preserve headers in production bundles

* Use ECMASCRIPT5_STRICT to preserve "use strict"
2017-09-07 19:38:16 +01:00
Daniel Liburd
f1d00156df Add comment for renderToStringImpl parameter (#10634) 2017-09-07 10:05:19 -07:00
Robert Haritonov
79074a8059 add React Day Berlin (#10492) 2017-09-07 07:37:04 -04:00
Sophie Alpert
16a39b8f02 Remove "const" in uncompiled code (#10631)
Test Plan: All fixtures/packaging iframes display correctly on Chrome 38.0.2125.0 from https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Mac/290001/; previously several were blank with "Use of const in strict mode" errors logged to the console.
2017-09-06 20:32:15 -07:00
Sophie Alpert
d8ecc4c2b5 Update .mailmap 2017-09-06 16:58:21 -07:00
Flarnie Marchan
49c8d717a0 16.0.0-rc.1 (#10630) 2017-09-06 15:43:22 -07:00
Flarnie Marchan
b5a1c2281d Add missing dependencies in art fixture, update yarn.lock (#10628)
* Add missing dependencies in `art` fixture, update `yarn.lock`

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

**why make this change?:**
We want the `art` fixture to be working so that we can test the latest
version of `react-art`.

**test plan:**
Built and inspected the fixture manually

**issue:**
Prepping for 16.0RC release - https://github.com/facebook/react/issues/10623

* ran prettier
2017-09-06 15:37:09 -07:00
Brian Vaughn
abce30f771 React native event type fixes (#10627)
* Added invariant check for native dispatching an unsupported event type
This prevents a case of a silent failure when native dispatches an event that JavaScript does not know how to handle.

* Added iOS direct event type 'onSnapshotReady'
This is used for snapshot testing.
2017-09-06 15:34:02 -07:00
Sophie Alpert
7ff922cf2a Pull in react-art/lib/{Circle,Rectangle,Wedge}.art (#10629)
* Import react-art/lib/{Circle,Rectangle,Wedge}.art

Copied from react-art@0.15.1 built files.

* Changes to built files to make ART shapes work

Test Plan: Opened the fixture. React logo shows up with its normal dot, now rendered by a `<Circle />`.
2017-09-06 15:10:14 -07:00
Flarnie Marchan
4a351eacdd Update to latest allowed versions of fbjs and prop-types (#10626)
**what is the change?:**
Updates to the latest allowed versions for two dependencies.

`yarn upgrade 'fbjs@^0.8.9'`
and
`yarn upgrade 'prop-types@^15.5.8'`

**why make this change?:**
Prepping for the 16.0 RC, we want to have a reproducible build that is
as close as possible to what new users will get when installing React.

**test plan:**
`yarn && yarn build && yarn test`

**issue:**
https://github.com/facebook/react/issues/10623
2017-09-06 14:29:23 -07:00
Flarnie Marchan
8e4654015a Update error codes and results.json (#10619)
* Update results.json

**what is the change?:**
Ran the build after updating Yarn lockfile and recorded latest build
size results.

**why make this change?:**
Let's get an idea of bundle size at this point, when we are preparing
the 16.0 RC.

**test plan:**
NA

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

* Update error codes

https://github.com/facebook/react/tree/master/scripts/release-manager#update-the-error-codes
2017-09-06 11:11:19 -07:00
Dan Abramov
faf186b235 Generate Markdown table from attribute fixture (#10595)
* Generate Markdown table

* Check in generated table

* Add fast mode

* Fix lint
2017-09-06 16:00:52 +01:00
Daniel Rotter
5f12867824 Add AgentConf 2018 (#10614)
* Add AgentConf 2018

We are having another edition of the AgentConf in 2018, which has again a strong focus on react, and we'll be skiing again 😎 Last year's PR for reference: https://github.com/facebook/react/pull/8196

* Update conferences.md
2017-09-06 08:56:36 -04:00
Andrew Clark
47d87028a7 Moar attribute tests (#10509)
* WIP

* WIP Add the rest of the tests for what we expect re: unknown attributes

**what is the change?:**
Adds tests for the following behavior -

- Numbers and booleans should be converted to strings, and not warn
- NaN, Symbols, functions, and objects should be converted to strings,
  and *should* warn

Going to add tests for the not-warning behavior in a follow-up.

These tests are not entirely passing - we either need to change what we
expect or change the behavior.

**why make this change?:**
Gets everyone on the same page about expected behavior, and codifies it
in a maintainable way

**test plan:**
`yarn test src/renderers/dom/shared/__tests__/ReactDOMAttribute-test.js`

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

* WIP Add check that we *don't* warn when handling some unknown attributes

**what is the change?:**
We are testing the behavior of unknown attributes, which has changed
since React 15.

We want to *not* warn for the following cases -
- null
- undefined
- missing
- strings
- numbers
- booleans

**why make this change?:**
We want to verify that warnings don't get fired at the wrong time.

**test plan:**
`yarn test src/renderers/dom/shared/__tests__/ReactDOMAttribute-test.js`

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

* ran prettier

* Symbols and functions passed to unknown attributes should remove and warn

* Abstract tests a bit to make them easier to read

* Remove Markdown from test names

I don't think we use this convention anywhere.

* Add an assertion for NaN warning message

* Update ReactDOMAttribute test based on attribute fixture

**what is the change?:**
- booleans don't get stringified
- some warnings have changed since we originally wrote this

**why make this change?:**
The attribute behavior is finalized and now we can test it :D

I also found it handy to have a row with a truly unknown attribute, so
added "imaginaryFriend".

**test plan:**
`yarn test src/renderers/dom/shared/__tests__/ReactDOMAttribute-test.js`
and comparing the tests to the attribute table

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

* remove imaginaryFriend to resolve conflict

* ran prettier
2017-09-05 11:25:23 -07:00
David Beitey
89edcf2388 Fix minor typo in Firefox name (#10605) 2017-09-05 10:28:54 -07:00
Nikita Lebedev
a8845587a3 Fix typo in script function name (#10611) 2017-09-05 10:28:34 -07:00
Dan Abramov
3f6e8d2803 Fix warning deduplication in attribute table (#10594)
* Fix warning deduplication by eval-ing React

* Move checkbox to the left

* Fix alphabetical sort

* Fix the pooling logic

* Avoid false positive warning due to controlled/uncontrolled switch

* Naming: 15 => Stable, 16 => Next

* Prettier

* Add "Save" button
2017-09-01 18:37:45 -07:00
Brandon Dail
80411ea9b4 Default to first non-disabled option for select elements (#10456)
* Default to first non-disabled option for select

Instead of defaulting to the first option for a select element, which could be a disabled option, we find the first non-disabled option available while we looping through the options. If no option matches, set the first non-disabled option as selected.

* Add ReactDOMSelect test for defaulting to non-disabled options

* Add test fixtures to cover disabled selected options

* Fix bad merge
2017-09-01 13:34:28 -07:00
Eric Nakagawa
f6ceacdd44 Adding Crowdin config file to master repo (#10579)
* Adding Crowdin config file to master repo

* Updated to include additional files while ignoring localized community files stored on github

* Additional files ignored

* Included additional files in root docs directory
2017-09-01 11:33:18 -07:00
Dan Abramov
9f772abdc6 Update sizes 2017-08-31 22:35:42 -07:00
Dan Abramov
fdf9d32a2e Ensure attribute table server-renders SVG inside SVG container (#10588) 2017-08-31 18:41:50 -07:00
Dan Abramov
55209c8cc9 Don't treat dashed SVG tags as custom elements (#10586) 2017-08-31 18:24:23 -07:00
Dan Abramov
de05d2eded Remove disableNewFiberFeatures flag (#10585) 2017-08-31 18:23:08 -07:00
Andrew Clark
edc9c2fc70 [attribute-behavior] Canonicalize values immediately after reading them (#10584)
In case they are mutated
2017-08-31 16:46:44 -07:00
Brian Vaughn
e34ac7c066 Embed ReactNative event types in JavaScript (#10567)
* ReactNative doesn't query UIManager for native event types
This is a pre-req to unblock Prepack optimiations for ReactNative apps
* Replaced mock ReactNativeEventTypes with mock Platform
* Added Platform.OS to RN host hooks Flow types
2017-08-31 15:27:54 -07:00
Brian Vaughn
8bd5b489b4 Defer reading native view config from UIManager until view is used (#10569)
* ReactNative supports lazy view registration
Don't react viewConfig from UIManager when a view is registered, but only when it is used for the first time. This will help unblock Prepack optimizations for RN views.

* Added new lazy-creation method for native views
Also exposed the native view config registry to allow invalid/unsupported host components to fall back to RCTView

* Removed ReactNativeViewConfigRegistry from RN __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
After discussion with Spencer Ahrens and Andy Street, it seems the early fallback behavior was mostly for the early days of Ads Manager when Android didn't yet support a lot of the view types. It should be okay now to use an invarient/redbox instead for unsupported views.

* Removed non-lazy createReactNativeComponentClass impl
There are only a handful of components with JavaScript-defined view configs. It's probably worth making them use the new lazy/async interface as well to be more consistent.
2017-08-31 13:42:27 -07:00
Nathan Hunzaker
c1dbc8e470 Changes to attribute whitelist logic (#10564)
* Remove HTMLPropertyConfig entries for non-boolean values

When we originally removed attributes from the whitelist, we assumed a
few attributes were string booleans, but they are not:

Autocomplete ("on", "off")
https://developer.apple.com/library/content/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/Attributes.html#autocomplete

Autocapitalize ("none", "sentence", "words", ...)
https://developer.apple.com/library/content/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/Attributes.html#autocapitalize

Autocorrect ("on", "off")
https://developer.apple.com/library/content/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/Attributes.html#autocorrect

Autosave (string)
https://developer.apple.com/library/content/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/Attributes.html#autosave

* Only HAS_BOOLEAN_VALUE attribute flag can assign booleans

* Use a non-boolean attribute in object assignment tests

* Add HAS_STRING_BOOLEAN_VALUE attribute flag

* Fix boolean tests, add boolean warning.

* Reserved props should allow booleans

* Remove outdated comments

* Style tweaks

* Don't treat dashed SVG tags as custom elements

* SVG elements like font-face are not custom attributes

- Adds exceptions to isCustomAttribute for dashed SVG elements
- Use consistent custom element check across all modules

* Move namespace check to isCustomAttribute. Add caveat for stack.

* Remove unused namespace variable assignment

* Fix the DEV-only whitelist

* Don't read property twice

* Ignore and warn about non-string `is` attribute

* Blacklist "aria" and "data" attributes

* Don't pass unknown on* attributes through

* Remove dead code

* Avoid accessing namespace when possible

* Drop .only in ReactDOMComponent-test

* Make isCustomComponent logic more solid

* Do attribute name check earlier

* Fix fbjs import

* Revert unintentional edit

* Re-allow "data" attribute

We intentionally allowed it.

* Use stricter check when attaching events

* Pass SVG boolean attributes with correct casing

* Fix the test

* Undo the SVG dashed-name fix

Per conversation with @sebmarkbage we decided that the fix is too complicated, and it's unfortunate it depends on the DOM element.
It's only relevant for super rare tags that aren't even working consistently across browsers so we'll leave it unfixed for now.

* Prettier

* Fix lint

* Fix flow

* Pass "aria" through but still warn

* Remove special cases for onfocusin, onfocusout

They're covered by event handler code now.

* Add a more specific warning for unknown events

* Pass badly cased React attributes through with warning
2017-08-30 18:28:55 -07:00
Andrew Clark
a6e34cc25f Track nested updates per root (#10574)
We track nested updates to simulate a stack overflow error and prevent
infinite loops. Every time we commit a tree, we increment a counter.
This works if you only have one tree, but if you update many separate
trees, it creates a false negative.

The fix is to reset the counter whenever we switch trees.
2017-08-30 18:17:48 -07:00
Andrew Clark
88a079d5c2 [attribute-behavior] Track differences between DOM and server renderer (#10575)
* Load ReactDOMServer into attribute table

* Highlight differences between DOM and server renderer

* Use SSR behavior when comparing behavior across renderers

* Use less severe color if SSR differences are only due to warnings

* Ensure result node's tagName matches what's expected

* Throw on unexpected HTMLUnknownElement
2017-08-30 18:17:31 -07:00
Jason Quense
1924c28a54 Update issue template with PropTypes package (#10578)
Adds `prop-types` to the template
2017-08-30 16:35:29 -04:00
Brian Vaughn
5ee72dcd82 Add --sync-www flag to build script (#10571) 2017-08-30 09:38:14 -07:00
Brian Vaughn
99171321c3 Lint command fails if there are any warnings (#10572)
You get a lint failure! You get a lint failure! Eeeeverybody gets a lint failure!
2017-08-30 08:03:17 -07:00
Brian Vaughn
cd52f7ed80 Fixed lint error in ReactErrorUtils-test (#10570) 2017-08-29 17:54:36 -07:00
Tyler Deitz
f5547ee372 Update reference-events.md (#10554) 2017-08-29 08:11:45 -07:00
Andrew Clark
dd9db8b9d2 Add ability to "complete" rows and store state in localStorage (#10562)
* Add ability to "complete" rows and store state in localStorage

* Sort groups based on size

Also: include tagName and containerTagName in info object.

* Tweak sort order
2017-08-28 19:44:26 -06:00
Dan Abramov
2add1ed1b9 Fix {false} test in attribute table 2017-08-28 16:31:08 -07:00
Dan Abramov
c813c82e45 More consistent hashing (#10561) 2017-08-28 16:39:19 -06:00
Dan Abramov
ed0ceb4f07 Disable hasOwnProperty test in attribute table (#10560) 2017-08-28 15:46:38 -06:00
Brian Vaughn
d8d7edde5d Upgrade flow-bin to 0.53.1 (#10510)
* Update flow-bin to 0.53.1

* Ran flow-upgrade utility
Manually corrected a few over-eager cases where it tried to replace our ReactElement sub-type.

* Replaced a couple of React.Element types with React

* Removed temporary ReactComponent/ReactComponent Flow types

* Prettier

* Replaced React with React based on Dan's PR feedback
2017-08-28 14:39:58 -07:00
Dan Abramov
ebb5a33ec2 Tweak attribute whitelist table (#10559)
* Move null and undefined to the end

* Highlight attributes with changes
2017-08-28 15:13:35 -06:00
Sebastian Markbåge
575cfadf3e Read SVG properties instead of attributes where applicable (#10549)
Also canonicalize object results (since these SVG properties are objects).

The canonicalized format is what we compare against.

(This will cause unknown objects to show up as unchanged.)
2017-08-28 14:11:32 -07:00
Mitermayer Reis
7f78749ee3 Updating param flow type definition (#10558) 2017-08-28 11:06:56 -07:00
zombieJ
c282a8ef4f Refactor ensureUpdateQueues to avoid returning a tuple (#10437)
* remove tuple

* clean up

* prettier code

* Use module-level varibles
2017-08-28 11:04:28 -07:00
Mitermayer Reis
a7c479b3e9 Fixing incorrect documentation tags (#10530) 2017-08-26 16:53:37 -07:00
Flarnie Marchan
c0a41196e6 [attribute-behavior] Add alphabetical and rev-alphabetical sorting (#10546)
* Add alphabetical and rev-alphabetical sorting

This is just an initial convenient way to jump to the top or bottom of
the list.

Next we will add a sorting which groups rows together if their behavior
pattern is the same.

* Add sorting to group the rows by behavior pattern

**what is the change?:**
Another sorting option - if the content of a row is the same, it takes
those rows and groups them together.

**why make this change?:**
This will help us find groups of attributes that behave similarly.

**test plan:**
manual testing

* rename variable to be more clear
2017-08-25 18:03:25 -07:00
Sebastian Markbåge
d7fcdd9c7a Use proper SVG tags for all SVG attributes and read using a special function (#10545) 2017-08-25 17:27:07 -07:00
Andrew Clark
b9c8e4e9df Remove UMD builds from fixture directory (#10547) 2017-08-25 17:17:31 -07:00
Andrew Clark
be9d982e8f [attribute-behavior] Use development builds of React and ReactDOM (#10544)
Enables warning detection.

Start-up is noticeably slower, but after that the perf is about the same.
2017-08-25 15:44:37 -07:00
Andrew Clark
2d5c4542df Update eslintignore and prettier config to ignore UMD builds of React 2017-08-25 11:35:43 -07:00
Andrew Clark
e421df8151 Add basic popover with additional information 2017-08-25 11:35:43 -07:00
Andrew Clark
87a32314ae Delete vestigial CRA files 2017-08-25 10:43:47 -07:00
Andrew Clark
5fd942a03c Move attribite-behavior to fixtures 2017-08-25 10:40:09 -07:00
Andrew Clark
b775e74e4e Use monospace font-family 2017-08-25 10:37:46 -07:00
Andrew Clark
888c537121 Wrap string values in quotes
All other types are formatted as as <type: param>
2017-08-25 10:37:46 -07:00
Andrew Clark
5f71165486 Add table of attribute behavior (#10536)
* [WIP] Table of attribute behavior

* getAttribute helper

* add getters for attributes V-Z

* More special cases

* Add getters for more attributes

* Add tagName to attribute config

* Switch default accessor to getProperty instead of getAttribute

* Add containerTagName and tagName config

* Compare result to default value

* Add overrideStringValue config option

* add section for Sebastian and update a couple more attributes

* 'array with string' should use string override, too

* Add additional value types

Strings on, off, true, false

* more attribute updates

* More attributes

* Remove old directory

* add more attribute configs

* More attributes

* just a couple more attribute updates

* More attributes

* Fix the seb parts

* Fix the seb parts

# Conflicts:
#	scripts/attribute-behavior/src/App.js

* More attributes

* Prettier

* More attributes

* More attributes

* Fix some bugs in seb's set

* Fix the rest of flarnie's section

* More attributes

* Prettier

* Finish my section (Andrew)

* Compare against UMD build of master

Once we get past MVP stage we can hook this up to the build system so
these files are automatically copied over.

* Fix attributes that don't have compatible properties

Avoid all undefined reads.

* Test multiple input types

Tests different input types and valueAsNumber property. This value is often
NaN. To compare that we also need to switch to Object.is.

* Ignore checked in copies of React 15 bundles in attribute fixture

**what is the change?:**
We checked in bundles of React v15 to run comparisons of attribute
behavior on DOM elements between 15 and 16.

This commit tells prettier and eslint to ignore those files, and fixes a
prettier lint in one other file from that fixture.

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

**test plan:**
`yarn prettier` doesn't change anything, eslint passes

**issue:**

* update README for attribute table fixture

* run prettier again
2017-08-25 10:03:30 -07:00
Mitermayer Reis
0e556fef24 Adding the correct argument name to documentation tag (#10529) 2017-08-25 09:15:47 -07:00
Mitermayer Reis
c39a976be7 Removing unecessary assignment (#10528) 2017-08-25 07:58:49 -07:00
Andrew Clark
83393bc2be Enable opt-in to async mode (#10535)
When the feature flag enableAsyncSubtreeAPI is true,
React.unstable_AsyncComponent creates an async subtree. When it's false,
it behaves like a normal, sync React component. We use this flag in www
as a fail safe so that if we ship an async bug, we can set the flag to
false and revert back to sync mode.

For open source, we should enable the feature flag.
2017-08-24 10:54:03 -07:00
Brandon Dail
1f55e2dcf8 Put warnForInvalidEventListener call behind nextProp check (#10527) 2017-08-23 23:34:12 -05:00
Brian Vaughn
2fa38ac1cc Delete ReactNativeStack 🎉 🎉 🎉 (#10511)
* Removed createReactNativeComponentClassStack and renamed createReactNativeComponentClassFiber => createReactNativeComponentClass

* Removed findNumericNodeHandleStack and renamed findNumericNodeHandleFiber => findNumericNodeHandle

* Renamed ReactNativeFiberEntry => ReactNativeEntry

* Removed all references to ReactNativeFeatureFlags and RN stack

* Removed severl RN modules that are no longer used

* Renamed ReactNativeEntry => ReactNativeFiberEntry for now. We'll probably remove 'fiber' references later

* Update build results json

* Deleted snapshot

* Re-add accidentally deleted test

* Remove now-unnecessary hack in test

* Fix lint

* RN findNodeHandle no longer adds props directly to read-only owner (#10520)

* Added ReactNativeMount-test snapshot for 'renders and reorders children' test
2017-08-23 15:53:55 -07:00
Brandon Dail
34780da5c8 Warn early for non-functional event listeners (#10453)
* Add early warning for non-functional event listeners

* Use functional listeners in ReactDOMComponent test

To avoid triggering the non-functional event listener component

* spy on console.error in non-function EventPluginHub test

This should warn from ReactDOMFiberComponent, but we just ignore it here

* Remove redundant check for listener

* Add expectation for non-functional listener warning in EventPluginHub

* Hoist listener typeof check in hot paths

* Include stack addendum in non-functional listener warning

* Make it pretty

* Remove it.onnly from ReactDOMFiber test

* Fix message

* Update expected message

* Change invariant message to match the new style

* Fix remaining warning
2017-08-23 13:38:48 +01:00
Brian Vaughn
6ab2869a20 RN (fiber) avoids the overhead of bridge calls if there's no update. (#10505)
This is an expensive no-op for Android, and causes an unnecessary view invalidation for certain components (eg RCTTextInput) on iOS.
2017-08-22 13:31:46 -07:00
Ben Alpert
640eb70446 Revert "Use the virtual target for change events to avoid restoring controlled state on the real target (#10444)" (#10504)
This reverts the meaningful (src, non-test) part of commit 3bc64327f0 since we've reverted the commit it depended on in 18083a8a73. I don't fully understand the negative implications of leaving this unreverted but it sounds like consensus is that it's safer to revert.

I left the new fixture and verified it works correctly in Chrome 62 Mac, as well as the jest tests passing.
2017-08-21 17:51:26 -07:00
Nathan Hunzaker
35859df941 Add missing single-word attributes to property warning list (#10495)
* Add missing single-word attributes to property warning list

* Alphabetize svg and html configs in possible names

* Add basic test coverage for known single word attributes

* Add note about including whitelist properites in `possibleStandardNames

* Also add attribute sync comment to possibleStandardNames
2017-08-21 12:27:09 -04:00
Alexander
ec77740ac3 Add renderer id to react-devtools injection (#10475)
* add renderer id to react-devtools injection

* rename renderer id to rendererPackageName in react-dom injection

* add rendererPackageName to react-native entries
2017-08-21 12:10:44 +02:00
Brian Vaughn
e464cf2def Removed ReactNativeFeatureFlag shim from RN bundle (#10472) 2017-08-18 08:26:11 -07:00
Flarnie Marchan
18083a8a73 Revert "Remove old IE polyfill code" (#10483)
**what is the change?:**
This reverts 0b220d0f04
Which was part of https://github.com/facebook/react/pull/10238

**why make this change?:**
When trying to sync the latest React with FB's codebase, we had failing
integration tests.

It looks like they are running with an old version of Chrome and there
is something related to file upload that fails when these polyfills are
missing.

For now we'd like to revert this to unblock syncing, but it's worth
revisiting this change to try and add some polyfill for FB and remove it
from React, or to fix whatever the specific issue was with our file
upload error.

**test plan:**
`yarn test` and also built and played with the `dom` and `packaging`
fixtures
2017-08-17 16:19:41 -07:00
Andrew Clark
caaa0b047d Reset instance vars before calling commit phase lifecycles (#10481) 2017-08-17 13:52:38 -07:00
Jack Ford
072b1d9860 Add invariant check for composite components to event simulation test utils (#10414)
* Add invariant check for composite components to event simulation test utils

* Change simulate variable names from domComponentOrNode to domNode, language for new simulate invariant, and add space in existing invariant

* Update test name

* Update test for invariant with shallow rendering

* Update text for existing invariant and change comments to reflect change to only domNode usage

* Update text for existing invariant to reflect syntax with new invariant

* Update ReactTestUtilsEntry.js

* Update React element invariant to reflect usage with shallow rendering

* Move Simulate-related tests into Simulate block

* Run prettier
2017-08-17 20:23:36 +02:00
Flarnie Marchan
149860bada Replace object getter with Object.defineProperty in TestRenderer (#10473)
* Add babel transform for object getters

**what is the change?:**
We were not transforming object getters[1], and our new TestRenderer
uses one.[2]

[1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get
[2]: https://github.com/facebook/react/blob/master/src/renderers/testing/ReactTestRendererFiberEntry.js#L569

**why make this change?:**
Our internal build system was not supporting object getters.

**test plan:**
`yarn build && yarn test`
Also built and opened the 'packaging' fixture.

Honestly I'm not sure what else to test, this seems pretty low risk.

**issue:**
None opened yet

* Replace object getter with `Object.defineProperty` in TestRenderer

**what is the change?:**
Replaces an Object Getter [1] with `Object.defineProperty`.

[1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get

**why make this change?:**
Our internal build system does not support object getters.

**test plan:**
We should do follow-up work to ensure that this doesn't come up again -
we can't commit code which uses object getters.

**issue:**
No issue opened yet

* Tweak the Object.defineProperty call in test renderer to make flow pass

**what is the change?:**
- switched from `Object.defineProperties` to `Object.defineProperty`
- set some undefined properties to get flow to pass

**why make this change?:**
- Flow doesn't seem to play nicely with `Object.defineProperty/ies`
  calls, specifically when you implement `get` and `set` methods.
  See https://github.com/facebook/flow/issues/1336
- Switched from `properties` to `property` because it seems more
  conventional in our codebase to use `property`, and I'm only setting
  one anyway.

**test plan:**
`flow`

**issue:**
no issue

* More flow type tweaking

**what is the change?:**
Forced the typing of an argument to 'Object.defineProperty' to be
'Object' to avoid an issue with Flow.

**why make this change?:**
To get tests passing and flow passing.

**test plan:**
`flow && yarn test`

**issue:**
2017-08-17 07:23:16 -07:00
Flarnie Marchan
34092a0f24 Throw error to warn of mistaken loading of prod + dev React bundles (#10446)
* Throw error to warn of mistaken loading of prod + dev React bundles

**what is the change?:**
Credit to @gaearon for coming up with a clever way to check for this. :)

I mainly just did the manual testing and fixed a couple of typos in his
idea.

I'd like to do a follow-up PR to add a link and a page explaining this
issue more and suggesting how to fix it.

**why make this change?:**

We want to warn for an unfortunate gotcha for
the following situation -
1. Wanting to shrink their JS bundle, an engineer runs it through
   'uglifyjs' or some other minifier. They assume this will also do
   dead-code-elimination, but the 'prod' and 'dev' checks are not
   envified yet and dev-only code does not get removed.
2. Then they run it through browserify's 'envify' or some other tool to
   change all calls to 'process.env.NODE_ENV' to "production". This
   makes their code ready to ship, except the 'dev' only dead code is
   still in the bundle. Their bundle is twice as large as it needs to
   be, due to the dead code.

This was a problem with the old build system before, but with our new
build system output it's possible to detect and throw an informative
error in this case.

**test plan:**
1. run the build in react as usual; `yarn build`
2. manually run 'uglifyjs -mt' on 'build/packages/react/index.js' to
   simulate mistakenly minifying React before env variables are
   resolved, which skips dead code elimination.
3. run the fixtures build - `cd fixtures/packaging && node
   ./build-all.js && serve ../..`
4. Visit just the production browserify fixture -
   http://localhost:5000/fixtures/packaging/browserify/prod/
5. You should see the error thrown indicating this problem has occurred.
(Flarnie will insert a screenshot)
6. Do the above steps with NO uglifyjs step, and verify that no error is
   thrown. When there is no minification applied, we don't assume that
   this mix-up has occurred.
(Flarnie will insert a screenshot)

**issue:**
fixes #9589

* Remove extra 'prod' env. check and add link to docs in error message

**what is the change?:**
Based on helpful feedback from @gaearon
- removed outer check that `process.env.NODE_ENV` is "production" since
  we are only calling the `testMinification` method inside of another
  check for "production" environment.
- Added an fburl that points to [our current docs on using the production version of React](https://facebook.github.io/react/docs/optimizing-performance.html#use-the-production-build)

**why make this change?:**
To save an extra layer of conditionals and to make the error message
more clear.

**test plan:**
Same test plan as earlier -

1. run the build in react as usual; yarn build
2. manually run 'uglifyjs -mt' on 'build/packages/react/index.js' to
   simulate mistakenly minifying React before env variables are
   resolved, which skips dead code elimination.
3. run the fixtures build - cd fixtures/packaging && node ./build-all.js && serve ../..
4. Visit just the production browserify fixture -
   http://localhost:5000/fixtures/packaging/browserify/prod/
   You should see the error thrown indicating this problem has occurred.
   (Flarnie will insert a screenshot in comments on the PR)
6. Do the above steps with NO uglifyjs step, and verify that no error is thrown. When there is no minification applied, we don't assume that this mix-up has occurred.
(Flarnie will insert a screenshot in the comments on the PR.)

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

* WIP fix and test 'testMinificationUsedDCE' method

**what is the change?:**
- Instead of looking for one match when having the method inspect it's
  own source, we look for two matches, because the search itself will be
  a match.
- WIP moving this method into another file and testing it.

Next steps:
- Figure out why the babel.transform call is not actually minifying the
  code
- Add tests for uglifyjs
- Update build process so that this file can be accessed from
  `packages/react/index.js`

**why make this change?:**
- We had a bug in the 'testMinification' method, and I thought the name
  could be more clear. I fixed the code and also changed the name.
- In order to avoid other bugs and keep this code working in the future
  we'd like to add a unit test for this method. Using the npm modules
  for 'uglifyjs' and 'babel'/'babili' we should be able to actually test
  how this method will work when minified with different configurations.

**test plan:**
`yarn test`

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

* Add babeli and uglifyjs as dev-only dependencies

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

**why make this change?:**
In order to test that we are correctly detecting different minification
situations, we are using these modules in a test.

**test plan:**
NA

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

* Fix typo and add 'uglifyjs' tests

**what is the change?:**
There was a mix-up in the conditional in 'testMinificationUsedDCE' and
this fixes it.

The great new tests we added caught the typo. :)

Next steps:
- get the tests for 'babili' working
- update build scripts so that this the 'testMinificationUsedDCE'
  module is available from 'packages/react/index.js'

**why make this change?:**
We want to modularize 'testMinificationUsedDCE' and test it.

This verifies that the method warns when `uglifyjs` is used to minify
but dead code elimination is not done, in a production environment.
Generally this is a 'gotcha' which we want to warn folks aboug.

**test plan:**
`yarn test src/shared/utils/__tests__/testMinificationUsedDCE-test.js`

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

* Run prettier

* var -> const/let

* Require specific version of `uglify-js`

**what is the change?:**
Removed the '^' from the npm package requirement

**why make this change?:**
I am seeing failures in CI that show `uglify-js` is returning different
output there from my local environment. To further debug this I'd like
to run CI with the exact same version of `uglify-js` that I am using
locally.

**test plan:**
push and see what CI does

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

* Add build step copying testMinificationUsedDCE into build/packages/react/cj

**what is the change?:**
This is a first step - we still need (I think) to process this file to
get it's contents wrapped in an 'iffe'.

Added a step to the build script which copies the source file for the
'testMinificationUsedDCE' module into the 'cjs' directory of our react
package build.

**why make this change?:**
We want this module to be available to the 'index.js' module in this
build.

**test plan:**
Will do manual testing once the build stuff is fully set up.

**issue:**

* Inline 'testMinificationUsedDCE' and remove unit test for now

What:
- Inlines the 'testMinificationUsedDCE' method into
  'packages/react/index.js'
- Removes unit test for 'testMinififcationUsedDCE'
- Puts dependencies back the way that they were; should remove extra
  dependencies that were added for the unit test.

Why:
- It would add complexity to the build process to add another file to
  the 'build/packages/react/cjs' folder, and that is the only way to
  pull this out and test it. So instead we are inlining this.

* Revert unintentional changes to dependency versions, variable placing

**what is the change?:**
- We had updated and added some dependencies, but ended up reverting
  this in a previous commit. The `yarn.lock` and `package.json` needed
  updated still though.
- There is a call to `Function.toString` which we wanted to wrap in a
  `try/catch` block.

**why make this change?:**
To remove unrelated dependency changes and increase the safety of the
`Function.toString` call.

**test plan:**
Manual testing again

**issue:**
https://github.com/facebook/react/issues/9589
2017-08-16 11:44:31 -07:00
Nathan Hunzaker
5ba1803ba2 Custom attribute follow up (#10470)
* Wrap ARIA prop warnings in backticks.

* Use accurate test names after updating custom attribute logic
2017-08-16 16:07:08 +02:00
Karthik Balakrishnan
7e297e9b20 Add ReactFoo 2017 to list of upcoming conferences (#10467) 2017-08-16 08:10:28 -04:00
ksvitkovsky
488e7413ca Use only public API in CSSProperty-test (#10429)
* Use only public API in CSSProperty-test

* Move test to ReactDOMServerIntegration

* Add explanation
2017-08-16 10:09:03 +02:00
Nathan Hunzaker
2999811b07 Custom Attributes Scenario 2: Write badly cased attributes. Remove most of whitelist. (#10385)
* Allow custom attributes. Add flag to toggle custom attribute behavior

* Update custom attribute logic

- Only allow string attributes
- Remove custom attribute feature flag
- Add additional tests for data, aria, and custom attributes

* Allow numbers and booleans custom attributes. Cut isCustomAttribute

* Cover objects with custom attributes in warning test

* Rename DOMProperty.isWriteable to shouldSetAttribute

* Rework conditions in shouldSetProperty to avoid edge cases

* Update unknown property warning to include custom attribute information

* Remove ref and key from reserved props

* Ensure SSR test coverage for DOMProperty injections

* Add ajaxify attribute for internal FB support

* Ajaxify is a stringifiable object attribute

* Remove non-case sensitive standard attributes. Make ARIA hook dev only.

* Update test name for custom attributes on custom elements

* Remove SSR custom injection test

* Remove case sensitive props

* Remove onAfterResetModules hooks in SSR render tests

* Add back a few attributes and explain why they are needed

* Remove possibleStandardNames from DOMProperty.js

* Fix typo in HTMLPropertyConfig comment

* Remove duplicative comment

* Add back loop boolean property

* Do not allow assignment of attributes that are aliased

* Update custom attribute test to check value, not just presence

* Address case where class is assigned as an attribute on custom elements. Improve SSR tests

* Cover cases where className and for are given to custom elements

* Remove unnecessary spys on console.error. Reduce extra space in tests

* Cover cased custom attributes in SSR tests

* Custom attributes are case sensitive

* Allow uppercase letters in custom attributes. Address associated edge cases

* Allow improperly cased aliased attributes. Add additional tests

* Handle special properties like onFocusOut

* Add some comments to document where casing matters. Remove DOMPropertyNames

* Fix spelling mistake in ajaxify HTML property comment

* Make ARIA enforcement dev-only

* Remove alias test that covers multiple aliases for one property

* Fix typo in comment

* Build SVG aliases dynamically

* Remove unused DOMPropertyNames reference

* Do not translate bad casings of aliased attributes

- classname writes to the DOM as classname
- class does not write to the DOM
- cLASS does not write to the DOM
- arabic-form does not write to the DOM

* Revise the way custom booleans are treated

- Custom attributes can not have boolean values unless they are aria
  or data attributes
- Attributes with boolean values have been added back to the whitelist
- Warnings now exclude booleans from supported types
- Associated test coverage

* Add developer warnings for NaN and ARIA hooks

* Use string comparison instead of regex to check for data and aria attributes.

* Warn about unsupported properties without case sensitivity

* Remove attributes that are updated to invalid values

* Support object property values with toString methods. Allow boolean props to coerce objects

* Add back ajaxify test

* Address bad references in ReactDOMComponent-test. Format.

* Revert changes to the docs

We'll update them separately

* Allow all objects and pass incorrect aliases
2017-08-15 09:00:44 -07:00
Ian Sutherland
7f6b940919 Added unit tests for creating an element with a ref in a constructor. Only set ReactCurrentOwner.current in dev mode when the component has no constructor. (#10025) 2017-08-15 11:21:49 +02:00
Brian Vaughn
b4a3e3b345 Added "Advanced Guides" page about cross-origin Errros (#10457) 2017-08-14 13:43:24 -07:00
Brian Vaughn
6c6ff8c4b6 Better messaging for componentDidCatch cross-origin errors (#10447)
The prior message was a bit wordy and didn't cover all cases (like the one we discovered while researching #10441).

We can use the new URL to explain background info on the DEV-mode technique we're using in addition to common fixes (eg crossorigin attribute for CDN scripts and Webpack devtools settings). Putting this information behind a link will allow us to more easily edit it in the future as common causes for this issue change.

Resolves #10441
2017-08-14 11:05:29 -07:00
Ben Alpert
5e85f0065b Don't warn about casing in SSR for non-HTML NS (#10452)
Fixes #10415.
2017-08-13 16:17:45 -07:00
Ben Alpert
9921e57272 Warn when nesting 15 subtree inside 16 (#10434) 2017-08-13 16:03:31 -07:00
Brandon Dail
5ff5700625 Add explicit invariant when ReactDOM is loaded w/o React (#10449) 2017-08-13 13:16:13 -05:00
Sebastian Markbåge
3bc64327f0 Use the virtual target for change events to avoid restoring controlled state on the real target (#10444)
* Add test for nested controlled selects

The failure repros only when two events are fired sequentially, where the second
event is what updates the value.

* Add failure case to DOM select fixture

* Use virtual event target for change event instead of native target

Ensures that we use the same node to make decisions instead of two like
we do now.

This will cause restore to be called or not called consistently.

* Pass native event target to the event

We normally pass the native event target to the event object. This ensures
that we do the same thing here.

We still want to schedule a "restore" on the virtual target though since
those are the only nodes known to React.
2017-08-11 19:02:10 -07:00
Edgar (Algebr)
2cd0ecdaac Fixes #10443 (#10448) 2017-08-11 18:08:00 -07:00
Sebastian Markbåge
abc0efa6cc Update version on dom fixtures (#10445)
And yarn lock file.

Avoids a dependency that my proxy won't let me install.
2017-08-11 17:01:37 -07:00
Dan Abramov
58e6edeef6 Find callsites that would call toString() if we pass attributes through (#10416)
* Find callsites that would call toString() if we pass attributes through

* Warn for all object unknown props, not just 'toString' ones

fixing this as per Sebastian's feedback, because we want to find all
objects and not just ones with 'toString' defined. Because there may be
other corner cases and issues that are revealed.
2017-08-11 11:07:41 -07:00
Sasha Aickin
4d08914985 Fix for #10388. Renames renderToStream to renderToNodeStream. (#10425) 2017-08-10 12:23:00 -07:00
Brian Vaughn
8b1b0720cc Wrap warning() calls in a DEV check for RN_* builds too (#10428)
* Wrap warning() calls in a DEV check for RN_* builds too.
* Wrapped several warning() imports and calls in if-DEV checks.
* Removed a useless variable (allTypesByEventName) and loop from ReactNativeBridgeEventPlugin.
2017-08-10 08:41:51 -07:00
Dominic Gannaway
e97143cca5 Use Closure Compiler for UMD/Node bundles instead of Uglify (#10236)
* Use GCC instead of Uglify for UMD/NODE bundles

* Prettier run

* Fixes fixtures that were alterated by Pretter and trailing function commas

* prettier on prettier

* updated prettier config

* altered prettier config slightly

* Reverted prettier changes

* updated results.json
2017-08-10 11:12:29 +01:00
Dominic Gannaway
5caa65c3c5 Make createFiber use a constructor object rather than an object literal object (#9369)
* made createFiber create a constructed FiberNode object

* updated comment

* satisfying flow and prettier

* better comments :)

* fixes flow error

* updates comment

* converted function constructor to a ES2015 class

* Revert "converted function constructor to a ES2015 class"

This reverts commit c020982c5fe62446667f6f933c834366c3f009b3.

* fixed some merge conflict issues

* Flow....

* removed exact types to make flow pass

* opted for $FlowFixMe instead

* removed exact types to make flow pass

* opted for $FlowFixMe instead

* run prettier
2017-08-09 23:40:35 +01:00
Dominic Gannaway
b9e92c6747 Moved around package dependencies fixes #10335 (#10424) 2017-08-09 18:47:52 +01:00
Brandon Dail
64287af8d1 Set date to initial value when reset (#10412) 2017-08-09 10:52:26 -05:00
Mateusz Burzyński
9166cf9b8d Add test for duplicate events with nested dispatch 2017-08-09 09:30:08 -05:00
Andrew Clark
32c9f7e827 Update Flow to 0.52 (#10417)
For opaque types
2017-08-08 19:02:10 -07:00
Brian Vaughn
c3718c48f0 16 beta 5 version bump and results JSON 2017-08-08 10:25:25 -07:00
Brian Vaughn
1724b116cd Enable new fiber ReactTestRenderer API methods (#10410)
Enable new fiber ReactTestRenderer API methods
2017-08-08 10:17:59 -07:00
Andrew Clark
5cdd744e06 Fix bugs related to unmounting error boundaries (#10403)
* Don't warn about setState on unmounted when scheduling error recovery

We shouldn't schedule an update on unmounted error boundaries, but we
don't know if a boundary is unmounted until we traverse its parents.
Added an additional argument to scheduleUpdate so we know not to warn
about setState on unmounted components.

* Should be able to unmount an error boundary before it is handled

Fixes the case where an error boundary captures an error, but its
parent is unmounted before we can re-render it. componentDidCatch is
never called, and we don't remove the boundary from our set of
unhandled error boundaries.

We should not assume that if capturedErrors is non-null that we still
have unhandled errors.
2017-08-08 10:09:43 -07:00
Brian Vaughn
9ebd0c9e9a Updated packages and results JSON for 16 beta 4 2017-08-08 09:08:17 -07:00
Rodrigo Pombo
fc3fb4bd72 Fiber debugger enhancements (#10393)
* Add effect tag

* Add graph settings (direction and trackActive)

* Support multiple effect tags
2017-08-08 11:31:48 +01:00
Ben Alpert
a6e20d0bd8 Add traversal for Fiber test renderer (#10377)
Not clear the path to shipping this but this gives us a migration path internally that we need right now (replaces https://fburl.com/udq9ksvk).
2017-08-07 16:47:22 -07:00
Dan Abramov
efcac24af2 Remove data-reactid and data-reactchecksum from whitelist (#10402) 2017-08-07 21:28:26 +01:00
Dan Abramov
4e4653da9b Rewrite DOMPropertyOperations-test in terms of public API (#10281)
* Rewrite DOMPropertyOperations-test in terms of public API

* Add more assertions

I don't understand what the jsdom comments are about since they pass.

* Address review feedback
2017-08-07 20:12:13 +01:00
Ben Alpert
7aec5f8f49 Update installation.md 2017-08-04 17:10:50 -07:00
Rodrigo Pombo
07acd7db81 [fiber-debugger] Support undefined progressedPriority (#10375)
[fiber-debugger] Fix the debugger to match changes to Fiber
2017-08-04 19:45:20 +01:00
Dan Abramov
145986ec17 Compile spread to Object.assign calls (#10387) 2017-08-04 19:12:12 +01:00
Dan Abramov
327d126392 Move PooledClass to Stack folder (#10386) 2017-08-04 19:10:07 +01:00
Brandon Dail
755724a24c Implement event-specific pooling for SyntheticEvent (#10237)
* Remove PooledClass from FallbackCompositionState

The only module that uses FallbackCompositonState is BeforeInputEventPlugin. The way its structured means there can only be a single instance of FallbackCompositionState at any given time (stored in a local variable at the top-level) so we don't really need pooling here at all. Instead, a single object is now stored in FallbackCompositionState, and access (initializing, reseting, getting data) is gaurded by the exported helper object.

* Use new FallbackCompositionState API in BeforeInputEventPlugin

* Implement event-specific pooling in SyntheticEvent

* Remove PooledClass from TopLevelCallbackBookKeeping

* Update results.json

* Add pooled event test fixtures (#1)

* Fix fixture lint
2017-08-04 18:24:48 +01:00
Dan Abramov
efa71484b3 Warn about unresolved function as a child (#10376)
* Warn about unresolved function as a child

* Oops
2017-08-04 15:51:47 +01:00
Nathan Hunzaker
6f28ecf0cb Fix incorrect reference to undefined diffValueForAttribute (#10235)
* Fix incorrect reference to undefined diffValueForAttribute

* Remove custom attribute branch in getValueForProperty
2017-08-04 14:47:28 +01:00
Devedse
25894e82c2 Wop optimized this repository (#10374)
The Web Optimization Project optimized this repository. This commit contains the optimized files in this repository.
2017-08-04 14:41:38 +01:00
Brian Vaughn
230d41218e Built 16.0.0 beta 3. Updated versions, results.json, and error codes 2017-08-03 16:05:28 -07:00
Brian Vaughn
6188832c5e Log captured errors sooner (#10373)
This prevents the captured error from becoming separated from the component stack if other errors (or console.error calls) are made between them, eg a component errors during unmount.
2017-08-03 15:51:09 -07:00
Dan Abramov
80577eb649 Don't call componentDidUpdate() in shallow renderer (#10372)
* Don't call componentDidUpdate() in shallow renderer

* Lint

Sent from my iPhone haha

* Consistent comments
2017-08-03 22:49:29 +01:00
Dan Abramov
a130757cd3 Remove hidden functional shouldComponentUpdate API (#10371) 2017-08-03 20:24:09 +01:00
Andrew Clark
a650699d2f Cross-origin error handling in DEV (#10353)
* Add DOM fixture for cross-origin errors

* Use a custom error object in place of cross-origin errors

Cross-origin errors aren't accessible by React in DEV mode because we
catch errors using a global error handler, in order to preserve the
"Pause on exceptions" behavior of the DevTools. When this happens, we
should use a custom error object that explains what happened.

For uncaught errors, the actual error message is logged to the console
by the browser, so React should skip logging the message again.

* Add test case that demonstrates errors are logged even if they're caught

* Don't double log error messages in DEV

In DEV, the browser always logs errors thrown inside React components,
even if the originating update is wrapped in a try-catch, because of the
dispatchEvent trick used by invokeGuardedCallback. So the error logger
should not log the message again.

* Fix tests

* Change how error is printed in DEV and PROD

In DEV, we don't want to print the stack trace because the browser already always prints it.
We'll just print the component stack now.

In PROD, we used to omit the JS error message. However we *do* want to show it because
if the application swallows the error, the browser will *not* print it. In DEV it works
only because of the fake event trick. So in PROD we will always print the underlying error
by logging the error object directly. This will show both the message and the JS stack.

* Make the wording tighter and emphasize the real error is above

There's a few goals in the rewording:

* Make it tighter using line breaks between sentences.
* Make it slightly less patronizing ("You should fix it" => "You can find its details in an earlier log")
* ^^ This also helps highlight that the real error message and stack is above
* Group subsections: intro (there's an error), component stack, and final addendum about error boundaries
* ^^ Otherwise people might think error boundaries are part of the reason they have an error
* Make it clear "located at" is not the stacktrace. Otherwise it feels confusing. This makes it clearer you should still look for stack trace (with other details) above and introduces the concept of component stack.

* Make the message shorter

* Unused variables

* Fix an error caused by fixing lint

* One more bikeshed

* Fix fixture

* Remove unused file

* Concise wording

* Unused variables
2017-08-03 18:25:53 +01:00
Brian Vaughn
028e0ea937 Fix lint error in DOM fixtures (#10369) 2017-08-03 17:32:04 +01:00
Dan Abramov
03ca99d9ba Add documentation about <script crossorigin> for React CDN usage (#10368) 2017-08-03 16:13:13 +01:00
Jason Quense
0b220d0f04 Remove old IE polyfill code (#10238)
* Upgrade DOM Fixtures

Upgrade to react-scripts v1 and include required polyfills for older
browsers

* Remove ChangeEvent polyfills for unsupported browsers
2017-08-03 13:45:41 +01:00
Dan Abramov
c1833b4b7e Fix CI maybe 2017-08-03 00:59:40 +01:00
Dan Abramov
fc86ef0f3d Use single entry point for SSR via browser field (#10362)
* Use single entry point for SSR via browser field

* Add server.browser entry point and smoke tests

* Tweak bundle naming

* Fix import

* Re-record

* Fix the robot nits

* Add resetModules for some extra isolation
2017-08-03 00:41:09 +01:00
Brian Vaughn
630afb3186 Wrap contents of if-DEV condition in an IIFE (#10361)
This avoids strict mode conflicts for certain browsers wrt functions being defined within an if-block.
Also re-added the if-DEV condition for the ReactNative renderer since it was removed for this reason.
2017-08-02 14:24:43 -07:00
Brian Vaughn
f3e502c613 FB bundles wrap warning() calls in __DEV__ (#10314)
FB bundles wrap warning() calls in __DEV__

Split dev-mode transforms into separate parts:
1) umd+cjs+fb: Wrap warning calls with process.env checks
2) umd+cjs: Replace error messages with minified codes

Also updated transforms to use __DEV__ since it transforms to smaller code after stripEnvVariables is run.

Also renamed 'scripts/error-codes/dev-expression-with-codes.js' -> 'scripts/error-codes/replace-invariant-error-codes.js'
2017-08-02 14:14:26 -07:00
Dan Abramov
8890db707b Don't suggest downloading React DevTools inside Chrome extension (#10359) 2017-08-02 20:04:49 +01:00
Dan Abramov
9823808632 Upsell React DevTools in 16 (#10351)
* Upsell React DevTools

* Fix Flow

* Upsell message nits

* Avoid extra checks in onCommitRoot and onCommitUnmount
2017-08-02 18:56:24 +01:00
Dan Abramov
4e6cc2f495 Warn on missing Set/Map polyfills (#10356)
* Crash on missing Set/Map polyfills

* Change Map/Set to emit warnings instead

* Change rAF polyfill check to also be a warning

* Liiiiiint
2017-08-02 18:55:18 +01:00
Toru Kobayashi
ffec3be560 Remove an unnecessary __DEV__ condition (#10350) 2017-08-02 17:57:41 +01:00
Brian Vaughn
2da37a8a44 Shallow renderer passes context to componentWillReceiveProps (#10342)
This parameter was accidentally omitted before. Leland reported it because it impacts Enzyme.
I also added a basic lifecycle parameter test for shallow renderer.
2017-08-02 08:18:46 -07:00
Andrew Clark
372445735e Remove rAF export from ReactDOMFrameScheduling (#10337)
Fiber doesn't schedule animation callbacks anymore (though it does use
the browser's requestAnimationFrame to polyfill requestIdleCallback).

This removes the rAF export from ReactDOMFrameScheduling, since it's not
being used.
2017-08-02 19:56:37 +05:30
Nathan Hunzaker
81706eeb7a Remove event namespace check from react-partial-renderer (#10344) 2017-08-02 11:30:44 +01:00
Toru Kobayashi
7917709782 Fix a typo (#10349) 2017-08-02 11:09:09 +01:00
Michał Pierzchała
73217a74a0 Fix error-codes not updating correctly (#10348)
* Fix error-codes not updating correctly

* Revert changes to codes.json
2017-08-02 10:38:27 +01:00
Greg Hurrell
c5d1558a5b Grammar fixes for a code comment (#10343) 2017-08-02 01:20:53 +01:00
Dan Abramov
35e3133610 Remove hydrate() warning about empty container (#10345)
* Remove hydrate() warning about empty container

It used to have false positives for cases where we legitimately don't render anything.

* Use existing constant

* Test empty string case using its parent
2017-08-02 01:05:56 +01:00
Dan Abramov
a43ba2625b Add an extra test for arrays and strings from composites (#10346) 2017-08-02 01:05:42 +01:00
Dan Abramov
f8062df1d6 Add ReactDOM.hydrate() as explicit SSR hydration API (#10339)
* Add ReactDOM.hydrate()

* Deprecate ReactDOM.render() hydration in favor of ReactDOM.hydrate()

* Downgrade the warning level to console.warn()

* Warn when hydrate() is called with empty container
2017-08-01 21:17:24 +01:00
Dan Abramov
a2ed7a6d96 Make unexpected console.warn() calls fail tests (#10341)
* Make console.warn() calls fail tests

* Replace matchers with a more straightforward cleanup
2017-08-01 19:53:37 +01:00
Brian Vaughn
d947654913 Context improvements (#10334)
Refactored fiber context to fix a nested updates bug
2017-08-01 08:38:54 -07:00
Dan Abramov
78165276c7 Test for specific SSR warning (#10340)
* Test for specific SSR warning

* Same in another place
2017-08-01 14:38:17 +01:00
Jack Ford
04db3511fe Remove trapBubbledEventsLocal (#10258)
* Inline trapBubbledEventsLocal

* Revert "Inline trapBubbledEventsLocal"

This reverts commit 0ee65ff491deeec70223c2e39d04ef0aeda95d73.

* Merge remove-local-trap-bubbled-events branch
2017-08-01 08:37:26 +01:00
Toru Kobayashi
73038840ef Move ShallowRenderer tests (#10184) 2017-08-01 08:27:28 +01:00
Toru Kobayashi
56cd54f0ad Add tests that ShallowRenderer supports string and fragment (#10241) 2017-08-01 00:39:43 +01:00
Dan Abramov
1454f9c10c Fix invariant parity for SSR (#10333) 2017-07-31 21:13:50 +01:00
Dan Abramov
67347a6459 Fix SSR integration test swallowing lack of expected error (#10331)
* Don't catch the assertion about missing errors

Previously, even if an error was not thrown, the assertion about this was ignored.

This fix exposes two failing cases in new SSR that weren't failing in Stack.

* Add child context validation to new SSR

This fixes the error cases that were silently failing before but are now exposed.
2017-07-31 17:57:05 +01:00
guoyong yi
f732fc677b fix renderToString fails with array type children when react-dom/server render (#10221)
* fix(*): fix renderToString fails with array type children when react-dom/server render

* Add an integration test that verify renderToString with array type children

* Add integration test to renderToString with array type child

* Update integration test to renderToString with array type child

* fix renderToString fails with array type children when react-dom/server render

* Update integration test to renderToString with array type child

* Add to iterate that are not arrays

* Add the validation react element

* Improve an integration test of server renderToString with array type

* prettier

* prettier

* Make SSR can handle a single array element and nested array

* prettier

* Change integeration test description

* 	modified:   src/renderers/dom/ReactDOMNodeStreamRenderer.js

* Make invariants consistent

* Gate outdated test itself by feature flag

* Change test to make sense both with old and new code

* Test more cases
2017-07-31 16:59:14 +01:00
Dominic Gannaway
ca46c5278f Move line to within DEV block (#10316)
* move line to within DEV block

* addressed code review feedback
2017-07-27 17:31:34 -07:00
Dan Abramov
c7e9044c51 Make it more specific 2017-07-27 23:44:43 +01:00
Fernando Montoya
95cec9927c Add Babel plugin note to Error boundaries post (#10313)
* Add Babel plugin note to Error boundaries post

* Added section with screenshots

* Add context to Component stack traces

* Update 2017-07-26-error-handling-in-react-16.md

* Move section, more minor changes

* Change pics
2017-07-27 23:25:59 +01:00
Dominic Gannaway
6b3b9b5563 Wraps two warnings that should be removed from PROD (#10315) 2017-07-27 11:24:34 -07:00
Nathan Hunzaker
083cc5f4f9 Add date time test fixtures (#10154)
* Add date time test fixtures

This commit adds a new section for the DOM test fixtures specifically
for date inputs. Additionally, it adds a test case to verify that
correct transference of dates between the `"date"` and
`"datetime-locale"` input types.

* Adjust date parsing to be clearer
2017-07-27 13:24:04 -04:00
Dan Abramov
138224f6b3 16.0.0-beta.2 2017-07-27 18:06:26 +01:00
Dan Abramov
7a60a80921 Make server hydration warnings more obviously about server (#10312) 2017-07-27 18:02:16 +01:00
Sebastian Markbåge
e1cfd6c082 Remove Error event listener eagerly instead of using depth count (#10296)
A little simpler.
2017-07-27 09:45:07 -07:00
Dan Abramov
44c74c7b12 Add smoke tests for styles (including SSR) (#10308)
* Add style to ReactDOM smoke test

* Add production smoke test for ReactDOMServer
2017-07-27 14:58:03 +01:00
Toru Kobayashi
69d07612c5 Add a link for the error boundaries codemod into the blog post (#10305)
* Add a link for the error boundaries codemod into the blog post

* Update 2017-07-26-error-handling-in-react-16.md
2017-07-27 14:57:33 +01:00
Dan Abramov
bc0d241be1 Reword further 2017-07-27 10:48:37 +01:00
Daniel Lo Nigro
759690f7b2 Replace "children (and grandchildren)" with "descendants" (#10297) 2017-07-27 10:23:36 +01:00
Keyan Zhang
3abbcc48a5 Fix ReactPartialRenderer in production (#10300) 2017-07-27 10:19:05 +01:00
Dominic Gannaway
f92343159d Wrap "warning" call in DEV block to prevent PROD error (#10295)
* re-adds warning module to FB PROD bundle

* Wrap the warning call too
2017-07-26 14:59:44 -07:00
Dan Abramov
1f3de403bc Link to React 16 beta 2017-07-26 21:20:12 +01:00
Dan Abramov
4ac21f2a5f Blog post: Error Handling in React 16 (#10267)
* Blog post: Error Handling in React 16

* Change the date
2017-07-26 21:15:19 +01:00
Brian Vaughn
834d2c6954 Updated package versions and Rollup results 2017-07-26 12:55:31 -07:00
Dan Abramov
f3b4aaf388 Fix process override in ErrorUtils test (#10293) 2017-07-26 20:40:09 +01:00
Brian Vaughn
36a7d5b326 Fix error utils test failure caused by updating error codes (#10291) 2017-07-26 12:39:58 -07:00
Brian Vaughn
52849c94a7 Updated error codes (after merging in missing code from 15 stable) (#10290) 2017-07-26 12:18:02 -07:00
Dan Abramov
9a290fb1a7 Link warning to error boundary post (#10289) 2017-07-26 19:59:07 +01:00
Brian Vaughn
8d5f2c4324 Regenerate error codes and update bundle size stats (#10287) 2017-07-26 11:21:43 -07:00
Brian Vaughn
e2d1bc8a71 Update pre-release instructions for generating error-codes (#10286) 2017-07-26 11:18:32 -07:00
Dan Abramov
ac76c95fbc Add a disclaimer to internal invariants (#10285) 2017-07-26 19:08:22 +01:00
Andrew Clark
6c66d38d25 Remove feature test from invokeGuardedCallbackDev (#10283)
The critical semantics are resilient to browser flakiness, so we don't
need this feature test.

Also added comments explaining how invokeGuardedCallback dev works.
2017-07-26 10:01:31 -07:00
Dan Abramov
77e1129628 Delete react-dom-factories package (#10279) 2017-07-26 13:00:58 +01:00
Dan Abramov
66065115dc Update sizes 2017-07-26 12:27:29 +01:00
Dan Abramov
dea43046ef Dedupe unknown tag name warning and ignore <time> (#10275)
* Deduplicate unknown DOM tag warning

* Don't warn about <time> because it is widely used

Other browsers implement it, and Chrome will ship it soon too.

* Use hasOwnProperty

* Fix corner case: hasOwnProperty as a tag

* Update comments to be more correct factually
2017-07-26 11:57:29 +01:00
Dan Abramov
5495a7f24a Fix event name check to be more exact (#10274) 2017-07-26 11:56:38 +01:00
Andrew Clark
812cf1c6a3 [invokeGuardedCallback] Handle nested errors across separate renderers (#10270)
invokeGuardedCallback is a function we use in place of try-catch
statement. It accepts a function, and if the function throws, it
captures the error. In production, the implementation is a normal try-
catch. In development, we swap out the prod implementation for a special
version designed to preserve "Pause on all exceptions" behavior of the
browser DevTools.

invokeGuardedCallbackDev works by dispatching an event to a dummy DOM
node and calling the provided function inside a handler for that event.
We also attach an error event handler to the window object. If the
function throws, the global event handler is called and we can access
the error.

The global event handler is added and removed right before and after the
fake event is dispatched. But if invokeGuardedCallbackDev is nested --
 that is, if it's invoked inside the body of another
invokeGuardedCallbackDev -- multiple error event handlers will attached
simultaneously. We only want the handler that corresponds to the deepest
level to handle the error. So we keep track of a depth counter, and
within the event handler, we only handle the error if the current depth
matches the depth at the time the function was invoked.

The problem that we discovered, and that this PR fixes, is that the
depth counter is local to each renderer. So if you nest separate copies
of invokeGuardedCallback from separate renderers, each renderer will
have its own depth counter, and multiple error handlers will fire for a
single, nested error.
2017-07-25 09:44:43 -07:00
Dan Abramov
4c46b6c98a Fix false "unknown property" warnings for events in SSR (#10272)
* Reset modules between importing client and server modules in the test

Client and server renderers still share some modules, including injections.
This means they have shared state in this test, potentially missing issues that would occur in real world.

After this change, the client and server modules are completely isolated in the test.
This makes the tests fail due to https://github.com/facebook/react/issues/10265 (a real issue that was missed).

* Don't validate events if no plugins are injected
2017-07-25 17:01:48 +01:00
Brian Vaughn
171149a4b0 Fix failing Prettier command (#10268)
* Ran prettier over non-modified files to change them
* Fixed output of failing Prettier message to show invalid files
* Failing Prettier command now suggests 'yarn prettier-all'
2017-07-24 13:59:16 -07:00
Brian Vaughn
8d2fdc8e76 Don't add dangling commas to functions for packaging fixtures (#10264) 2017-07-24 09:09:40 -07:00
Andrew Clark
4fcc25a229 Support throwing null (#10213)
* Support throwing null

In JavaScript, you can throw values of any type, not just errors. That
includes null. We currently rely on null checks to determine if a user-
provided function has thrown. This refactors our error handling code to
keep track of an explicit boolean flag instead.

* Add DOM fixture test case for break on exception behavior

* preventDefault error events during feature test

We call invokeGuardedCallbackDev at startup as part of a feature test.
But we don't want those errors to log to the console.

* Add throwing null test case

* Use ReactFeatureFlags instead of ReactDOMFeatureFlags

React ART uses this, too.

* Non-errors in error logger

If a non-error is thrown, we'll coerce the value to a string and use
that as the message.
2017-07-21 15:34:41 -07:00
Andrew Clark
b3943497c2 Upgrade to Flow v0.50.0 (#10249)
No particular reason, just hoping memory usage is maybe better.
2017-07-21 15:30:32 -07:00
Andrew Clark
0a24255475 ReactDOM.activeUpdates (#10225)
ReactDOM.flushSync(batch)
2017-07-21 13:22:11 -07:00
Flarnie Marchan
1f74eca993 Add warning for rendering into container that was updated manually (#10210)
* RFC Add warning for rendering into container that was updated manually

RFC because we still need to tidy this up and verify that all tests
pass.

**what is the change?:**
We want to warn when users render into a container which was manually
emptied or updated outside of React. This can lead to the cryptic error
about not being able to remove a node, or just lead to silent failures
of render. This warning should make things more clear.

Note that this covers the case where the contents of the root container
are manually updated, but does not cover the case where something was
manually updated deeper in the tree.

**why make this change?:**
To maintain parity and increase clarity before releasing v16.0 beta.

**test plan:**
`yarn test`

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

last item under the '16 beta' checklist.

* Add test and tweak check for rendering into manually updated container

STILL TODO: figure out how to skip this warning when the component
renders to a portal.

Unfortunately 'ReactPortal.isPortal(children)' returns false, even in
the failing test where we are rendering to a portal.

**what is the change?:**
- added a test for the case where we call 'ReactDOM.render' with a new
  container, using a key or a different type, after the contents of the
  first container were messed with outside of React. This case throws,
  and now at least there will be an informative warning along with the
  error.
- We updated the check to compare the parent of the 'hostInstance' to
  the container; this seems less fragile
- tweaked some comments

**why make this change?:**
Continue improving this to make it more final.

**test plan:**
`yarn test`

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

* Stub our `console.error` in one of the portal tests

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

**why make this change?:**
See comment in the code

**test plan:**
`yarn test`

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

* Skip warning in 'ReactDOMFiberEntry' when mounting to Comment node

**what is the change?:**
We have a warning for cases when the container doesn't match the parent
which we remembered the previously rendered content being rendered into.

We are skipping that warning when you render into a 'comment' node.

**why make this change?:**
Basically, if you render into a 'comment' node, then the parent of the
comment node is the container for your rendered content. We could check
for similarity there but rendering into a comment node seems like a
corner case and I'd rather skip the warning without knowing more about
what could happen in that case.

**test plan:**
`yarn test`

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

* Improve warning message, remove dedup check, and unmock console.error

**what is the change?:**
Various changes to get this closer to being finished;
- Improved warning message (thanks @spicyj!!!)
- Removed dedup check on warning
- Remove mocking of 'console.error' in portals test

**why make this change?:**
- warning message improvement: communicates better with users
- Remove dedup check: it wasn't important in this case
- Remove mocking of 'console.error'; we don't want to ignore an
  inaccurate warning, even for an "unstable" feature.

**test plan:**
`yarn test` -> follow-up commits will fix the remaining tests

**issue:**
issue #8854

* Possible fix for issue of incorrect warning for portal re-render

**what is the change?:**
Add a property to a container which was rendered into using
`ReactDOM.unstable_createPortal`.

**why make this change?:**
We don't want to warn for mismatching container nodes in this case - the
user intentionally rendered into the portal container instead of the
original container.

concerns;
- will this affect React Native badly?
- will this add bloat to the portal code? seems small enough but not
  sure.

**test plan:**
`yarn test`

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

* Fix logic for checking if the host instance container is a portal

**what is the change?:**
When focusing on fixing the warning to not check when we are using
portals, I missed checking for the existence of the host instance parent
before checking if it was a portal. This adds the missing null checks.

**why make this change?:**
To fix a bug that the previous commit introduced.

**test plan:**
`yarn test`
-> follow-up commits fix more of the test failures

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

* Clean up new tests in ReactDOMFiber-test

**what is the change?:**
- removed extra single quotes, downgrade double quotes to single
- update expected warning message to match latest warning message
- fix indentation

**why make this change?:**
- get tests passing
- code maintainability/readability

**test plan:**
`yarn test`
follow up commits will fix the remaining tests

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

* Add 'unmountComponentAtNode' call in test for reconciling pre-rendered markup

**what is the change?:**
We have a test that verifies React can reconcile text from pre-rendered
mark-up. It tests React doing this for three strings and three empty
strings.

This adds a call to 'unmountComponentAtNode' between the two
expectations for strings and empty strings.

**why make this change?:**
We now warn when someone messes with the DOM inside of a node in such a
way that removes the React-rendered content. This test was doing that. I
can't think of a situation where this would happen with server-side
rendering without the need to call 'unmountComponentAtNode' before
inserting the server-side rendered content.

**test plan:**
`yarn test`

Only one more failing test, will fix that in the next commit.

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

* ran prettier

* remove unused variable

* run scripts/fiber/record-tests

* Fix type error and improve name of portal container flag

**NOTE:** I am still looking for a good place to move this flag
assignment to, or a better approach. This does some intermediate fixes.

**what is the change?:**
- fixed flow error by allowing optional flag on a DOMContainer that
  indicates it was used as a portal container.
- renamed the flag to something which makes more sense

**why make this change?:**
- get Flow passing
- make this change make more sense

We are still not sure about adding this flag; a follow-up diff may move
it or take a different approach.

**test plan:**
`yarn test`

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

* Add flag to portalContainer on mount instead of in `createPortal`

**what is the change?:**
We add a flag to the container of a 'portal' in the 'commit work' phase
in Fiber. This is right before we call `appendChildToContainer`.

**why make this change?:**
- Sometimes people call `ReactDOM.render(... container)`, then manually
clear the content of the `container`, and then try to call another
`ReactDOM.render(... container)`.
- This leads to cryptic errors or silent failure because we hold a
  reference to the node that was rendered the first time, and expect it
  to still be inside the container.
- We added a warning for this issue in `renderSubtreeIntoContainer`, but
  when a component renders something returned by
  `ReactDOM.unstable_createPortal(<Component />, portalContainer);`,
  then the child is inside the `portalContainer` and not the `container,
  but that is valid and we want to skip warning in that case.

Inside `renderSubtreeIntoContainer` we don't have the info to determine
if a child was rendered into a `portalContainer` or a `container`, and
adding this flag lets us figure that out and skip the warning.

We originally added the flag in the call to
`ReactDOM.unstable_createPortal` but that seemed like a method that
should be "pure" and free of side-effects. This commit moves the
flag-adding to happen when we mount the portal component.

**test plan:**
`yarn test`

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

* Force an 'any' type for the `hostInstance.parentNode` in warning check

**what is the change?:**
This is awful. :(
I'm not sure how else to let Flow know that we expect that this might be
a sort of `DOMContainer` type and not just a normal `Node` type.

To at least make the type information clear we added a comment.

**why make this change?:**
To get `flow` passing. Looks like we have `any` types sprinkled
throughout this file. phooey. :(

**test plan:**
`yarn flow`

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

* Ignore portals in `DOMRenderer.findHostInstance`

**what is the change?:**
We want to ignore portals when firing a certain warning.

This allows us to get the host instance and ignore portals.

Also added a new snapshot recording while fixing things.

**why make this change?:**
Originally we had added a flag to the DOM node which was used for

rendering the portal, and then could notice and ignore children rendered
into those nodes.

However, it's better to just ignore portals in
`DOMRenderer.findHostInstance` because
 - we will not ignore a non-portal second child with this approach
 - we meant to ignore portals in this method anyway (according to a
   'TODO' comment)
 - this change only affects the DOM renderer, instead of changing code
   which is shared with RN and other renderers
 - we avoid adding unneeded expandos

**test plan:**
`yarn test`

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

* Ran prettier

* Remove error snapshot test

I think there is a bug where an empty snapshot is treated as an 'outdated snapshot'.

If I delete the obsolute snapshot, and run ReactDOMFiber-test.js it generates a new snapshot.
But then when I run the test with the newly generated snapshot, it says "1 obsolete snapshot found",
At some point I will file an issue with Jest. For now going to skip the snapshot generation for the error message in the new test.

* Remove expando that we were adding to portal container

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

**why make this change?:**
this is part of an old approach to detecting portals, and we have
instead added a check in the `findHostInstance` method to filter out
portals.

**test plan:**
`yarn test`

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

* Fork `findHostInstance` to make `findHostInstanceWithNoPortals`

**what is the change?:**
We need to get host instances, but filter out portals. There is not
currently a method for that.

**why make this change?:**
Rather than change the existing `findHostInstance` method, which would
affect the behavior of the public `findDOMNode` method, we are forking.

**test plan:**
`yarn test`

**issue:**
https://github.com/facebook/react/issues/8854
2017-07-21 08:48:46 -07:00
Andrew Clark
ae430b7913 React.unstable_AsyncComponent (#10239)
Alternative to using the static class property unstable_asyncUpdates.
Everything inside <AsyncComponent /> has async updates by default. You
can also extend it like PureComponent or Component.
2017-07-20 18:00:53 -07:00
Sebastian Markbåge
9d248e0616 Remove record-tests step from contribution guides (#10223) 2017-07-20 14:16:35 -07:00
Dan Abramov
240b84ed8e Remove PooledClass from isomorphic build (#10227)
* Inline traverseAllChildren into ReactChildren

* Remove ForEachBookKeeping

* Inline traversal pooling logic into ReactChildren

* Reuse emptyFunction for dummy callback

* Move code around

* Record sizes
2017-07-20 15:56:49 +01:00
Dan Abramov
9cf888f661 Delete flattenChildren (#10224)
* Delete flattenChildren

* Stop exporting mapIntoWithKeyPrefixInternal

* Remove unescapeInDev()

flattenChildren() was the only traverseAllChildren() caller that relied on it.
2017-07-20 01:25:53 +01:00
Sebastian Markbåge
7b9f64307d Fix lint (#10222) 2017-07-19 11:12:47 -07:00
Sebastian Markbåge
1b4776f319 In SSR, Store Elements of Composites on the Stack for Warnings (#10187)
In DEV mode this keeps an additional sub-stack within the stack of the
server renderer. This substack keeps track of all the elements that we
resolved to get to to the next processing frame.

This lets us recreate the full composite component stack for warnings.
Normally the stack only contains host components.

We reset this every time we're going to resolve another sibling.
2017-07-19 10:36:57 -07:00
Sebastian Markbåge
9011182c55 Configure Jest with Stack and Fiber as separate projects (#10214)
* Disable Fiber specific test run in CI

This disables the comparison against previously recorded test. Instead,
we'll rely on jest failures to fail tests.

* Extract jest config into two separate projects for Fiber and Stack

Allows us to run both in the same jest run. The setupMocks file is forked into
specific environment configuration for each project. This replaces the
environment variable.

I used copy pasta here to make it clear. We can abstract this later. It's clear
to me that simply extracting shared stuff is not the best way to abstract this.
setupMocks for example didn't need all the code in both branches.

I think that some of the stuff that is shared such as error message extracting
etc. should probably be lifted out into a stand-alone jest project instead of
being shared.

* Fix class equivalence test

There's a behavior change when projects are used which makes
setupTestFrameworkScriptFile not override the normal config.

This test should probably just move to a separate CI script or something
less hacky.

* Only run Fiber tests with scripts/fiber/record-tests
2017-07-19 10:35:45 -07:00
Jason Quense
acd9818b90 Move input valueTracker to DOM nodes (#10208)
* Move input valueTracker to DOM nodes

This moves the storage of the input value tracker to the DOM node
instead of the wrapperState. This makes it easier to support both Stack
and Fiber without out a lot of ugly type casting and logic branches.

related: #10207

* run prettier

* remove instance accepting methods

* rm unused trst method

* address feedback

* fix naming

* fix lint
2017-07-19 12:10:13 -04:00
Dominic Gannaway
357925a84e Move DEV only module requires into __DEV__ blocks (#10185)
* modulesToStub cleaned up and DEV only modules put into __DEV__ blocks

* prettier run

* Prettier + new build run for bundle sizes
2017-07-19 17:28:55 +02:00
Dan Abramov
9254ce27a8 Split markup generation from DOM property management (#10197)
* Replace SSR unit test with integration test

* Remove unit test that is already covered by integration suite

* Replace unit tests for boolean attrs with integration tests

* Replace unit test for aria attrs with integration test

* Replace unit tests for numeric 0 with integration tests

* Remove unit test covered by integration tests

* Replace unit test for injection with integration test

It still touches internals but it tests both renderers.

* Fork DOMPropertyOperations into DOMMarkupOperations

* Trim down DOMPropertyOperations and DOMMarkupOperations

* Record SSR sizes

* Record them tests

* Fix false positive warning for overloaded booleans when passing numbers

* Remove stray import

* Replace CSS markup tests with public API tests

Some of these are handy as integration tests so I moved them there.
But some test markup specifically so I changed them to use DOMServer.

* Make CSSPropertyOperations client-only

I forked createMarkupForStyles() into ReactDOMComponent and ReactPartialRenderer. Duplication is fine because one of them will soon be gone (guess which one!)

The warnInvalidStyle helper is used by both server and client, unlike other client-only stuff in CSSPropertyOperations, so I moved it to a separately module used in both.

* Record server bundle size

* Add an early exit to validation

* Clarify what is being duplicated
2017-07-19 14:06:53 +01:00
Sebastian Markbåge
12d5c7a842 Upgrade jest to 20.1.0-delta.1 (#10211)
* Upgrade jest to 20.1.0-delta.1

This includes multi-project support.

* Use isSpy polyfill that is not available in jest 20

* Remove use of jasmine.createSpyObj

We don't really need this and it's not in jest 20.

* Upgrade record-tests script to use the new jest 20 APIs
2017-07-18 17:24:54 -07:00
Andrew Clark
71f591501b Fix scheduler control flow (#10015)
* Use performFailedUnitOfWork

instead of beginFailedWork and completeUnitOfWork separately. Also, we
unwind the context stack *before* beginning work again.

* Only use error loop directly after a commit

We have a special, forked version of work loop that checks if a fiber is
in a failed state (needs to be unmounted). This is only relevant right
after a commit -- begin phase errors are handled differently, by
unwinding the stack.

Also renamed findNextUnitOfWork to resetNextUnitOfWork and made it a
void function to signal that it's impure.

* Reset nextUnitOfWork after every commit

* Include the error boundary when unwinding a failed subtree

Also added a warning to the error boundary to show that it failed.

* Push context providers in beginFailedWork to avoid push/pop mismatch

Added a test that demonstrates how an error boundary that is also a
context provider could pop its context too many times if you neglect
to push it in beginFailedWork. This happens because we've already
popped the context once in unwindContext.

The solution is a code smell. I don't like how we push/pop context in
so many places. Shouldn't they all happen in the same location?

* Refactor work loop

- Optimizes the normal, non-error path by reducing the number of checks
needed to begin performing work.
- Prevents control flow from oscillating between fast normal loop and
slower error loop.

* Improve context unwinding test

Tests that we correctly unwind an error boundary that is also a
context provider.

* Triangle tester should assert the tree is consistent after every action

...not just at the end.

* Better implementation of infinite loop error

Infinite loops should only be possible if a while loop never terminates.
Now that we've refactored to avoid oscillation between different
work loops, we can count updates local to each loop.

The two loops that could infinite loop are the sync work loop and the
loop that surrounds the body of the render phase catch block. The
async loop could also fall into an infinite loop if the deadline never
terminates, but we'll assume that it always eventually does.

This change also creates better error stack traces because the error is
thrown from inside the first setState that exceeds the limit.

Added a test case for an error boundary whose parent remounts it
on recovery.

* Use invokeGuardedCallback in DEV
2017-07-18 16:31:49 -07:00
Dan Abramov
c2ed1b87dc Record sizes 2017-07-18 20:06:17 +01:00
Dan Abramov
9043ad6b9d Fix crash on master introduced during the radio bugfix (#10207)
* Add a regression test that passes in Stack but fails in Fiber

The failure happens because trackValueOnNode() can exit early if it detects an existing descriptor on node, or if it sees a "broken" Safari descriptor (which is how we encountered this bug in the wild).

As a result, the tracker field was not set, and subsequent updateValueIfChanged() call went into the branch that initializes the tracker lazily. That branch has a bug in Fiber mode where it passes the wrong type.

We did not see this issue before because that branch is relatively hard to hit (you have to either run it in Safari or define a custom DOM value descriptor which is what I did in the test).

In the future, we will likely remove the lazy branch altogether since if we bailed out of setting up the tracker once, we will likely bail out every time. But for now I'm just focused on a minimal fix to unbreak master.

* Fix updateValueIfChanged() lazy path to work with DOM argument

* Slightly reorder lines for clarity and record tests

* Also test the change event code path

This makes it go through the Fiber argument code path.
2017-07-18 16:31:04 +01:00
Brian Vaughn
197e184859 Replaced "unstable_handleError" with "componentDidCatch" (#10200)
Ran new codemod to rename all identifiers. Searched-and-replaced strings occurrences.
2017-07-17 14:38:37 -07:00
Sebastian Markbåge
3b5e3b5a23 Refactor Debug Frames to Enable Renderers to Provide Custom Logic (#10105)
* Extract the top element frame from ReactDebugCurrentFrame

This is part of a larger refactor to decouple stack addendums. All
renderers have their own way of getting the stack of the currently
executing components.

There is one special case in Element Validator that adds an additional line
for the element being validated. This commit moves that special case in
into the validator.

There is another case where it looked like this was used in shallow
renderer but this is actually something different. It is part of the
component stack. It just happens to be that shallow renderer has a simpler
implementation of the component stack that just happens to be a single
element.

This will let us decouple the implementation to get a stack from
ReactDebugCurrentFrame and put that in each renderer.

* Stop using ReactComponentTreeHook for Fiber

Currently we fall back to ReactCurrentOwner in ReactComponentTreeHook for
stack addendums. We shouldn't need to because we should use
ReactDebugCurrrentFiber.

Ensure we always set both ReactDebugCurrentFiber and ReactDebugCurrentFrame
so that we can rely on these for all stacks.

* Make ReactDebugCurrentFrame implementation independent

Introduced ReactDebugCurrentStack for the Stack renderer which does the
same thing as ReactDebugCurrentFiber.

ReactDebugCurrentFrame no longer keeps track of the current fiber/debug id.
That's handled by the individual renderers.

Instead, it is now used to keep track of the current *implementation* of
the current stack frame. That way it is decoupled from the specifics of
the renderers. There can be multiple renderers in a context. What matters
is which one is currently executing a debuggable context (such as a render
function).

* Add debug frames to ReactPartialRenderer (ssr)

Basic functionality.

* Add shared modules to shallow renderer

This is now needed because we share describeComponentFrame.
2017-07-14 15:36:24 -07:00
Andrew Clark
fb30d235db Remove didCommit from scheduler (#10182)
Don't actually need to track this, now that we removed the infinite
loop check to findNextUnitOfWork
2017-07-13 22:11:35 -07:00
Andrew Clark
b1a2ac89ca Uhhhh remove the extra space I literally just added (#10180)
0 spaces -> 2 spaces -> 1 space yay!
2017-07-13 16:19:40 -07:00
Andrew Clark
7c63d0178d Add missing space to key warning (#10179)
Found this when running the warnings script.
2017-07-13 16:14:45 -07:00
Andrew Clark
4dabdd2a30 Limit the number of nested synchronous updates (#10178)
* Limit the number of nested synchronous updates

In Stack, an infinite update loop would result in a stack overflow. This
gives the same behavior to Fiber.

Conceptually, I think this check belongs in findNextUnitOfWork, since
that is what we call right before starting a new stack. I've put it
in scheduleUpdate for now so I have access to the component that
triggered the nested update. But we could track that explicitly instead.

I've chosen 1000 as the limit rather arbitrarily. Most legit use cases
should really have a much smaller limit, but a smaller limit could break
existing code. For now I'm only concerned with preventing an infinite
loop. We could add a warning that fires at the smaller limit.

* Move check to findNextUnitOfWork

Including the name of the component in the message probably isn't
necessary. The JS stack will include either componentDidUpdate or
componentWillUpdate. And the component that's updating won't
necessarily be the component whose lifecycle triggered it.

So let's move the infinite loop check to findNextUnitWork as I
originally wanted to.
2017-07-13 15:56:02 -07:00
Jason Quense
999df3e777 Fix uncontrolled radios (#10156)
* Add fixture

* Fix Uncontrolled radio groups

* address feedback

* fix tests; prettier

* Update TestCase.js
2017-07-13 16:02:31 -04:00
Dan Abramov
2dcdc3c633 Simplify environment injections (#10175)
* Remove unnecessary injection guard

* Remove inject() indirection for global injections

It was necessary when they shared global state. But now these are flat bundles so we can inject as side effect.
This feels a bit less convoluted to me.

Ideally we can get rid of this somehow soon.
2017-07-13 20:44:52 +01:00
Dan Abramov
0070925a4f Don't use Stack-only helper in new SSR (#10174) 2017-07-13 19:55:48 +01:00
Dan Abramov
7dd7c1702b Remove dependency to event system on the server (#10173)
I do this by splitting ReactDOMInjection into generic and client-only injection.
2017-07-13 19:32:27 +01:00
Flarnie Marchan
309412d8b6 Improve error message thrown in Fiber with multiple copies of React (#10151)
* WIP Improve error message thrown in Fiber with multiple copies of React

**what is the change?:**
Adding an 'invariant' with detailed error message for the problem that
occurs when you load two copies of React with the Fiber reconciler.

WIP:
 - Is there any other likely cause for this error besides two copies of
   React?
 - How can we make the message more clear?

Still TODO:
 - Write a unit test
 - Write a documentation page and create the link to the page, similar
   to https://facebook.github.io/react/warnings/refs-must-have-owner.html

It would also be nice to have a page with instructions on how to fix
common cases of accidental double-loading of React, but we can open a
separate issue on that and let the community do it.

**why make this change?:**
This error comes up relatively often and we want to make things clear
when it happens in v16.0+

**test plan:**
WIP

**issue:**
Fixes #9962

* Add improved warning and docs for 'refs must have owner' in Fiber

**what is the change?:**
 - Added warning in the place where this error is thrown in Fiber, to
   get parity with older versions of React.
 - Updated docs to mention new error message as well as old one.

I started to write a new docs page for the new error, and realized the
content was the same as the old one. So then I just updated the existing
error page.

**why make this change?:**
We want to avoid confusion when this error is thrown from React v16.

**test plan:**
- manually inspected docs page
- manually tested in a CRA to trigger the error message

(Flarnie will insert screenshots)

**issue:**
Fixes #9962
Related to #8854

* Add test for the informative warning around multiple react copies

@gaearon debugged the test for this and now it works!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!! :)

**what is the change?:**
We now test for the warning that the previous commits add in Fiber, and
also test for the old warning in the stack reconciler.

**why make this change?:**
This is an especially important warning, and we want to know that it
will fire correctly.

**test plan:**
`yarn test src/renderers/__tests__/multiple-copies-of-react-test.js`
`REACT_DOM_JEST_USE_FIBER=1 yarn test src/renderers/__tests__/multiple-copies-of-react-test.js`

* Fix up test for 'multiple copies of react'

**what is the change?:**
refactor test for 'multiple copies of React' to be simpler and remove
some copypasta

* run prettier

* Fix conditionals in 'multiple copies of react' test

**what is the change?:**
When moving the 'fiber' and 'non-fiber' conditions from two assertions
into one, we copy pasted the wrong message into the 'fiber' condition.

This wasn't caught because we were using an outdated name for the
'fiber' constant when running the tests locally with fiber enabled.

This fixes the copy-paste error and we now are actually running the
tests with fiber enabled locally.

* Run scripts/fiber/record-tests
2017-07-13 10:41:32 -07:00
Brian Vaughn
5495e495de Remove conditional __DEV__ wrapper from RN bundles (#10171)
This causes an error with the older version of JSC packaged for Android.
2017-07-13 09:26:45 -07:00
Flarnie Marchan
3b43f3190b Reword duplicate key warning (#10148)
* Reword duplicate key warning

**what is the change?:**
 - Removes the now-inaccurate description of behavior around duplicate
   keys
 - Adds link to 'key' docs page
 - Changes tone to be more casual and friendly

Alternative wording idea;
'Encountered two children with the same key, ${key}
Child keys must be unique; using duplicate keys is not supported and
will cause unexpected behavior in some versions of React.
See https://fb.me/react-warning-keys for more information on how to
fix this.'

**why make this change?:**
Mainly this change was needed because in React 16, duplicate keys will
not cause omission of items with duplicate keys. All items will be
rendered. It could happen that in future versions of React we will have
different behavior though.

**test plan:**
`yarn test`

**issue:**
Wishlist item on https://github.com/facebook/react/issues/8854

* Further improve wording of duplicate key error

**what is the change?:**
Another tweak to the wording of this error to make it more clear and
accurate.

**why make this change?:**
The previous tweak was too casual in tone and still not clear enough.

**test plan:**
`yarn test` and `REACT_DOM_JEST_USE_FIBER=1 yarn run test`

**issue:**
Wishlist item on https://github.com/facebook/react/issues/8854

* Run prettier

* Fix typo in error message for duplicate keys

**what is the change?:**
Fixed a typo in the updated message

* Fix two more typo spots
2017-07-12 15:49:41 -07:00
Garrett McCullough
50d905b083 change the argument passed to CallbackQueue.getPooled (#10101)
* change the argument passed to CallbackQueue.getPooled

* remove undefined from function call

* add test for ReactNativeReconcileTransaction

* update log of tests

* change test to one that operates on setState

* added new tests and fixed another instance of the bug

* run prettier

* update names of tests and minor clean up

* remove arg from CallbackQueue and update tests
2017-07-12 18:49:13 +01:00
Michiya
5d5589b295 Update conferences.md (#10160) 2017-07-12 12:31:45 -05:00
Brandon Dail
d04618b28b Run all fixtures through Prettier (#10157)
* Include fixtures in prettier default pattern

* Run all fixtures through Prettier
2017-07-12 11:19:24 -05:00
Peter Ruibal
cff012fc16 Add react-dom-unstable-native-dependencies (#10138)
* Add react-dom-unstable-native-dependencies

react-native-web and react-primitives currently access a few internals
for shimming DOM events into native ones.  Changes in react@16 packaging
hide these internals completely.  This change adds a submodule to react-dom,
unstable-native-dependencies that includes the necessary modules to
continue enabling that method of dom-native event injection.

* Update ResponderEventPlugin to use "public" interfaces for test

In order to get some sort of smoke testing on
react-dom-unstable-native-dependencies, update ResponderEventPlugin-test
to use the "public" interfaces provided by react-dom and the new
react-dom/unstable-native dependencies

Also adds the missing references in package.json as well as missing
files required for unittests to do imports correctrly

Also exports injectComponentTree() which is required for the unittests
to re-set the shared component state between runs.

* Tweak bundle comment

* Bundle content updates from exporting injectComponentTree

* Added FB_DEV, FB_PROD to bundle types

* Run yarn prettier for -unstable-native-dependencies updates
2017-07-12 02:27:26 +01:00
Dan Abramov
2e2f503cb8 Tweak deprecation messages to be less scary (#10145) 2017-07-11 14:05:27 +01:00
walrusfruitcake
b79619e52a move augmentClass definition above SyntheticEvent Proxy replacement (#10011) 2017-07-11 11:37:11 +01:00
Brandon Dail
ab4ddf6493 Add columns to isUnitlessNumber list (#10115) 2017-07-11 11:28:57 +01:00
Eli White
8ca40630e6 Adding missing assertion to ReactDOMComponent-test (#10131) 2017-07-10 18:51:44 -06:00
Dheeraj Kumar
5ac6209599 Fix shallow renderer callbacks (#10106)
* Add failing test to show that shallow test renderer doesn't call setState's callback arg
* Record tests
* Fix shallow renderer's setState/replaceState/forceUpdate to execute any callbacks passed. (#10089)
* Ensure shallow renderer callbacks are called with the correct  binding.
2017-07-10 14:41:50 -07:00
Eli White
5bc25cb186 Fixing typo in ReactDOMComponent test name (#10132) 2017-07-09 19:34:39 -04:00
Martin V
242929bac1 Add Node v8.x support to devEngines in package.json (#10129) 2017-07-09 20:24:33 +01:00
Andrew Clark
ce7c01429c Don't increase priority when cloning current children (#10123)
This fixes a snapshot test regression introduced by #10008. I had
noticed this change and believe the new behavior was correct, but upon
further investigation I was wrong. This reverts the snapshot test and
fixes it accordingly.
2017-07-07 15:34:27 -07:00
Nick Kasten
8f4d30737d Updated Immutable Data Stuctures Docs (#9845)
* updated immutable data structures section

* improved immutable clarifications

* changes to example immutable code
2017-07-05 19:08:43 -05:00
Ilya Gelman
b22387d4fe Add ReactNext 2017 to conference list (#10114) 2017-07-05 18:44:04 -05:00
Andrew Rota
a39858f399 Add React Boston 2017 to upcoming conferences (#10099) 2017-07-03 21:07:09 -04:00
Guilherme Ruiz
83f56370e6 Fix the data-height of Step 5 CodePen embed (#10083) 2017-07-03 21:05:35 -04:00
Kiho · Cham
03db57aa71 doc: fix the order of lint and prettier (#10095) 2017-07-02 17:39:09 +01:00
Kiho · Cham
4880eb0fbc doc: switch the order of lint and prettier (#10094)
Ref #9876

Thanks to @wdhorton bring it up.
2017-07-02 13:24:45 +01:00
Andrew Clark
f9af9aacd3 Down-prioritize children of hidden host components
To make sure we don't reset the priority of a down-prioritized fiber,
we compare the priority we're currently rendering at to the fiber's
work priority. If the work priority is lower, then we know not to reset
the work priority.
2017-06-30 18:39:04 -07:00
Andrew Clark
de08c2af15 Ignore incremental tests that assert on work reuse
it -> xit

The diff looks messier than it actually is because of Prettier.
2017-06-30 18:39:04 -07:00
Andrew Clark
5a32e89b3d Failed error boundaries are a special case of resuming work
When an error in thrown in the begin phase, we begin work on the
error boundary a second time to unmount the children. This is a special
case of "resuming" work that we need to account for. The children are
set to the current children so that we can delete them.
2017-06-30 18:39:04 -07:00
Andrew Clark
ccbb92f9ef Enable the fuzz tester
Now that we've removed the buggy implementation of resuming work, the
fuzz tester passes consistently.
2017-06-30 18:39:04 -07:00
Andrew Clark
264a921054 Clear pending props when cloning from current
When we create a new work-in-progress, the existing pending props are
no longer valid.
2017-06-30 18:39:04 -07:00
Andrew Clark
a0af1e1317 Remove ability to resume work
The current implementation of resuming work is buggy. The underlying
model is also flawed. Rather than attempt to fix a flawed model, we'll
scrap the feature entirely and add it back later.
2017-06-30 18:39:04 -07:00
Andrew Clark
9749a6ea6a Update fuzz tester to not use animation priority
Neglected to fix this earlier because these tests were ignored.
2017-06-30 18:39:04 -07:00
Sebastian Markbåge
e6f1d29f07 Warn for inline style mismatches (#10084)
I use the technique of generating a style string and comparing that against the
attribute.
2017-06-30 18:24:04 -07:00
Almero Steyn
79868a978d docs(a11y): Small fixes (#10079) 2017-06-30 07:39:46 -04:00
Sebastian Markbåge
8d61138186 Warn When The HTML Mismatches in DEV (#10026)
* Warn for text content

* Warn for different attributes/properties values

Warns if there are unknown extra attributes in the hydrated node.

It also tries to compare the existing property or attribute against the
expected value. It does this by reading the property and comparing it to
the prop. Except it's not that simple because multiple prop values can
yield the same output. For this we pass an extra expected value that is
a hint as to which one was used. This is a bit weird but I'm not sure the
alternatives were much better.

* Warn when there is an insertion or deletion during hydration

This warns if there is ever an insertion or deletion due to hydration
failing to find a match.

Currently we can't warn for insertions required into the root because
that's how we do all non-hydrating renders atm. Left a todo.

This strategy is a bit unfortunate that it leads to so much plumbing code.
And we have to add three extra methods to the HostConfig that are only used
in DEV and not for anything else. I don't really have a better idea.

* Don't try to delete children of a textarea

Textareas are special cases. The initial mount inserts children
as the default value, but we should leave that untouched. This is the same
as the special case where we set text content of children so I'll use that
mechanism.

* Change expected format for text differences

In Stack this is presented as HTML which needs to have normalized escaping
rules. In Fiber it is currently not presented as HTML but a raw string
so we don't escape it.

* Unmount component in between tests

In Fiber, the second warning isn't issued because it's considered an update
not a new initial render and we don't fire the warning for those.

* Change expectation of white space text behavior in Fiber

In Fiber we don't expect empty strings to be different from rendering null.
In fact, in a follow up I plan on formalizing this by never creating text
Fibers for empty strings.

* Warn for different dangerouslySetInnerHTML

We can't just compare the raw innerHTML value because it will have been
normalized. Instead, we'll create another element, set its innerHTML and
read it back.

Since there can be custom elements registered with this document, we want
to avoid any side-effects they might cause. So I do this in a fresh new
document.

I'm not sure how this would affect controlled components and other stuff
that could have changed after runtime. I think for those cases maybe we
just need a general way of opting out of the diff.
2017-06-29 19:47:44 -07:00
Nathan Hunzaker
9d13557244 Add test to ensure extra zeros are covered by tests (#10033)
* Add test to ensure extra zeros are covered by tests

* Add DOM test fixture for trailing zeros

* Drop quotes to improve clarity
2017-06-29 12:44:05 -05:00
Henry Harris
dccc3850dc Tiny changes to tutorial (#10048)
* Initial commit

* PR feedback
2017-06-29 16:00:04 +01:00
Ben Alpert
21df484f25 Don't build ReactDOMNodeStream for FB (#10065)
require('stream') doesn't work for us right now.
2017-06-28 16:13:58 -07:00
Toru Kobayashi
85f3498fda Types Fiber as an exact object type (#10063) 2017-06-28 13:01:46 -05:00
Ben Alpert
864ae8fa98 Support comment node as a mount point (#9835)
This means you don't need an extra wrapper div for each component root you need. Rendered stuff is inserted before the comment you pass in.
2017-06-27 17:22:07 -07:00
Sebastian Markbåge
52a2365f19 Fix mount and unmount warnings in Fiber (#10056)
* Warn if unmounting a non-container

* Warn if the 2nd+ child is a "root" element but not first

This triggers our non-reuse mode. This is covered by ReactMount already but
the test doesn't pass yet without also landing #10026.
2017-06-27 17:15:53 -07:00
Sasha Aickin
f8a3a3989a Removed ReactMarkupChecksum from renderToString (#10053)
* Removed ReactMarkupChecksum from renderToString

* Oops. I messed up the merge in the previous commit.
2017-06-27 14:20:45 -07:00
Sebastian Markbåge
e955008b9b Remove most comments from HTML generation output (#10029)
Simplifies markup generation by only inserting a simple comments between
consecutive text nodes.

I also skip past comments and other nodes while hydrating. This leaves them
in place instead of being removed by the hydration mechanism. This is more
efficient but will also be needed by hydration validator.

There's a special case for empty strings. We probably shouldn't have nodes
for those at all. For now I special case it by assuming there won't be one
so if we need one, we'll insert an empty text node.

I also dropped the ID from the react ID.
2017-06-27 10:43:27 -07:00
Sebastian Markbåge
3c5b515286 Update yarn.lock (#10046) 2017-06-27 10:41:54 -07:00
Jack Ford
7831440dc9 Fix Typo in ReactFiberTreeReflection (#10055) 2017-06-27 17:53:16 +01:00
Jack Ford
15d3f2852f Fix Typo in ReactDOMFiberEntry (#10054) 2017-06-27 17:53:10 +01:00
Sebastian Markbåge
90b7facd52 Don't use the render callback with promises (#10050)
This covers up errors that are thrown in Fiber, because callback gets
fired *and* an error is thrown. Created a follow up #10049 to reevaluate
these semantics.

# Conflicts:
#	scripts/fiber/tests-passing-except-dev.txt
#	scripts/fiber/tests-passing.txt
2017-06-27 08:24:31 -07:00
Brian Vaughn
cb32253d2f ReactNativeFiberErrorDialog mutates error message (#10045)
This ensures that custom properties that are required by Facebook's error tooling (eg 'framesToPop') don't get dropped.

I also improved the handling/messaging of thrown strings.
2017-06-26 12:34:29 -07:00
Almero Steyn
2675ce13b8 [Docs: A11y] Add accessibility docs (#9519)
* [Docs: A11y] Add accessibility docs

* Fix the link

* Replace link image

* Tweak style
2017-06-26 18:17:05 +01:00
Sasha Aickin
8e2b70c772 Add node-stream.js to react-dom's package.json files entry, enabling the file to be uploaded to npm. (#10044) 2017-06-26 17:17:15 +01:00
Sasha Aickin
167f54c949 Documentation: added info about streaming character encoding. (#10039) 2017-06-26 16:32:11 +01:00
Sasha Aickin
c01d3061bb Pin prettier to a specific version so that it produces the same output on dev machines and CI. (#10038) 2017-06-26 16:30:45 +01:00
Simen Bekkhus
b629b78350 Remove Travis badge from readme (#10041) 2017-06-26 11:22:21 +01:00
Sasha Aickin
411e04bd71 Add ReactDOMNodeStream, adding streaming rendering. (#10024)
* Add ReactDOMNodeStream, adding ability to stream generated HTML.

* Forgot to rename a documentation page.

* Tests are passing locally but failing on CI; attempt to fix that with this tweak.

* Adding some debugging info to try to track down CI problem.

* More debugging of CI. Yay for printf debugging.

* More printf debugging of CI to figure out what is going on with includes during tests.

* I made a truly stupid error with my printf debugging statements for CI. Fixing that.

* And another dumb copy and paste typo.

* The node-stream.js stub for tests wasn't being added because of .gitignore.

* Fix for code review coment https://github.com/facebook/react/pull/10024#discussion_r123606138 . Thanks to @razh for helping me out.

* Removing all the console.logs I put in to debug the build problems on the CI server.

* Fix for code review coment https://github.com/facebook/react/pull/10024#discussion_r123628227 . Thanks to @aweary for the suggestion.

* Response to code review comment https://github.com/facebook/react/pull/10024#discussion_r123649131 . Thanks, @gaearon.

* Responding to code comments https://github.com/facebook/react/pull/10024#pullrequestreview-46104491 , https://github.com/facebook/react/pull/10024#pullrequestreview-46104616 , and https://github.com/facebook/react/pull/10024#pullrequestreview-46104822 . Thanks to @sebmarkbage for the help.

* Attempt to tweak spacing to see if it makes the prettier build step happy.

* Found a prettier bug that wasn't being reported by npm run prettier for some reason.

* Fixed a small prettier issue
2017-06-24 22:31:42 -07:00
Sasha Aickin
55c5cc264b As pointed out by @gaearon in code review comment https://github.com/facebook/react/pull/10024#discussion_r123649131 , ReactDOMServer is an object, not a class. (#10027) 2017-06-23 16:07:25 +01:00
Sasha Aickin
a494741b21 Excluding src/node_modules from .gitignore. (#10028) 2017-06-23 08:05:09 -07:00
Dan Abramov
fa98ecba9f Remove Stack-only www shim code (#10019) 2017-06-22 02:38:02 +01:00
Dan Abramov
8e251c5416 Remove unused www shims (#10018)
* Remove unused www shims

* Delete ReactElement.js
2017-06-21 19:10:45 +01:00
Dan Abramov
df10073f7d Remove "unstable" warning from ReactDOM (#10017)
* Remove "unstable" warning from ReactDOM

* Remove assertion about the warning

* There's more!
2017-06-21 19:06:25 +01:00
Dan Abramov
e68e95284b Remove more isomorphic www shims (#10007) 2017-06-21 17:54:11 +01:00
Michael Ridgway
7b05946776 [#9627] Fix componentWillUnmount test case in isMounted tests (#9629)
* Fix componentWillUnmount test case in isMounted tests and add mixin tests

* Upgrade create-react-class to 15.6.0
2017-06-20 23:37:01 +01:00
Toru Kobayashi
e817e8c95a Fix to work fiber-debugger (#10000) 2017-06-19 21:30:00 +01:00
Andrew Clark
11d67115f3 Update flow to 0.48 (#10006) 2017-06-19 11:45:36 -07:00
Andrew Clark
443ab45835 Only check minPriorityLevel after a commit 2017-06-19 09:53:19 -07:00
Andrew Clark
dcc02dd0f1 Task work inside batched updates is always sync, even for initial mounts
Behavior now matches Stack. It's unfortunate that this prevents us
from unifying SynchronousPriority and TaskPriority.
2017-06-19 09:53:19 -07:00
Andrew Clark
812244b57a Remove Animation priority
There's no advantage to scheduling updates with animation priority
versus scheduling sync work inside requestAnimationCallback. So we can
remove all the animation-specific code. Now there's only one type of
callback.
2017-06-19 09:53:19 -07:00
Andrew Clark
6a0c56cffc ReactNoop.flush methods return an array of yielded values
Allows us to make assertions on the values that are yielded when
performing work. In our existing tests, we do this manually by pushing
into an array.

ReactNoop.flushThrough extends this concept. It accepts an array of
expected values and flushes until those values are yielded.
2017-06-19 09:53:19 -07:00
newvlad
390fda7260 Create higher-order-components.md (#9976) 2017-06-19 10:06:54 -04:00
tokikuch
00ba97a354 Use KeyboardEvent.char in the fallback logic if available (#9792)
When a user types an emoji via Touch keyboard in IE, React's fallback logic
creates the `BeforeInput` event based on the `keypress`.  However, the length
of an emoji character (e.g. `\uD83D\uDE0A`) is two, so the `which` property
does not represent an emoji correctly.

Because IE's KeyboardEvent has the `char` property holding an entire emoji,
we can use it directly instead of converting from the `which`.
2017-06-16 15:14:09 -07:00
Ben Alpert
5029c3d6bc Split out container methods in host config (#9983)
This makes it so you don't need to pattern-match manually to build a renderer where the container and instance types are not the same. Prerequisite to #9835.
2017-06-16 15:00:38 -07:00
Dominic Gannaway
54e8478a3d Move out more ReactDOM FB shims (#9987)
* move out further ReactDOM shims from FB

* fixed a typo
2017-06-16 15:41:47 +02:00
Dominic Gannaway
52e13922b5 removes Synthetic event forwarding module shims (#9945) 2017-06-15 17:07:34 +01:00
Dan Abramov
ca83e3d321 Changelog for 15.6.1 (#9977) 2017-06-15 15:09:13 +01:00
Dan Abramov
310a6c4fc1 Wrap all non-UMD DEV bundles into a condition (#9969)
* Wrap all non-UMD DEV bundles into a condition

* Update header.js

* Create header.js
2017-06-15 00:53:22 +01:00
Bogdan Chadkin
29eb21dd04 Prevents adding units to css custom properties (#9966)
* Prevents adding units to css custom properties

* Fix code style

* Optimize custom property checking

* Prevents adding units to css custom properties in markup creation

* Update passing tests

* Fix argument name and reuse check in DEV
2017-06-14 23:15:09 +01:00
Dan Abramov
7dc27d35c1 Streamline Fiber/Stack testing and bundling setup a little bit (#9964)
* Remove internal forwarding modules for /lib/

* Add *Entry suffix to all entry points

* Don't bundle ReactNativeFeatureFlags since it's shimmed

* Delete TestRendererStack

* Switch tests at forwarding modules rather than via Jest

* Share mocks between regular and equivalence fixtures

* Rename environment flag to be more generic

* Remove accidental variable name change

* Minor naming changes for consistency

Files that have two versions get the engine in variable name.
2017-06-14 22:10:33 +01:00
Andrew Clark
462f4debfe Fuzz tester that simulates Sierpinski Triangle demo (#9952)
* Add ReactNoop.yield, ReactNoop.flushAndYield, ReactNoop.flushUnitsOfWork

Incremental tests often rely on yielding at a specific point. Using an
explicit API should make our tests more resilient to changes
in implementation.

* Fuzz tester that simulates Sierpinski Triangle demo

The tests only assert that the output of the tree is consistent after
each action, and that the final result after all work has flushed is
the expected value. It does not assert how work is reused, which means
it can't detect starvation issues. However, this also means that it
is fairly resilient to changes in our incremental algorithm.
2017-06-14 10:54:18 -07:00
Dan Abramov
14c0fd562d Add addon changes to 15.6.0 changelog (#9958)
* Add addon changes to 15.6.0 changelog

* Oops

* Add to blogpost
2017-06-14 13:57:00 +01:00
Dan Abramov
e2cf6f61c2 Add future changelog for 15.6.0 addon release (#9953) 2017-06-14 13:52:25 +01:00
Dan Abramov
d1445d42ed Reword animation documentation deprecation (#9957) 2017-06-14 13:04:04 +01:00
Dan Abramov
4f19558c6b Use public API in tests wherever possible (#9954)
* Use public API in tests wherever possible

* Add missing src/node_modules files
2017-06-14 00:58:35 +01:00
Flarnie Marchan
ce6108dac3 Blog post for 15.6.0 (#9950)
* Blog post for 15.6.0

**what is the change?:**
A short and sweet summary of 15.6.0 changes

**why make this change?:**
To thank community contributors and call out important changes.

**test plan:**
Visual inspection.
I also looked it over in a markdown viewer - http://dillinger.io/

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

* Add 'Installation' and 'Changelog' to 15.6.0 blog post

**what is the change?:**
Added the 'Installation' section we have on most release blog posts,
customized for the 15.6.0 version of React.
Added the 'Changelog' from master to the blog post.

**why make this change?:**
To show folks how to install React and what changes are in this release.

**test plan:**
Visual inspection

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

* Improvements to blog post, and add self to `authors.yml`

**what is the change?:**
- Add self to contributors so my name turns into a link
- Use backticks for code-ish things
- Second header to ##, not #
- Change production mode link to the new address per @bvaughn's comment
- Update changelog with fixes from https://github.com/facebook/react/pull/9951

**why make this change?:**
Make things more clear and accurate.

**test plan:**
Visual inspect - @flarnie will paste an image of how it appears in the
actual docs.

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

* Further improvements to 15.6 blog post

**what is the change?:**
- Reword heading about deprecation warning changes
- add 'br' s to the list of installation options
- add some stray missing backticks

**why make this change?:**
Clarity and readability

**test plan:**
Visual inspection

**issue:**
https://github.com/facebook/react/issues/9398
2017-06-13 15:51:45 -07:00
Dan Abramov
00340f436b Minor fixes to 15.6.0 changelog (#9951)
* Minor fixes to 15.6.0 changelog

* Remove remaining double space

* Backticks
2017-06-13 13:25:08 -07:00
Flarnie Marchan
ac2f142729 Update changelog for 15.6 (#9949) 2017-06-13 10:53:57 -07:00
Nathan Hunzaker
d7157651f7 Add controlList to DOM property whitelist (#9940)
See:

- https://github.com/WICG/controls-list/blob/gh-pages/explainer.md
- https://developers.google.com/web/updates/2017/03/chrome-58-media-updates#controlslist
2017-06-12 21:09:33 -04:00
Taehwan, No
35ae38db2f Remove addons path deleted in #9209 (#9921) 2017-06-11 20:23:40 +01:00
Dan Abramov
7cd6fd2bc1 Don't build ReactDOMServerStack (#9916) 2017-06-10 18:08:05 +01:00
Jack Ford
a0534fb5c9 Initial commit (#9917) 2017-06-10 15:51:13 +01:00
Brian Vaughn
4aea7c3fad RN Inspector guard against clicks outside of RN (#9911) 2017-06-09 16:10:40 -07:00
Dan Abramov
107d6228db Fix doc styling and formatting issues 2017-06-10 00:04:50 +01:00
Danilo Vitoriano
a8d5b2b329 Move Past Confs, add React Conf Brazil 2017 (#9697)
* move past confs, add React Conf Brazil 2017

* move react europe to past confs

* resolve react europe conflicts

* Create conferences.md
2017-06-09 22:55:18 +01:00
Mario Souto
2b3a7df8d8 Remove extra brace (#9910) 2017-06-09 14:48:59 -07:00
Dan Abramov
2d9d4f6349 Return empty static markup for null components (#9907) 2017-06-09 16:32:00 +01:00
Dominic Gannaway
d13f07925f Add support for implicitly mocked components using ReactServerRenderer (#9906)
* adds the fix (from stack) and adds a test

* updated name of test and ran fiber script
2017-06-09 16:27:00 +01:00
Dan Abramov
47731c9f74 16.0.0-alpha.13 2017-06-09 15:00:01 +01:00
Dominic Gannaway
eadc2b1b7f remove alder32.js (#9905) 2017-06-09 15:19:16 +02:00
Dan Abramov
5c6a496d98 Inline some internals, reduce shared/ utilities between isomorphic and renderers (#9903)
* Make ReactControlledValuePropTypes DEV-only

* Remove canDefineProperty

This breaks IE8. We don't support it.

* Remove getNextDebugID

It was added temporarily to avoid Stack shared state issues across renderers.
Not a problem anymore.

* Make KeyEscapeUtils.unescape() DEV-only

* Remove unused deprecated() module

It's unlikely we'll deprecate anything else on React.* object soon.

* Inline getIteratorFn at the call sites

* Inline ReactElementSymbol

* Inline KeyEscapeUtils into Children and move the file into Stack

It's only used in one place in isomorphic.
It's used more broadly in Stack so we move it there to die.

* Update artifacts

* Reorder declarations for consistency

* Fix Flow
2017-06-09 12:41:50 +01:00
Nathan Hunzaker
cd7ee0f770 Revert "Add React Riot hackathon (#9861)"
This reverts commit 3daabf1efe.
2017-06-08 21:43:37 -04:00
pingan1927
8ab56e5c8b [#9712] fix <input type="number" /> value '.98' should not be equal to '0.98'. (#9714)
* [#9712] fix <input type="number" /> value ".98" should not be equal to "0.98".

* fix eslint error

* fix label error
2017-06-08 21:27:17 -04:00
Sakina Crocker
3daabf1efe Add React Riot hackathon (#9861)
React Riot is the first online worldwide hackathon for React! No cost to enter and teams can win some cool prizes. It's a community event to build the best React app in 48 hours.
2017-06-08 21:18:49 -04:00
Victoria Quirante
b8f32d7a3a Adding React Alicante 2017 to upcoming conferences (#9897) 2017-06-08 21:14:20 -04:00
Dan Abramov
9ff53dd0f4 Rebuild sizes 2017-06-09 00:47:49 +01:00
Dan Abramov
a37012a6b5 Add Bailout effectTag for React DevTools (#9887)
* Add Bailout effectTag for React DevTools

* Instead of tracking bailout, track performed work
2017-06-08 21:23:34 +01:00
Dan Abramov
6ab0531d68 Exclude Stack from DOMServerStream (#9896) 2017-06-08 19:41:02 +01:00
Dan Abramov
6f1d2c940d Delete ReactARTStack (#9895) 2017-06-08 17:05:21 +01:00
Dan Abramov
80fffbe0de Fix a bug with memoizedState affecting React DevTools (#9886)
* Fix a bug with memoizedState affecting React DevTools

* Restructure to avoid duplication
2017-06-07 19:54:57 +01:00
Flarnie Marchan
045e5bce35 Add check for string and null 'rootElement' in ReactDOMFiber (#9869)
* Add check for string and null 'rootElement' in ReactDOMFiber

**what is the change?:**
Before we call 'rootElement.getAttribute' we check that the method is
defined.

**why make this change?:**
There is an internal use case I found where 'rootElement' is a string
and null at different points as the page is rendered.

It looks like this method was added as part of support for re-hydration
of server-side rendered content. I can't imagine we would want to reuse
content if the rootnode is a string or null. Not sure if we want an
earlier check that it's an element before this point.

**test plan:**
`yarn test`
and I manually tested this fix in the internal case where it was
breaking

* Add test and improve check for non-element rootElement

**what is the change?:**
We use the nodeType to check that we have the correct type of
rootElement, and we added a unit test.

**why make this change?:**
Improve this solution to the problem.

**test plan:**
`yarn test`

* run ./scripts/fiber/record-tests
2017-06-07 07:51:05 -07:00
Dan Abramov
34927ea04f Remove useCreateElement flag (#9873)
* Remove useCreateElement flag

* Use Circle node #3 for ESLint
2017-06-07 13:22:26 +01:00
Dan Abramov
fc15d702b8 Delete .travis.yml (#9874) 2017-06-06 23:42:37 +01:00
Dan Abramov
b840229286 Remove prepareNewChildrenBeforeUnmountInStack flag (#9872) 2017-06-06 23:22:34 +01:00
Sebastian Markbåge
262b9c72f5 Don't hydrate any properties other than event listeners and text content (#9858)
* Don't hydrate any properties other than event listeners and text content

This strategy assumes that the rendered HTML is correct if the tree lines
up. Therefore we don't diff any attributes of the rendered HTML.

However, as a precaution I ensure that textContent *is* updated. This
ensures that if something goes wrong with keys lining up etc. at least
there is some feedback that the event handlers might not line up. With
what you expect. This might not be what you want e.g. for date formatting
where it can different between server and client.

It is expected that content will line up. To ensure that I will in a follow
up ensure that the warning is issued if it doesn't line up so that in
development this can be addressed.

The text content updates are now moved to the commit phase so if the tree
is asynchronously hydrated it doesn't start partially swapping out. I use
the regular update side-effect with payload if the content doesn't match up.

Since we no longer guarantee that attributes is correct I changed the
bad mark up SSR integration tests to only assert on the textContent
instead.

* Hydrate text node if possible

Currently we're never matching text nodes so we need to properly branch.
2017-06-06 15:19:38 -07:00
Brian Vaughn
7b16a46e0c Updated label in build-script (#9871)
Changed from "STARTING" to "BUILDING"
2017-06-06 14:54:35 -07:00
Dan Abramov
f50c4c9a43 Stop building ReactTestRendererStack (#9870)
* Stop building ReactTestRendererStack

We no longer use it.

* Remove now-unused sizes in JSON stats
2017-06-06 22:23:16 +01:00
Kurt Furbush
0966e77a2e Update reference-react-component.md (#9863)
Grammatical edit to match same statement in state-and-lifecycle.html
2017-06-06 09:59:44 -07:00
Garmash Nikolay
54ca9181ce Fix url to ng-animate (#9859) 2017-06-06 08:16:27 -07:00
Flarnie Marchan
30e6c6c9c9 Tweak syntax in rollup build script (#9852)
* Tweak syntax in rollup build script

@bvaughn and I already discussed this.

**test plan:**
`yarn build`

* Remove JSDoc comments

**what is the change?:**
removing some comments

**why make this change?:**
The code is basically self explanatory and these comments could get out
of sync.

**test plan:**
Visual inspection, `yarn build` and `yarn test`

**issue:**
https://github.com/facebook/react/issues/9398
2017-06-06 07:26:47 -07:00
Flarnie Marchan
467dda6863 Add PR #9302 to 15.6RC CHANGELOG (#9857)
Just keeping things updated.

https://github.com/facebook/react/issues/9398
2017-06-06 07:26:24 -07:00
Ben Alpert
9d07ea7105 Remove reactComponentExpect (#9856)
Legacy.
2017-06-05 16:42:56 -07:00
Dan Abramov
1710e6c231 Fix CI (#9854) 2017-06-05 22:44:52 +01:00
Sebastian Markbåge
195aa65198 Disable tests of recovering from node.normalize() (#9853)
According to #9836 we're intentionally chosing to not support this until
we have better proof of this being a big need. E.g. to protect against
extensions. In a way that it's not better to push extensions to be fixed.
2017-06-05 16:46:26 -04:00
Arthur Gunn
5aa31534cd Avoid adding trailing semicolons to inline styles. (#9550)
* Avoid adding trailing semicolons to inline styles.

* Prettify.

* For sake of performance, avoid messing around with arrays.

* Change approach to avoid calling .substring.
2017-06-05 10:17:41 -05:00
Fernando Montoya
bc23cc31de Update webpack according to brand guidelines (#9595)
* Update webpack according to brand guidelines

* Change all ocurrences to webpack
2017-06-05 10:01:43 -05:00
Lipis
f4c9ad5791 Remove commented out code (#9795) 2017-06-05 09:59:18 -05:00
Ricardo
9d8519fc0d Insert blockquote on prop value explanation. (#9770)
While reading the page, the "chain of thought" is broken by stating that the `tempertature` and `onTemperatureChange` don't have any special meaning. Making this a blockquote makes that note look more like a comment and keep the "chain of thought" intact.
2017-06-05 09:51:59 -05:00
cjshawMIT
550b0220ca Clarifying how to apply aria-* attributes (#9843)
Provide explicit example of what "keep lowercase" means for `aria-*` attributes.
2017-06-05 09:48:21 -05:00
António Nuno Monteiro
d2824165ae changed -> changes in Changelog (#9833) 2017-06-05 09:37:01 -05:00
Edvin Erikson
b9ddd206f9 Fiber SSR tests (#9846) 2017-06-04 15:44:24 -07:00
Dan Abramov
28e89cfa2d Don't expose internal instance to React Native Inspector (#9840) 2017-06-02 19:34:26 +01:00
Brian Vaughn
a5d659d07e shouldSetTextContent accepts type parameter in addition to props (#9841) 2017-06-02 10:40:29 -07:00
Brian Vaughn
8b6b2f26c4 Add NPM 5 to devEngines (#9838) 2017-06-02 08:03:28 -07:00
Brian Vaughn
5f5cfe80f2 Removed unnecessary RN fiber "topsecret-" prefix (#9837)
* Removed RN fiber 'topsecret-' prefix
* Added a test to ensure that duplicate view-names can't be registered with createReactNativeComponentClass
2017-06-02 07:57:28 -07:00
Dustan Kasten
5f99a48229 Update to Flow 0.47 (#9815)
* bump flow to 0.47

* Fix variadic function flow issues in fiber

* Fix variadic function flow issues in ReactFiberNative

* fix ReactDOM type issues with flow 0.47

* getChildHostContext *does* take an `instance` argument

* change recently added anys to mixedies

* HydrationContext needs a handle on the rootContainerInstance

* prettier
2017-06-01 12:17:21 -07:00
Sebastian Markbåge
9dcc60af33 Delete logTopLevelRenders flag and console timing (#9825)
This was mostly used for timing of initial mounts. However, we haven't
implemented that in Fiber and yet nobody has complained despite running
without it. Further more the update tracks any update within the tree,
not just updates to the props of the top level. This is much less useful
due to the variation.

I could make this track initial mounts too but it's a bit awkward so I'd
rather just delete it if possible. We can run the full profiling mode if
we want more coverage.
2017-06-01 13:00:45 -04:00
Flarnie Marchan
f3dd489f36 Update CHANGELOG for unreleased 15.6 branch (#9827)
* Update CHANGELOG for unreleased 15.6 branch

**what is the change?:**
Added entries for the latest changes.

**why make this change?:**
We are about to do an RC release and folks can look at these notes to
see what is in the planned release.

**test plan:**
Visual inspection

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

* Update changelog regarding `createClass` dep. warning

**what is the change?:**
We decided to strike through the previous changelog item and add it to
the more recent changelog section, since this is the release where the
deprecation warning will actually go out.

**why make this change?:**
To make things clear for everyone using 15.6

**test plan:**
Visual inspection

**issue:**
https://github.com/facebook/react/issues/9398
2017-06-01 09:23:28 -07:00
Nathan Hunzaker
e796d77004 Remove ensureScrollValueMonitoring (#9819)
I never actually removed the rest of this when I got rid of
ViewportMetrics. We no longer need `ReactDOMEventListener.monitorScrollValue`.
2017-06-01 07:18:51 -04:00
Timothy Yung
3f75ea8cdc Create ReactNativeComponent Abstract Class (#9814)
This creates `ReactNativeComponent`, the modern replacement for `NativeMethodsMixin`.

This class is going to allow us to start migrating React Native off `React.createClass(...)` into a typesafe, class-based brave new world.

This also introduces `IReactNativeComponent`, an interface that enforces consistency between `ReactNativeComponent` and `ReactNativeFiberHostComponent`.
2017-05-30 21:55:24 -07:00
Lipis
b88c42d970 Rename Javascript to JavaScript (#9796) 2017-05-30 21:35:22 -05:00
Brian Vaughn
8ca82e1df6 Fixed arity issues in advance of Flow strict checking being enabled (#9816) 2017-05-30 13:50:11 -07:00
Nathan Hunzaker
74044e0eba Inputs should not mutate value on type conversion (#9806)
This is a follow-up on
https://github.com/facebook/react/pull/9584#discussion_r115642293. There
is no need to assign the value property of an input if the value
property of the React component changes types, but stringifies to the
same value. For example:

```javascript
DOM.render(<input value="true" />, el)
DOM.render(<input value={true} />, el)
```

In this case, the assignment to `input.value` will always be
cast to the string "true". There is no need to perform this
assignment. Particularly when we already cast the value to a string
later:

```javascript
// Cast `value` to a string to ensure the value is set correctly. While
// browsers typically do this as necessary, jsdom doesn't.
node.value = '' + value;
```
2017-05-30 15:25:44 -05:00
Dustan Kasten
80bdebc1f9 Fix ReactFiberReconciler annotation to include PI (#8751)
* Fix ReactFiberReconciler annotation to include `PI`

https://github.com/facebook/react/pull/8628#issuecomment-271970297

* Make getPublicInstance type safe

* attempting to trigger the issue @sebmarkbage described

https://github.com/facebook/react/pull/8751#discussion_r95669118

* Unify renderer-specific getPublicInstance with getRootInstance

* Switch on fiber type HostComponent for getPublicRootInstance

* Fix test that was too dynamic (and failing)

* Use PI in reconciler public API

* Prettier
2017-05-30 20:15:48 +01:00
Dan Abramov
af3ba36c7f Add bench remote repo to eslintignore 2017-05-30 16:43:03 +01:00
Dan Abramov
2b44565fca Don't build some stack bundles (#9812)
* Don't build ReactDOMStack and ReactARTStack bundles

* Regenerate results.json
2017-05-30 15:49:32 +01:00
Dan Abramov
fedb2ff8ec Remove createClass, PropTypes, DOM factories, and createMixin from React object (#9788) 2017-05-30 15:35:30 +01:00
Dominic Gannaway
319ba0bba9 adds getName() to base component, to be used by RN inspector (#9811) 2017-05-30 15:27:41 +02:00
Lipis
07d229b28e Rename Github to GitHub (#9797) 2017-05-29 07:36:14 -04:00
Ben Alpert
ba7ba84ec3 Ignore events on not-yet-mounted fibers (#9742)
This isn't necessarily what we want long-term especially with more async, but currently we crash in jsdom in some cases when an img load event gets dispatched synchronously. (Needed for FB-internal D5060180.)
2017-05-26 16:46:46 -07:00
Erik Hellman
d30bc9807e Add Videos link to React Europe 2017 (#9751) 2017-05-27 00:06:28 +02:00
Flarnie Marchan
4ef8865120 Fix externalization of 'lowPriorityWarning' in fb builds (#9790)
**what is the change?:**
 - Add two more special cases for 'lowPriorityWarning' in 'modules.js',
   treating it the same as 'ReactCurrentOwner'.

**why make this change?:**
Without this, the build was including 'lowPriorityWarning' seemingly both as an external module and as part of the bundle.

**test plan:**
Ran `yarn build` and inspected the `React-dev` build. `lowPriorityWarning` did not get bundled in this time.

**issue:**
None yet - @gaearon flagged this for me directly.
2017-05-26 10:35:39 -07:00
Flarnie Marchan
e6af1580fa Update print warning script for low priority warning (#9756)
* Add back caught error and other checks to 'lowPriorityWarning'

**what is the change?:**
This change makes 'lowPriorityWarning' an exact copy of 'warning.js' from
e66ba20ad5/packages/fbjs/src/__forks__/warning.js
where before we had skipped some checks from that module.

- Adds an error which we catch, in order to let people find the error and resulting stack trace when using devtools with 'pause on caught errors' checked.
- Adds check that 'format' argument is passed

**why make this change?:**
- To maintain a closer fork to 'warning.js'
- To allow easier debugging using 'pause on caught errors'
- To validate inputs to 'lowPriorityWarning'

**test plan:**
`yarn test`

**issue:**

* Update 'print-warnings' script to include 'lowPriorityWarning' output

**what is the change?:**
We print the logs from 'lowPriorityWarning' as well as 'warning' from the 'print-warnings' script.

NOTE: This PR is branching off of https://github.com/facebook/react/pull/9754

**why make this change?:**
We want to use the same process of white/blacklisting warnings with 'lowPriorityWarning' that we do with 'warning'.

**test plan:**
This is not super easy to test unless we are doing a sync with FB afaik. I plan on running a sync in the next few days, or next week at latest, for the sake of not landing big things on a Friday. That will be the actual test of this.

**issue:**
https://github.com/facebook/react/issues/9398
2017-05-26 07:47:49 -07:00
Flarnie Marchan
114b9c5500 Add 'Test Utils' docs back to main navigation (#9676)
* Add 'Test Utils' docs back to main navigation

**why make this change?:**
We accidentally removed this - still supporting the use of Test Utilities, so we should have them in the docs.

**test plan:**
Manually tested the website - will insert a screenshot.

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

* Move test-utils docs to reference section

**what is the change?:**
Moved from 'advanced guides' to 'reference'

**why make this change?:**
It makes more sense as a reference

**test plan:**
Visual inspection (flarnie may add a screenshot)

**issue:**

* Add back the shallow renderer docs and remove outdated docs

**what is the change?:**
- Remove outdated 'shallow renderer' docs on 'test utils' page, and point to the updated 'shallow renderer' docs.
- Re-add a link to the updated 'shallow renderer' docs on the main navigation.

**why make this change?:**
This was already approved in https://github.com/facebook/react/pull/9331 which was then cherry-picked to https://github.com/facebook/react/pull/9359/commits and landed on master.

I'm not sure why some of these changes didn't persist. For now just adding back the changes we need.

**test plan:**
Manually inspected website - will insert screenshots.

**issue:**

* Further improvements to 'shallow rendering' and 'test utils' docs

Thanks @gaearon for the improvements!

**what is the change?:**
- Remove <hr/> from end of 'shallow rendering' docs
- 'documents' -> 'documentation'
- Move 'shallow rendering' redirection section to top of 'test utils' docs
- Add intro sentence about testing to 'shallow rendering' docs

**why make this change?:**
Documentation helps people learn.

**test plan:**
Visual inspection
2017-05-26 07:47:18 -07:00
Will Myers
546e7721ec Update blog post which creates unhandled promise rejection (#9668)
* Update 2015-12-16-ismounted-antipattern.md

In case anybody else stumbles across this old blog post, I wanted to submit a patch to help with unhandled rejections.  

`#then` and `#catch` each return new Promise instances, so here we actually create two new promises (that aren't assigned).  If the argument promise to `#makeCancelable` rejects, the promise created by `#then` will be an unhandled rejection, which in Node 7 will be an uncaught error.  

By using the second argument of `#then` to handle rejections instead, we don't need to worry about the runtime finding any unhandled rejections here.

* Style updates

* Add update notice
2017-05-26 14:35:19 +01:00
Dan Abramov
c632e58da6 Update numbers 2017-05-26 14:32:26 +01:00
Max Donchenko
43f2ea079c Fix typo (#9786) 2017-05-26 12:37:35 +01:00
Brian Vaughn
3630bf3559 Corrected a stubbed modules problem for RN fiber bundle (#9784) 2017-05-26 11:15:37 +01:00
Sebastian Markbåge
9c7a312d7c Hydration of previously rendered server markup (#9580)
* Don't double validate the DOM container

The warnings need to check a valid container but that should happen in
unstable_renderSubtreeIntoContainer too so might as well move it in.

* Hydrating DOM

Hydrates a server-rendered DOM tree by traversing it and connecting up the nodes if they match. Attributes are not diffed. They're assumed to be accurate on matching nodes.

* Remove meta data filtering from test

Because the current server renderer includes the meta data, it remains in a revived tree.

* Annotate because Flow

* Don't track insertion effects if we're going to hydrate

During initial mount, we should not track Placement

* Fix up test cases to ignore errors that we no longer throw

TODO make these warnings instead.

* Correctly track hydration state inside a newly inserted tree

When we don't match the first hydration node, we'll do an insertion.
Currently we keep the next hydratable sibling so that we know where to
pick up once we're done with the insertion. Unfortunately this makes the
nodes inside the insertion think that there's a node to hydrate.

I used to check for the direct parent but that doesn't work on nested host components.

We need to instead keep track of that we're in an hydration context but
we're not currently hydrating. Once we pop passed the inserted node can
we resume hydrating.

* Hacky fix to isMounted

isMounted checks whether a component is inside a Placement. During
hydration we ideally don't do any Placements if hydration matches the tree.

To work around this I use the Placement flag on the root, which isn't used
for anything else. But only temporarily while we're hydrating. Then reset
it before committing.

* Record tests

* Comments
2017-05-25 15:19:19 -04:00
Dan Abramov
63cd93af07 Fix Prettier 2017-05-25 19:34:14 +01:00
Dan Abramov
7494e0485d Don't strip error messages from builds (#9778) 2017-05-25 18:56:18 +01:00
Dominic Gannaway
492f7a8200 extractErrors -> extract-errors (#9777) 2017-05-25 19:49:58 +02:00
Brian Vaughn
824d22c9d9 Prevent fiber from leaking into RN stack renderer (#9775)
Since stripEnvVariables was used to replace __DEV__ references, I assumed it (and other plugins) we run before requires statements were processed. Obviously I was wrong 😬 and as a result, the RN Stack and Fiber builds were way too large. This is an attempt to mimic the approach taken with DOM renderer and stub out modules that we explicitly don't want to include.

The alternative to this would have been to fork findNodeHandle, NativeMethodsMixin, ReactNativeBaseComponent, etc. and essentially avoid using the feature flag. That didn't seem tenable. The previous injection approach also doesn't work here because the circular references it resulted in caused Rollup to choke when creating the modules.
2017-05-25 18:14:46 +01:00
Tom Occhino
7b5bdc14d8 Remove build time extractErrors message when error codes can't be found (#9555)
* Remove error message when error codes cannot be found

* Re-record fiber tests to fix CI
2017-05-25 17:07:55 +01:00
Brian Vaughn
108a395f4e Strip comments from UMD_PROD and NODE_PROD builds, not FB_PROD (#9776)
This regressed with the recent addition of RN_* bundles. I was accidentally stripping comments from FB_PROD when I meant to do the opposite. This corrects that mistake.

No significant bundle size change occurs when re-running this build against the version prior to the RN_* bundles.
2017-05-25 16:24:05 +01:00
Toru Kobayashi
cbef3fd412 Warn it only in DEV (#9772) 2017-05-25 07:31:35 -07:00
Danny Hurlburt
1f667fd37f Bind handleChange Instead of Calling (#9764) 2017-05-24 17:26:44 +01:00
Brian Vaughn
c22b94f14a ReactNative flat renderer bundles (#9626)
* Split ReactNativeFiber into separate ReactNativeFiberRenderer module
Hopefully this is sufficient to work around Rollup circular dependency problems. (To be seen in subsequent commits...)

* Split findNodeHandle into findNodeHandleFiber + findNodeHandleStack
This allowed me to remove the ReactNative -> findNodeHandle injections, which should in turn allow me to require a fully-functional findNodeHandle without going through ReactNative. This will hopefully allow ReactNativeBaseomponent to avoid a circular dependency.

* Un-forked findNodeHandle in favor of just inlining the findNode function impl

* takeSnapshot no longer requires/depends-on ReactNative for findNodeHandle
Instead it uses the new, renderer-specific wrappers (eg findNodeHandleFiberWrapper and findNodeHandleStackWrapper) to ensure the returned value is numeric (or null). This avoids a circular dependency that would trip up Rollup.

* NativeMethodsMixin requires findNodeHandler wrapper(s) directly rather than ReactNative
This works around a potential circular dependency that would break the Rollup build

* Add RN_* build targets to hash-finle-name check

* Strip @providesModule annotations from headers for RN_* builds

* Added process.env.REACT_NATIVE_USE_FIBER to ReactNativeFeatureFlags
This is kind of a hacky solution, but it is temporary. It works around the fact that ReactNativeFeatureFlag values need to be set at build time in order to avoid a mismatch between runtime flag values. DOM avoids the need to do this by using injection but Native is not able to use this same approach due to circular dependency issues.

* Moved a couple of SECRET exports to dev-only. Removed SyntheticEvent and PooledClass from SECRET exports. Converted Rollup helper function to use named params.

* Split NativeMethodsMixins interface and object-type

* Add @noflow header to flat-bundle template to avoid triggering Flow problems
When Flow tries to infer such a large file, it consumes massive amounts of CPU/RAM and can often lead to programs crashing. It is better for such large files to use .flow.js types instead.

* NativeMethodsMixin and ReactNativeFiberHostComponent now share the same Flow type

* Collocated (externally exposed) ReactTypes and ReactNativeTypes into single files to be synced to fbsource. ReactNativeFiber and ReactNativeStack use ReactNativeType Flow type

* Build script syncs RN types and PooledClass automatically

* Added optional sync-RN step to Rollup build script

* Added results.json for new RN bundles
2017-05-24 17:06:30 +01:00
Flarnie Marchan
6ac91d24c4 Improve low priority warning (#9754)
* Add back caught error and other checks to 'lowPriorityWarning'

**what is the change?:**
This change makes 'lowPriorityWarning' an exact copy of 'warning.js' from
e66ba20ad5/packages/fbjs/src/__forks__/warning.js
where before we had skipped some checks from that module.

- Adds an error which we catch, in order to let people find the error and resulting stack trace when using devtools with 'pause on caught errors' checked.
- Adds check that 'format' argument is passed

**why make this change?:**
- To maintain a closer fork to 'warning.js'
- To allow easier debugging using 'pause on caught errors'
- To validate inputs to 'lowPriorityWarning'

**test plan:**
`yarn test`

**issue:**

* Update results.json

* Run prettier
2017-05-24 07:55:00 -07:00
Flarnie Marchan
e5f4327993 Add #8575 to changelog for 15.6 (#9740)
Just two more items before we will have an RC ready. :)
2017-05-23 15:43:38 -07:00
Dominic Gannaway
0ea4674d08 Adds a ReactNativeInspector API to ReactNativeRenderer (#9691)
* fixed conflicts with master

* splits fiber and stack implementations

* prettier run

* updated fiber implementation based on feedback

* updated fiber implementation for selecting inspector hierarchy

* run of prettier

* fixed flow issues

* updated stack implementation

* fixes an implementation difference where before it wasnt properly understoof

* addresses comments in PR feedback

* updated stack inspector to use emptyObject

* Update ReactNativeFiberInspector.js

Fixes a flow error

* fixes last flow error

* prettier

* applied changes to how viewConfig works for fibers and extracted measure out

* fixed bad paste

* fixes flow errors

* prettyify

* revmoed getComponentName changes

* updated logic for getHostProps and addressed other PR feedback

* improved throwing to invariant and update stack implemenation based on feedback

* prettier
2017-05-23 22:22:21 +02:00
Flarnie Marchan
964c263d8f Downgrade deprecation warnings from errors to warnings (#9650)
* Initial regeneration of results.json

**what is the change?:**
We ran `yarn build` and updated the perf. stats record.

**why make this change?:**
Some commits have landed without updating this. By getting an initial update, I can run the build script again after my changes and see any size regressions.

* Downgrade deprecation warnings from errors to warnings

**what is the change?:**
Swapping out `warning` module for a fork that uses `console.warn`.
It looks like we were using the `warning` module for deprecation notices, *but* there is also a 'deprecated' module designed specifically for deprecation notices.

However, we could not find any place that it was currently used.

Since React's build process is not 100% clear to me, I assume it could still be used somewhere by something and just updated it along with other deprecation notices.

We might consider a follow-up diff that does some clean up here;
 - remove 'deprecated' module if it's unused, OR
 - use 'deprecated' module for all our current deprecation warnings

**why make this change?:**
- We have had complaints about noisy warnings, in particular after introducing new deprecations
- They potentially cause CI failures
- Deprecations are not really time-sensitive, can ship without breaking your app, etc.

For more context - https://github.com/facebook/react/issues/9395

**test plan:**
`npm run test`
and unit tests for the new modules
and manual testing (WIP)

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

* Add 'lowPriorityWarning' to ReactExternals

**what is the change?:**
We won't bundle 'lowPriorityWarning' with the rest of React when building for Facebook.
NOTE: A parallel commit will introduce an internal implementation of 'lowPriorityWarning' in Facebook's codebase, to compensate. Will post a comment with the diff number once that is up.

**why make this change?:**
So that the sync between github and Facebook can go more smoothly!

**test plan:**
We will see when I run the sync! But this is a reasonable first step imo.

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

* Make state mutations an error, not low-pri warning

**what is the change?:**
Even though this is a "deprecation" warning, we still want to use 'console.error' for it.

**why make this change?:**
- It's not likely to come up now, hopefully, because this warning has been present for some time
- This will cause real issues in production if ignored

**test plan:**
`yarn test` - we did fix one test which failed bc of this change

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

* Fix test of assigning to this.state that was only passing in fiber

**what is the change?:**
updated a unit test for assigning directly to state; it once again raises an error and not a warning.

**why make this change?:**
So that tests pass

**test plan:**
 REACT_DOM_JEST_USE_FIBER=1 yarn run test

**issue:**

* Update results.json
2017-05-23 09:35:42 -07:00
Samuel Hapák
1f80931d32 Add ReactiveConf (#9723) 2017-05-22 16:12:52 +02:00
Erik Hellman
5b7e81579d Move ReactEurope 2017 from Upcoming Conferences to Past Conferences (#9726) 2017-05-22 13:52:46 +02:00
Hikaru Suido
3d6d641a8c Move previous events to the end (#9729) 2017-05-22 11:45:57 +02:00
Ben Alpert
f1abc3cd12 Expose ReactFiberTreeReflection in FB build (#9741)
I need this for some hacky stuff I'm doing (D5060180).
2017-05-21 16:37:17 -07:00
Ben Alpert
f0a0999c3b Add test for key warning at top level (#9473) 2017-05-21 15:39:25 -07:00
Dave Lunny
5cf571839e "Timeline" => "Performance" (#9602)
As of Chrome 58, the Timeline tab is now called the Performance tab, this updates the "Optimizing Performance > Profiling Components with Chrome Performance" section of the docs to reflect that.
2017-05-21 15:28:25 -04:00
Paul Manta
4b53dd0e6b Disable ESLint's no-extend-native for two lines (#9625) 2017-05-20 19:58:23 -04:00
Flarnie Marchan
91459086a9 Add PR #9642 to 15.6 change log (#9649)
Just keeping this fresh.

Issue:
2017-05-20 09:22:07 -07:00
Dan Abramov
bb89c11788 New blog post: What's New in Create React App (#9719) 2017-05-19 05:31:35 +01:00
Dylan Kirby
c1d4c8bc60 fix typo in benchmark docs (#9706) 2017-05-18 19:13:59 -04:00
Billy Shih
6ee701d18a Fix typo (#9717)
The example explaining how redux's connect works doesn't use the same component name. Line 264 references (Comment) while 274 referenced (CommentList). Changed 264 to match 274.
2017-05-18 19:06:29 -04:00
Sebastian Markbåge
39671ba45b Move some tests from failing to passing except dev (#9711)
These throw because we're asserting on the warnings. Make this not throw
so that they instead only fail to assert the warnings.
2017-05-17 23:54:26 -07:00
Sebastian Markbåge
e5e874d0e8 Add package builds for new server renderer and enable tests (#9710)
* Adjust some expectations of the server markup format of Fiber

Currently this case is using the stack renderer.

* Ensure debug hooks are injected into the Stack server renderer

In our tests this normally happens because ReactDOM.js injects them into
the shared module, but when Fiber is enabled or this is its own flat
bundle, that doesn't happen.

* Add package builds for new server renderer and enable tests

ReactServer -> ReactDOMServerStream

This file is going to be the replacement for ReactDOMServer.

I mock ReactDOMServer and user ReactDOMServerStream when we have
the fiber flag enabled. I'm now also enabling this as the default for
distributions builds (react-dom/server on npm and
react-dom-server.production.min.js as umd bundle).

I'm using traverseStackChildren instead of traverseAllChildren because
traverseAllChildren is now only in the isomorphic package and we don't
want to build all of that that into the server package.

I also have to require lower case react for the builds to work.
2017-05-17 17:19:11 -07:00
Tom Occhino
8af729231b Initial Stack-Free SSR Implementation (#9673)
* Server Rendering initial commit

Originally authored by spicyj, tweakes to rebase it and make it run by tomocchino.

Adding ReactDOMServerRendering and a createTagMarkup utility function which will be used in it.

* Fix build system, add shortcut scripts

* Make more ReactServerRendering-test unit tests pass

* Make ReactServerRendering-test pass with copious help from Ben

This is pretty hacky and I just inlined everything, but at least I sort of understand how it works now, and all of the tests are passing. There are also only 68 tests failing in the integration test suite.

* remove some unnecessary cruft

* Run prettier on ReactDOMServerRendering.js

* Fix more unit tests with Ben

* Add support for input and textarea by copy pasting a bunch of code from ReactDOMInput/ReactDOMTextarea

* Fix context unit tests with more copy paste :)

* progress on select

* Holy shit, 100% of ReactDOMServerIntegration tests are passing

* Checkpoint to fix some of the ReactDOMComponent-test tests

* Fix missing checkPropTypes

* Fix some unit tests in ReactDOMComponent-test

* Run prettier on everything, thanks Ben

* get rid of ssr tests that are looking for component file names

* add assertValidProps check

* rename flattenChildren to flattenOptionChildren per Ben

* Fix all the lint crap

* Move things around in the file and turn ReactDOMServerRenderer into a class

* remove changes I added to package.json

* remove separate createOpenTagMarkup file for now since everything should be copy pasted into a single file

* re-record Fiber tests

* Revert ReactDOMServer.js and the fiber tests per Sebastian

This also reverts the changes I made to ReactDOMComponent-test.js which removed the stack which is missing in the new server renderer"

* Rename files based on feedback

Moving src/renderers/dom/server/ReactDOMServerRendering.js to src/renderers/server/ReactServerRenderer.js and add src/renderers/server/ReactServer.js which makes this new codepath completely separate.

* Change throw to invariant, even though we probably need to remove this at some point

* fix prettier.. sigh
2017-05-17 14:53:59 -07:00
Nathan Hunzaker
7deb12fdde Remove invalid css from DOMFixtures (#9600) 2017-05-17 17:22:32 +02:00
Michal Srb
1c449cea34 Make the world a better place by placing closing /> on a new line (#9699) 2017-05-16 15:42:48 -07:00
Toru Kobayashi
17ab69c1ec [Fiber] Fix to call deferred callbackQueue even if updates are aborted (#9634)
* Fix to call deferred callbackQueue even if updates are aborted

* Add an assertion to make sure the update processed, but wasn't committed yet
2017-05-12 10:45:51 -07:00
Flarnie Marchan
0f129973ea Move 'lighthouse' and 'nodegit' to 'optionalDependencies' (#9675)
**what is the change?:**
See title.

**why make this change?:**
Both these dependencies were causing issues when working on React internally at
FB.

'lighthouse' requires node >=6 and we don't want to folks working on React to
using that version of node.
https://github.com/GoogleChrome/lighthouse/blob/master/package.json#L11

'nodegit' for me throws an error related to libssh2 and it's annoying to make
this work in every OS. See https://github.com/nodegit/nodegit/issues/1266

**test plan:**
`npm/yarn install`
Runs with no errors on my CentOS machine and also on MacOSX laptop.

**issue:**
This is blocking work related to https://github.com/facebook/react/issues/9398
2017-05-12 15:41:30 +01:00
Ben Alpert
f0df495f9a Run prettier on scripts/bench (#9671) 2017-05-11 16:14:17 -07:00
Ben Alpert
e736b4c4b9 "yarn prettier" only checks changed files (#9670)
CI still checks all of them.
2017-05-11 14:47:29 -07:00
Tom Occhino
fe750c9d5d Move assertValidProps into shared/utils since it will be used by the … (#9669)
* Move assertValidProps into shared/utils since it will be used by the server renderer

* Extract getCurrentOwnerName from assertValidProps and pass it in
2017-05-11 14:43:35 -07:00
Flarnie Marchan
bec0f736df Wrap fiber-only test in feature flag (#9665)
**what is the change?:**
A test was added for a change to Fiber's behavior in #9608, and because of a
bug in our CirclCI script it landed when failing for non-fiber runs of the
tests.

This just wraps the test in a feature flag because it seems clear it was
only intended to test the new fiber behavior.

Thanks to @gaearon for pairing on this! :)

**why make this change?:**
So that tests are passing on master.

**test plan:**
`npm run test ReactCompositeComponentState`

**issue:**
None - figured it out before anyone opened an issue afaik.
2017-05-11 13:32:04 +01:00
Dan Abramov
cc2450b7bf Always pass error code to CI (#9663) 2017-05-11 13:13:01 +01:00
shifengchen
d7e6ef0f88 Edit two errors in docs (#9659) 2017-05-11 11:34:35 +01:00
Tom Occhino
ffcbb0bfc2 Move small utility modules out of ReactDOM(Fiber)?Component (#9658)
* Move small utility modules out of ReactDOM(Fiber)?Component

These are all going to be needed in the server renderer, so I'm moving them out now so I can use them from in there.

* Fix `didWarnShadyDOM = false;` line
2017-05-10 22:01:48 -07:00
Philipp Spieß
b48107ed57 Remove injectReactDOMEventListener from ReactBrowserEventEmitter (#9656)
* Remove injectReactDOMEventListener from ReactBrowserEventEmitter

This PR removes the injection of ReactDOMEventListener from
ReactBrowserEventEmitter. Instead, the required initialization will
happen directly in ReactDOMInjection.

This injection was (probably) originally implemented for React Native
but never used, so we can clean it up.

* Mention how to see the full ouput of fiber tests
2017-05-10 17:05:38 -07:00
Carolina Powers
7c1e971e7f Fix typo on tutorial.md. (#9644)
The absence of the word `this` will cause CodePen
to scream at you. This fix should avoid that.
2017-05-10 08:23:53 +01:00
Dan Abramov
c1ba8ef264 Mention new fixes for addons in Changelog (#9643) 2017-05-10 01:03:34 +01:00
Philipp Spieß
c0e32a1b03 Rename ReactEventListener to ReactDOMEventListener (#9640)
`ReactEventListener` is a DOM-specific module although the name suggests
otherwise. This change renames the module to the more specific
`ReactDOMEventListener`.
2017-05-09 16:17:03 -07:00
Dan Abramov
831fd6940e Sync RN downstream fix (#9637) 2017-05-09 20:29:37 +01:00
Flarnie Marchan
7842ff97c2 Add PR #8356 to the change log for v15.6 (#9636)
Another change log update ~ v15.6 is closer than ever! :)

Issue:
2017-05-09 18:54:45 +01:00
Flarnie Marchan
e249c935ed Add PR #9584 to 15.6 change log (#9598)
Updating the change log~ :)

**issue:**
https://github.com/facebook/react/issues/9398
2017-05-09 18:22:17 +01:00
Dominic Gannaway
a7d8ebd2b5 Add React benchmarking infrastructure (#9465)
* Initial commit for WIP benchmarking infrastructure

* fixed lint issues and ran prettier

* added <rootDir>/scripts/bench/ to ignore paths for Jest

* tidied up code and fixed a few bugs in the runner.js

* fixed eslint

* improved the benchmark output from the runner

* fixed typo

* tided up print output in runner.js

* throw error if chrome canary is not installed on mac

* added better bench stats output (tables)

* added benchmark diff to table results

* adds bundle size comparisons to results

* tidied up the results

* fixed prettier output

* attempt to trigger bech for circleci build

* fixes flow exlclusion for lighthouse module

* added class components benchmark

* cleaned up stats.js

* stability changes

* circleci node version to 7

* added another benchmark

* added colours to the different benchmarks to check if being cached

* force no-cache headers

* added more info messages

* refactor chrome launching.

* fixed an issue where launcher.kill might fail

* Move server to runner. Launch it only once.

* tidy up

* changes the logic in how the remote repo is checked out

* removes bench from circleci build

* removed colors from benchmarks (no longer needed)

* added CI integration comment

* added hacker news benchmark

* added skipBuild functionality

* relabelled remote

* Add confidence intervals

* added first meaningful paint

* removed some unused code

* reverted code.json

* updated benchmark runs back to 10

* no longer breaks when results contain missing bundles

* adds CPU throttling

* renamed build to remote-repo

* small fix to build

* fixed bad merge

* upped runs to 10 from 2 again

* properly pulls master

* removes old-bench

* runs benchmarks in headless mode

* adds a --headless option

* improved the git build process

* added README

* updated based feedback from review

* adds merge base commit sha

* addressing more PR feedback

* remove built JS react files

* updated .gitignore

* added combined bundle load times to the metrics
2017-05-09 17:13:54 +01:00
Ben Alpert
542dac4a23 Fix return value of ReactDOMFiber.unmountComponentAtNode (#9619) 2017-05-05 17:54:53 -07:00
Andrew Clark
767a5d60e8 updateQueue -> newUpdateQueue
Fix typo introduced after renaming a variable to address shadowing.
2017-05-05 14:21:17 -07:00
Andrew Clark
628b82c808 Allow assigning to this.state inside componentWillMount, with a warning 2017-05-05 14:03:29 -07:00
Andrew Clark
1232666590 Don't recreate instance when resuming a class component's initial mount
Recreating the class instance causes refs (and other callbacks) to close
over stale instances.

Instead, re-use the previous instance. componentWillMount is called
again. We also call componentWillReceiveProps, to ensure that
state derived from props remains in sync.
2017-05-05 14:03:29 -07:00
Dan Abramov
6facb85f85 Fix horizontal scrolling in docs (#9613) 2017-05-05 18:03:39 +01:00
Dan Abramov
138ff5e46b Fix sequencing in the Tutorial (#9615)
* Fix sequencing in the Tutorial

* Update tutorial.md

* Update tutorial.md
2017-05-05 18:02:13 +01:00
Andrew Clark
824e991241 Update flow to 0.45 (#9603) 2017-05-04 11:31:14 -07:00
Dan Abramov
943367faa7 Tweak Tutorial based on feedback 2017-05-04 00:30:12 +01:00
Nathan Hunzaker
6875fa867f Remove loose check on non-number controlled inputs. Fix trailing dot issue. (#9584)
* Remove loose check when assigning non-number inputs

This commit removes a check I added when working on number input
issues where we perform a loose check on an input's value before we
assign it. This prevented controlled text inputs from disallowing
numeric text entry.

I also added a DOM fixture text case.

Related issues:

https://github.com/facebook/react/issues/9561#issuecomment-298394312

* Use strict equality as a guard before assigning input.value

This commit adds back the guard around assigning the value property to
an input, however it does it using a strict equals. This prevents
validated inputs, like emails and urls from losing the cursor
position.

It also adds associated test fixtures.

* Add copy command after build for interup with surge.sh
2017-05-03 13:37:56 -05:00
Flarnie Marchan
50a60dbe74 Add 'unreleased' incremental change log for v15.6.0 (#9544)
* Add 'unreleased' incremental change log for v15.6.0

**what is the change?:**
Adding a section to the change log where we start accumulating
annotations for React v15.6.0.

**why make this change?:**
- Saves us the trouble of writing the change log entry all at once when
  we do the release.
- Adds transparency about what is in the upcoming release, for those who
  aren't following https://github.com/facebook/react/issues/9398

**test plan:**
Visual inspection

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

* Minor tweaks to v15.6.0 changelog annotation

**what is the change?:**
- added missing `#` for commit hashes
- added minor details to two annotations

Thanks to @gaearon for the code review comments.

**why make this change?:**
Consistency and clarity.

**test plan:**
Visual inspection

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

* Remove hashes from commit numbers

**what is the change?:**
We had added hashes to some commit numbers, but ideally only do that
for PRs.

**why make this change?:**
Consistency - this is how github displays those types of links too. PRs
get a '#', and commits don't.

**test plan:**
Visual inspection

**issue:**
https://github.com/facebook/react/issues/9398
2017-05-03 09:00:36 -07:00
Dan Abramov
2b7012ffb0 Fix mobile layout 2017-05-03 15:39:02 +01:00
Dan Abramov
ac00e849fd Fix a typo 2017-05-03 15:04:25 +01:00
Dan Abramov
e6c0ac9a0a Use a more specific link 2017-05-03 11:04:18 +01:00
Addy Osmani
f86256ece0 Add DEV mode note to installation doc (#8784) (#9157)
* Add DEV mode note to installation doc (#8784)

* Address feedback from Dan on wording
2017-05-03 11:03:04 +01:00
Dan Abramov
185db64c76 Add more info about building for production (#9592)
* Add more info about building for production

* Add more info to the docs
2017-05-03 11:01:53 +01:00
Andrew Clark
535afaf759 16.0.0-alpha.12 2017-05-02 14:26:42 -07:00
Dan Abramov
ba72c99183 Report version and bundle type to DevTools (#9586)
* Report version and bundle type to DevTools

* Flip the flag the other way around

It's easier to remember 0 is always PROD, and 1 is like DEV flag. 2 could be PROFILE in the future.

* Add version to RN inject call
2017-05-02 20:34:10 +01:00
Joe Critchley
109d1c95e3 [Docs] Show the name 'React' first in the homepage's <title> (#9582) 2017-05-02 14:22:24 +01:00
Dan Abramov
45dbcfb67d Add missing passing test 2017-05-02 14:22:09 +01:00
Andrew Clark
4d8174480c Only perform class checks on initial mount
Avoids firing warnings multiple times
2017-05-01 15:53:19 -07:00
Andrew Clark
9145f40eb8 Fix bug where null props is passed to constructor when resuming mount
Another example of where the pending/progressed/memoized props model
would benefit from a refactor.
2017-05-01 15:53:19 -07:00
Andrew Clark
ae4fa9ad94 Demonstrate failing test when resuming mount of class component 2017-05-01 15:53:14 -07:00
Dan Abramov
8dcf9c7be7 Change warning casing (#9573)
* Change warning casing

* Update ReactFiberClassComponent.js

* Update ReactCompositeComponent.js
2017-05-01 21:51:47 +01:00
Andrew Clark
b1384062d2 Move AsyncUpdates flag check to class-only path (#9570) 2017-05-01 13:23:54 -07:00
Andrew Clark
835c21a5ef Don't prevent extensions on Fiber if using bad Map polyfill (#9572)
Many Map polyfills work by adding an extra field to the key type.

In the future, we'll likely print a warning.
2017-05-01 13:23:37 -07:00
Abhay Nikam
1f5693ec67 Warning message updated if defaultProps were defined as an instance property (#9493)
* Updated the warning message for setting defaultProps on instance property.

* Updated the testcases for the defaultProps warning.

* Updated the warning message for defaultProps set on instance property.
2017-05-01 13:30:40 -05:00
Dan Abramov
ca4250a1e0 Remove unnecessary # in changelog 2017-05-01 18:32:08 +01:00
Frankie Bagnardi
e9d6f3f10e [Tutorial] Make it easier to follow the instructions (#9454)
* tutorial: adds note about onClick

* tutorial: show full square component

* merge

* fixes line number

* tutorial: misc changes

* fixes Board render initial code sample

* [tutorial] adds codepen links and misc small fixes

* removes useless arrow functions, #9531

* {this.renderSquare} new lines

* be more explicit about history state

* fixes highlight

* following along locally

* changes todo to this.props.value

* removes calculateWinner from initial codepens and includes it in tutorial

* removes note about calculateWinner at end of file

* adds debug-view and debug-view-final

* removes debug view, updates codepen instructions

* adds another codepen

* tutorial.md

* tutorial.md

* tutorial.md

* tutorial.md

* Put . into links for consistency with docs

* Make the very first change easier to follow

* A few more changes
2017-05-01 17:22:26 +01:00
Flarnie Marchan
2e053a5be3 fix typos in CHANGELOG 2017-05-01 09:01:36 -07:00
Flarnie Marchan
0549c4506f Update Changelog for v15.5.1-15.5.4 (#9537)
* Update Changelog for v15.5.1-15.5.4

This could really use extra code review attention since the history of
these changes was a bit convoluted to follow.

After talking to @bvaughn and @acdlite, we thought it might make sense
to put the 'add-ons' changes in a separate change log. The other option,
of including them in the main React change log, seemed the more
confusing of the two.

Also this commit is related to and somewhat blocked by
https://github.com/reactjs/prop-types/pull/40

**what is the change?:**
Adding the change log for recent patch versions of React.

**why make this change?:**
We missed this step in the flurry of releasing patches, and it's useful
for folks who want info about what version to use.

**test plan:**
Visual inspection of the change log.

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

* Further improve CHANGELOG entries for v15.5.1-15.5.4

**what is the change?:**
- Use the '[@author] in [#PR/commit]' format for annotations
- Make annotations less technical, more clear
- Move 'React Addons' updates into main changelog
- Remove separate 'React Addons' changelog

**why make this change?:**
These changes each make things more clear and accurate.

**test plan:**
Visual inspection

**issue:**

* Fix final nits in CHANGELOG

**what is the change?:**
- Put backticks around package names
- Reformat link to to commit in '([@user](...) in [#NNNN](...))' format
- Remove newlines after subheaders; in the past we sometimes have
  included a newline after the subheader, but most recently it looks
  like we do not.
- Add some missing punctuation.

**why make this change?:**
Consistency and aesthetics

**test plan:**
Visual inspection

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

* Add deprecation notice to v15.5.0-15.5.3

**what is the change?:**
Adding deprecation notice to some recent React versions.

**why make this change?:**
These versions of React use a version of `prop-types` that had a
critical bug. We updated the dependency in React 15.5.4, and hopefully
people will see this notice and update.

**test plan:**
Visual inspection

**issue:**
https://github.com/facebook/react/pull/9537
2017-05-01 08:59:42 -07:00
Dan Abramov
f217228326 Clarify where docs live 2017-05-01 13:39:10 +01:00
Marcos Ojeda
f737d63302 docs better indicate that state updaters shallowly merge with state (#9554)
this was a surprise to me because the docs seemed to indicate that when
using an updater, the result _needed_ to be a new state object. I was
[not alone](https://twitter.com/ken_wheeler/status/857939690191806464)
i think in discovering this as a result of the previous tweet in the
thread.
2017-04-30 17:40:22 -07:00
Ben Alpert
f677bfc964 Fix __proto__ bug in ReactDOMSelect (#9536)
https://twitter.com/rauschma/status/857307345231249409
2017-04-29 08:23:00 -07:00
Sebastian Markbage
50d6f9656d Don't try to load asset manifest in dev mode
We're not going to use it so don't try to load it since it may not have
been built yet.
2017-04-27 21:57:01 -07:00
Sebastian Markbåge
b9da1741cb SSR fixture (#9547)
Adds a server-rendering fixture based on create-react-app without ejecting.

This is using the full-page strategy because I wanted to flush out any issues with it. Turns out there's a lot of little things that are fixable and some non-fixable. This actually surfaced some differences between the current strategy and the one I had in mind.

This uses the asset manifest from webpack to pass the final URLs to the client. This ensures that we can render the same exact mark up on the client - including the URL to our own script that we're running in.

Doing full document renders work with 15.x as long as the checksum matches. However, with the patch up reviving strategy I had in mind it would end up removing the CSS tags that webpack injects before running our render call. This is a behavior change.

In dev mode the server runs a proxy in front of the normal CRA webpack server so that we can replace the HTML request for the root page.

I don't know what the best way to link in the react and react-dom packages. Each fixture has a different strategy so here's another one. Just add NODE_PATH=../../build/packages in front of all commands.
2017-04-27 21:03:32 -07:00
Manas
182642b2ea Fiber ReactDOM shouldn't throw on import in Node environment if it's unused (#9389)
* Fixes #9102 by fake polyfilling rAF (and rIC)

* Ensure we restore globals even if test fails + minor nits

* Remove periods
2017-04-27 13:13:03 +01:00
Sriram Thiagarajan
70c01963d9 pre format only compile time errors (#9538)
* pre format only compile time errors

* Style tweak
2017-04-27 11:49:34 +01:00
Andrew Clark
0e3280e2c6 includes -> indexOf 2017-04-26 18:10:27 -07:00
Andrew Clark
1fd582ba20 Fix unnecessary ReactDOM require (#9534)
Apparently, when you mark something as external in Rollup, a require
statement is inserted even if the module isn't used. This is causing
ReactDOM and several other modules to be inserted unnecessarily.

We need a better fix for this, but I'm pushing this quick fix for
now since it's blocking sync to www.
2017-04-26 18:07:53 -07:00
lamo2k123
48479438a3 Completely remove Object.prototype.hasOwnProperty.call() (#7853)
* Avoid directly calling hasOwnProperty

* correct use hasOwnProperty

* added eslint rules `no-prototype-builtins` http://eslint.org/docs/rules/no-prototype-builtins

* single style hasOwnProperty

* added file info /* global hasOwnProperty:true */

* added file info /* global hasOwnProperty:true */

* fixed no-prototype-builtins after merge

* yarn run prettier fixed

* remove src/addons

* return space after *

* remove /* global hasOwnProperty:true */

* Removed using Object.prototype.hasOwnProperty.call()

* yarn run prettier fixed

* Removed using Object.prototype.hasOwnProperty.call()
2017-04-26 20:30:38 +01:00
wacii
1816d06d6b Add guide on integrating with non-react code (#9316)
* Add guide on integrating with non-react code

* Capitalize guide title

* Make links to other docs relative

* Rephrase 'What it does do'

* Remove experimental syntax

* Capitalize Backbone

* Remove empty lifecycle method in generic jQuery example

* Use shouldComponentUpdate() not componentWillUpdate()

* Prefer single quotes

* Add cleanup to generic jQuery example

* Capitalize React

* Generalize the section on Backbone Views

* Generalize the section on Backbone Models, a little

* Add introduction

* Adjust wording

* Simplify ref callbacks

* Fix typo in generic jQuery example

* Fix typos in Backbone models in React components

* Fix more typos in Backbone models in React components

* Add generic section on integrating with other view libraries

* Stress the benefits of an unchanging React element

* Small changes to introduction

* Add missing semicolon

* Revise generic jQuery wrapper section

Moved the section on using empty elements to prevent conflicts above the
code example and added brief introduction to that example.

* Add usage example for Chosen wrapper

* Prevent Chosen wrapper from updating

* Note that sharing the DOM with plugins is not recommended

* Mention how React is used at Facebook

* Mention React event system in template rendering section

* Remove destructuring from function parameters

* Do not name React components Component

* Elaborate on unmountComponentAtNode()

* Mention preference for unidirectional data flow

* Rename backboneModelAdapter

* Replace rest syntax

* Respond to updated model in connectToBackboneModel

* Rewrite connectToBackboneModel example

* Rework connectToBackboneModel example

* Misc changes

* Misc changes

* Change wording

* Tweak some parts
2017-04-26 17:24:22 +01:00
RSG
9824d52a4c React.createElement syntax (#9459)
* React.createElement syntax

Added React.createElement syntax.
I think this is required for this tutorial.

* Reword
2017-04-26 14:25:40 +01:00
Tetsuya Hasegawa
d6cc1d1755 Remove outdated Troubleshooting section (#9489)
* fixed a simple typo in README.md troubleshooting section

* Remove the troubleshooting section
2017-04-26 14:14:07 +01:00
Sriram Thiagarajan
7ccfb07337 fixed error formatting in live editor (#9497) 2017-04-26 14:06:53 +01:00
Daniel Lo Nigro
cf24d87177 [site] Load libraries from unpkg (#9499)
* [site] Load libraries from unpkg

* Revert Gemfile changes
2017-04-26 14:02:50 +01:00
chocolateboy
3d60d4cc7d [Docs] Fix confusing description for the <script>...</script> usage (#9502)
* Fix confusing description for the <script>...</script> usage

* Update jsx-in-depth.md

* Update reference-react-dom-server.md

* Update reference-react-dom.md

* Update reference-react.md
2017-04-26 13:57:22 +01:00
Dmitri Zaitsev
a8c223ab41 Add reference to the Hyperscript libraries (#9517)
* Add reference to the Hyperscript libraries

I feel these should be mentioned as they provide terser syntax than using `R.createElement` directly, even with a shorthand.

* Rephrase
2017-04-26 13:54:31 +01:00
Mateusz Burzyński
dce3c28ccb Prevent process polyfill to be included in builds because of process guards preventing code replace (#9518) 2017-04-26 13:47:35 +01:00
Dominic Gannaway
71f201b5c3 updates yarn.lock (#9530) 2017-04-26 13:43:36 +01:00
Frankie Bagnardi
14fa8a5452 adds indirect refs to docs (#9528)
* adds indirect refs to docs

* Add more info

* Explain clearer

* Rephrase

* Update refs-and-the-dom.md

* Update refs-and-the-dom.md

* Update refs-and-the-dom.md

* Update refs-and-the-dom.md

* Update refs-and-the-dom.md

* Update refs-and-the-dom.md

* Update refs-and-the-dom.md

* Update refs-and-the-dom.md

* Update refs-and-the-dom.md

* Update refs-and-the-dom.md

* Update refs-and-the-dom.md
2017-04-26 13:40:09 +01:00
Andrew Clark
8ba820a699 Use prop-types instead of prop-types factory (#9526)
Latest versions of prop-types don't depend on React, so the factory is
not necessary, and in fact bloats the build because it is intended for
15.5 and so doesn't strip out the checkers in prod.
2017-04-25 14:32:27 -07:00
Andrew Clark
09a9c646fd Rename react-dom to ReactDOM in Facebook www (#9525) 2017-04-25 13:30:48 -07:00
Brian Vaughn
81336fd8ce Prettier 2017-04-25 10:19:06 -07:00
Benedikt Meurer
0e587c1a8e Improve component type check in getComponentKey. (#9464)
* Improve component type check in getComponentKey.

The sequence
```
component && typeof component === 'object'
```
checks whether component is any JavaScript object except document.all.
Since document.all cannot occur here, this can be replaced with the
usual
```
typeof component === 'object' && component !== null
```
sequence, which yields true for all JavaScript objects and is well
optimized by all JavaScript engines.

* Run yarn prettier.
2017-04-25 09:39:30 -07:00
Nathan Hunzaker
a9d0deb8e1 Consolidate events between EventConstants and BrowserEventEmitter (#9512) 2017-04-25 09:24:10 -07:00
Maciej Kasprzyk
d12c41c7a6 Describe fixtures dir in the codebase overview (#9516)
* Describe fixtures dir in overview

* Fix folder name
2017-04-25 10:25:32 +01:00
Brian Vaughn
2905e56904 Bumped version numbers and built 16.0.0-alpha.11 2017-04-24 18:52:10 -07:00
Brian Vaughn
e71b3087c8 Added stack renderer to react-test-renderer bundle temporarily (#9514)
Also fixed an error in a temporary export property that had been added to the React object
2017-04-24 18:45:43 -07:00
Andrew Clark
4cbadd3fb6 Prettier 2017-04-24 17:19:38 -07:00
Andrew Clark
b61f060044 ReactARTStack should use ReactDOM's ReactUpdates (#9515) 2017-04-24 17:03:12 -07:00
Nathan Hunzaker
86dd083f45 Move ReactDOMFactories into separate package (#8356)
- Update examples to no longer use React.DOM
- Add package and documentation entries for react-addons-dom-factories
- Update dom-factories readme
- Set up proxy to intercept React.DOM usage
- Update ReactDOM children tests to use createElement
- Add more specific warning assertion for React DOM factories
- Do not use expectDev in ReactDOMFactories tests
2017-04-24 08:08:17 -07:00
Jen Wong
c8a64e2637 Updates how-to-contribute.md to use JSFiddle referenced in submit Git issue template (#9503) 2017-04-23 18:03:11 -05:00
Paul O’Shannessy
bcb6f0eac4 Don't build gh-pages branch on CircleCI (#9442) 2017-04-22 22:33:43 +01:00
Flarnie Marchan
39ca8aacf8 Add link to 'Typechecking with PropTypes' under 'Advanced Guides' (#9472)
This should have been retained in our docs, since PropTypes are only
moved and not deprecated.

Partially handles #9467, and I'll make a separate PR to
https://github.com/reactjs/prop-types to add more docs to the README
there.
2017-04-22 10:41:39 -07:00
Brian Vaughn
9d225b5a44 Stop passing prevContext param to componentDidUpdate (#8631) 2017-04-21 13:15:22 -07:00
Soo Jae Hwang
ec527cc834 [WIP] Warn in dev if shouldComponentUpdate is defined on PureComponent (#9240)
* Add test for React.PureComponent

* Add warning when shouldComponentUpdate is declared in a PureComponent

* Add actionable warning

* Add warning in Fiber

* Format added code by running yarn prettier

* Move pure sCU check to checkClassInstance

That way it warns before the component updates
2017-04-21 09:55:16 -05:00
Abhay Nikam
5518bd44a9 Warning added if defaultProps were defined as an instance property (#9433)
* Added warning when defaultProps was defined as an instance property

* Added testcases to check warning message for defaultProps

* Update fiber tests
2017-04-21 09:46:19 -05:00
Vitaliy Potapov
895dca587b Warn about Infinity in style value (#9360)
* warn about Infinity in style value

* prettier
2017-04-21 09:41:43 -05:00
Roman Matusevich
6dfb65a121 Remove Prev Next links from add-ons documentation (#9226) 2017-04-21 15:31:17 +01:00
David Hu
f5144121f9 Add more details in jsx-in-depth.md (#9006)
* jsx-in-depth.md add ternary statement for javascript expressions section

* jsx-in-depth.md add explanation to get falsey values for props

* update jsx-in-depth.md

* ensure links work locally, remove section about falsey prop values

* Fix links
2017-04-21 15:27:39 +01:00
Benton Rochester
217d271032 Ignoring files for vim users. (#9199) 2017-04-21 15:25:34 +01:00
Brandon Dail
42bc28bbfd Use setProperty when setting style properties (#9302)
* Use setProperty when setting style properties

setProperty is faster in all/most modern browsers. It also lets us support CSS variables.

* Only use setProperty when setting CSS variables

* Add test to ensure setting CSS variables do not warn

* Make this PR pretty again

* Run fiber test script
2017-04-20 15:25:39 -05:00
Brian Vaughn
41290742e6 Bumped version numbers for alpha 10 (#9474) 2017-04-20 13:06:51 -07:00
Brian Vaughn
73ca89408b Updated PropTypes test to work with newer prop-types version (#9471)
The prop-types lib got an anti-spamming change in 15.5.8 that broke some of our tests (see reactjs/prop-types/commit/e1d51dd0efbd0eee5e4a8d24759f2a4d518721d3). This PR resolves that by resetting the prop-types import between tests.
2017-04-20 12:48:53 -07:00
Andrew Clark
28bc8860bc Run prettier after update to 1.2 in master 2017-04-20 11:39:04 -07:00
Andrew Clark
b4d77b98ed Fix subtree tests so that async component is not top-level 2017-04-20 11:38:13 -07:00
Andrew Clark
9b676a7d0b Remove enableAsyncSubtreeAPI from host config
Use a ReactFeatureFlag instead. It won't be per-renderer, but we likely
won't need that.

When enableAsyncSubtreeAPI is false, unstable_asyncUpdates is ignored,
but does not warn or throw. That way if we discover a bug in async mode,
we can flip the flag and revert back to sync without code changes.
2017-04-20 11:38:13 -07:00
Andrew Clark
0c896ffe6b Change unstable_asyncUpdates from an instance to a static property
This lets us check for its existence before the instance is constructed.

Also works with functional components.
2017-04-20 11:38:13 -07:00
Andrew Clark
488b973d68 Use number type for bitfields
Unions don't enumerate all the possible combinations of bitfields. I'm
not actually sure why this was type-checking before.

number doesn't provide much safety but it's more correct.
2017-04-20 11:38:13 -07:00
Andrew Clark
f69748601d Remove unstable_asyncRender() API in favor of always using a wrapper 2017-04-20 11:38:13 -07:00
Andrew Clark
abd07dffb3 Rename contextTag -> internalContextTag 2017-04-20 11:38:13 -07:00
Andrew Clark
26d70fd334 Add enableAsyncSubtreeAPI to host config
Allows us to control this feature on a per-renderer basis
2017-04-20 11:37:18 -07:00
Andrew Clark
864973c544 Run Fiber test script 2017-04-20 11:37:18 -07:00
Andrew Clark
ada638a064 Run prettier 2017-04-20 11:37:18 -07:00
Andrew Clark
609e97ebe7 instance.unstable_asyncUpdates = true creates an async subtree
Same behavior as unstable_asyncRender. Can be used to wrap a specific
subtree, rather than an entire root.
2017-04-20 11:37:18 -07:00
Andrew Clark
3bf398bcbc ReactDOM.unstable_asyncRender creates an async-by-default tree
The default priority of updates in a async tree is LowPriority, rather
than SynchronousPriority.

Warns if you call unstable_asyncRender on a tree that was created with
the normal, sync ReactDOM.render.
2017-04-20 11:37:18 -07:00
Andrew Clark
6f8fec4b80 Use different default priority depending on the AsyncUpdate context flag
- A priority context of NoWork represents the default priority
- Changed the signature of getPriorityContext to accept the fiber that
is about to be updated.
2017-04-20 11:36:35 -07:00
Andrew Clark
1b388366c1 Inherit contextTag from the parent on creation
A fiber has all the context flags of its parent. It may also add
additional ones during construction/mount. After mounting, contextTag
shouldn't change.
2017-04-20 11:35:08 -07:00
Andrew Clark
f1df675b93 Add contextTag field to Fiber type
contextTag is a bitmask that describes properties about the fiber
and its subtree. For example, the AsyncUpdates flag indicates whether
the subtree should use async scheduling.

When a fiber is created, it inherits the bitmask of its parent.
2017-04-20 11:35:08 -07:00
Eric Sakmar
648822952f Adds CSS Grid properties to list of unitless numbers (#9185) 2017-04-20 11:20:15 -07:00
Ben Alpert
b1768b5a48 Prettier 1.2 (#9462) 2017-04-20 11:18:33 -07:00
Ben Alpert
32480a0462 Add component stack to invalid-object-child error (#9415)
https://twitter.com/EsaMatti/status/835952325525188608 (28 likes!)
2017-04-20 09:49:46 -07:00
Dan Abramov
e59506c478 Bump prop-types 2017-04-20 16:40:58 +01:00
Almero Steyn
a92128e7fb [Docs: Installation] Fix tabs responsive layout - Resubmit (#9458)
* [Docs: Installation] Fix tabs responsive layout

* Move tabs a pixel down

* Remove left margin on first tab

* Remove the long line

* Fix mobile styles
2017-04-20 11:49:48 +01:00
Brian Vaughn
9bb7ca5001 Fix master (ran prettier) 2017-04-19 19:03:04 -07:00
Brian Vaughn
66f2097f33 Shallow renderer and test utils bundles (#9426)
Shallow renderer and test utils bundles

Adds new bundles introduced with React 15.5 release to master (and 16 alpha)

react-dom/test-utils:

This new bundle contains what used to be react-addons-test-utils. This bundle shares things from react-dom rather than duplicates them.

A temporary createRenderer method has been left behind as a way to access the new shallow renderer. This is for the ReactNative release cycle only and should be going away before the final release.

react-test-renderer/shallow:

This new shallow renderer is almost entirely stand-alone (in that it doesn't use the React reconciler or scheduler). The only touch points are ReactElement and prop/context validation. This renderer is stack and fiber compatible.
2017-04-19 16:45:31 -07:00
Ben Alpert
53dbb191d6 Uncomment invariant in UIManager mock (#9461) 2017-04-19 16:28:59 -07:00
Brian Vaughn
8782ab759e Fix CI failures in master (#9455)
* Ran prettier over UIManager mock
* Temporarily disabled an invariant() in UIManager mock that was breaking tests
* Updated Fiber passing tests
2017-04-19 08:59:40 -07:00
Flarnie Marchan
3e48422fdc Warn for keys in fragments - third approach (#9445)
* Fix tests to pass when we warn for missing keys in fragments

In most cases we just needed to add the 'key' prop.

This ignores the tests which are already failing on master when running
with ` REACT_DOM_JEST_USE_FIBER=1` - there are 8.

All tests should now pass with `npm run test`, and the 8 which fail when
running `REACT_DOM_JEST_USE_FIBER=1 npm run test` are the same 8 which
are failing on master.

* Added missing key warning for children in array fragments

After trying twice to reuse the code between the ReactChildFiber and
ReactElementValidator, I am thinking that it's simpler to just have some
duplication of code. The parts that are shared are interleaved with
parts which cannot be shared, either because of singleton modules that
must be required differently in 'isomorphic' and the 'renderers', or the
fact that 'warning' requires a hard coded string.

Test Plan:

- Added test to ReactChildren-test
- Manually tested via fixture that was not committed.

* commit updated "scripts/rollup/results.json"

* Make 'ReactChildren-test' more specific, and remove unneeded nesting

Based on helpful tips from @spicyj and @aweary's review
 - Made the unit test for the warning on missing keys more specific
 - Removed unneeded nesting in the code which generates missing key
   warning
 - Change test syntax to use JSX to be more consistent

Also fixes flow warning.

* Commit update of scripts/rollup/results.json

* run "scripts/fiber/record-tests"
2017-04-19 08:05:04 -07:00
Almero Steyn
9526174e30 [Docs] Add accessibility to tabs in installation documentation (#9431)
* Add accessibility to tabs in installation documentation

* Change color and fix styling
2017-04-19 12:31:39 +01:00
Joel Denning
233195cb6b Fixing the instantiation of customized builtin elements (related to custom elements) (#9313)
* Fixing the creation of customized builtin elements

* Whitespace

* Running prettier

* Updating ReactDOMFiberComponent
2017-04-19 12:07:16 +01:00
Fabrizio Castellarin
1ce562ead3 Reorganize the "following along" instructions (#9453)
* Reorganize the "following along" instructions

* Minor tweaks
2017-04-19 12:00:15 +01:00
Ben Alpert
b392f1e2fc Fix errors in React Native children management (#9449)
* Fix errors in React Native children management

- Support using appendChild to move an existing child (Fiber does this, but we were assuming all children here were new; Yoga throws if you insert a child that already has a parent)
- Calculate beforeChildIndex after removing old child (previously, off by one when the new position is later than the old position)

* Add better children management tests for RN
2017-04-18 17:31:33 -07:00
Filip Hoško
10eaf26809 FIX: Move CRA build info under it's tab page (#9452)
* FIX: Move CRA build info under it's tab page

* Add some links
2017-04-18 18:17:28 +01:00
Dan Abramov
c5783901a8 Tweak tutorial structure 2017-04-18 18:07:16 +01:00
Dan Abramov
7b80361b6b Add missing tutorial sidebar links 2017-04-18 18:00:54 +01:00
Dan Abramov
a41d469bcf Minor tutorial nits 2017-04-18 17:53:53 +01:00
Dan Abramov
a7f124f48f Fix duplicate sentence 2017-04-18 17:44:32 +01:00
Dan Abramov
da124f2fb1 Minor tweaks to tutorial 2017-04-18 17:40:59 +01:00
Frankie Bagnardi
8417534bd0 [Tutorial] ES6, installation, and button closing tag (#9441)
* adds notes to tutorial on es6 and installation

* fixes tutorial mention of opening button tag

* More writing

* Update
2017-04-18 17:34:43 +01:00
Abhishek Soni
d724115144 Fixed grammar (#9432)
* Update codebase-overview.md

* Some more fixes
2017-04-18 16:38:39 +01:00
hanumanthan
53a3939fb0 Lift state up - Updating the documentation to mention that onClick is a synthetic event handler (#9427)
* Lift state up - Updating the documentation to mention that onClick is a synthetic event handler

* Review comments - Rephrase to handle synthetic events and event handler patterns

* Tweak
2017-04-18 16:27:45 +01:00
Michał Ordon
37f9e35ad9 Sort out conferences by date (#9172) 2017-04-18 15:38:19 +01:00
Jayen Ashar
ccb38a96cf Update jsx-in-depth.md (#9178)
* Update jsx-in-depth.md

Line 9 isn't changed

* Move selection down

* Fix
2017-04-18 15:29:17 +01:00
Fraser Haer
363f6cb2e5 Unique headings for linking purposes (#9259)
Previously two headings were 'Javascript Expressions' - now 'Javascript
Expressions as Props' and 'Javascript Expressions as Children'
2017-04-18 14:47:44 +01:00
NE-SmallTown
359f5d276f [Documentation] Impreove the react-component section of doc (#9349)
* Impreove react-component of doc 

[#9304](https://github.com/facebook/react/issues/9304)

* update description

* add missing space
2017-04-18 14:42:40 +01:00
Chris Pearce
f6c4fe6cbb Only attempt to clear measures if we created the measure (#9451)
This fixes an issue where if we decided not to create a measurement we would clear ALL measurements from the performance entry buffer due to passing `undefined` as the entry name.
2017-04-18 14:31:47 +01:00
Sung Won Cho
ac9d698636 Make nodeType into constant for readability and reuse (#9113)
* Make nodeType into constant for readability and reuse

* Fix eslint line length warning

* Delete unused nodeType values

* Destructure HTMLNodeType constant

* Make nodeType into constant for readability and reuse

* Fix eslint line length warning

* Delete unused nodeType values

* Destructure HTMLNodeType constant

* Fix test

* Format using prettier
2017-04-15 18:37:12 +01:00
Ben Alpert
7bf686b76f Add component stack to ReactControlledValuePropTypes (#9435) 2017-04-14 19:50:43 -07:00
Ben Alpert
1447d9f1ae Add component stack to uncontrolled-to-controlled warning (#9416)
https://twitter.com/JulianVModesto/status/836089555304448000
https://twitter.com/abevoelker/status/836040051993763842
2017-04-14 16:57:47 -07:00
Arshabh Kumar Agarwal
f54fdd5441 Add warning if rendering and HTMLUnknownElement (#9163)
* Add warning if rendering and HTMLUnknownElement

* Records fiber tests

* Fixes linting and server render tests

* Incorporates review comments

* Uses ownerDocument instead of document

* uses el instead of creating a new element

* Removes warning check of voidElementTags

* Add missing space to unknown element warning

* Only call isCustomComponent once

* Spy on console in menuitem test

Since menuitem is treated as an unknown element in jsdom it triggers the unknown element warning.

* Add unknown element warning to Fiber

* Replace instanceof with toString check

It is more resilient.

* Record tests
2017-04-14 11:30:38 -05:00
Abhay Nikam
36c935ca8f Updated the Good First Bug section in readme (#9429)
* Updated the Good First Bug section in readme

* Inconsistent use of quotes. Prefered single quotes instead of double quotes

* Updated Good first bug link in how_to_contribute doc.

* Undo JSX attribute quote change

* don't capitalize "beginner friendly issue"
2017-04-14 11:02:07 -05:00
Vikash Agrawal
db989c0f63 Updated link for good first bug's in README.md (#9273)
* Updated link for good first bug's in README.md

* Changed text for beginner friendly bugs

* update beginner friendly bugs section title
2017-04-14 10:56:38 -05:00
Abhay Nikam
a95e1d8ffc Updated recommended links for installation in readme (#9425) 2017-04-13 23:15:13 +01:00
Dan Abramov
4c8c5debac Switch Installation to a tab when hash is present (#9422) 2017-04-13 21:51:19 +01:00
Marks Polakovs
855b8d3526 Add tabs to installation page (#9275, #9277) (#9401)
* Add tabs to installation page (#9275, #9277)

This adds tabs for create-react-app and existing apps to the installation section of the docs. The tab implementation is a simplified version of React Native's installation page.

Fixes #9275.

* Use classList instead of className

* Use same implementation as in RN
2017-04-13 20:54:12 +01:00
Eric Elliott
30d6c598c6 Docs: Clarification of setState() behavior (#9329)
* Clarification of setState() behavior

`setState()` is a frequent source of confusion for people new to React, and I believe part of that is due to minimization of the impact of the asynchronous behavior of `setState()` in the documentation. This revision is an attempt to clarify that behavior. For motivation and justification, see [setState Gate](https://medium.com/javascript-scene/setstate-gate-abc10a9b2d82).

* Update reference-react-component.md

* Signature fix

* Update to address @acdlite concerns

* Add more details
2017-04-13 19:13:55 +01:00
Jack
4e0c57315a Update proptypes doc (#9391)
* Update proptypes doc

* Removed note
2017-04-13 18:11:23 +01:00
Gabriel Lett Viviani
22655d5759 Fix the proptypes deprecation warning url on the "Don't Call PropTypes Warning" doc page (#9419)
* Use the same prop-types link on the warning docs page as the main proptypes doc page

* Link to repo instead
2017-04-13 15:15:34 +01:00
hanumanthan
5cd44d21e9 Refractor docs to indicate that state set to props in constructor will not recieve the updated props (#9404) 2017-04-13 00:56:22 +01:00
Dominic Gannaway
446f186279 Update typechecking-with-proptypes.md (#9392)
* Update typechecking-with-proptypes.md

* Update typechecking-with-proptypes.md

* Use consistent style for PropTypes import
2017-04-12 00:04:38 +01:00
Brian Vaughn
6cd7618bd7 Bumped versions for 16.0.0-alpha.9 and re-built 2017-04-11 14:40:56 -07:00
Brian Vaughn
2beec2f308 createClass + PropTypes + checkPropTypes warnings (#9399)
(Temporarily) re-adds getters with deprecation warnings for React.PropTypes, React.checkPropTypes, and React.createClass.

* 08bd020: Replace all references to React.PropTypes with prop-types to avoid triggering our own warning message.
* ef5b5c6: Removed several references to React.createClass that appeared after rebasing this branch. (reviewed by @flarnie)
* 524ce20: Added getters for createClass and PropTypes to the main React isomorphic object, behind one-time warning messages. (reviewed by @spicyj)
* db48f54: Fixed Rollup bundles to inline 'prop-types' and 'create-react-class' for UMD builds only. (reviewed by @spicyj, @trueadm )
* cf49cfd: Updated tests-passing.txt to remove tests that were deleted in this branch.
* d34109a: Responses to PR feedback from @spicyj. (Added package.json dependencies to packages/react and packages/react-dom. Renamed a var. Expanded on an inline comment.)
* 488c8d2: Added warning for moved package to React.checkPropTypes accessor too and updated build script.
* 83bcb29: Wordsmithing for deprecation notices (added fb.me links).
* afdc9d2: Tweaked legacy module inlining to remove order-of-deps constraint
* d1348b9: Removed $FlowFixMe.
* 7dbc3e7: More wordsmithing of deprecation notices based on Dan's feedback.
2017-04-11 14:28:03 -07:00
Dan Abramov
aa1f8687d7 Use caret range in blog instructions
The release was a bit broken.
2017-04-11 22:04:29 +01:00
Denis Pismenny
cec9b07402 Fix minor typo in lifting-state-up.md (#9408) 2017-04-11 22:03:53 +01:00
Ben Alpert
b1a06bd945 Fix ignore patterns in package.json (#9409) 2017-04-11 13:58:14 -07:00
Andrew Clark
957fbc92b1 react-create-class -> create-react-class 2017-04-10 17:06:32 -07:00
Andrew Clark
ce489262a1 Add react-create-class integration tests
These are mostly copied from the old ReactClass-test module.
2017-04-10 17:03:05 -07:00
Andrew Clark
6b539f280d Convert createClass caller
This snuck in after rebasing
2017-04-10 17:03:05 -07:00
Andrew Clark
646e786334 Warn once when attempting to access React.createClass
Should still be undefined.
2017-04-10 17:03:05 -07:00
Andrew Clark
194b25f709 Run prettier 2017-04-10 17:03:05 -07:00
Andrew Clark
c76a4eaa2a Update tests to use plain JavaScript classes
Tests that rely on replaceState or isMounted use
updater.enqueueReplaceState and updater.isMounted instead.
2017-04-10 17:03:05 -07:00
Andrew Clark
087fe88f20 Rewrite Stack implementation of ReactART using plain classes
instead of createClass
2017-04-10 17:03:05 -07:00
Andrew Clark
5cfaa7cf68 Delete createClass
Remove createClass from isomorphic package
2017-04-10 17:03:05 -07:00
Maciej Kasprzyk
c2309bf4b5 Delete examples dir from codebase overview (#9397)
Removes doc about folder that no longer exists.
2017-04-10 16:26:09 -05:00
Dan Abramov
457b812c26 Fix ReactARTStack bundles to not include DOM Stack inside (#9394)
* Move ReactDOMFrameScheduling.js to shared (between dom and art)

* Fix ReactARTStack bundles to not include DOM Stack inside
2017-04-10 22:01:56 +01:00
Luke Belliveau
6c8fd16a06 Amended implementation-notes.md with link to Dan Abramov's post describing difference between React components, elements, and instances (#9388)
* Amended implementation-notes.md to include a link to a blog post by Dan Abramov, explaining the difference between components, elements, and instances. An understanding of this distinction is crucial in tracing through Implementation pseudocode, and reading Dan's blog first may ease newcomers into understanding the implementation.

* adjusted wording to maintain stylistic consistency with rest of content, per @aweary's request
2017-04-09 14:37:41 -05:00
Aaron Ackerman
d3d4b599b9 Point users to the npm page instead of the github project for prop-types (#9373) 2017-04-08 04:05:34 +01:00
Andrew Clark
e5ce3fd368 Blog post and changelog for 15.5.0 (#9368) 2017-04-07 14:41:16 -07:00
Dan Abramov
72196da829 Replace shims with explicit React access from the renderers for shared global state (#9366)
* Remove non-existent /lib/ from souce files

* Replace all shims with explicit access

This deletes shims and changes to access require('react').__DO_NOT_USE__ from renderers for global shared state.

I cloned flattenChildren() and traverseAllChildren() because they relied on CurrentOwner but were used both from Stack and Isomorphic. The stack implementations will die, and the isomorphic ones can be changed to be optimized for Children specifically in the future.

I also deleted UMD shims because they are now unnecessary. I moved the internals assignment to main modules since they're now used in tests, and made them direct UMD entry points.
2017-04-07 22:07:10 +01:00
Flarnie Marchan
6eaa539ad5 Update example snippet in old 'React.addons' doc page (#9363)
* Update example snippet in old 'React.addons' doc page

This makes the example more consistent.

* Add back the pointers in docs that were mistakenly removed

In https://github.com/facebook/react/pull/9359 we accidentally removed
pointers in some doc pages. Putting them back now.

* Link to npm package instead of github page

This seems like a more stable place to link to in the 'context'
document.
Based on @bvaughn's feedback in https://github.com/facebook/react/pull/9359
2017-04-07 13:47:54 -07:00
Dan Abramov
d88696941d 16.0.0-alpha.8 2017-04-07 18:47:23 +01:00
Dan Abramov
d9fd08df26 Make ReactDebugCurrentFrame shared state between core and renderers (#9365) 2017-04-07 17:03:22 +01:00
Dan Abramov
e303e00d06 Tweak Rollup setup (#9364)
* Remove unused Rollup shim and exports

* Add a way to build multiple bundles
2017-04-07 16:17:36 +01:00
Dan Abramov
a8d37a7aa0 Remove indirection in checking propTypes (#9358)
* Remove indirection in checking propTypes

* Silence flow errors
2017-04-07 15:23:28 +01:00
Flarnie Marchan
8f7281199d All doc updates forv15.5 (#9359)
* `react-addons-test-utils` -> `react-dom/test-utils`

Updating all references and docs on the `React.addons.TestUtils` and the
shallow renderer to refer to the correct targets.

Instead of:
```
const React = require('react');

// ...
React.addons.Testutils
// or

const ReactTestUtils = require('react-addons-test-utils');
```
we now show:
```
const ReactTestUtils = require('react-dom/test-utils');
```

And for shallow renderer, instead of:
```
const shallowRenderer = TestUtils.createRenderer();
```

we now show:
```
const shallowRenderer = require('react-test-renderer/shallow');
```

* Update the 'prev' and 'next' attributes of 'add-ons' docs

These flags are used to set arrow links to easily navigate through the
documents. They were wrong or missing in some of the 'add-ons' pages and
this bothered me when manually testing the updates from the previous
commit.

* Update syntax for instantiating shallow renderer

Missed this when updating the docs for the changes to shallow-renderer
in React 15.5.

* Fix pointers in addons docs

Thanks @bvaughn for catching this

* Make example of shallow renderer more consistent

We should show using the same variable names between code samples.

* Make names in example even more consistent

We should use the same variable name for the same thing across examples.
`renderer` -> `shallowRenderer`.

* Update docs to deprecate React<CSS>TransitionGroup

 - removes link to the docs about `ReactCSSTransitionGroup` and
   `ReactTransitionGroup` from the main navigation
 - updates 'prev' and 'next' pointers to skip this page
 - adds deprecation warning to the top of the page
 - remove references to these modules from the packages README
 - updates 'add-ons' main page to list this as a deprecated add-on

* Update `React.createClass` to `createReactClass` in the docs

The `React.createClass` method is being deprecated in favor of
`createReactClass`.

* Remove 'React.createClass' from top level API docs

It no longer makes sense to have a section for the 'createClass' method
in this page, since it won't be available as a top level method on
'React'.

I initially was going to pull the section about 'createClass' into a
separate page to add under 'addons' but it was short and duplicative of
the 'react-without-es6' docs. So I just linked to those.

* Remove *most* `React.PropTypes` from the docs

I am doing the docs for `context` in a separate commit because that case
was a bit less clear-cut.

We will no longer support `React.PropTypes` as a built-in feature of
React, and instead should direct folks to use the `PropTypes` project
that stands alone.

Rather than retaining the `React.PropTypes` examples and just revamping
them to show the use of the stand-alone `PropTypes` library with React,
it makes more sense to direct people to that project and reduce the
perceived API area and complexity of React core. The proper place to
document `PropTypes` is in the README or docs of that project, not in
React docs.

* Update `context` docs to not use `React.PropTypes`

We use `React.PropTypes` to define the `contextType` for the `context`
feature of React. It's unclear how this will work once `React.PropTypes`
is replaced by the external `PropTypes` library. Some options;

a) Deprecate `context`, either in v16 or shortly after. Seems reasonable
based on the intense warnings against using context that we have in the
docs -
https://facebook.github.io/react/docs/context.html#why-not-to-use-context
**Except** that probably some widely used libraries depend on it, like
`React-Router`.

b) Expect users will use external `PropTypes` library when defining
`contextTypes` and just don't do our `checkReactTypeSpec` against them
any more in v16.

c) Stop masking context and pass the whole context
unmasked everywhere. Worst option, do not recommend.

I went with `b` and assume that, for now, we will get users to use the
external `PropTypes` when defining context. I will update this PR if we
want a different approach.

* Remove 'addons' items from left nav, and deprecate 'addons' doc page

The plan:
[X] Remove links to 'addons' items from main navigation
[X] Add deprecation notices where appropriate, and update syntax to show
using the separate modules.
[ ] Update other references to 'React.addons' in docs. Coming in next
commit.
--- blocked but coming in future PRs
[ ] Link to a blog post describing the new locations of add-ons in the
deprecation notice on the '/docs/addons.html' page. Blocked until we
actually publish that blog post.
[ ] Move the docs for each add-on to the actual github repo where it now
lives.
[ ] Redirect the old add-ons doc permalinks to the docs in the separate
github repos for those modules.
[ ] Remove the old add-ons doc markdown files from React core docs.

* Remove references to `React.addons` from docs

Just misc. places where we referenced the 'addons' feature. All gone!
2017-04-06 17:20:54 -07:00
Dan Abramov
21bb8c00d4 16.0.0-alpha.7 2017-04-06 19:50:22 +01:00
Brian Vaughn
6ba42514ea Remove 'takeSnapshot' from ReactNative renderer\nUpstream sync from react-native repo (#9356) 2017-04-06 10:39:18 -07:00
Dominic Gannaway
832488ab09 change permissions of test_print_warnings (#9347) 2017-04-05 23:18:39 +01:00
Dominic Gannaway
3ebdd0911e Fixes the eager react-dom replacement on the rollup plugin (#9346)
* Fixes the eager react-dom replacement on the rollup plugin

* added the other replaceInternalModules
2017-04-05 22:42:12 +01:00
Dan Abramov
84b5b49aec Delete extra babel-standalone.html: it already exists in a folder 2017-04-05 21:17:10 +01:00
Dan Abramov
2429fd2cee Fix art fixture 2017-04-05 21:05:23 +01:00
Dan Abramov
3a416762e7 Fix glob ignore for build script 2017-04-05 20:24:30 +01:00
Dan Abramov
a85d7eed9a Run prettier 2017-04-05 19:51:23 +01:00
Dan Abramov
6a48f32f21 Exclude tests from warning print script 2017-04-05 19:51:19 +01:00
Brian Vaughn
c80570b016 Synced ReactNativeFiber bugfix for leaf-node children (#9330) 2017-04-05 11:29:45 -07:00
Dan Abramov
fc1f324cc4 Fix warnings script to work on Node 4 2017-04-05 19:01:09 +01:00
Dan Abramov
398d449c48 Fix the print warnings script (#9344) 2017-04-05 18:54:48 +01:00
Dominic Gannaway
6b68410808 Adds support for labels on building bundles (#9342)
* adds support for labels on bundles

* -fiber

* reverts results
2017-04-05 18:30:12 +01:00
Dominic Gannaway
24dc43c49f fixes circleci/upload_build.sh paths for dist files (#9341)
* fixes circleci/upload_build.sh paths for dist files

* updated the react filenames to include development or production
2017-04-05 17:25:09 +01:00
Dan Abramov
4fa8122d5d Update release manager with latest change 2017-04-05 17:16:36 +01:00
Dan Abramov
665f80483e Update build paths in docs (#9340) 2017-04-05 16:53:25 +01:00
Dominic Gannaway
4b2eac3de7 Convert current build system to Rollup and adopt flat bundles (#9327)
* WIP

* fbjs support

* WIP

* dev/prod mode WIP

* More WIP

* builds a cjs bundle

* adding forwarding modules

* more progress on forwarding modules and FB config

* improved how certain modules get inlined for fb and cjs

* more forwarding modules

* added comments to the module aliasing code

* made ReactPerf and ReactTestUtils bundle again

* Use -core suffix for all bundles

This makes it easier to override things in www.

* Add a lazy shim for ReactPerf

This prevents a circular dependency between ReactGKJSModule and ReactDOM

* Fix forwarding module for ReactCurrentOwner

* Revert "Add a lazy shim for ReactPerf"

This reverts commit 723b402c07116a70ce8ff1e43a1f4d92052e8f43.

* Rename -core suffix to -fb for clarity

* Change forwarding modules to import from -fb

This is another, more direct fix for ReactPerf circular dependency

* should fix fb and cjs bundles for ReactCurrentOwner

* added provides module for ReactCurrentOwner

* should improve console output

* fixed typo with argument passing on functon call

* Revert "should improve console output"

This breaks the FB bundles.

This reverts commit 65f11ee64f678c387cb3cfef9a8b28b89a6272b9.

* Work around internal FB transform require() issue

* moved  ReactInstanceMap out of React and into ReactDOM and ReactDOMFiber

* Expose more internal modules to www

* Add missing modules to Stack ReactDOM to fix UFI

* Fix onlyChild module

* improved the build tool

* Add a rollup npm script

* Rename ReactDOM-fb to ReactDOMStack-fb

* Fix circular dependencies now that ReactDOM-fb is a GK switch

* Revert "Work around internal FB transform require() issue"

This reverts commit 0a50b6a90bffc59f8f5416ef36000b5e3a44d253.

* Bump rollup-plugin-commonjs to include a fix for rollup/rollup-plugin-commonjs#176

* Add more forwarding modules that are used on www

* Add even more forwarding modules that are used on www

* Add DOMProperty to hidden exports

* Externalize feature flags

This lets www specify them dynamically.

* Remove forwarding modules with implementations

Instead I'm adding them to react-fb in my diff.

* Add all injection necessary for error logging

* Add missing forwarding module (oops)

* Add ReactART builds

* Add ReactDOMServer bundle

* Fix UMD build of ReactDOMFiber

* Work in progress: start adding ReactNative bundle

* tidied up the options for bundles, so they can define what types they output and exclude

* Add a working RN build

* further improved and tidied up build process

* improved how bundles are built by exposing externals and making the process less "magical", also tidied up code and added more comments

* better handling of bundling ReactCurrentOwner and accessing it from renderer modules

* added NODE_DEV and NODE_PROD

* added NPM package creation and copying into build chain

* Improved UMD bundles, added better fixture testing and doc plus prod builds

* updated internal modules (WIP)

* removed all react/lib/* dependencies from appearing in bundles created on build

* added react-test-renderer bundles

* renamed bundles and paths

* fixed fixture path changes

* added extract-errors support

* added extractErrors warning

* moved shims to shims directory in rollup scripts

* changed pathing to use build rather than build/rollup

* updated release doc to reflect some rollup changes

* Updated ReactNative findNodeHandle() to handle number case (#9238)

* Add dynamic injection to ReactErrorUtils (#9246)

* Fix ReactErrorUtils injection (#9247)

* Fix Haste name

* Move files around

* More descriptive filenames

* Add missing ReactErrorUtils shim

* Tweak reactComponentExpect to make it standalone-ish in www

* Unflowify shims

* facebook-www shims now get copied over correctly to build

* removed unnecessary resolve

* building facebook-www/build is now all sync to prevent IO issues plus handles extra facebook-www src assets

* removed react-native-renderer package and made build make a react-native build dir instead

* 😭😭😭

* Add more SSR unit tests for elements and children. (#9221)

* Adding more SSR unit tests for elements and children.

* Some of my SSR tests were testing for react-text and react-empty elements that no longer exist in Fiber. Fixed the tests so that they expect correct markup in Fiber.

* Tweaked some test names after @gaearon review comment https://github.com/facebook/react/pull/9221#discussion_r107045673 . Also realized that one of the tests was essentially a direct copy of another, so deleted it.

* Responding to code review https://github.com/facebook/react/pull/9221#pullrequestreview-28996315 . Thanks @spicyj!

* ReactElementValidator uses temporary ReactNative View propTypes getter (#9256)

* Updating packages for 16.0.0-alpha.6 release

* Revert "😭😭😭"

This reverts commit 7dba33b2cfc67246881f6d57633a80e628ea05ec.

* Work around Jest issue with CurrentOwner shared state in www

* updated error codes

* splits FB into FB_DEV and FB_PROD

* Remove deps on specific builds from shims

* should no longer mangle FB_PROD output

* Added init() dev block to ReactTestUtils

* added shims for DEV only code so it does not get included in prod bundles

* added a __DEV__ wrapping code to FB_DEV

* added __DEV__ flag behind a footer/header

* Use right haste names

* keeps comments in prod

* added external babel helpers plugin

* fixed fixtures and updated cjs/umd paths

* Fixes Jest so it run tests correctly

* fixed an issue with stubbed modules not properly being replaced due to greedy replacement

* added a WIP solution for ReactCurrentOwner on FB DEV

* adds a FB_TEST bundle

* allows both ReactCurrentOwner and react/lib/ReactCurrentOwner

* adds -test to provides module name

* Remove TEST env

* Ensure requires stay at the top

* added basic mangle support (disbaled by default)

* per bundle property mangling added

* moved around plugin order to try and fix deadcode requires as per https://github.com/rollup/rollup/issues/855

* Fix flow issues

* removed gulp and grunt and moved tasks to standalone node script

* configured circleci to use new paths

* Fix lint

* removed gulp-extract-errors

* added test_build.sh back in

* added missing newline to flow.js

* fixed test coverage command

* changed permissions on test_build.sh

* fixed test_html_generations.sh

* temp removed html render test

* removed the warning output from test_build, the build should do this instead

* fixed test_build

* fixed broken npm script

* Remove unused ViewportMetrics shim

* better error output

* updated circleci to node 7 for async/await

* Fixes

* removed coverage test from circleci run

* circleci run tets

* removed build from circlci

* made a dedicated jest script in a new process

* moved order around of circlci tasks

* changing path to jest in more circleci tests

* re-enabled code coverage

* Add file header to prod bundles

* Remove react-dom/server.js (WIP: decide on the plan)

* Only UMD bundles need version header

* Merge with master

* disabled const evaluation by uglify for <script></script> string literal

* deal with ART modules for UMD bundles

* improved how bundle output gets printed

* fixed filesize difference reporting

* added filesize dep

* Update yarn lockfile for some reason

* now compares against the last run branch built on

* added react-dom-server

* removed un-needed comment

* results only get saved on full builds

* moved the rollup sized plugin into a plugins directory

* added a missing commonjs()

* fixed missing ignore

* Hack around to fix RN bundle

* Partially fix RN bundles

* added react-art bundle and a fixture for it

* Point UMD bundle to Fiber and add EventPluginHub to exported internals

* Make it build on Node 4

* fixed eslint error with resolve being defined in outer scope

* Tweak how build results are calculated and stored

* Tweak fixtures build to work on Node 4

* Include LICENSE/PATENTS and fix up package.json files

* Add Node bundle for react-test-renderer

* Revert "Hack around to fix RN bundle"

We'll do this later.

This reverts commit 59445a625962d7be4c7c3e98defc8a31f8761ec1.

* Revert more RN changes

We'll do them separately later

* Revert more unintentional changes

* Revert changes to error codes

* Add accidentally deleted RN externals

* added RN_DEV/RN_PROD bundles

* fixed typo where RN_DEV and RN_PROD were the wrong way around

* Delete/ignore fixture build outputs

* Format scripts/ with Prettier

* tidied up the Rollup build process and split functions into various different files to improve readability

* Copy folder before files

* updated yarn.lock

* updated results and yarn dependencies to the latest versions
2017-04-05 16:47:29 +01:00
Nathan Hunzaker
d99b3fc6d6 Remove MouseEvent.button polyfill (#9334)
MouseEvent.button is supported in every browser React targets:
https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
2017-04-05 12:34:48 +01:00
Rahul Gupta
3829859e22 Moved the JSdoc for invokeGuardedCallback to correct position (#9337) 2017-04-05 12:34:14 +01:00
Justin
0c7863075d Fix grammar typo in Design Principles docs (#9324)
features → feature
> There is nothing "bad" about using state or lifecycle hooks in components. Like any powerful feature**s**, they should be used in moderation, but we have no intention to remove them.

I can’t explain the exact grammatical principle this violates, but it sounds wrong to my native English ears that “feature” is plural here. Another way to check if the grammar sounds right is to change the order of the clauses: ”They should be used in moderation, like any powerful feature“ sounds right, whereas “They should be used in moderation, like any powerful features” does not.
2017-04-04 17:16:54 -05:00
Ben Alpert
e50f97b4cb Update addons-two-way-binding-helpers.md
I don't think this reference is that helpful and could turn people away since it sounds very fancy and isn't relevant..
2017-04-04 11:14:09 -07:00
Aaron Cannon
50b3cab3ec Make it clear that textarea also supports defaultValue. (#9318) 2017-04-03 23:05:50 -05:00
Dan Abramov
4a37718e4e Remove examples/ folder (#9323) 2017-04-03 20:32:02 +01:00
Sasha Aickin
04713fc4bd Merge pull request #9264 from aickin/server-render-unit-tests-forms
Adding SSR test for form fields.
2017-03-31 15:42:07 -07:00
Andrey Marchenko
d9915db43b Deleting a specific style name float for ie8 (#9311)
* Deleting a specific style name float for ie8

* Remove unnecessary condition
2017-03-31 23:31:52 +01:00
Sasha Aickin
a734aecc98 Response to code review comment https://github.com/facebook/react/pull/9264#discussion_r108974871 . Thanks, @spicyj! 2017-03-31 14:49:03 -07:00
Ben Alpert
6fd539ec66 Fix build
oops i broke it
2017-03-31 16:20:28 +01:00
Ben Alpert
e9c995974d Port out bug fixes to ReactARTFiber (#9309)
D4616127 D4629747 D4631778
2017-03-31 16:13:01 +01:00
Nathan Hunzaker
27c844905f Remove scroll capture support warning (#9303)
I removed the scroll capture feature check for IE8, however I missed
the associated warning.
2017-03-31 11:36:08 +01:00
Nathan Hunzaker
bd2802523c Remove viewport metrics, other pageX/pageY behaviors (#9290)
* Remove viewport metrics

event.pageX and event.pageY are in every browser React supports.

* Rerecord tests
2017-03-31 02:20:57 +01:00
Andrey Marchenko
5ad1c76386 Deleted a specific code for ie8 - document.selection (#9298) 2017-03-30 19:00:12 -05:00
Brian Vaughn
76c5c6deb5 Disabling a no-unreachable lint error (#9300) 2017-03-30 16:40:45 -07:00
Brian Vaughn
4f69474e03 Added explicit null return to completeUnitOfWork() to resolve Flow error (#9299) 2017-03-30 15:45:13 -07:00
Brian Vaughn
224487a0e2 Show more meanignful stack trace for ReactNative errors (#9291)
* Show more meanignful stack trace for ReactNative errors

Clicking on the stack should jump to where the error actually occurred rather than to where it's logged in a redbox component.

* Made showDialog() return type stricter. Added mock and Flow types for ExceptionManager

* Prettier

* Handle null/string thrown errors

* Removed unused reference to emptyFunction
2017-03-30 15:15:33 -07:00
Nathan Hunzaker
b8857d4f27 Remove captured focus feature check (#9285)
IE8 was the only browser that did not support captured focus. We no
longer have that constraint.
2017-03-30 13:47:14 -07:00
Brian Vaughn
004c937cb0 Move takeSnapshot from UIManager to ReactNative renderer(s) (#9292)
* Move takeSnapshot from UIManager to ReactNative renderer(s)

* Prettier
2017-03-30 13:10:15 -07:00
Brandon Dail
8d6d3e8c05 Update JSFiddle for issue template (#9289) 2017-03-30 11:43:16 -05:00
Brandon Dail
686010037d Remove IE8-specific setInnerHTML behavior (#9288)
Since IE8 is not supported anymore, lets save those bytes!
2017-03-30 17:24:58 +01:00
Nathan Hunzaker
dbeb37fe69 Add DOM fixture for unmasking passwords (#9269)
IE11 and Edge have a password unmask field that React prevents the
display of for controlled inputs. This commit adds DOM fixture
coverage for this test case.
2017-03-30 10:16:36 -05:00
Damian Nicholson
0c70fb8b18 Added semicolons to addons imports examples. (#9287) 2017-03-30 15:55:27 +01:00
Ben Alpert
e57ad7f51e Allow returning null as host context (#9278)
If your renderer doesn't use host context, you might prefer to return null. This used to give an error:

> Invariant Violation: Expected host context to exist. This error is likely caused by a bug in React. Please file an issue.

I use a sentinel value instead now.

The code in ReactFiberHostContext is a little complicated now. We could probably also just remove the invariants.
2017-03-30 13:18:39 +01:00
Nathan Hunzaker
4c292facc9 Remove captured scroll feature check (#9283)
* Remove captured scroll feature check

IE8 was the only browser that did not support captured scroll. We no
longer have that constraint.

* Remove WINDOW_HANDLE const
2017-03-30 11:01:29 +01:00
Brandon Dail
9a93be0b33 Remove IE8-specific ChangeEventPlugin logic (#9281) 2017-03-29 17:37:56 -05:00
Brandon Dail
da91e9ebe9 Add DOM fixtures for disabled button click events (#9271) 2017-03-29 11:17:54 -05:00
Dominic Gannaway
09f0a5ded9 Merge pull request #9276 from trueadm/getDeclarationErrorAddendum_DEV
[Fiber] Adds DEV condition around getDeclarationErrorAddendum
2017-03-29 13:55:04 +01:00
Dominic Gannaway
660306982c added DEV condition around getDeclarationErrorAddendum contents 2017-03-29 13:49:30 +01:00
Sasha Aickin
aaabd655a6 Added jest-cli to the package.json for the Fiber record-tests script. (#9270) 2017-03-28 22:55:22 +01:00
Brian Vaughn
a749f4fb63 Adding fix to EventPropagators that was accidentally omitted from PR #9219 (#9274) 2017-03-28 11:24:13 -07:00
Brian Vaughn
fca5d3ffc5 Added missing @flow annotation to ReactNativeFeatureFlags file (#9267) 2017-03-27 14:59:37 -07:00
Andrew Clark
090efbdb17 Merge branch 'giamir-add_toggle_to_fiber_triangle_demo' 2017-03-27 12:48:39 -07:00
Andrew Clark
f6a64cad5d Use radio buttons for toggle 2017-03-27 12:48:05 -07:00
Andrew Clark
ef9dac518f Merge branch 'add_toggle_to_fiber_triangle_demo' of https://github.com/giamir/react into giamir-add_toggle_to_fiber_triangle_demo 2017-03-27 11:46:59 -07:00
Nathan Hunzaker
29d9710892 Fix Chrome number input backspace and invalid input issue (#7359)
* Only re-assign defaultValue if it is different

* Do not set value if it is the same

* Properly cover defaultValue

* Use coercion to be smart about value assignment

* Add explanation of loose type checks in value assignment.

* Add test coverage for setAttribute update.

* Only apply loose value check to text inputs

* Fix case where empty switches to zero

* Handle zero case in controlled input

* Correct mistake with default value assignment after rebase

* Do not assign bad input to number input

* Only trigger number input value attribute updates on blur

* Remove reference to LinkedValueUtils

* Record new fiber tests

* Add tests for blurred number input behavior

* Replace onBlur wrapper with rule in ChangeEventPlugin

* Sift down to only number inputs

* Re-record fiber tests

* Add test case for updating attribute on uncontrolled inputs. Make related correction

* Handle uncontrolled inputs, integrate fiber

* Reorder boolean to mitigate DOM checks

* Only assign value if it is different

* Add number input browser test fixtures

During the course of the number input fix, we uncovered many edge
cases. This commit adds browser test fixtures for each of those instances.

* Address edge case preventing number precision lower than 1 place

0.0 coerces to 0, however they are not the same value when doing
string comparision. This prevented controlled number inputs from
inputing the characters `0.00`.

Also adds test cases.

* Accommodate lack of IE9 number input support

IE9 does not support number inputs. Number inputs in IE9 fallback to
traditional text inputs. This means that accessing `input.value` will
report the raw text, rather than parsing a numeric value.

This commit makes the ReactDOMInput wrapper check to see if the `type`
prop has been configured to `"number"`. In those cases, it will
perform a comparison based upon `parseFloat` instead of the raw input
value.

* Remove footnotes about IE exponent issues

With the recent IE9 fix, IE properly inserts `e` when it produces an
invalid number.

* Address exception in IE9/10 ChangeEventPlugin blur event

On blur, inputs have their values assigned. This is so that number
inputs do not conduct unexpected behavior in
Chrome/Safari. Unfortunately, there are cases where the target
instance might be undefined in IE9/10, raising an exception.

* Migrate over ReactDOMInput.js number input fixes to Fiber

Also re-record tests

* Update number fixtures to use latest components

* Add number input test case for dashes and negative numbers

* Replace trailing dash test case with replace with dash

Also run prettier
2017-03-27 11:39:18 -05:00
Sasha Aickin
14863c9a87 Adding SSR test for form fields. 2017-03-26 20:51:40 -07:00
Sasha Aickin
c51411c812 Adding new SSR tests for context, refs, and reviving markup. (#9257) 2017-03-26 13:32:23 -07:00
Giamir Buoncristiani
b62f851e64 Add a button to switch from Fiber with time-slicing to Fiber without it 2017-03-26 17:24:26 +01:00
najisawas
c47f334ac9 Fixed typo on implementation notes page (#9258)
Added paren to "mountComponent()" for consistency
2017-03-25 20:57:28 -05:00
Brian Vaughn
cb585229bc Ran yarn and fixed line-length lint issue 2017-03-24 19:59:05 -07:00
Brian Vaughn
1a29b4e2a3 Updating packages for 16.0.0-alpha.6 release 2017-03-24 15:44:09 -07:00
Brian Vaughn
1acf949240 ReactElementValidator uses temporary ReactNative View propTypes getter (#9256) 2017-03-24 15:37:21 -07:00
Sasha Aickin
25deff6203 Add more SSR unit tests for elements and children. (#9221)
* Adding more SSR unit tests for elements and children.

* Some of my SSR tests were testing for react-text and react-empty elements that no longer exist in Fiber. Fixed the tests so that they expect correct markup in Fiber.

* Tweaked some test names after @gaearon review comment https://github.com/facebook/react/pull/9221#discussion_r107045673 . Also realized that one of the tests was essentially a direct copy of another, so deleted it.

* Responding to code review https://github.com/facebook/react/pull/9221#pullrequestreview-28996315 . Thanks @spicyj!
2017-03-24 13:31:15 -07:00
Dan Abramov
0a41890eaa Remove rethrowCaughtError injection (#9252) 2017-03-24 18:19:12 +00:00
Johan Tinglöf
38d8f3ee6b Updated Router import for example (#9233)
Updated import in order to be a correct working example as in accordance with the docs
2017-03-24 09:37:32 -05:00
Dan Abramov
f082e35b36 Fix up invariant import to be from fbjs/lib/ 2017-03-23 19:45:10 +00:00
Dan Abramov
d6a2c669d2 Fix ReactErrorUtils injection (#9247) 2017-03-23 19:13:07 +00:00
Dan Abramov
1c9dcd53d5 Add dynamic injection to ReactErrorUtils (#9246) 2017-03-23 18:45:38 +00:00
Brian Vaughn
c8897f8382 Updated ReactNative findNodeHandle() to handle number case (#9238) 2017-03-23 08:16:52 -07:00
Dan Abramov
b0b9f37960 Fix up Flow syntax 2017-03-22 18:41:42 +00:00
Dan Abramov
8de9c6c12c Add injection for error dialog (#9235) 2017-03-22 18:21:12 +00:00
Bernard Lin
fbc6977fbc Conferences (#9234)
* standard format for React Rally

* move React Conf 2017 to past conferences
2017-03-22 10:40:13 -05:00
Brian Vaughn
8ce5fe97b5 Bumped React version to 16.0.0-alpha.5 2017-03-21 13:04:08 -07:00
Valentin Shergin
97ab3f5ef8 Removed optimization for events without target in ReactNativeEventEmitter (#9219)
* Removed optimization for events without target in ReactNativeEventEmitter

This PR fixes the problem originally introduced in https://github.com/facebook/react/pull/6590
The problem is that `ResponderEventPlugin` (and `ResponderTouchHistoryStore`) relies on that fact that touch events are balanced.
So if one `startish` event happened, should be coming `endish` event. Otherwise there is no way to maintain internal `trackedTouchCount` counter. So, if we drop some events, we break this logic.

Moreover, that optimization clearly contradict with this statement from `ResponderEventPlugin`:
```
We must be resilient to `targetInst` being `null` on `touchMove` or
`touchEnd`. On certain platforms, this means that a native scroll has
assumed control and the original touch targets are destroyed.
```

This issue causes several major problems in React Native, and one of them (finally!) is easy to reproduce: https://github.com/facebook/react-native/issues/12976 .

The test also illustrates this problem.

* Prettier
2017-03-20 17:07:28 -07:00
Brian Vaughn
7f665da0ee ReactNative upstream sync (#9197)
* Addresses a circular dependency between NativeMethodsMixin and ReactNativeFiber:

* Created new ReactNativeFiberHostComponent with similar interface but without unnecessary call to findNodeHandle.
* Created new Flow interface for mixins to ensure ReactNativeFiberHostComponent and NativeMethodsMixinUtils stay synced.
* Moved helper methods to NativeMethodsMixinUtils to be shared between the 2 wrappers.

This diff was submitted and reviewed internally along with some other ReactNative changes. This is the React-only portion.

* Removed unused Flow type import

* Copied a Flow fix from internal
2017-03-20 13:50:31 -07:00
Dan Abramov
e15a481773 Re-add tests unintentionally deleted in #9209 (#9225)
These tests are useful and don't test addons specifically.
I moved them to appropriate places in the codebase.
2017-03-20 19:38:54 +00:00
Dan Abramov
34e4352cba Delete addons (#9209)
* Delete addons

* Remove ReactFragment dependency from tests

* Remove addons testing from fixtures

* Don't mention createFragment() in a warning

* Address feedback

* Remove unused variables

* Remove mention of deleted file

* Add a missing key to the test

* Fix lint
2017-03-20 16:15:01 +00:00
CodinCat
0ceb5115ac Use single quotes, remove extra whitespace (#9215) 2017-03-19 18:34:53 +00:00
Sasha Aickin
78761c387f Add unit tests for props to attribute mapping in SSR. (#9106)
* Added a handful of SSR unit tests, ported from a previous pull request.

* Fixing linting errors

* Fixed a test helper function to properly report errors.

* Un-nested the new rendering tests. Updated the fiber test passing/not passing lists.

* Edited to comply with the react/jsx-space-before-closing eslint rule, which will soon be merged into master.

* Response to code review from @spicyj. Moved tests to separate file, reworked wording of test names, corrected use of canUseDom, and simplified tests against tagName. Thanks for the help, @spicyj!

* Converted the unit tests to use async-await style.

* Moved async-await babel transform for tests from .babelrc to preprocessor.js.

* Response to code review in PR #9089. Thanks, @spicyj!

* Fixing some bugs in the SSR unit tests.

* Missed deleting some repeated code in the last commit.

* Adding unit tests for property to attribute mapping in SSR.

* Removing some redundant unit tests.

* Oops. I forgot to re-run record-tests after c593dbc; fixing that here.

* Reformatting for prettier so that the build will pass.
2017-03-19 16:08:55 +00:00
Andrew Clark
f606e0e7d3 Merge pull request #9145 from acdlite/explicitnullcheckfiberupdatequeue
Use explicit null checks in ReactFiberUpdateQueue
2017-03-17 10:44:11 -07:00
Brian Vaughn
ad2b6545fe Upgraded Flow dev dependency to 41 for 'implements' support (#9196) 2017-03-16 17:12:50 -07:00
Sebastian Markbåge
096975afab Record fiber tests (#9195) 2017-03-16 16:29:05 -07:00
Sebastian Markbåge
9c7cf20dd5 Ignore event listener extraction on numeric text components (#9194)
In ReactDOM we don't dispatch events in the synthetic event system on to
text nodes. We back up one to the element before dispatching.

In React Native we don't do that. The iOS native side doesn't dispatch on
the text nodes but only the parent. The Android native side however does
dispatch on text nodes.

We already covered this for strings, but current element in Stack can be
a number if it is numeric text content.
2017-03-16 15:29:06 -07:00
Andrew Clark
9549ebfae5 Merge pull request #9187 from acdlite/prettierci
Failing to run prettier should block CI
2017-03-16 11:55:41 -07:00
Andrew Clark
8802c20c22 Run yarn prettier to format code
CI should now pass
2017-03-16 11:53:44 -07:00
Andrew Clark
cbdddbeb58 (test) Commit changes without running prettier to see if CI fails 2017-03-16 11:53:44 -07:00
Andrew Clark
0e5be287f7 Exit with failing code if prettier throws to ensure CI is blocked 2017-03-16 11:53:44 -07:00
Andrew Clark
c71a8ecd00 Add prettier instructions to PR template and contribution guide 2017-03-16 11:53:44 -07:00
Andrew Clark
7cf2950ebb Pass args as an array 2017-03-16 11:53:44 -07:00
Andrew Clark
ecf2e44908 CI should fail if prettier wasn't run 2017-03-16 11:53:44 -07:00
Andrew Clark
f365e52dd7 Add prettier script
`scripts/prettier/index.js write` will run prettier on source files.
Run using `yarn prettier`.

`scripts/prettier/index.js` will throw if any source files are not
formatted with prettier. We'll use this to block CI.

Based on similar script in Jest repo.
2017-03-16 11:53:44 -07:00
Jamison Dance
7253e6544b Add React Rally to conferences list (#9179) 2017-03-15 14:20:57 -10:00
Andrew Clark
bc30ef9842 Work around loose typing for fiber.updateQueue
The updateQueue field is currently an any type. Check the fiber's tag so
that only UpdateQueues are passed to getPendingPriority.
2017-03-15 15:05:04 -07:00
Andrew Clark
21e0e3711b Use explicit null checks in ReactFiberUpdateQueue
Follow-up to #8978
2017-03-15 15:04:59 -07:00
James Long
b1b4a2fb25 Merge pull request #9101 from sebmarkbage/prettier
Use Prettier
2017-03-14 15:33:27 -07:00
Sebastian Markbage
7e078d6a92 Fix lint rules
The typeof one is a bit strange because the disable rule gets moved.
2017-03-14 14:12:35 -07:00
Sebastian Markbage
ba1299acc2 Non idempotent steps in prettier 2017-03-13 17:06:03 -07:00
Sebastian Markbage
1843f87168 Run prettier 2017-03-13 17:05:18 -07:00
Sebastian Markbage
46bcd7fdf2 Add ignore to multichild test 2017-03-13 17:04:37 -07:00
Sebastian Markbage
b363803d26 Update to prettier 0.22 2017-03-13 17:02:21 -07:00
Sebastian Markbage
898ba574d6 Try 80-character line limit instead 2017-03-13 16:57:16 -07:00
Sebastian Markbage
df6388ab52 Add prettier-ignore where we do matrix style formatting 2017-03-13 16:57:13 -07:00
Sebastian Markbage
9d34dd3c01 More options 2017-03-13 16:55:59 -07:00
Sebastian Markbage
4adad94eac Add prettier option in scripts 2017-03-13 16:55:58 -07:00
Bernard Lin
2b59afb984 Updated React Native EU (#9170)
* Updated Chain React

Changed conference date from "Summer 2017" to given date on website

* Updated React Native EU 

Updated date and place with information from website
2017-03-13 22:43:03 +00:00
Ben Alpert
a2716d087e Fix two bugs in version bump script (#9165)
* Fix version bump script when files are missing

* Add noop renderer to version bump script

Without this, grunt build fails due to the version mismatch.
2017-03-13 10:04:14 -07:00
Ben Alpert
0d7b4d6dba 16.0.0-alpha.4 2017-03-13 08:54:41 -07:00
Ben Alpert
f3a26c0f75 Switch UMD build to use Fiber 2017-03-13 08:46:20 -07:00
Adam
bf5abdf14f Remove ref usage in main markdown example (#9160)
from [elsewhere in the docs](https://facebook.github.io/react/docs/refs-and-the-dom.html):

> Avoid using refs for anything that can be done declaratively.
2017-03-12 15:29:10 +00:00
Ben Alpert
19c2649e02 Use fiber by default (#9155)
Affects our builds. But not in tests yet.
2017-03-10 17:06:02 -08:00
Dan Abramov
8de68c56f9 [Fiber] Remove unnecessary second getComponentName() (#9153)
* Remove unnecessary second getComponentName()

We already have one. The other one is also less fragile and doesn't throw on null type.

* Make setState in render warning check simpler

This skips it earlier since in most cases phase won't be "render".
This is unobservable.
2017-03-10 19:29:20 +00:00
Dan Abramov
c96482d37f Remove PR check from GH Pages build hook for stable branch (#9144) 2017-03-10 01:17:27 +00:00
Dan Abramov
7fa311bcd9 Reorder sections in alphabetical order (#9143)
* Reorder sections in alphabetical order

* Reorder here too
2017-03-09 20:46:55 +00:00
Dan Abramov
6559b10b11 Use more widely supported emoji (#9139) 2017-03-09 00:55:36 +00:00
Dan Abramov
266481dacf Don't count skipped tests when calculating Fiber facts (#9136) 2017-03-08 21:03:21 +00:00
Dan Abramov
73378c9293 [Fiber] Performance measurements (#9071)
* wip

* better

* better

* track commits

* better

* wip

* Fix

* Add some lifecycles

* wip

* Naming

* Moar emojis

* Remove stacks in favor of a flag

* Fix Flow

* Gate behind __DEV__

* Revert flag for testing

* Measure all lifecycles

* Push it to the limits

* Polish

* Indent

* Refactor and track cascading updates

* More prominent warnings

* Make mark names themselves readable

This is useful for RN Systrace which doesn't let us assign labels after the fact.

* Keep track of how many effects we call

* Fix typo

* Do less work to reduce the overhead

* Fix lint

* Remove closure

* Remove unintentional formatting changes

* Add tests

* Fix test regex and record tests

* Disable irrelevant tests needed for ReactPerf

* Fix typo

* Fix lint and flow

* Don't treat cWM or cWRP as cascading

* Whitespace

* Update tests

* Gate callComponentWillUnmountWithTimerInDev definition by DEV
2017-03-08 18:28:53 +00:00
Dominic Gannaway
4e9d7ac833 Merge pull request #9096 from trueadm/component-tree-hook-dev
[Fiber] Split dev methods within ReactComponentTreeHook
2017-03-07 14:09:22 +00:00
Dominic Gannaway
a159e85c46 removed inline boolean checks for methods 2017-03-07 13:35:41 +00:00
Brandon Dail
6ca2140c73 Remove _resetEventPlugins, use jest.resetModuleRegistry (#9111)
* Move EventPluginRegistry._resetEventPlugins to DEV

This is not called during runtime at all and is only using in internal unit tests. Despite that, its currently being included in production builds. This change makes it so its only defined in DEV, which might even be too much (we can maybe inject it in our unit tests to avoid defining it at all in EventPluginRegistry)

* Remove _resetEventsPlugin, use resetModuleRegistry
2017-03-07 02:25:24 +00:00
Ben Alpert
d79c6ab995 Fiber DOM async feature flag (#9127)
D4662171
2017-03-06 16:21:43 -08:00
Vincent Taing
bb149c8170 Fix redundant null type coercion (#9114) 2017-03-06 15:20:12 -08:00
Ben Alpert
678cb70da2 Fix radio buttons using stale props in Fiber (#9126)
D4662269
2017-03-06 14:58:29 -08:00
Andrew Clark
0b06b0b35e Merge pull request #9121 from jddxf/refactor
Don't reset the return fiber again after cloning the child fibers
2017-03-06 12:21:10 -08:00
Dominic Gannaway
f992d54157 removed describe.only 2017-03-06 15:18:21 +00:00
Dominic Gannaway
af4d249aa9 fixes tests so they correctly pass in fiber 2017-03-06 15:15:18 +00:00
Dominic Gannaway
b67a29a8ab Merge remote-tracking branch 'upstream/master' into component-tree-hook-dev 2017-03-06 14:55:33 +00:00
Dominic Gannaway
b572e3c907 moved non DEV methods to a new file called ReactFiberComponentTreeHook.js
This moves the non DEV methods to a new file called ReactFiberComponentTreeHook, updates existing references to DEV functions to remain inside DEV flags so they do not pull in ReactComponentTreeHook
2017-03-06 14:19:23 +00:00
jddxf
f939c1bca4 Don't reset the return fiber after cloning the child fibers, as we already do that while cloning. 2017-03-06 17:08:56 +08:00
Brandon Dail
12ad77d006 Remove EventPluginRegistry.getPluginModuleForEvent (#9110) 2017-03-06 00:52:56 -06:00
Brandon Dail
0c1f515faf Remove sliceChildren (#9109) 2017-03-06 00:52:39 -06:00
Brandon Dail
ceafdbf0a5 Remove ReactStateSetters (#9107) 2017-03-03 22:42:25 -06:00
Dan Abramov
d87c4d5e5c [Fiber] Don't schedule class fibers without relevant lifecycles for commit (#9105)
* Don't schedule class fibers without relevant lifecycles for commit

* Separate Update and Ref effects

* Simplify the exit condition

* Add missing annotation

* Write conditions differently to avoid an extra check

* Inline markUpdateIfNecessary()

* Inline markUpdateIfAlreadyInProgress()
2017-03-04 04:23:09 +00:00
Dima Beznos
0bedd0697a Added Brunch build tool to the docs (#9074)
* Added Brunch build tool to the docs

* Improved grammar

* product build -> production build
2017-03-03 16:15:25 -06:00
Andrew Clark
ccde21cd2b Merge pull request #9088 from acdlite/testerrorutilsshim
Test that ReactErrorUtils module can be shimmed
2017-03-03 14:09:10 -08:00
Andrew Clark
e3f6c850c2 Merge pull request #9097 from acdlite/dontextractprodproptypeerror
Fix production propTypes test so it works with error code system
2017-03-03 11:06:04 -08:00
Sasha Aickin
fcf41e7ca2 Add async/await to unit tests; modify server rendering tests to use async/await. (#9089) 2017-03-03 10:34:14 -08:00
Andrew Clark
fc4633775a Remove destructuring, since the version of node on www doesn't support it 2017-03-02 16:44:04 -08:00
Andrew Clark
cf4c06ceba Merge pull request #9098 from acdlite/printwarnings
Add script to print out a list of warnings
2017-03-02 16:39:43 -08:00
Andrew Clark
673f514f81 Fix PropTypes production test so it works with error code system 2017-03-02 16:12:50 -08:00
Dominic Gannaway
91de17ec52 added guards in place to prevent mixed prod+dev errors from occuring 2017-03-02 23:06:32 +00:00
Dominic Gannaway
397fd2b92e removed double semicolon 2017-03-02 22:09:12 +00:00
Dominic Gannaway
9a1db49259 removed comment 2017-03-02 22:08:15 +00:00
Dominic Gannaway
1f7cbb63e8 updated flow annotations 2017-03-02 22:06:46 +00:00
Dominic Gannaway
54fef50186 re-added missing files 2017-03-02 21:52:54 +00:00
Dominic Gannaway
da9d91829e WIP - not sure how to get the Flow type working properly 2017-03-02 21:50:02 +00:00
Sunny Ripert
179240ca30 Fix spacing in documentation (#9070)
Replace non-breaking space by space.
2017-03-02 13:57:58 -06:00
Jason Quense
2757a53fa5 Add fixture components (#8860)
* add fixture components

* add a few more options and styles

* Test fixture updates

- Pull in React from window global
- Add field to TestCase for fix PR links
- Update some styles

* Remove unused Fixture.Result comment

* Remove leading # from resolvedBy link

* Implement tag loading utility that caches response

Don't bust the cache doing feature detection

COME ON

* Use 'local' without version for option
2017-03-02 13:38:27 -06:00
Andrew Clark
9c8547cc9f Add script to print out a list of warnings
We'll use this in the GH sync script to track which warnings have
changed since the last sync
2017-03-02 11:37:01 -08:00
Dominic Gannaway
e8f3f92a88 fixed flow issues and bug resulting in failing tests 2017-03-02 17:53:09 +00:00
Dominic Gannaway
0e23042e4b refactor of ReactComponentTreeHook to isolate dev methods 2017-03-02 16:15:37 +00:00
Vesa Laakso
a190cfce29 Update Lifting State Up not to mix up DOM value with component state (#9032)
* Update Lifting State Up not to mix up DOM value with component state

A few weeks ago when teaching my friend, she got stuck on
`this.state.value` vs. `event.target.value`. As the documentation
talked a lot about "values", and the term value could mean three
different things (values in general, the "value" prop / DOM value of
the <input> component and the value in state/props), it was not weird
that she got a bit confused.

* Rename Lifting State Up onChange props to onTemperatureChange

This is in-line with how the temperature is provided as a prop named `temperature`

* Fix one value prop not being renamed to temperature

* Update codepen examples in Lifting state up documentation

* Update devtools state change to reflect docs change
2017-03-02 00:28:09 +00:00
Dan Abramov
c8f14c26b0 Add a step to the release process 2017-03-01 22:56:06 +00:00
Andrew Clark
b1a565f8fa Convert shorthanded syntax for function Flow types to expanded form
Something in www's test pipeline isn't able to parse this.
2017-03-01 14:38:48 -08:00
Andrew Clark
a293d75f75 Test that ReactErrorUtils module can be shimmed
We do this in www
2017-03-01 14:38:48 -08:00
Andrew Clark
5881371b61 Merge pull request #9087 from acdlite/fixstringcasting
Fix string casting and remove Flow suppression comments
2017-03-01 13:51:17 -08:00
Sasha Aickin
3788654d57 Adding some server rendering unit tests. (#9055)
* Added a handful of SSR unit tests, ported from a previous pull request.

* Fixing linting errors

* Fixed a test helper function to properly report errors.

* Un-nested the new rendering tests. Updated the fiber test passing/not passing lists.

* Edited to comply with the react/jsx-space-before-closing eslint rule, which will soon be merged into master.

* Response to code review from @spicyj. Moved tests to separate file, reworked wording of test names, corrected use of canUseDom, and simplified tests against tagName. Thanks for the help, @spicyj!
2017-03-01 13:39:47 -08:00
Andrew Clark
5e5bc69230 Fix string casting and remove Flow suppression comments 2017-03-01 13:07:22 -08:00
Andrew Clark
d1ee199492 Fix usage of Boolean constructor 2017-03-01 12:30:32 -08:00
Bryan Braun
7a878d27e3 Replace the header_links plugin with client-side generated anchors. (#4165)
* Replace the header_links plugin with client-side generated anchors.

Fixes facebook/react#4124

* Move anchor-link code into a separate script

Also adds a couple comments, for context.
2017-03-01 11:52:54 -08:00
Andrew Clark
737dac4f03 areChildrenOffscreen -> shouldDeprioritizeSubtree 2017-03-01 10:56:31 -08:00
Andrew Clark
a1cd77db6e Pass type to areChildrenOffscreen, too 2017-03-01 10:56:31 -08:00
Andrew Clark
4602e768f3 Add areChildrenOffscreen to host config
Renderers can determine whether a node's children are offscreen based on
the host component's props. If so, they are given OffscreenPriority.

useSyncScheduling takes precedence.
2017-03-01 10:56:31 -08:00
Andrew Clark
4ef197b7d4 Check if we're in sync mode before deprioritizing hidden subtrees 2017-03-01 10:56:31 -08:00
Andrew Clark
81eef12507 Test that hidden subtrees render/update synchronously
When useSyncScheduling is set to true (as it is in the DOM renderer),
we shouldn't give OffscreenPriority to hidden subtrees. Everything
should be sync/task.
2017-03-01 10:56:31 -08:00
Andrew Clark
0585ee8b22 Merge pull request #9082 from acdlite/nobooleanorstringconstructors
Enforce no boolean or string constructors
2017-03-01 10:55:42 -08:00
Dominic Gannaway
18b86bc9d8 Merge pull request #9080 from trueadm/remove-stack-dependencies-from-tests
[Fiber] Remove stack dependencies from tests
2017-03-01 18:24:10 +00:00
Fokke Zandbergen
8eb7068364 Square renders button, not div (#9084) 2017-03-01 09:40:45 -06:00
Dominic Gannaway
8bc11649df Merge branch 'master' into remove-stack-dependencies-from-tests 2017-03-01 12:32:36 +00:00
Andrew Clark
b963396c61 Run test script 2017-02-28 18:57:06 -08:00
Andrew Clark
7d5cc2eee3 Add test for no-primitive-constructors rule 2017-02-28 18:57:06 -08:00
Andrew Clark
2f63b0d6c9 Add error for number constructor, too 2017-02-28 18:57:06 -08:00
Andrew Clark
b9c96cfc73 Add caveat about symbols to string error message 2017-02-28 18:57:06 -08:00
Andrew Clark
6ac5fd3c2b Rename rule to no-primitive-constructors 2017-02-28 18:57:06 -08:00
Andrew Clark
1e9812e31b Convert usage of String and Boolean constructors 2017-02-28 18:56:57 -08:00
Sebastian Markbåge
e452e33741 providesModule -> explicit requires for cross-package dependencies (#9078)
* Add forwarding modules

* Codemod to use full package path outside of own package

Files that require modules from a different package than their own now
does so by the npm path name instead of the providesModule.

* Codemod fbjs module dependencies

* Fix gulp module mapping config

This is a bit lame but because of our module rewrite we need to white
list all the paths that we don't *don't* want to rewrite.
2017-02-28 18:42:52 -08:00
Andrew Clark
5f92d28e52 New ESLint rule that warns against Boolean and String constructors 2017-02-28 13:04:33 -08:00
Ben Alpert
a269e7ec3f Enable react/jsx-space-before-closing rule (#9077)
We mostly do this but not 100%; I fixed the stragglers here with `./node_modules/.bin/eslint --fix src` and enabled the lint rule.
2017-02-28 09:03:08 -08:00
Dominic Gannaway
d2944bb5bf updates test-failing and tests-passing 2017-02-28 15:02:48 +00:00
Dominic Gannaway
04cd2b2a81 refactors/removes stack dependent tests to work with fiber 2017-02-28 15:00:42 +00:00
Sebastian Markbåge
e35724a03d Move webcomponents.js polyfill to mocks (#8993)
* Move webcomponents.js polyfill to mocks

I'd like to move it out of shared to make it easier to sync this to RN.
Since this is only used for testing and a polyfill is essentially a mock.
Maybe this makes sense?

Rename to camel case to be consistent with providesModule.

* Update path to ignore in configs
2017-02-27 18:35:05 -08:00
Brian Vaughn
f923adb585 Pass component stack to error boundary handler (#9073)
This information is probably more useful for custom redbox components than the call stack info we are already passing.
2017-02-27 16:53:17 -08:00
Bernard Lin
fe46def5e2 Updated Chain React (#9067)
Changed conference date from "Summer 2017" to given date on website
2017-02-27 09:53:47 -06:00
Andrew Clark
07dc04d9f4 Merge pull request #8961 from acdlite/fiberbreakonuncaught
[Fiber] Preserve "Break on all/uncaught exceptions" behavior in DEV mode
2017-02-24 16:21:35 -08:00
Andrew Clark
2c59713f71 Remove invokeGuardedCallbackProd
We weren't using it anywhere except for the test suite. Instead, we can
change the environment flag and run the tests in both environments.
2017-02-24 16:19:29 -08:00
Andrew Clark
7e348acab7 Use invokeGuardedCallback in place of Fiber try-catch blocks
Only in DEV. In production, continue using a local try-catch.
2017-02-24 15:49:33 -08:00
Andrew Clark
13d4574228 invokeGuardedCallback should work when nested
Added a guard in the global error event listener to prevent nested
errors from being captured higher up the stack.

Also found a bug where the DEV version of invokeGuardedCallback would
infinite loop if there were nested invocations with the same name. Fixed
by appending the depth to the fake event name. (I'm actually not sure
why this is necessary.)
2017-02-24 15:49:33 -08:00
Andrew Clark
0304008a65 invokeGuardedCallback returns a thrown error
We can use this more flexible version for error handling in Fiber.

The DEV mode version uses same fake event trick as before to preserve
"break on uncaught exception" behavior when debugging.
2017-02-24 15:49:33 -08:00
Ben Alpert
0934ab948d Flatten Text children before rendering (#9063)
From FB-internal D4613844.
2017-02-24 13:40:08 -08:00
Andrew Clark
bc86ac4380 Merge pull request #8950 from acdlite/fibercompositecomponenttests
[Fiber] ReactCompositeComponent-test.js
2017-02-24 11:17:19 -08:00
Andrew Clark
393cdbc745 Consolidate ReactCurrentFiber and ReactDebugLifeCycle 2017-02-24 11:16:58 -08:00
Andrew Clark
d2c28be69b Use ReactDebugLifeCycle to track if we're inside getChildContext 2017-02-24 11:02:21 -08:00
Andrew Clark
309dea5b4c Track which lifecycle method we're in during DEV
Use this to detect setState inside of render instead of relying on
the owner.
2017-02-24 11:02:21 -08:00
Andrew Clark
ebfde985d9 Warn about nested renders 2017-02-24 11:02:21 -08:00
Andrew Clark
75ee3c1424 Warn about setState inside getChildContext
Stack uses a module called ReactInvalidSetStateWarningHook, but all it
does is warn about setState inside getChildContext. Doesn't seem worth
keeping around, so I didn't use it for Fiber, but if I'm mistaken I'll
change it.
2017-02-24 11:02:21 -08:00
Andrew Clark
2f3df5f0b3 Warn about setState in render 2017-02-24 11:02:21 -08:00
Andrew Clark
769c6e0ebe Merge pull request #9060 from acdlite/fixrecordtestsscript
Fix record-tests script
2017-02-24 10:59:44 -08:00
Andrew Clark
3bdc6d0c8e Fix record-tests script
Result of readConfig changed slightly in Jest 0.19.
2017-02-24 10:46:49 -08:00
Andrew Clark
1ae7436d01 Merge pull request #9058 from nihgwu/patch-1
fix version
2017-02-24 10:10:11 -08:00
Neo
18229fdeda fix version
per ca4325e3ef (commitcomment-21033948)
2017-02-24 17:35:27 +08:00
Andrew Clark
ca4325e3ef 16.0.0-alpha.3 2017-02-23 15:36:08 -08:00
Andrew Clark
18217cfede Merge pull request #9054 from acdlite/fiberpreventextensions
[Fiber] Prevent extensions to fiber in DEV
2017-02-23 14:42:16 -08:00
Andrew Clark
f3c2d9f308 Merge pull request #9004 from acdlite/proptypescheck
API for checking external objects against React prop types
2017-02-23 14:37:19 -08:00
Maxwel D'souza
b81175d37a Removed unnecessary if (#9031) 2017-02-23 15:14:21 -06:00
mdogadailo
49840f2e6b Missing onLoad and onError events on image tag (#9042) 2017-02-23 15:05:38 -06:00
Dai Nguyen
d724aed404 Update tutorial.md (#9051) 2017-02-23 14:54:03 -06:00
Andrew Clark
ddf59c403a Prevent extensions to fiber in DEV
Helps us avoid accidentally adding fields to the fiber class
2017-02-23 11:23:44 -08:00
Andrew Clark
03ed3437c9 Fix build config
ReactDebugCurrentFrame is shared state.

checkPropTypes should be imported via the main React export,
not imported directly.
2017-02-23 11:14:15 -08:00
Andrew Clark
0320b8ecb4 Wrap checkPropTypes in DEV conditional so it's stripped out in prod 2017-02-23 11:14:15 -08:00
Andrew Clark
e6d6ad3e88 Remove closure in checkReactTypeSpec by tracking stack info globally
There's a lot of overlap between ReactCurrentOwner,
ReactDebugCurrentFrame, and ReactDebugCurrentFiber that should
be consolidated.
2017-02-23 11:14:14 -08:00
Andrew Clark
9993fdd957 Change formatMessage parameter to getStack
Gives us flexibility in the future to deal with the stack and the
message separately.
2017-02-23 11:14:14 -08:00
Andrew Clark
6ff5211dee Remove warnOnRepeat option
Don't need this internally; doubt external users will need it either
2017-02-23 11:14:14 -08:00
Andrew Clark
3746a9dafb Invert dependency between checkPropTypes and checkReactTypeSpec
Expressing checkReactTypeSpec using the public API frees us to move it
to a separate module in the future.
2017-02-23 11:14:14 -08:00
Andrew Clark
e4acd12a9b Test that checkPropTypes does not throw or return a value 2017-02-23 11:14:14 -08:00
Andrew Clark
600685bdef Add PropTypes.checkPropTypes API
Allows users to check arbitrary objects against React prop types without
relying on the implementation details of the prop validators themselves.
An example of why this is important: some prop validators may throw,
while others return an error object. Calling a prop validator manually
requires handling both cases. `checkPropTypes` does this for you.
2017-02-23 11:14:14 -08:00
Andrew Clark
bef723e47f Remove ReactPropTypeLocationNames module
ReactPropTypeLocationNames was a map of location identifiers to location
display names, for use in warnings. But in practice, this did nothing
except rename "childContext" to "child context." Not worth it, IMO.

Since we are going to add an API for running prop type checks manually,
we need the ability to support arbitrary prop type locations. So
each place that used to accept a ReactPropTypeLocation now just accepts
a string.
2017-02-23 11:14:14 -08:00
Dominic Gannaway
91e8081cf0 Merge pull request #9045 from trueadm/emptyObject-reference-mismatch-due-to-mocking
[Fiber] fix ensure class components refs get re-assigned to emptyObject on mount
2017-02-23 15:38:10 +00:00
Dominic Gannaway
23f245173a Merge pull request #9043 from trueadm/fix-fiber-functional-componment-childcontext
[Fiber] adds `childContextTypes` warnings for functional components
2017-02-23 15:37:48 +00:00
Dominic Gannaway
bde5df1d76 addressed code in feedback 2017-02-23 15:37:19 +00:00
Dominic Gannaway
a99d77e073 added a regression test for factory components 2017-02-23 14:00:02 +00:00
Dominic Gannaway
925743bfc9 reverted ReactDOMFeatureFlags 2017-02-23 13:40:16 +00:00
Dominic Gannaway
e7d7809eb1 reverted the getChildContext warning from showing on functional components in Fiber 2017-02-23 13:39:08 +00:00
Dominic Gannaway
25f4abc9d5 mountClassInstance() now re-assigns instance.refs to emptyObject 2017-02-23 12:58:37 +00:00
Dominic Gannaway
a749083b85 fixed comment that was incorrect 2017-02-23 12:42:21 +00:00
Dominic Gannaway
724ae9b35a reverts previous changes to inlining requires and fixes test suite instead 2017-02-23 12:31:58 +00:00
Ben Alpert
5f6f3277f5 Add test for hack to stop bubbling (#8922) 2017-02-22 14:02:10 -08:00
Ben Alpert
9503abe5c7 Pass errorBoundary to logCapturedError (#9050) 2017-02-22 13:06:49 -08:00
Andrew Clark
2081a0053a Merge pull request #8949 from acdlite/fibercomponentlifecycletests
[Fiber] Component lifecycle tests
2017-02-22 12:54:42 -08:00
Brian Vaughn
a44a5d68d8 Fix bugs that occur when event responder unmounts during a touch event sequence
> This PR adds a test (initially failing) for this case along with a fix for stack and fiber. The stack fix was copied from a Diff submitted by @sema. The fiber fix just required us to stop leaking properties for unmounted views.
> Longer term we may want to explicitly invoke a release event listener for a responder just before unmounting it. This PR does not do that.
2017-02-22 12:47:34 -08:00
Andrew Clark
42c375b136 Merge pull request #9040 from acdlite/assignstateincwrp
Support for assigning to this.state inside componentWillReceiveProps
2017-02-22 12:45:58 -08:00
Stephie
5cc2a4fe3e Fixed typo: "Calcutor" to "Calculator" (#9047) 2017-02-22 17:37:55 +00:00
Dan Abramov
55f18f20ea Update Fiber debugger deps 2017-02-22 17:20:53 +00:00
Michał Pierzchała
67c1fde70e Upgrade Jest to v19 (#9034) 2017-02-22 16:59:18 +00:00
Dominic Gannaway
b8cf75a5b4 updated tests-failing and test-passing 2017-02-22 16:16:21 +00:00
Dominic Gannaway
3a7d6f5384 moved require(emptyObject) to inline calls to get around referential mismatch
Due to how Jest and other mocking libraries work in userland, modules that are required might not be referentially equal at various stages of the application lifecycle. This isnt a perfect fix, but by having the require calls inline, it has a better liklihood of ensuring emptyObject is the same reference
2017-02-22 16:12:51 +00:00
Dominic Gannaway
a9325e2ec4 adds childContextTypes warnings for functional components
ReactStatelessComponent-test.js fails due to warnings not showing up when functional components mount or update. This PR ports the existing warnings from stack and re-applies them to fiber functional components and attempts to re-use some logic in ReactFiberContext that currently exists for showing warnings when dealing with class components.
2017-02-22 14:21:10 +00:00
Andrew Clark
d649ebc6e1 Test should ensure that update is applied before corresponding render
Tightens up the test a bit to prevent regressions.
2017-02-21 16:47:25 -08:00
Brian Vaughn
3d44a6a486 Improved stack/fiber type-check to avoid false negative match when inst._rootNodeID is 0 2017-02-21 15:14:18 -08:00
Andrew Clark
28dbbe5734 Run test script 2017-02-21 14:43:01 -08:00
Andrew Clark
d3cbbe3b36 Add deprecation warning for assigning to this.state inside cWRP
We'll remove support for this in a future release, though we'll likely
still warn.
2017-02-21 14:42:12 -08:00
Andrew Clark
adc1641fec Should be able to setState inside cWRP before assigning to this.state
...without dropping the update. This won't work the other way around,
if you assign to this.state before calling setState. we'll add a
deprecation warning so people stop relying on this pattern.
2017-02-21 14:40:56 -08:00
Andrew Clark
d98a3d9269 Support assigning directly to this.state inside cWRP
We don't explicitly support this but it happens to work in Stack. We'll
give it the same semantics as replaceState.
2017-02-21 14:29:30 -08:00
Dan Abramov
51733c9a36 Add more details to the doc 2017-02-19 12:07:54 +00:00
Dan Abramov
6d6211f526 Doc consistency tweaks 2017-02-19 11:58:42 +00:00
Roman Matusevich
d28264e689 Remove extra article from documentation (#9028) 2017-02-19 11:10:50 +00:00
DanZeuss
fc362bf095 Improved for a better understanding (#8970)
* Improved for a better understanding

that code shouldn't name this parameter onchange. It is so confusing for a starter of ReactJs like me. It looks like that the onChange is an common event from props.

* Update the lifting state up paragraph

I tried to write something to explain to starter programmers in react, how we lift the state up calling a method defined by the ancestor and called by the children that will affect the children element.

* Rewrite Lifting State Up
2017-02-19 02:21:05 +00:00
Ben Alpert
bc2702f8bd Fix Fiber devtools prod (#9019) 2017-02-16 18:00:49 -08:00
Dimzel Sobolev
764531d53a Switch to shipping Fiber in npm packages (#9015) 2017-02-16 15:42:04 +00:00
Ben Alpert
d20dea1de2 Update to babel-plugin-transform-es2015-block-scoping 6.23 (#9002)
Now we won't add closures unnecessarily. I verified that we have no code that throws -- adding some then running `grunt build:modules` correctly throws.
2017-02-14 11:24:01 -08:00
Sebastian Markbåge
66bae80b08 Move validation calls behind DEV blocks (#8999)
This was done for Fiber but not Stack, causing these to throw in prod.
2017-02-14 11:10:59 -08:00
Sebastian Markbåge
5a1e30a868 Ignore events on text nodes (#9000)
In React Native events can fire on text nodes (on Android at least).

In that case, the current element will be a string and not props. These
can not have event handlers on them so we need to bail out so that
we don't throw later on.
2017-02-14 11:08:29 -08:00
Dan Abramov
7bdc189147 Revert "update react perf docs (#8060) and (#6174)" (#8997) 2017-02-13 23:43:08 +00:00
Toru Kobayashi
080f21e64f Remove an unnecessary condition 2017-02-13 15:36:13 -08:00
Dan Abramov
2464cd2d53 Update Thinking in React embed to match the link (#8996) 2017-02-13 23:25:47 +00:00
Brandon Dail
1ccb9361fe Revert "Revert "Missing a space for error 125"" (#8995) 2017-02-13 23:15:08 +00:00
Dan Abramov
c906fecd26 Revert "Missing a space for error 125" (#8994) 2017-02-13 23:11:05 +00:00
Ben Alpert
1e722e4a97 Check alternate in ReactTreeTraversal (#8992)
Test Plan: Couldn't figure out how to write a unit test. :\ Verified that enter/leave bubbling now works correctly in one FB interface that was broken though.
2017-02-13 14:24:44 -08:00
Phil Rajchgot
6367f9fbf3 Missing a space for error 125 (#8981) 2017-02-13 16:21:15 -06:00
Sean Gransee
c16ec5df13 fix misspellings in comments and tests (#8946)
* fix misspellings in comments and tests

* revert change in docs/js/react-dom.js
2017-02-13 16:01:54 -06:00
Sebastian Markbåge
890d52bafc Move ReactElementType to shared (#8991)
This is currently used by both isomorphic and the renderer. I think that
we can probably split these up. The isomorphic type should actually be
different. It has to do with that the caller needs to know exactly which
type of element it is but this is never needed in the renderer which only
needs to know that the type is internally consistent.

The owner type is renderer dependent so it can literally be anything.
2017-02-13 13:54:40 -08:00
Dan Abramov
4a05f268c8 Revert "Fix createNodeMock doc to avoid Invariant Violation" (#8990) 2017-02-13 20:15:49 +00:00
Andrew Clark
5ee033e40b Merge pull request #8974 from acdlite/fibercallbackvalidation
[Fiber] Move callback validation to top level
2017-02-13 12:15:42 -08:00
Andrew Clark
ea2ade251f Don't pass method names in production
Requires us to make the error message a bit more generic.
2017-02-13 12:13:50 -08:00
BDav24
00092957b6 Fix createNodeMock doc to avoid Invariant Violation (#8989) 2017-02-13 20:13:31 +00:00
Andrew Clark
d3aeca1ff8 Validate callbacks just before they are invoked
This delays the type check until the point when the engine will have to
perform a type check regardless.

Because the error is now thrown during the commit phase rather than
when the callback is originally scheduled, we warn in DEV when
scheduling so it's easier to track down.
2017-02-13 12:12:44 -08:00
Andrew Clark
662170673f Merge pull request #8978 from acdlite/nooptionaltypes
[Fiber] Use `T | null` instead of `?T` types
2017-02-13 11:20:58 -08:00
Jiminikiz
7958c1d77d Fixing grammatical error ... (#8987)
... in the Create React App section.
2017-02-13 10:04:09 -08:00
Prayag Verma
c60f852cdb Fix a typo in design principles doc (#8985)
unambigious → unambiguous
2017-02-13 15:09:00 +00:00
Andrew Clark
350d736361 Use T | null instead of ?T types
Flow maybe types accept both null and undefined. When the final
parameter of a function accepts a maybe type, passing nothing
(undefined) successfully typechecks, which can lead to bugs if the
omission is accidental. Being forced to pass null is harder to screw up.

Explicit null checks are also faster.
2017-02-10 17:30:09 -08:00
Toru Kobayashi
77c7792556 Remove React.__spread 2017-02-10 12:27:02 -08:00
Moacir Rosa
de673bca8d Only fix a small wrong key in example (#8976)
Only fix a small wrong key in example
2017-02-10 15:40:24 +00:00
Brian Vaughn
2e095b4140 Hardened validateCallback to better handle null values (#8973)
Previously, calls to validateCallback() with a null callback value resulted in runtime errors if a certain transform was not applied prior to running. This commit wraps the invariant() with the condition check so as to avoid calling formatUnexpectedArgument() unless necessary. It also replaces the truthy/falsy callback check with an explicit check for improved performance.
2017-02-09 14:10:45 -10:00
Leland Richardson
869c779861 Add toTree() method to stack and fiber TestRenderer (#8931)
* Add toTree() method to stack and fiber TestRenderer

* Address PR feedback

* Refactor TestRenderer to use correct root

* Rebase off master and fix root node references

* Add flow types

* Add test for null rendering components

* Remove last remaining lint error

* Add missing test
2017-02-09 20:55:00 +00:00
Dan Abramov
3f48caab40 Fix release guide again 2017-02-09 16:15:04 +00:00
Dan Abramov
6cfc0ecd72 Fix release guide 2017-02-09 16:14:27 +00:00
Dan Abramov
c11733dfb7 Update Yarn lockfile with fresh deps 2017-02-09 16:10:35 +00:00
Dan Abramov
c7ebe88c2a 16.0.0-alpha.2 2017-02-09 16:07:56 +00:00
Brian Vaughn
df13eb354e Fixed lint warning in master (#8960) 2017-02-09 16:02:47 +00:00
Sebastian Markbåge
741d9b2db9 Move React Native Environment Mocks to root (#8963)
These mocks are things we expect to be available in the React Native
environment. I'd like to move them out of the renderer folder so that we
can sync that folder to React Native as is without overriding its mocks.

I motivate by the fact that they're not really part of the renderer code
itself. I leave the ReactNative mock since that is in fact part of the
renderer.
2017-02-09 16:02:09 +00:00
Sebastian Markbåge
13e05b4237 Use separate feature flag for ReactTestRenderer (#8965)
The ReactDOMFeatureFlags is not reachable from the npm package since it is
in a separate build so we need a separate one.
2017-02-09 16:00:59 +00:00
Brian Vaughn
ab757e905c Fixed ReactNativeFiber event handling regression (#8959)
* Fixed ReactNativeFiber event system regression introduced in b354db2
Also added test coverage to ReactNativeEvents-test for Fiber

* ReactNative tests now run against fiber renderer when env flag set
Updated the test-framework-setup file so that record-tests runs native tests against ReactNativeFiber. ReactComponentTreeHook native tests all now fail but that's expected.

* Avoid calling setChildren() if no children
2017-02-08 21:28:56 -10:00
Sebastian Markbåge
81bd138144 findNodeHandle -> ReactNative.findNodeHandle (#8962)
Submitted this internally already.

Needed because people import this file directly and they might not have the renderer inject the findNodeHandle handler yet.
2017-02-08 17:13:33 -08:00
Andrew Clark
9b7dc4036c Merge pull request #8948 from acdlite/fiberdonttesthostcleanup
[Fiber] Don't test input value clean-up in Fiber
2017-02-08 15:33:20 -08:00
Andrew Clark
5b181a696e Make Stack error message more generic, too
We want to avoid passing around caller names because stripping them
out in production complicates the code for little benefit.
2017-02-08 11:43:53 -08:00
Andrew Clark
e9aca8e389 Warn about calling setState on an unmounted component 2017-02-08 11:23:58 -08:00
Andrew Clark
3955e222d2 Use isMounted instead of instance map to check if mounted 2017-02-08 10:33:00 -08:00
Andrew Clark
76a168fed6 Warn if findDOMNode is used inside render
Need to reset current owner to null before committing
2017-02-08 10:32:14 -08:00
Andrew Clark
4d52ebc066 Warn about isMounted inside render 2017-02-08 10:31:30 -08:00
Andrew Clark
f4cabafc8d Don't test input value clean-up in Fiber
Fiber doesn't clean up host components; relies on GC.
2017-02-08 10:26:47 -08:00
Sebastian Markbåge
b187142103 Move DOM dependent tests out of the shared folder (#8954)
We have a bunch of tests that are meant to test generic React behavior.
However, we've written the tests against the DOM renderer. This moves
tests that depend on ReactDOM or ReactTestUtils out of the shared repo.

This will let us sync the shared repo directly to environments that don't
support running these tests. Such as React Native.
2017-02-08 10:20:02 -08:00
Dan Abramov
1d90894f93 Re-add the warning if PropType function is called manually (#8903)
* Revert "Revert "Warn if PropType function is called manually (#7132)""

This reverts commit be71f76ed8b7dbad25e3519455605252d3daf683.

In other words, now we again have the warning if you attempt to call PropTypes manually.
It was removed in #8066 but we shouldn't have done this since we still want to avoid people accidentally calling them in production (and even more so since now it would throw).

Fixes #8080.

* Pass secret in ReactControlledValuePropTypes

* Record tests
2017-02-08 16:29:19 +00:00
Dhyey Thakore
994a0c8b0c update react perf docs (#8060) and (#6174) (#8236)
* update react perf docs issue 8060 and 6174

* Grammar

Small stuff
2017-02-07 14:00:08 -08:00
Dan Abramov
e280f5a1a7 Fix lint (#8945) 2017-02-07 14:42:09 +00:00
Andrew Clark
5cfff8706e Merge pull request #8919 from acdlite/fibermounttests
[Fiber] Mount/unmount warnings and invariants
2017-02-06 18:00:50 -08:00
Andrew Clark
0564b08cf2 Split into multiple invariants
That way the messages are extracted by the error code transform.
2017-02-06 17:59:53 -08:00
Andrew Clark
23f9e7b8ad Merge pull request #8937 from acdlite/inlineinternalerrormessage
Inline internal error message
2017-02-06 17:44:26 -08:00
Andrew Clark
2c7c783498 Merge pull request #8936 from acdlite/removemapsaschildren
Remove experimental support for maps as children
2017-02-06 17:14:30 -08:00
Andrew Clark
14962f8b40 Continue warning if a Map is rendered as a child
The entries of a map are a two-element array of [key, value], which
React will treat as fragments with children. This is unlikely to ever
be the intended behavior, so we warn.
2017-02-06 17:07:19 -08:00
Andrew Clark
94e843955d Remove experimental support for maps as children 2017-02-06 15:51:19 -08:00
Andrew Clark
2e1b3aab91 Inline internal error message
So that it is stripped out by the error code transform
2017-02-06 15:43:47 -08:00
Andrew Clark
a2c49f48bf Merge pull request #8926 from acdlite/fiberuseinvariant
[Fiber] Replace `throw new Error` with invariant module
2017-02-06 14:49:14 -08:00
Andrew Clark
915a3e88a2 Add additional message to internal invariants
The message tells users that the error is likely due to a bug in React,
and that they should file an issue.
2017-02-06 14:43:57 -08:00
Andrew Clark
b338c75c28 Get rid of DEV only invariant 2017-02-06 14:43:22 -08:00
Andrew Clark
a1ef4c4391 Replace throw new Error with invariant module 2017-02-06 14:43:14 -08:00
Andrew Clark
9fcf761e90 Run test script 2017-02-06 14:22:27 -08:00
Andrew Clark
255e5aeb3e Rendering into an empty React-rendered element should not warn
Only warn if the container has a React-rendered child.
2017-02-06 14:22:16 -08:00
Sebastian Markbåge
e05f0a3a13 Only expose FiberRoot at the top level instead of a Fiber (#8934)
It is strange to get a handle on the Fiber since it is one of possibly two
root Fibers. The correct way to get the current Fiber is through the
root.current.

I exposed the Fiber originally because I thought we might use it for
Portals but we went with a different approach. So we don't need this.
2017-02-06 13:19:33 -08:00
Andrew Clark
b49611e643 Merge pull request #8927 from mitenka/patch-5
Update higher-order-components.md
2017-02-06 11:42:31 -08:00
Jon Bretman
afdf47f425 Bump fbjs to 0.8.9 (#8910) 2017-02-06 19:02:17 +00:00
Dan Abramov
fb1444c463 Inject DevTools integration for RN Fiber (#8930) 2017-02-06 17:36:59 +00:00
KB
d42c285aa2 [docs] Add note about refs on stateless components (#8916)
* Add note about refs on stateless components

* Move info about refs in the stateless components to the main section

* Simplification of the part about refs and functional components

* Tweaks

* Move sections around

* Oops

* Rearrange more sections
2017-02-06 16:49:36 +00:00
António Nuno Monteiro
4313059702 Change the order between function declaration and object assignment (#8895)
This fixes #8894
2017-02-06 16:02:13 +00:00
Dmitry Zhuravlev-Nevsky
1b69a79136 Update higher-order-components.md 2017-02-04 03:35:06 +03:00
Ben Alpert
fa1087b42c Ensure first error is thrown if HostRoot catches two errors in commit phase (#8923)
Previously, we were overwriting capturedErrors with the second error and throwing that one.
2017-02-03 11:12:28 -08:00
Diego Muracciole
ad133f5b3d Add onToggle event to details tag (#8831)
* Add onToggle event to details tag

Fixes #8761

* Map onToggle event on ReactDOMFiberComponent

* Tweak doc

* Trap events on setInitialProperties for details tag
2017-02-03 10:25:09 +00:00
Andrew Clark
269555e35c Merge pull request #8921 from facebook/revert-8907-fiberproderrorcode
Revert "Loosen assertion so it matches any production error"
2017-02-02 15:24:04 -08:00
Andrew Clark
bd3070f774 Revert change to test
See: https://github.com/facebook/react/pull/8907#issuecomment-277111278
2017-02-02 15:22:28 -08:00
Andrew Clark
57d2d6d77d Merge pull request #8907 from acdlite/fiberproderrorcode
Loosen assertion so it matches any production error
2017-02-02 14:42:23 -08:00
Andrew Clark
87bc7cef2c Warn if unmounting a tree that was rendered by a different copy of React 2017-02-02 14:30:12 -08:00
Dan Abramov
7e8068b984 Move component base classes into a single file (#8918) 2017-02-02 20:24:39 +00:00
Andrew Clark
f4823295af Warn when rendering into React-rendered child that isn't a root 2017-02-02 12:18:18 -08:00
Andrew Clark
d47c21589b Warn when mounting into document.body 2017-02-02 12:18:18 -08:00
Andrew Clark
822587ea06 Add extra invalid element info to invariant message 2017-02-02 12:18:18 -08:00
Andrew Clark
ea2aa6e613 Fix messages so that they use the same template as Stack
The production error code system depends on the exact template string
that is passed to `invariant`. This changes the Fiber templates to
match the Stack ones.
2017-02-02 12:05:00 -08:00
Andrew Clark
02edc6bf18 Loosen assertion so it matches any production error
The exact error code isn't important.
2017-02-02 11:17:56 -08:00
Pontus Abrahamsson
55a18bca64 Update conferences.md (#8915)
* Update conferences.md

* Move confs around
2017-02-02 13:37:27 +00:00
Omid Hezaveh
79be3543dd Explain arbitrariness of ref name in callback (#8913)
* Explain arbitrariness of ref name in callback 

The sample code was confusing because it's not clear that "textInput" in this.textInput is an arbitrary name for the ref.

* Tweak wording
2017-02-02 13:33:12 +00:00
Dan Abramov
9e3a31b2c6 Fix indentation in tutorial (#8914) 2017-02-02 13:24:26 +00:00
Eduard
dc04ee87ae Update tutorial.md (#8896)
* Update tutorial.md

The status <div> used in Board can be deleted as well from render.

* Little tweaks
2017-02-01 18:12:00 -08:00
Tiago Fernandez
05f5bf6eb6 Link to CodePen editor rather than final result (#8849)
People want to see the final JS/CSS/HTML, and the final result is already displayed by CodePen.
2017-02-01 18:02:44 -08:00
Jeffrey Wan
3f5482ee20 Update tutorial.md (#8792)
* Update tutorial.md

* Fix quoting to be consistent
2017-02-01 17:42:19 -08:00
John Longanecker
b8f0522cc6 Lifting State Up more legible (#8691) 2017-02-01 17:31:01 -08:00
Andrew Clark
86fbb9d583 Merge pull request #8905 from acdlite/fiberfinddomnodeunmount
[Fiber] findDOMNode during componentWillUnmount
2017-01-31 16:05:05 -08:00
Andrew Clark
c158ff6179 Merge pull request #8908 from acdlite/fiberemptycomponent
[Fiber] Fix formatting of invalid element invariant
2017-01-31 16:03:54 -08:00
Andrew Clark
2afcf6e09f Fix formatting of invalid element invariant
Message is slightly different for functional and class components.
2017-01-31 15:29:53 -08:00
Andrew Clark
6545012af2 Merge pull request #8893 from gaearon/fix-dom-prod-test
Add process.cwd to the test process shim
2017-01-31 15:04:39 -08:00
Andrew Clark
10e5438422 Merge pull request #8906 from acdlite/warningnewline
Add missing newline to warning
2017-01-31 14:42:21 -08:00
Andrew Clark
6846ef9fb8 Add newline to warning 2017-01-31 14:41:14 -08:00
Andrew Clark
af7ae1be91 Don't swap the trees until after the first pass of the commit phase,
where componentWillUnmount is called, but before the second pass,
where componentDidMount/Update is called.
2017-01-31 14:39:52 -08:00
Andrew Clark
35ddd05da4 Merge pull request #8890 from acdlite/fiberfragmentinvariants
[Fiber] Throw on plain object children
2017-01-31 13:14:11 -08:00
Andrew Clark
73d27d755e Merge pull request #8897 from acdlite/fiberfixfinddomnode
[Fiber] Fix findDOMNode algorithm
2017-01-31 13:13:56 -08:00
Andrew Clark
2a0fb5b4aa Remove legacy React element warning 2017-01-31 11:46:30 -08:00
Andrew Clark
17ec96b014 Run test script 2017-01-31 11:44:35 -08:00
Andrew Clark
7daa90206d Add missing portal case to updateSlot switch statement 2017-01-31 11:44:35 -08:00
Andrew Clark
7af673afc1 Allow object as textarea child
Preserves Stack behavior. There's already a warning for this.
2017-01-31 11:44:35 -08:00
Andrew Clark
802c820545 Fallback to owner of returnFiber
Won't work if the returnFiber is a fragment. Not sure it matters;
warning will just be less descriptive.
2017-01-31 11:44:35 -08:00
Andrew Clark
3089db94ce Throw on invalid object type children
Same behavior as Stack
2017-01-31 11:44:30 -08:00
Andrew Clark
ba5b9c0af3 Add invariant
Defensive coding to prevent an infinite loop.
2017-01-31 11:35:10 -08:00
Dan Abramov
ea9e1575b7 Suppress lint warnings
Using [] is intentional because we don't want to trigger Babel plugin.
2017-01-31 19:30:26 +00:00
Andrew Clark
97f6786cba Fix findDOMNode algorithm 2017-01-31 10:24:03 -08:00
Dan Abramov
d6d129a1b2 Reassign process.env.NODE_ENV instead of shimming process 2017-01-31 16:28:20 +00:00
Marius Skaar Ludvigsen
d8450845fe #6049 add support for onCancel and onClose event (#6247) 2017-01-31 08:10:48 -06:00
Richie Thomas
469e68542b Added double newline delimiters to the following functions/files: (#8777)
* 'beginLifeCycleTimer' function of ReactDebugTool.js
            * 'bindAutoBindMethod' function of ReactClass.js
            * 'warnNoop' function of ReactServerUpdateQueue.js
            * 'getInternalInstanceReadyForUpdate' function of ReactUpdateQueue.js
            * 'warnNoop' function of ReactNoopUpdateQueue.js
            * 'getDeclarationErrorAddendum' function of ReactDOMComponent.js
            * 'getSourceInfoErrorAddendum' function of ReactElementValidator.js
            * 'getDeclarationErrorAddendum' function of instantiateReactComponent.js and ReactElementValidator.js
            * 'traverseAllChildrenImpl' function of traverseAllChildren.js
            * 'attachRef' function of ReactRef.js
            * 'mountIndeterminateComponent' function of ReactFiberBeginWork.js
            * 'createFiberFromElementType' function of ReactFiber.js
            * 'getDeclarationErrorAddendum' function of ReactDOMSelect.js
            * 'unmountComponentAtNode' function of ReactMount.js
            * 'getDeclarationErrorAddendum' function of ReactControlledValuePropTypes.js
            * 'checkRenderMessage' function of CSSPropertyOperations.js
            * 'getDeclarationErrorAddendum' function of ReactDomFiberSelect.js
            * 'getCurrentComponentErrorInfo' function in 'ReactElementValidator'
            * 'getDeclarationErrorAddendum' function in ReactDOMFiberComponent.js
2017-01-31 07:41:24 -06:00
Vladimir Kovpak
8bc5a87d04 Added undefined example (#8899)
Into section `Booleans, Null, and Undefined Are Ignored` I've added example with undefined.
2017-01-31 07:24:29 -06:00
Ben Alpert
64a47e9fb4 Don't crash Fiber with old devtools (#8900)
Typo.
2017-01-31 13:06:53 +00:00
Roman Liutikov
59aac010dd refer to object by name instead of function call context (#8892) 2017-01-30 18:32:26 -06:00
Senin Roman
466bb4ffb9 Fix incorrect markup for ie10 (#8886) 2017-01-30 18:32:07 -06:00
Dan Abramov
3195bcdbcb Add process.cwd to the test process shim 2017-01-30 21:48:05 +00:00
Maksim Shastsel
ec936dd848 Delete @nosideeffect annotation (#8882) 2017-01-30 21:42:17 +00:00
Dan Abramov
fb4c08baee Fix lint (#8888) 2017-01-30 17:46:07 +00:00
MICHAEL JACKSON
564fa64626 Update context example for react-router v4 beta (#8889)
* Update context example for react-router@4.0.0-beta.1

* Style nits
2017-01-30 17:36:47 +00:00
Dan Abramov
d8491ca73f Declare __REACT_DEVTOOLS_GLOBAL_HOOK__ for Flow (#8884) 2017-01-30 14:14:30 +00:00
Zac Braddy
cae2a6f9d3 Got rid of linting errors on windows machines and a number of linting warnings. (#8846) 2017-01-28 15:36:03 -08:00
Frank Yan
751d221172 Fix typo in EventPropagators.js (#8879) 2017-01-27 18:36:21 -06:00
Dan Abramov
d3e29d4e54 [Fiber] Support React DevTools (#8818)
* Initial React DevTools support for Fiber

* Record a newly failing irrelevant test

This is fine because we don't use it in Stack anyway (at least not that part), and we also rely on Set/Map in other parts of code.
The newly failing test is the one saying "it works without Map/Set".

* Explicitly check for Fiber DevTools support

This lets us ignore pre-Fiber DevTools instead of crashing them by injecting a different API.

* Track the roots in DevTools instead

* Lol Dan this is not how warnings work in our codebase

* Move injection to the renderer

* Notify DevTools about unmounts

* Make it work in production

* Fix lint and flow

* Fixups

* Address feedback
2017-01-27 22:50:35 +00:00
Paul O’Shannessy
3c75593692 [examples] Use react-standalone (#7669)
[examples] Use babel-standalone
2017-01-26 11:57:01 -06:00
Sebastian Markbåge
b26265718a Merge pull request #8840 from sebmarkbage/statelesscoroutines
[Fiber] Simplify coroutines by making yields stateless
2017-01-26 07:15:36 -08:00
Mitchel Humpherys
39472f1c3e installation.md: Add missing "as" (#8871) 2017-01-25 23:33:49 -06:00
Sebastian Markbåge
3f409df468 ReactElement is private to isomorphic React (#8868)
This fixes the build since this dependency is not reachable from React DOM.
2017-01-25 17:52:45 -08:00
Sebastian Markbage
975ad92e68 Don't bail to .child of coroutines
This should bail to stateNode instead.
2017-01-25 17:50:21 -08:00
Sebastian Markbage
754f72a175 Don't visit siblings of the coroutine when looking for yields
When visiting the yields, the root is the stateNode of the coroutine. If
its return value is wrong we'll end up at the alternate of the
workInProgress which will start scanning its children which is wrong.
2017-01-25 17:36:20 -08:00
Sebastian Markbage
e8500fb1c2 Add failing tests for coroutines
There are a few different issues:

* Updates result in unnecessary duplicate placements because it can't find the current fiber for continuations.
* When run together, coroutine update and unmounting tests appear to lock down in an infinite loop. They don't freeze in isolation.

I don't have a solution for this but just leaving it for future fixes.
2017-01-25 15:41:48 -08:00
Sebastian Markbage
fd8d5f7a8a Simplify coroutines by making yields stateless
Coroutines was kind of broken because it tried to do reparenting and
enabling state preservation to be passed along the coroutine. However,
since we couldn't determine which Fiber was "current" on a reified yield
this was kind of broken.

This removes the "continuation" part of yields so they're basically just
return values. It is still possible to do continuations by just passing
simple functions or classes as part of the return value but they're not
stateful.

This means that we won't have reparenting, but I actually don't think we
need it. There's another way to structure this by doing all the state in
the first phase and then yielding a stateless representation of the result.
This stateless representation of the tree can then be rendered in different
(or even multiple) locations.

Because we no longer have a stateful continuation, you may have noticed
that this really no longer represent the "coroutine" concept. I will
rename it in a follow up commit.
2017-01-25 15:41:47 -08:00
Sebastian Markbage
648d6e190c Swap .child and .stateNode in coroutines
It is slightly more useful this way because when we want to find host nodes
we typically want to do so in the second phase. That's the real tree where
as the first phase is more of a virtual part of the tree.
2017-01-25 15:41:47 -08:00
Brian Vaughn
88b6175cb1 Bumping package.json versions from 16.0.0-alpha.0 to 16.0.0-alpha.1 2017-01-25 12:14:00 -08:00
Andrew Clark
63edf30f5d Merge pull request #8797 from acdlite/fix-arrays
[Fiber] disableNewFiberFeatures bugfix: host component children arrays
2017-01-25 12:06:08 -08:00
Andrew Clark
ba1d3829bc Use multiple checks instead of forking the entire function
Easier to follow this way, and less chance the two paths will get
out of sync.
2017-01-25 12:05:32 -08:00
Andrew Clark
645ad6d261 Add test for mocked render functions
Treat them as if they return null
2017-01-25 11:52:48 -08:00
Andrew Clark
c0e5df66ec Make disableNewFiberFeatures = true the default when runnings tests
This exposed a few more cases that I missed.
2017-01-25 11:52:48 -08:00
Andrew Clark
5c4362dc5c Remove outdated TODO 2017-01-25 11:52:48 -08:00
Andrew Clark
1ac6be2677 Add test for iterables, too 2017-01-25 11:52:48 -08:00
Andrew Clark
16956ed640 disableNewFiberFeatures bugfix: host component children arrays 2017-01-25 11:52:48 -08:00
jddxf
a3ff8c3833 Improve tests (#8866)
* refactor one test suite to use jest's mock function

* keep the comment
2017-01-25 10:13:09 -06:00
Brandon Dail
2b113c527e Use correct optional paramater JSDoc syntax 2017-01-25 09:24:00 -06:00
lokson
facd67d000 [docs] forEachAccumulated params 2017-01-25 09:24:00 -06:00
Scott
4c6fec902f Add benchmarking tutorial (#8698)
* Add benchmarking tutorial

I've written what I hope is the simplest introduction to benchmarking React components. It's meant to be straightforward and easy to follow for beginners. If you agree that it would be helpful, I'd like to add it to the docs.
Would also welcome any and all feedback.

* Just put links together
2017-01-25 15:14:18 +00:00
Oscar Bolmsten
c2f94385a1 webpack 2 is now stable (#8859)
Remove notice about different webpack versions
Update webpack URLs
2017-01-25 14:56:52 +00:00
Edvin Erikson
0c7f21a705 Component -> Unknown (#8863)
Fix Flow issue and revert to showing "Unknown" in warnings for anonymous components
2017-01-25 14:49:19 +00:00
Edvin Erikson
5170db8e72 Remove unnecessary null (#8858)
* Remove unnecessary null

* always return string
2017-01-24 18:19:07 +00:00
Dan Abramov
7683211efd Fix Flow (#8857) 2017-01-24 13:45:49 +00:00
Brandon Dail
2be0583ed3 Update deprecation wording to be less aggressive 2017-01-24 00:18:23 -06:00
Brandon Dail
4bba89f047 Add deprecation tests to fiber test tracker 2017-01-24 00:18:23 -06:00
Brandon Dail
23deea0f02 Add test for deprecation warnings 2017-01-24 00:18:23 -06:00
Brandon Dail
2b7814f713 Deprecate React.createMixin
This API was never fully implemented. Since mixins are no longer considered part of the future React API, it will be removed.
2017-01-24 00:18:23 -06:00
Ben Alpert
046f7448d7 Two minor changes from internal (#8855) 2017-01-23 17:11:10 -08:00
Keyan Zhang
eb89bc4c30 Add a link to "State Updates are Merged" in the forms doc (#8851)
* Added a link to "State Updates are Merged"

* better inline links

* moved the explanation down

* Minor unrelated tweaks
2017-01-23 21:09:48 +01:00
mguidotto
b2b6d9daf7 Update conferences.md (#8841)
* Update conferences.md

* Update conferences.md

path fixed

* Changed capitalization to match the website and Twitter
2017-01-23 20:31:21 +01:00
OJ Kwon
f5662456e1 Update test setup Windows compatible (#8651)
- relates to #7849
2017-01-23 19:59:06 +01:00
Dan Abramov
ee6358bb7d Tweak RRM instructions to mention Yarn instead 2017-01-23 18:01:27 +00:00
Dan Abramov
beb2e0124d Clarify use of ES6 idiom in Forms doc 2017-01-23 17:59:44 +00:00
Justin Grant
fc302494b7 Reminder: strip quotes from attributes with JS code (#8806)
* Reminder: strip quotes from attributes with JS code

Web developers who are used to standards-compliant HTML and XML will, out of habit, put quotes around all attributes because the standards require them. Other templating systems like ASP.NET also require (or at least allow) quotes around attributes that contain code. This behavior will get users into trouble in JSX because a quoted attribute is always treated as a string literal, even if it contains curly-braced javascript code.  Let's add to the docs to help newbies evade this problem.

* Tweak wording
2017-01-23 18:09:35 +01:00
Ragnar Þór Valgeirsson
09b3ec5d3c Match eslint's line length settings (#8845) 2017-01-23 17:47:48 +01:00
SunHuawei
5494b267d9 Fix a typo (#8580) 2017-01-23 17:43:48 +01:00
Mark Pedrotti
f56cf66945 Replace 2 occurrences of string in type ReactTestRendererJSON (#8816)
* Replace 2 occurrences of string in type ReactTestRendererJSON

* restore string in ReactTestRendererFiber.js
2017-01-23 17:29:47 +01:00
Sebastian Markbåge
5659bd2a63 Polyfill requestIdleCallback when native is not available (#8833)
I introduce the ReactDOMFrameScheduling module which just exposes
rIC and rAF.

The polyfill works by scheduling a requestAnimationFrame, store the time
for the start of the frame, then schedule a postMessage which gets
scheduled after paint. The deadline is set to time + frame rate.
By separating the idle call into a separate event tick we ensure that
layout, paint and other browser work is counted against the available time.

The frame rate is dynamically adjusted by tracking the minimum time between
two rAF callbacks. This is not perfect because browsers can schedule
multiple callbacks to catch up after a long frame. To compensate for this
we only adjust if two consecutive periods are faster than normal.

This seems to guarantee that we will hit frame deadlines and we don't end
up dropping frames. However, there is still some lost time so we risk
starving by not having enough idle time.

Especially Firefox seems to have issues keeping up on the triangle demo
However, that is also true for native rIC in Firefox. It seems like more
render work is scheduled on the main thread pipeline and also that JS
execution just generally has more overhead.
2017-01-21 10:27:46 -08:00
Brian Vaughn
f546505e4e Support for ReactFeatureFlags.logTopLevelRenders timing (#8687)
Call `console.time` / `console.timeEnd` for the top level component when `ReactFeatureFlags.logTopLevelRenders` is enabled
2017-01-21 09:44:47 -08:00
Sebastian Markbåge
4f8c16a750 Read "current" props from the node instead of the Fiber (#8839)
It's not just events that read the current props. Controlled components
do as well. Since we're no longer updating the Fiber pointer during updates
we have to instead read from the node props to get the current props.

Since this method is no longer just used for events I renamed it.
2017-01-20 23:25:25 -08:00
EugeneGarbuzov
30c7c4fbe6 Corrected a typo. (#8837)
shoud -> should
2017-01-20 13:25:21 -06:00
Sebastian Markbåge
b354db22a9 [Fiber] Compute the Host Diff During Reconciliation (#8607)
* Allow renderers to return an update payload in prepareUpdate

This then gets stored on updateQueue so that the renderer doesn't need to
think about how to store this.

It then gets passed into commitUpdate during the commit phase.

This allows renderers to do the diffing during the time sliced path,
allocate a queue for changes and do only the absolute minimal work to
apply those changes in the commit phase.

If refs update we still schedule and update.

* Hack around the listener problem

* Diff ReactDOMFiber properties in prepareUpdate

We now take advantage of the new capability to diff properties early.
We do this by generating an update payload in the form of an array with
each property name and value that we're about to update.

* Add todo for handling wasCustomComponentTag

* Always force an update to wrapper components

Wrapper components have custom logic that gets applied at the commit phase
so we always need to ensure that we schedule an update for them.

* Remove rootContainerInstance from commitMount

No use case yet and I removed it from commitUpdate earlier.

* Use update signal object in test renderer

* Incorporate 8652 into new algorithm

* Fix comment

* Add failing test for flipping event handlers

This illustrates the problem that happens if we store a pointer to the
Fiber and then choose not to update that pointer when no properties change.
That causes an old Fiber to be retained on the DOM node. Then that Fiber
can be reused by the pooling mechanism which then will mutate that Fiber
with new event handlers, which makes them active before commit.

* Store current props in the RN instance cache and on the DOM node

This represents the current set of event listeners. By not relying on the
Fiber, it allows us to avoid doing any effects in the commit phase when
nothing changes.

This is a bit ugly. Not super happy how this all came together.
2017-01-19 21:56:15 -08:00
Dan Abramov
c6a7dc7f24 Preserve license headers from dependencies in minified build (#8803)
* Preserve license headers from dependencies in minified build

Fixes #8789.

* Bump minimal object-assign version
2017-01-20 02:29:06 +01:00
Keyan Zhang
06399b8ce3 Add "Handling Multiple Inputs" to Forms doc (#8552)
* added "Handling Multiple Inputs"

* renamed and added a codepen

* simplified the example
2017-01-17 22:19:46 -08:00
Brian Vaughn
16abcef937 Tweaked captured error log slightly based on feedback (#8785)
Tweaked captured error log slightly based on feedback. Normalized stack format/display for different browsers
2017-01-17 14:32:06 -08:00
Dan Abramov
935bdbec84 Ignore fixtures in Flow and ESLint 2017-01-17 19:26:27 +00:00
Rohan Nair
5d96162b57 Updating Thinking in React doc to replace refs with event handlers (#8815)
* Updating Thinking in React doc to replace refs

* Updating doc copy to reflect changes to example
2017-01-17 10:17:32 -08:00
Faheel Ahmad
c8a41672ed I -> we (#8817) 2017-01-17 10:01:40 -08:00
DQNEO
6308238498 use an easier word (#8809)
* use an easier word

The word `mandatory` is relatively difficult for people with ESL (English as a second language), so I propose an alternative word.
This would be much easier to understand.

* use simpler word
2017-01-17 10:00:11 -08:00
Jack Cross
bfd5b1878e Add Flow reminder to PR template (#8805)
* Added flow to PR template

* Added record-tests step to PR template and contribution docs

* Updated order of PR checks
2017-01-17 06:34:44 -08:00
Rich Harris
e69ff955f4 add docs for building with Rollup (#8799)
* add docs for building with Rollup

* Tiny unrelated fix
2017-01-17 05:55:49 -08:00
Toru Kobayashi
0758bb0035 Fix to work fiber debugger with npm start (#8811)
* FiberDebugger uses packages built in local

* Fix key warnings in FiberDebugger

* Remove react packages from package.json and yarn.lock for using pacakges built in local

* Remove fiber.js from `files` in package.json
2017-01-17 05:34:02 -08:00
Superlaziness
66540fdf16 fix HOC doc (#8802) 2017-01-16 06:49:01 -08:00
Tom Gasson
c77632791f Fix fiber/record-tests to work on windows (slash differences) (#8796) 2017-01-14 21:16:03 -06:00
Eric Churchill
cd4afca043 Add unit test to onlyChild to ensure onlyChild returns child element (#8667)
Add unit test to onlyChild to ensure onlyChild returns child element
2017-01-14 14:09:24 -08:00
Vladimir Tikunov
ebd83e809e Remove error ref to the 'render' function (#8781)
What is the `render` function of a functional component?
2017-01-14 13:36:55 -06:00
Dan Abramov
6a488913b9 [Fiber] Fix rendering SVG into non-React SVG tree (#8638)
* Add a test for rendering SVG into a non-React SVG tree

It is failing in Fiber.

* Add a test for rendering HTML into non-React foreignObject

It happens to pass in Fiber.

* Determine root namespace by container namespace, not just tag

A tag alone is not enough to determine the tree namespace.

* Skip the test that exhibits jsdom bug in non-createElement mode

jsdom doesn't give HTML namespace to foreignObject.innerHTML children.
This problem doesn't exist in the browsers.

https://github.com/facebook/react/pull/8638#issuecomment-269349642

We will skip this test in non-createElement mode considering
that non-createElement mounting is effectively dead code now anyway.
2017-01-14 05:11:51 -08:00
Brian Vaughn
7817eb08f3 Replaced an Update effect in complete phase with a Ref effect
Also removed an unnecessary conditional check and improved a flow cast.

Relates originally to PRs #8646 and #8685
2017-01-13 15:32:49 -08:00
Brian Vaughn
be0de3455b Log all Fiber errors w/ component stack (#8756)
A new module has been added (ReactFiberErrorLogger). This logs error information (call stack and component stack) to the console to make errors easier to debug. It also prompts users to use error boundaries if they are not already using them.

In the future, perhaps this will be injectable, enabling users to provide their own handler for custom processing/logging. For the time being, this should help with issues like this / #2461.
2017-01-13 14:45:56 -08:00
Brian Vaughn
c359df7d58 Merge pull request #8645 from bvaughn/add-failing-scu-current-props-test
Added memoization test for interrupted low-priority renders
2017-01-13 13:52:01 -08:00
Brian Vaughn
2fb07b9502 Added memoization test for interrupted low-priority renders
Test added to verify that a high-priority update can reuse the children from an aborted low-priority update if shouldComponentUpdate returns false.
2017-01-13 13:46:20 -08:00
Iurii Kucherov
20c4aac9ec Update higher-order-components.md (#8780) 2017-01-13 13:17:48 -08:00
Brian Vaughn
3bc5595dfd Merge pull request #8742 from bvaughn/stack-fiber-gcc-warning
Warn about missing getChildContext method
2017-01-13 08:45:29 -08:00
Piper Chester
c61148ca58 Fix typo (#8770) 2017-01-13 05:19:23 -08:00
Diego Muracciole
de8173e567 Small ReactPropTypes refactor (#8771) 2017-01-13 04:53:18 -08:00
Dan Abramov
5afd8cd704 Improve Fiber debugger (#8767)
* Simplify the hooks
* Capture completion at the right moment
* Animate the scroll with the fiber on the stack
* Better display priorities
2017-01-13 04:41:56 -08:00
Brian Vaughn
7a2e35b93b Improved error message wording for missing getChildContext() method 2017-01-12 17:11:53 -08:00
Brian Vaughn
e17cc98a89 Removed redundant gCC test 2017-01-12 16:58:36 -08:00
Brian Vaughn
4f08884b5d Dedupe missing getChildContext warning by component name 2017-01-12 16:58:36 -08:00
Brian Vaughn
c7f1abade5 Stack and Fiber warn about missing getChildContext method
Previous (probably unintentional) behavior of Stack was to allow components to define childContextTypes without also supplying a getChildContext property. This PR updates Fiber to (temporarily) mimic that behavior. It also adds warning messages to both Fiber and Stack (along with a test).

For the time being, Fiber components with a missing getChildContext method will return the parent context as-is, after warning.
2017-01-12 16:58:36 -08:00
Andrew Clark
199db638c4 Merge pull request #8655 from acdlite/fibermemoizepremptedwork
[Fiber] Move memoization to begin phase
2017-01-12 16:08:02 -08:00
Andrew Clark
d28ac9eea0 Merge pull request #8757 from acdlite/fiberfeatureflag
Add feature flag to disable Fiber-only features
2017-01-12 13:52:32 -08:00
Andrew Clark
9459bad912 Run test script and fix regressions
Fixes the case where there's an uncaught error and the root unmounts.
We implement this by rendering the root as if its child is null. Null is
not usually allowed at the top level, so we need to special case it.
2017-01-12 13:51:22 -08:00
Andrew Clark
c8adedc054 Warn if undefined is passed to top-level render
Moved the top-level check to ReactChildFiber like the other ones
2017-01-12 13:51:22 -08:00
Andrew Clark
397810f844 Top-level render only accepts a React element if feature flag is on 2017-01-12 13:51:15 -08:00
Ben Alpert
54ebcbcd18 Add test for state merging when sCU is false 2017-01-12 12:04:33 -08:00
Dan Abramov
fd1ef53711 [Fiber Debugger] Bring up to date (#8765)
* Ignore orphaned fibers in the debugger

* Remember last entered code via localStorage

* Update Create React App

* Minor fixes

* Dogfood Fiber
2017-01-12 11:55:59 -08:00
Andrew Clark
d17b9a13f8 Confirm that a shallow bailout does not drop work in the child
Includes a test that confirms that work that is bailed out before
completing can be reused without dropping the entire subtree.
2017-01-12 11:55:52 -08:00
Andrew Clark
1ed304fa87 Move memoization to begin phase
Currently we update the memoized inputs (props, state) during the
complete phase, as we go back up the tree. That means we can't reuse
work until of its children have completed.

By moving memoization to the begin phase, we can do a shallow bailout,
reusing a unit of work even if there's still work to do in its children.

Memoization now happens whenever a fiber's `child` property is updated;
typically, right after reconciling. It's also updated when
`shouldComponentUpdate` returns false, because that indicates that the
given state and props are equal to the memoized state and props.
2017-01-12 11:55:52 -08:00
Paul O’Shannessy
8835955218 Add error codes update to release process (#8749)
* Add error codes update to release process

* Update
2017-01-12 07:13:04 -08:00
Whien
3ec1da800d move blog post [Profiling Components with Chrome Timeline] into docs article (#8680)
* move blog post into docs article

* move to second section and changed description

* Minor tweak
2017-01-12 07:06:15 -08:00
俞火江
e240470cf1 fix failed tests on Windows #8737 (#8747)
* fix failed tests on Windows #8737

* Use regexp literal instead of `RegExp` constructor so that we don't need to bother with escaping special character like `\` and `.`.
Note that by removing the path separator in regexp, I've relaxed the matching condition a little.Since there's little chance we have files like `XXXReact.d.ts`,it should not matter.
2017-01-12 06:46:23 -08:00
Liangzhen Zhu
cb82bc37b6 fix typo (#8760)
It seems that the class name in comments should be CallbackQueue
2017-01-12 06:31:40 -08:00
Snowmanzzz(Zhengzhong Zhao)
2cb7637607 Update handling-events.md (#8762)
* Update handling-events.md

* Update handling-events.md
2017-01-12 06:30:43 -08:00
Andrew Clark
80cf21cae4 In DEV, allow treat auto-mocked render methods as if they return null
Consider deprecating this in the future.
2017-01-11 18:06:16 -08:00
Andrew Clark
204d3dd703 Throw if undefined is returned from a composite component 2017-01-11 18:01:44 -08:00
Andrew Clark
86280187d7 Disallow Fiber-only render return types when feature flag is on
Except for portals, which we use in some places.
2017-01-11 18:01:36 -08:00
Andrew Clark
bf117f82e1 Add feature flag to disable Fiber-specific features
We'll enable this in www in case we need to roll back to Stack.
2017-01-11 17:41:13 -08:00
Dan Abramov
3ec1779837 Make test that forbids arrays Stack-only 2017-01-11 17:11:43 -08:00
Dan Abramov
df0532b0c3 Remove unnecessary warning for invalid node
We have an invariant that checks the same case right afterwards.

The warning was originally added in #5884 with a distinct wording.

However it was later changed to the same wording as the invariant in #6008.

I don't see why we would want to have both since they're saying the same thing and with (almost) the same internal stack.
2017-01-11 17:11:02 -08:00
Dan Abramov
33c3121f43 Remove a duplicate test
This test is identical to "should warn when stateless component returns array" earlier.

It was moved from another file in #5884 so it likely survived by accident.
2017-01-11 17:10:25 -08:00
Dan Abramov
fdf0f435c7 Add a test for stateless components returning undefined
We have one for arrays but it is going to become Stack-specific.
2017-01-11 17:10:08 -08:00
Toru Kobayashi
beb5b74c54 [Fiber] Fix to render falsy value as dangerouslySetInnerHTML (#8652)
* [Fiber] Fix to render falsy value as dangerouslySetInnerHTML

* Add more cases and rename test for clarity
2017-01-11 13:19:50 -08:00
Dustan Kasten
2da35fcae8 [Fiber] Implement test renderer (#8628)
* ReactTestRenderer move current impl to stack dir

* ReactTestRenderer on fiber: commence!

* ReactTestRenderer: most non-ref/non-public-instance tests are passing

* Move ReactTestFiberComponent functions from Renderer to Component file

* test renderer: get rid of private root containers and root Maps

* TestRenderer: switch impl based on ReactDOMFeatureFlag.useFiber

* ReactTestRenderer: inline component creation

* ReactTestRenderer: return to pristine original glory (+ Fiber for error order difference)

* TestRendererFiber: use a simple class as TestComponentInstances

* Add `getPublicInstance` to support TestRenderer `createNodeMock`

* Rename files to end. Update for `mountContainer->createContainer` change

* test renderer return same object to prevent unnecessary context pushing/popping

* Fiber HostConfig add getPublicInstance. This should be the identity fn everywhere except the test renderer

* appease flow

* Initial cleanup from sleepy work

* unstable_batchedUpdates

* Stack test renderer: cache nodeMock to not call on unmount

* add public instance type parameter to the reconciler

* test renderer: set _nodeMock when mounted

* More cleanup

* Add test cases for root fragments and (maybe?) root text nodes

* Fix the npm package build

Explicitly require the Stack version by default.
Add a separate entry point for Fiber.

We don't add fiber.js to the package yet since it's considered internal until React 16.

* Relax the ref type from Object to mixed

This seems like the most straightforward way to support getPublicInstance for test renderer.

* Remove accidental newline

* test renderer: unify TestComponent and TestContainer, handle root updates

* Remove string/number serialization attempts since Fiber ensures all textInstances are strings

* Return full fragments in toJSON

* Test Renderer remove TestComponent instances for simple objects

* Update babylon for exact object type syntax

* Use $$typeof because clarity > punching ducks.

* Minor Flow annotation tweaks

* Tweak style, types, and naming

* Fix typo
2017-01-11 11:19:32 -08:00
Piper Chester
837835d7f3 Update index.html: add spaces between Web/React components (#8750) 2017-01-11 11:00:16 -08:00
Andrew Clark
1c43f94717 Merge pull request #8746 from acdlite/fiberrevertcommitinfo
[Fiber] Revert CommitInfo to avoid extra allocation
2017-01-10 17:44:25 -08:00
Andrew Clark
b59cb4ae01 Revert CommitInfo to avoid extra allocation
I added this when I thought we might support interleaved commits, but
we don't.
2017-01-10 17:14:53 -08:00
Tomáš Hromada
4a7e06bab7 Added more info about refs in the documentation (#8707)
* Update refs-and-the-dom.md

I want to propose some changes to the Refs and the DOM documentation page. 
- Make it clear that string refs are legacy. It seems that this information got lost during the transition to new docs and only some part stayed the same, which was confusing when first reading the docs.
- Clarify and explain that during render, if the ref callback is provided, it will get called twice, first with `null` and then with the rendered DOM element. Discussed in https://github.com/facebook/react/issues/4533 and first proposed docs change in PR #8333.

I've also planned on adding an example for passing the refs up the component chain based on something I've needed to solve myself (e.g. you want to connect two dynamic components by line in React, so you need to both use refs and propagate them up the chain), and while it would be great to read up on this in the docs, it may be too specific for this section; I'd be happy to hear any recommendations.

* Adds more specific information about the callback

* Moved the ref callback description to the Caveats section

* Fixed suggested nits

* Replace 'each render pass' with 'updates'

* Tweak the wording
2017-01-10 12:18:23 -08:00
Dan Abramov
bd23aa2712 Dedupe warnings about refs on functional components (#8739)
* Verify that functional component ref warning is deduplicated

It's not a big problem for string refs because the ref stays the same and the warning code path runs once per mount.

However, it is super annoying for functional refs since they're often written as arrows, and thus the warning fires for every render.

Both tests are currently failing since we're mounting twice, so even the string ref case prints warnings twice.

* Extract the warning condition to the top level

We don't want to run getStackAddendumByID() unless we actually know we're going to print the warning.

This doesn't affect correctness. Just a performance fix.

* Deduplicate warnings about refs on functional components

This fixes the duplicate warnings and adds an additional test for corner cases.

Our goal is to print one warning per one offending call site, when possible.

We try to use the element source for deduplication first because it gives us the exact JSX call site location.

If the element source is not available, we try to use the owner name for deduplication.

If even owner name is unavailable, we try to use the functional component unique identifier for deduplication so that at least the warning is seen once per mounted component.
2017-01-10 09:54:48 -08:00
Brian Vaughn
540ea9e2fe Replaced chalk.color.red with chalk.red 2017-01-10 08:45:56 -08:00
Dmitry Zhuravlev-Nevsky
280bcfa9f5 Fix single vs plural (#8738)
Maybe it's not very important, just misprint fix
2017-01-10 08:00:16 -08:00
Spen Taylor
c3ce14a373 [Docs] Replace 'mix in' in PureComponent notes (#8730)
* [Docs] Replace 'mix in' in PureComponent notes

* Style nit
2017-01-10 06:02:22 -08:00
Dan Abramov
7e47c1aa4a Bump react-noop-renderer version to fix CI 2017-01-10 13:41:31 +00:00
Dmitry Zhuravlev-Nevsky
65bf19029d Swap components (#8735)
It's better to delare component before using.
2017-01-10 02:48:53 -08:00
Andrew Clark
00be2e437f Merge pull request #8728 from acdlite/fibernocallbacklist
[Fiber] Remove callbackList field from Fiber
2017-01-10 00:21:42 -08:00
Andrew Clark
288a4c4d6d Reset invalid UpdateQueue fields when cloning from current
Similar to what cloneFiber does. No change in behavior, but it's more
consistent this way.
2017-01-09 17:14:09 -08:00
Andrew Clark
d4e971a266 Remove callbackList field from Fiber
Moves it to UpdateQueue instead so that we don't waste memory for
components that don't have update queues.
2017-01-09 17:10:10 -08:00
Brian Vaughn
378ef5e730 16.0.0-alpha.0 2017-01-09 16:45:56 -08:00
Brian Vaughn
24b8ba7340 Merge pull request #8723 from bvaughn/improve-unmasked-context-caching
Improve unmasked context caching
2017-01-09 15:33:20 -08:00
Andrew Clark
f1a49e8d6e Merge pull request #8710 from acdlite/fiberscheduleupdateoptimization
[Fiber] Stop bubbling priority on equal priority
2017-01-09 15:24:25 -08:00
Brandon Dail
a1dd107d7a Merge pull request #8589 from nhunzaker/browser-testing
Add basic testing page for browser quicks
2017-01-09 17:22:17 -06:00
Dustan Kasten
90294ead4c Warn for callback refs on functional components (Stack + Fiber) (#8635)
* Fiber: warn for refs on SFCs

* Stateless refs: update warning to use component stack

* Warn for function refs (stack and fiber)

* Add owner reference to ref warnings

* Centralize stack ref warnings in ReactRef.attachRef

* Fiber stateless comp ref warning should only do work when necessary

* ReactDebugCurrentFiber maybe FunctionalComponents should act this way instead

* (chore) scripts/fiber/record-tests

* Add component._compositeType to ReactInstance Flow definition

* Don't handle 'stack inside fiber' case in the warning

We don't have a test for it. It's easy to mess it up and print the wrong thing so instead of verifying it I'll just remove this bit.

* Revert the change to getCurrentFiberOwnerName

This happened to work, but it is just a coincidence. This change didn’t really match what the function was supposed to be doing.

I’m not sure what the correct fix would be yet so this commit breaks tests.

* Add component indirection to the tests using owner name

This passes in Stack. It helps ensure we supply the correct owner name.

* Invalid type invariant should read owner from element

This brings the Fiber behavior in line with how Stack does it. The Fiber test was passing accidentally but broke down in more complicated cases (such as when we have an <Indirection> between the owner and the failing element).

Now we can also remove the weird cases from getCurrentFiberOwnerName() that didn't really make sense but helped get the (incomplete) tests pass in the past.

* Fiber should throw on a string ref inside functional component
2017-01-09 15:09:18 -08:00
Brandon Dail
2dbff6e10c Updating paths in packaging fixtures README 2017-01-09 16:06:08 -06:00
Brandon Dail
2f8a3e5100 Use absolute paths for resolve.root in webpack packaging fixtures
Webpack requires absolute paths here
2017-01-09 15:59:47 -06:00
Brandon Dail
429da399e9 Move build fixtures to fixtures/packaging, updated paths 2017-01-09 15:55:25 -06:00
Brian Vaughn
e5a7b75846 Improve unmasked context caching
Only store cached masked/unmasked contexts on context consumers. Move all references to __reactInternal* cached attributes inside of ReactFiberContext.
2017-01-09 13:51:03 -08:00
Richie Thomas
b2cc91e83a Remove one extraneous backtick from line 116 of 'codebase-overview.md' (#8724). (#8726) 2017-01-09 14:06:37 -06:00
Stuart Harris
c78e403d7b Added React London conference, March 28th (#8722)
Thanks :-)
2017-01-09 09:28:20 -08:00
Brian Vaughn
67c16e3148 Merge pull request #8706 from bvaughn/dont-recreate-masked-context-unless-needed
Dont recreate maked context unless unmasked context changes
2017-01-09 08:45:01 -08:00
Nik Nyby
fa4f79f9fc docs: add missing period in shouldComponentUpdate doc (#8720) 2017-01-09 08:22:04 -08:00
Jirat Ki
fb7e49439f Add component stack to invalid element type warning (#8495)
* Show Source Error Addemden if __source available

* Add Parent Stack on invalid element type

* refactor to use normalizeCodeLocInfo

* Remove ( ) from addendum
2017-01-09 07:26:01 -08:00
Dan Abramov
fbfecd13ce Write a release guide (#8705)
* Write a release guide

* Style nit
2017-01-09 06:39:27 -08:00
Dan Abramov
6b1c86020d Add missing entry for #7750 to 15.4.2 changelog 2017-01-09 14:15:35 +00:00
Bruno Heridet
00846fd3a6 docs(hoc): fix typo Rambda → Ramda (#8712) 2017-01-08 10:26:46 -06:00
Andrew Clark
8ad0e0c25b Stop bubbling priority on equal priority
Unobservable perf fix. Previously we only stopped bubbling if the
priority was lower, but we can stop on equal priority, too.
2017-01-07 21:25:45 -08:00
Brian Vaughn
a682059757 Dont recreate maked context unless unmasked context changes
Doing so can lead to infinite loops if componentWillReceiveProps() calls setState()
2017-01-07 08:53:24 -08:00
Brandon Dail
2085542d30 Remove fixture react build files from git tracking 2017-01-06 16:27:59 -06:00
Nathan Hunzaker
3d6a63d3c6 Remove primitive dom fixture READMEs for some test cases 2017-01-06 17:22:44 -05:00
Nathan Hunzaker
3c53d314a0 Move build fixtures to fixtures/build 2017-01-06 17:17:03 -05:00
Nathan Hunzaker
c79b3f11fe Fix relative reference to build folder in DOM fixtures 2017-01-06 17:15:40 -05:00
Nathan Hunzaker
9d3ceb6895 Update readme for DOM Fixtures 2017-01-06 17:14:50 -05:00
Nathan Hunzaker
96171662aa Move current fixtures into dom folder 2017-01-06 17:10:41 -05:00
Nathan Hunzaker
5e53c0cea4 Add missing semicolon 2017-01-06 17:10:41 -05:00
Nathan Hunzaker
d585590650 Address lint issues. 2017-01-06 17:10:41 -05:00
Nathan Hunzaker
565d63baa6 Remove trailing comma, causing crash in IE11 2017-01-06 17:10:41 -05:00
Nathan Hunzaker
3a51db27f2 Fix some CORS issues in IE 2017-01-06 17:10:41 -05:00
Nathan Hunzaker
2d75ae9fed Consolidate styles into single file 2017-01-06 17:10:41 -05:00
Nathan Hunzaker
1d1dd60899 Patch in console for IE9 2017-01-06 17:10:41 -05:00
Nathan Hunzaker
b006d05275 Test, not text. 🔤 2017-01-06 17:10:41 -05:00
Nathan Hunzaker
c31297b6d9 Remove extraneous binds from some fixtures 2017-01-06 17:10:41 -05:00
Nathan Hunzaker
85aa7eebfc Add test prompt message when no fixture is selected 2017-01-06 17:10:41 -05:00
Nathan Hunzaker
f10a1a7c6f Copy local build before starting 2017-01-06 17:10:41 -05:00
Nathan Hunzaker
6de9ff2deb Remove babel include from react-loader 2017-01-06 17:10:41 -05:00
Brandon Dail
52a1ee492a Remove duplicate fixture components 2017-01-06 17:10:41 -05:00
Brandon Dail
5deb9826ca Use create-react-app for fixtures application
This moves the current fixture architecture to one based around create-react-app. There are a few important things to note:

* The react-loader.js script is always loaded before the bundle and will populate React and ReactDOM on the window. It is then read from the window by all components.
* The UI for the "React Sandbox" or "React Fixtures App" is also rendered with whatever version of React the user has selected. This means we dont have to deal with iframes or worry about multiple versions of React potentially interferring. But it also means that all components must be written using createClass to be fully backwards compatable. I tested back to 0.13.1 and it works fine.
2017-01-06 17:10:41 -05:00
Brandon Dail
bf235489bf Display value for controlled select and textarea 2017-01-06 17:10:30 -05:00
Nathan Hunzaker
f37ff31d2e Fix lint issues in react-loader 2017-01-06 17:10:30 -05:00
Nathan Hunzaker
187bcafe65 Update section on number inputs 2017-01-06 17:10:30 -05:00
Nathan Hunzaker
92fe3673ed Add select, textarea, and range input fixtures
Also write up section on number inputs
2017-01-06 17:10:24 -05:00
Nathan Hunzaker
05ace7365a Move new example changes to fixtures folder 2017-01-06 17:09:39 -05:00
Nathan Hunzaker
e86948fc0d Update input example readme 2017-01-06 17:08:23 -05:00
Nathan Hunzaker
65d4795a1a Make toggleable test cases 2017-01-06 17:08:23 -05:00
Nathan Hunzaker
bbb643fd8d Add React options loader. 2017-01-06 17:08:23 -05:00
Nathan Hunzaker
3d06fb742d Properly slice out question mark in query string 2017-01-06 17:08:23 -05:00
Nathan Hunzaker
49f74f1d93 Add basic testing page 2017-01-06 17:08:23 -05:00
Dan Abramov
f589274604 Fix formatting 2017-01-06 20:33:03 +00:00
Dan Abramov
6df0793d51 Add 15.4.2 changelog 2017-01-06 20:18:50 +00:00
Brandon Dail
0b958fae65 Point all Webpack links to 1.x documentation (#8697)
* Point all Webpack links to 1.x documentation

* Add back webpack production guide, add warning
2017-01-06 12:51:26 -06:00
Brian Vaughn
933805b9d1 Merge pull request #8704 from murtazahaveliwala/patch-3
Update rendering-elements.md
2017-01-06 10:17:10 -08:00
Murtaza Haveliwala
97701ad6bf Update rendering-elements.md
Updating text to be in sync with sample html
2017-01-06 23:32:26 +05:30
Murtaza Haveliwala
2cf475de4f Updated hello world explanation message (#8703)
Output text in explanation now in sync with code sample
2017-01-06 11:59:14 -06:00
Dan Abramov
7f0dc413a2 No longer a WIP, eh? 2017-01-06 14:17:13 +00:00
Dan Abramov
bf763fd1a5 Revert "Add es6-promisify"
This reverts commit c8cd133116475677f35cb166b476c4921f59bfbb.

It's not used in the code.
2017-01-06 06:00:09 -08:00
Dan Abramov
f91bff6264 Remove unused import 2017-01-06 06:00:09 -08:00
Ben Alpert
d8f166bd66 Tweaks to npm-publish task 2017-01-06 06:00:09 -08:00
Paul O’Shannessy
441e74fa1f [rrm] Fix stable-prs command so it updates milestone correctly 2017-01-06 06:00:09 -08:00
Paul O’Shannessy
8796a0e70f [rrm] Update version script to account for dep change 2017-01-06 06:00:09 -08:00
Christopher Chedeau
6db38a143c Abort if not on -stable branch 2017-01-06 06:00:09 -08:00
Christopher Chedeau
ad16ab519d Display the help at startup, otherwise it's hard to figure out what to do 2017-01-06 06:00:09 -08:00
Christopher Chedeau
7684c14d0c Create data/ folder instead of crashing 2017-01-06 06:00:09 -08:00
Christopher Chedeau
a0bc99409d Add es6-promisify 2017-01-06 06:00:09 -08:00
Paul O’Shannessy
b763dc8778 [rrm] Rewrite stable-prs command
Now with
- better UX (can skip, handle each failed cherr-pick individually)
- easier to read code
- better error handling / cancellation
2017-01-06 06:00:09 -08:00
Paul O’Shannessy
7b4f3ea2e3 [rrm] Use git helper for all git commands 2017-01-06 06:00:09 -08:00
Paul O’Shannessy
0fbe927486 [rrm] Create start-release command, create git utils
This does the essentials for starting a new release on the stable branch
2017-01-06 06:00:09 -08:00
Paul O’Shannessy
823030d26b [rrm] Update init command to use Promise style 2017-01-06 06:00:09 -08:00
Paul O’Shannessy
14fd16b67b [rrm] Improve init & config loading experience 2017-01-06 06:00:09 -08:00
Paul O’Shannessy
c9165e0dd1 [rrm] Update to account for new react-test-renderer package 2017-01-06 06:00:09 -08:00
Paul O’Shannessy
c46dd23f4a [rrm] Add commands for npm access checking/granting 2017-01-06 06:00:09 -08:00
Paul O’Shannessy
cfd782471b [rrm] Lint 2017-01-06 06:00:09 -08:00
Paul O’Shannessy
e3a41edd83 [rrm] npm-publish command
This will publish all packages in build/packages/*.tgz to the "next" tag. If the current version is "stable" (doesn't trigger semver.prerelease()) then it will also update the "latest" dist-tag to point at that version.
2017-01-06 06:00:09 -08:00
Paul O’Shannessy
0e9aa2e9a9 [rrm] Add logging to execInRepo, dry-run option 2017-01-06 06:00:09 -08:00
Paul O’Shannessy
114ec049d4 [rrm] stable-prs: update milestone on PRs 2017-01-06 06:00:09 -08:00
Paul O’Shannessy
91f957cb1d [rrm] Move version reading up to app level 2017-01-06 06:00:09 -08:00
Paul O’Shannessy
a47041c0f7 Initial import of react-release-manager 2017-01-06 06:00:09 -08:00
Brandon Dail
8095ebaae7 [Fiber] Throw when attempting to unmount at an invalid node (#8688)
* Throw when attempting to unmount at an invalid node

* Remove extra character after invariant
2017-01-05 16:55:17 -08:00
Dan Abramov
ca2c71c0c5 Fix AMD and Brunch issues (#8686)
* Add manual build fixtures

* Inject ReactDOM into ReactWithAddons from ReactWithAddons

We used to read ReactDOM as a global inside ReactAddonsDOMDependenciesUMDShim.
This didn't work in AMD environments such as RequireJS and SystemJS.

Instead, I changed it so that ReactDOM gets injected into ReactWithAddons by ReactDOM itself.
This way we don't have to try to require it (which wouldn't work because AMD doesn't handle circular dependencies well).

This means you have to load ReactDOM first before using ReactDOM-dependent addons, but this was already the case before.

This commit makes all build fixtures pass.

* Memoize ReactDOM to avoid going into require on every access

* Add Brunch fixture

* Inline requires to work around Brunch bug

See #8556 and https://github.com/brunch/brunch/issues/1591#issuecomment-270742503 for context.
This appears to be a Brunch bug but we can keep a temporary fix until the next major.
2017-01-05 13:16:08 -08:00
Piotr Czajkowski
df0d2a5106 "Don't Mutate the Original Component" example and description mismatch (#8695) 2017-01-05 05:12:51 -08:00
Piotr Czajkowski
a52db12abf Higher-Order Components docs withSubscription() example fix (#8694) 2017-01-05 04:56:13 -08:00
Andrew Clark
39278c41e2 Merge pull request #8685 from acdlite/fiberrefeffect
[Fiber] Update refs even if shouldComponentUpdate returns false
2017-01-04 14:28:44 -08:00
Andrew Clark
2517a11875 Update refs even if shouldComponentUpdate returns false
Implemented using a Ref effect type.
2017-01-04 12:05:25 -08:00
Dan Abramov
0e6f784259 Replace Starter Kit with doc link (#8682)
* Replace Starter Kit with doc link

* https in Babel link
2017-01-04 09:39:01 -08:00
Andre Giron
60767630bc Fix typos (#8632)
* Fix typos

* Put back x in Latinx
2017-01-04 09:36:19 -08:00
Joel Sequeira
4fc4bd1214 Fix typo in Proposing a Change section in how-to-contribute.md (#8498)
* Fix typo in Proposing a Change section in how-to-contribute.md

Not sure if it was actually intended or was a typo but changed 'If you intend to change to the public API' --> 'If you intend to make a change to the public API'

* Simplify
2017-01-04 09:30:08 -08:00
Mateusz Burzyński
aa3fef9b67 [Docs] Fixed anchor links in Animations section (#8453) 2017-01-04 09:24:21 -08:00
Van der Auwermeulen Grégoire
8ce2ac0cdc Update state-and-lifecycle.md (#8424)
* Update state-and-lifecycle.md

Isn't  clock state and props the same in this example?

* Clarify
2017-01-04 09:18:52 -08:00
Devinsuit
315f62dc4a Update blog post link (#8421) 2017-01-04 09:15:09 -08:00
Mojtaba Dashtinejad
9b6cecd2cb [docs] Add a note about componentWillReceiveProps (#8234)
* Component Lifecycle In Depth documentation

* first steps to improve react component reference

* improved react component reference

- remove the component-lifecycle-in-depth

* add a note for usage of ReactDOM.findDOMNode

* one note on componentWillReceiveProps

* remove old useless images for lifecycle docs

* Tweak wording
2017-01-04 08:26:33 -08:00
Dan Abramov
8403a3e6a4 Nitpick: use FB style in doc 2017-01-04 15:59:32 +00:00
Karthik Chintapalli
6fa0b0a271 Fixed stray text appearing on top of the navbar at small screen sizes (#8681) 2017-01-04 04:48:53 -08:00
Brian Vaughn
41588058d4 Merge pull request #8679 from bvaughn/fix-react-conf-2017-name
Renamed React.js Conf to React Conf in conferences.md
2017-01-03 15:31:15 -08:00
Brian Vaughn
1ababda476 Renamed React.js Conf to React Conf 2017-01-03 15:27:23 -08:00
Brian Vaughn
b27cb2ca2b Merge pull request #8677 from bvaughn/add-callback-validation-to-dom-render
Add callback validation to fiber-based renderers
2017-01-03 14:57:42 -08:00
Brian Vaughn
8fbcd499bd Add callback validation to fiber-based renderers
Moved ReactFiberClassComponent validateCallback() helper function into a standalone util used by both fiber and stack implementations. Validation now happens in ReactFiberUpdateQueue so that non-DOM renderers will also benefit from it.
2017-01-03 12:10:06 -08:00
Andrew Clark
47f92b940f Merge pull request #8658 from acdlite/nullupdatetest
Should not re-render as the result of a null state update
2017-01-03 10:27:32 -08:00
Andrew Clark
d658ee8c11 Merge pull request #8661 from acdlite/fiberunbatchedupdates
[Fiber] Introduce API to opt-out of batching
2017-01-03 10:24:52 -08:00
Andrew Clark
ad7bcdf999 Use unbatchedUpdates to opt-out of batching
Reverses the effect of batchedUpdates by resetting the current
batching context.

Does not affect nested updates, which are always deferred regardless
of whether they are inside a batch.
2017-01-03 10:24:27 -08:00
Brian Vaughn
0402106058 Merge pull request #8671 from bonham000/update-docs
update to codebase-overview.md
2017-01-03 09:01:53 -08:00
Brian Vaughn
323125b252 Merge pull request #8673 from madeinfree/patch-1
fiber example typo
2017-01-03 08:58:41 -08:00
Brian Vaughn
962974cef0 Merge pull request #8674 from neeldeep/patch-1
Update conferences.md
2017-01-03 08:56:30 -08:00
neeldeep
2825519505 Update conferences.md 2017-01-03 19:23:55 +05:30
Whien
3b005a7e75 fiber example typo 2017-01-03 13:52:48 +08:00
Sean Smith
2447894008 update to codebase-overview.md 2017-01-01 15:27:57 -08:00
Andrew Clark
b79531eefe No nested updates
We may decide to provide this ability as an escape hatch in the future.
2016-12-30 11:30:40 -08:00
Andrew Clark
2af6d7a702 Should not re-render as the result of a null state update (Stack)
Stack now passes test added in previous commit.
2016-12-30 00:19:55 -08:00
Andrew Clark
5c927b902f Should not re-render as the result of a null state update
Fiber already happens to behave this way; this just adds a test.

TODO: Should we add this feature to Stack, too?
2016-12-29 23:31:48 -08:00
Andrew Clark
7dc5f91d88 Merge pull request #8641 from jddxf/remove-superfluous-check
remove superfluous check in while loop
2016-12-29 13:25:22 -08:00
Andrew Clark
9b015184b7 Merge pull request #8634 from acdlite/fibersyncmount
[Fiber] Sync mount and unmount
2016-12-29 13:11:57 -08:00
Andrew Clark
79f01b2425 prepareForCommit returns info object to be passed resetAfterCommit
The DOM renderer assumes that resetAfterCommit is called after
prepareForCommit without any nested commits in between. That may not
be the case now that syncUpdates forces a nested update.

To address, this changes the type of prepareForCommit to return a value
which is later passed to resetAfterCommit.
2016-12-29 10:39:24 -08:00
Andrew Clark
ce8c978d63 Disallow forced sync updates during begin phase
Stack allows this, but in Fiber it may cause an infinite loop. Instead
we'll print a warning and defer the update by giving it Task priority.
2016-12-29 10:39:18 -08:00
Andrew Clark
21f6d4145f syncUpdates prevents Synchronous priority from being downgraded to Task
Typically, a sync update is downgraded to Task priority if it's
scheduled within another batch of work, e.g. within a lifecycle like
componentDidMount. But syncUpdates should force sync updates to not
be downgraded to Task. This will cause performWork to be
called recursively.
2016-12-29 10:23:33 -08:00
Andrew Clark
8090cf59e3 Allow performWork to be called recursively
Currently we assume that performWork is never called recursively.
Ideally that is the case. We shouldn't rely on recursion anywhere
in Fiber.

However, to support the use of syncUpdates as an opt-in to forced-
synchronous updates, we need the ability to call performWork
recursively.

At the beginning of performWork, the state of the scheduler is saved;
before exiting, that state is restored, so that the scheduler can
continue where it left off. I've decided to use local variables to stash
the previous state. We could also store them in a record and push it to
a stack, but this approach has the advantage of being isolated to
performWork.
2016-12-29 10:23:33 -08:00
Andrew Clark
3926a3566f If an error is thrown and there's no nextUnitOfWork, it's fatal error
This can only be caused by a bug in the renderer, but we should handle
it gracefully anyway.

Added a TODO to change capturedErrors and failedBoundaries so that they
are sets of instances (stateNodes) rather than fibers, to avoid having
to check the alternate. (This outside the scope of this PR.)
2016-12-29 10:23:26 -08:00
Andrew Clark
ffbb86b361 Wrap top-level mount and unmount in syncUpdates
For legacy purposes. Only enabled in the DOM renderer. We can remove
this in a future release when we enable incremental-by-default.

This change is unobservable because syncUpdates actually schedules
Task updates when it is called from inside another batch. The correct
behavior is to recursively begin another batch of work. We will fix it
in a subsequent commit.
2016-12-28 20:41:40 -08:00
Brian Vaughn
df6ca0e2c1 Merge pull request #8646 from bvaughn/focus-side-effect
Renderers can queue commit effects for initial mount
2016-12-28 15:16:50 -05:00
Brian Vaughn
a10131304b Renderers can schedule commit-time effects for initial mount
The finalizeInitialChildren HostConfig method now utilizes a boolean return type. Renderers can return true to indicate that custom effects should be processed at commit-time once host components have been mounted. This type of work is marked using the existing Update flag.

A new HostConfig method, commitMount, has been added as well for performing this type of work.

This change set is in support of the autoFocus prop.
2016-12-28 15:03:08 -05:00
gitanupam
9e461c715c Changed webpack's hyperlink (#8650)
..to point to 2.x documentation instead of 1.x (and to be consistent with other links on the page)
2016-12-28 11:34:00 -06:00
gitanupam
86765baaef 'npm init' needed before installing react via npm. (#8649)
* 'npm init' needed before installing react via npm.

I was trying to install react in my django project directory and was getting warnings about package.json not being present. Started this SO post (http://stackoverflow.com/questions/41340909/npm-cant-find-package-json-when-installing-react/41340975#41340975) to figure it out. I think it'll be useful to others too if we add it in the documentation itself.

* Tweak instructions
2016-12-28 04:04:21 -08:00
Dan Abramov
6b73073557 Include owner in invalid element type invariant (#8637) 2016-12-27 08:41:23 -08:00
Dan Abramov
38ed61f4c4 Relax test about rendering top-level null (#8640) 2016-12-27 08:38:24 -08:00
Dan Abramov
119294dcae Validate that update callback is a function (#8639) 2016-12-27 08:38:10 -08:00
jddxf
b359be74a1 remove superfluous check in while loop 2016-12-25 09:41:47 +08:00
Eric Pitcher
3baa47ca7b Update conditional-rendering.md (#8636)
Stating the fact that component lifecycle methods will still fire as normal even though you return null from the render method.
2016-12-24 09:18:30 -08:00
Sebastian Markbåge
5d153c9dbe Don't call sCU with null props (#8633)
I missed this case in 8613 and it broke the triangle demo.
2016-12-22 15:47:10 -08:00
Ben Alpert
6e47f43e89 Fix typo 2016-12-22 12:44:28 -08:00
Ben Alpert
13980e6536 Fiber: Fix reentrant mounting in synchronous mode (#8623) 2016-12-22 11:34:35 -08:00
Dan Abramov
c978f789cc [Fiber] Push class context providers even if they crash (#8627)
* Push class context providers early

Previously we used to push them only after the instance was available. This caused issues in cases an error is thrown during componentWillMount().

In that case we never got to pushing the provider in the begin phase, but in complete phase the provider check returned true since the instance existed by that point. As a result we got mismatching context pops.

We solve the issue by making the context check independent of whether the instance actually exists. Instead we're checking the type itself.

This lets us push class context early. However there's another problem: we might not know the context value. If the instance is not yet created, we can't call getChildContext on it.

To fix this, we are introducing a way to replace current value on the stack, and a way to read the previous value. This also helps remove some branching and split the memoized from invalidated code paths.

* Add a now-passing test from #8604

Also rename another test to have a shorter name.

* Move isContextProvider() checks into push() and pop()

All uses of push() and pop() are guarded by it anyway.

This makes it more similar to how we use host context.

There is only one other place where isContextProvider() is used and that's legacy code needed for renderSubtree().

* Clarify why we read the previous context

* Use invariant instead of throwing an error

* Fix off-by-one in ReactFiberStack

* Manually keep track of the last parent context

The previous algorithm was flawed and worked by accident, as shown by the failing tests after an off-by-one was fixed.

The implementation of getPrevious() was incorrect because the context stack currently has no notion of a previous value per cursor.

Instead, we are caching the previous value directly in the ReactFiberContext in a local variable.

Additionally, we are using push() and pop() instead of adding a new replace() method.
2016-12-22 10:36:42 -08:00
Dan Abramov
c79af45f1e Update to Jest 18 (#8621) 2016-12-21 19:28:27 -08:00
Ben Alpert
efaa26eb50 Upgrade jest APIs to match www (#8536)
D4298654, D4298713
2016-12-21 19:07:40 -08:00
Brian Vaughn
f1e193b32e Merge pull request #8611 from bvaughn/shared-context-stack
Added ReactFiberStack shared by ReactFiberContext and ReactFiberHostContext
2016-12-21 18:50:34 -08:00
Brian Vaughn
d1e604004a Removed redundant calls to ReactFiberStack.reset() 2016-12-21 17:39:39 -08:00
Brian Vaughn
2f2a44007c Improved Flowtypes in response to code review feedback 2016-12-21 17:32:53 -08:00
Brian Vaughn
cb66f5c440 Merge pull request #8622 from bvaughn/preproccessor-jest-cching
Jest preprocessor better aware of error-codes/codes.json WRT caching
2016-12-21 17:12:17 -08:00
Brian Vaughn
b209804cfb Jest preprocessor better aware of error-codes/codes.json WRT caching 2016-12-21 16:58:33 -08:00
Brian Vaughn
ea6530d13a Removed exact object type for StackCursor Flow type
This was causing the 'react:extract-errors' Gulp taks to fail.
2016-12-21 16:48:14 -08:00
Brian Vaughn
e7a591ed57 ReactFiberStack cursor values are no longer corrupted on pop 2016-12-21 15:11:49 -08:00
Brian Vaughn
1148e827b9 Avoid reading the same StackCursor current multiple times 2016-12-21 15:11:49 -08:00
Brian Vaughn
6b51e037ca Avoid popping hosts that do not provide unique contexts 2016-12-21 15:11:49 -08:00
Brian Vaughn
0b7c5ff1a0 Tightened up Fiber | null type in ReactFiberStack to always require Fiber 2016-12-21 15:11:49 -08:00
Brian Vaughn
0c1fdfd41d Combined unwindContext and unwindHostContext into unwindContexts 2016-12-21 15:11:49 -08:00
Brian Vaughn
a0902fc306 Generic type added to StackCursor. Default emptyObject replaced with null. 2016-12-21 15:11:49 -08:00
Brian Vaughn
3d0cf47d26 Added ReactFiberStack shared by ReactFiberContext and ReactFiberHostContext
ReactFiberStack is the new underlying stack used by ReactFiberContext and ReactFiberHostContext. The goal is to simplify the 2 context managers and to add more errors/dev-warnings when we pop unexpected.
This changeset currently causes a lot of tests to fail (as we are currently popping too many times and/or in the wrong order). I'm pushing this branch now to share with Sebastian as he is working on a related cleanup pass at beginWork.
2016-12-21 15:11:49 -08:00
Dan Abramov
a27e4f3361 [Fiber] Make requestIdleCallback() and requestAnimationFrame() shims async (#8591)
* Add a failing test for recursion check

* Make requestIdleCallback() and requestAnimationFrame() shims async

They no longer need to be sync in tests because we already made DOM renderer sync by default.
This fixes a crash when testing incrementalness in DOM renderer itself.

* Style fix

* Fix lint
2016-12-21 14:04:05 -08:00
Ben Alpert
2a5fe4c2b0 Call refs and lifecycles on indeterminate components (#8614)
This was a bug because of the split between ClassComponent and IndeterminateComponent -- we didn't mark effects or push context when we come from an indeterminate component. Now they behave the same way.

The code is even clumsier than before but I'm pretty worried we'll screw these up in the future if we don't unify the paths.

Not many components exercise this path but Relay containers do so it's noticeable.
2016-12-21 13:51:59 -08:00
Sebastian Markbåge
4a05c242e8 Merge pull request #8613 from sebmarkbage/fiberrefactorbailout
[Fiber] Refactor bailoutOnFinishedWork
2016-12-21 13:22:20 -08:00
Ben Alpert
eca5b1d48e Improve error messages for invalid element types (#8612) 2016-12-21 13:17:34 -08:00
Sebastian Markbage
26c82cea72 Move other branches out of the bail out
This is the same thing as the previous commit but with class, root and portal.

I noticed host and portal now already covers this case in their branches
since pushHostContainer is always at the top.
2016-12-21 11:34:18 -08:00
Sebastian Markbage
9a210114e4 Move isHostComponent branches out of bailout
Since we only call bailout from within the host component branch now, we
can just move this to the branch where we already know that this is a
host component.

As part of this I noticed that we don't always push the host context so
I moved that to the beginning of the branch.
2016-12-21 11:34:18 -08:00
Sebastian Markbage
b7548b2030 Delete hasPendingUpdate
This is no longer needed. It is effectively covered by other branches
that tries to being merging the update queue which yields the same state
object as before if there is no work. That in turn bails out.

We can shortcut in the relevant paths if needed.
2016-12-21 11:34:18 -08:00
Sebastian Markbage
21dccad47f Move props equality check into each branch
Now we only bail out once we've entered each branch.

This has some repetition with regard to hasContextChanged but I'm hoping
we can just get rid of all those branches at some point since they're
mostly for backwards compatibility right now.
2016-12-21 11:34:18 -08:00
Sebastian Markbage
0907a49abd Add bailout to HostRoot
This doesn't need to compare props because it doesn't use props,
only state.
2016-12-21 11:34:13 -08:00
Sebastian Markbage
5a32fdb8e5 Compare memoized props in functional component branch
The functional component branch is a bit special since it has sCU in it.

The class component branch actually already covers this in a bit convoluted
way.

I will next replicate this check in each other branch.
2016-12-21 11:33:26 -08:00
Sebastian Markbage
b4b21486aa Move all the begin work stuff into their own helper functions
This just moves things around to continue the pattern that we already
started.
2016-12-21 11:33:26 -08:00
Sebastian Markbage
38a297d500 Always reset context before beginning new work
This consolidates the reset of context to one single place right before
any new work is started.

This place is burried in a bit of an awkward place but findNextUnitOfWork
happens right before any new work starts. That way we're guaranteed to have
an empty stack before we start anything new.

The benefit of this is that we don't have to rely .return being null when
entering beginWork but we also don't have to check it every time in the
hot path.
2016-12-21 11:33:26 -08:00
Andrew Clark
d47a3a36ee Merge pull request #8585 from acdlite/batchstateandcallback
Schedule state and callback at the same time
2016-12-21 13:24:08 -06:00
Andrew Clark
f4c0c99973 Remove enqueueCallback from updater API
This isn't being used anymore.

Also removes addCallback from ReactFiberUpdateQueue.
2016-12-21 13:03:39 -06:00
Andrew Clark
29c1e1deba Schedule state and callback in the same batch
Fixes an issue (in both Stack and Fiber) where enqueueSetState causes
a synchronous update that flushes before enqueueCallback is ever called.
Now enqueueSetState et al accept an optional callback so that both
are scheduled at the same time.
2016-12-21 12:54:19 -06:00
Andrew Clark
afd4a54d2a Merge pull request #8610 from acdlite/fiberfixrooterror
[Fiber] Handle errors thrown when committing root
2016-12-20 18:02:02 -08:00
Andrew Clark
15acbaa8e1 Handle errors thrown when committing root
Previously this caused an infinite loop.
2016-12-20 16:20:57 -08:00
Sebastian Markbåge
b49210f498 Update Flow to 0.37.0 (#8608)
Nothing really changes.
2016-12-20 11:09:03 -08:00
Andrew Clark
090e741c55 Merge pull request #8606 from acdlite/fiberhostrootupdatequeue
[Fiber] Queue top-level updates (take 2)
2016-12-19 21:36:25 -08:00
dfrownfelter
b106ca0c8e Delete fiveArgumentPooler (#8597) 2016-12-19 22:53:04 -06:00
Andrew Clark
470da6ea77 Add test for errors in host config while working on failed root
Test for a bug fixed in the previous commit that was causing an
infinite loop.
2016-12-19 18:46:13 -08:00
Andrew Clark
6c26e98ec2 Handle case where host environment throws when working on failed root
Otherwise you fall into an infinite loop where root fails -> host env
throws -> root fails...

This is a worst-case scenario that should only be possible if there's
a bug in the renderer.
2016-12-19 18:06:56 -08:00
Andrew Clark
da4ace152b Remove unmountContainer
Instead, renderers should pass null to updateContainer.
2016-12-19 16:33:25 -08:00
Andrew Clark
c6ccc19095 Use an UpdateQueue for top-level updates
...rather than mutate the pendingProps directly, which throws away any
previously scheduled work.
2016-12-19 16:33:16 -08:00
Andrew Clark
ab19dd0292 Merge pull request #8605 from facebook/revert-8584-fiberhostrootupdatequeue
Revert "[Fiber] Queue top-level updates"
2016-12-19 15:36:28 -08:00
Andrew Clark
0b37588171 Revert "[Fiber] Queue top-level updates" 2016-12-19 15:32:59 -08:00
Andrew Clark
ddc44b7add Merge pull request #8584 from acdlite/fiberhostrootupdatequeue
[Fiber] Queue top-level updates
2016-12-19 13:56:18 -08:00
Brian Vaughn
3c6d4bacdd Merge pull request #8594 from bvaughn/dont-warn-about-getInitialState-on-class-if-state-set
Don't warn about class components using getInitialState if state is set
2016-12-17 14:28:20 -08:00
Brian Vaughn
1b868cbd71 Don't warn about class component usage of getInitialState if state is also set
We warn about getInitialState() usage in class components because users may have accidentally used it instead of state. If they have also specified state though then we should skip this warning.

Context: https://twitter.com/soprano/status/810003963286163456
2016-12-17 11:16:27 -08:00
Brian Vaughn
a5e728747e Merge pull request #8590 from bvaughn/unexpected-context-pop
`bailoutOnLowPriority` pushes context to mirror complete phase context pop
2016-12-17 07:41:25 -08:00
Dan Abramov
70f704dca6 [Fiber] Nesting validation warnings (#8586)
* (WIP) Nesting warnings

* Remove indirection

* Add a note about namespace

* Fix Flow and make host context required

This makes it easier to avoid accidental nulls.
I also added a test for the production case to avoid regressing because of __DEV__ branches.
2016-12-16 18:57:58 -08:00
Andrew Clark
a9365b97e5 Remove unmountContainer
Instead, renderers should pass null to updateContainer.
2016-12-16 18:31:39 -08:00
Andrew Clark
d8ade83eb2 Use an UpdateQueue for top-level updates
...rather than mutate the pendingProps directly, which throws away any
previously scheduled work.
2016-12-16 16:30:28 -08:00
Andrew Clark
e1eccbfbb0 Merge pull request #8587 from acdlite/fiberupdatequeuefollowup
[Fiber] UpdateQueue follow-up improvements
2016-12-16 16:20:51 -08:00
Andrew Clark
7b6c94c767 Don't drop updates from queue when calling replaceState
We should be able to support passing a function to replaceState, which
receives the accumulation of all the previously applied state updates.
Which means we shouldn't drop those updates from the queue. Technically,
we could drop them only when an object is passed to replaceState, but
that seems like more trouble than it's worth.
2016-12-16 16:20:16 -08:00
Brian Vaughn
441cc5c82b bailoutOnLowPriority correct pushes context for ClassComponents to mirror complete phase context pop 2016-12-16 15:04:06 -08:00
Andrew Clark
f070aaa1b8 Remove confusing for-loop in favor of a helper function
This logic is hopefully easier to follow. Added more inline comments
to explain how the algorithm works.
2016-12-15 18:15:03 -08:00
Andrew Clark
dfe3d089cc Clean up some style nits and other code detritus in the update queue 2016-12-15 18:10:25 -08:00
Andrew Clark
ea622e52c2 Use warning instead of console.error 2016-12-15 17:34:24 -08:00
Andrew Clark
7fca464e7c Merge pull request #8538 from acdlite/fiberupdatequeue
[Fiber] Separate priority for updates
2016-12-15 16:41:53 -08:00
Andrew Clark
b8441ba955 Remove ForceUpdate effect
Go back to using a flag, instead. I removed it before because I thought
we might want to get rid of the top-level UpdateQueue type and put
the fields directly on the fiber, but since we're keeping UpdateQueue
we can put hasForceUpdate on there.
2016-12-15 16:35:54 -08:00
Andrew Clark
3a946fe094 Use 255 instead of infinity
Infinity is a floating point value.
2016-12-15 09:12:13 -08:00
Andrew Clark
496512f8b8 Update tests to not rely on key iteration order 2016-12-15 09:12:13 -08:00
Andrew Clark
e1b733fa83 Move priority context change to findNextUnitOfWork
...rather than changing it on every unit of work.
2016-12-15 09:12:13 -08:00
Andrew Clark
df9603ead8 Simplify test for whether we should flush a pending commit
We can just check if the deadline has expired.
2016-12-15 09:12:13 -08:00
Andrew Clark
eec431297a Priority context during reconciliation
setState inside render/cWRP should have the same priority as whatever
level is currently being reconciled.
2016-12-15 09:12:13 -08:00
Andrew Clark
e0981b8bc5 Handle setState inside an updater function
The update is scheduled as if the current processing update has already
been processed; if it has the same or higher priority, it will be
flushed in the same batch.

We also print a warning.
2016-12-15 09:12:13 -08:00
Andrew Clark
babace0c05 Add fast path for appending updates to the end of the queue
This is the most common case, so we should avoid scanning the entire
list to get to the end.
2016-12-15 09:12:13 -08:00
Andrew Clark
d7f89b8681 Don't rely on commit phase effect to clear updates
Instead clear updates on the work-in-progress during the begin phase.
Aborted updates are recovered by cloning from the current fiber.
2016-12-15 09:12:12 -08:00
Andrew Clark
ead8ab7e2d Add unstable_deferredUpdates
This is needed to get the triangle demo working.
2016-12-15 09:12:12 -08:00
Andrew Clark
20f00045d3 Apply pending updates in order of priority
The queue maintains a pointer to the last progressed update in the list.
Updates that come after that pointer are pending. The pointer is set to
the end of the list during reconciliation.

Pending updates are sorted by priority then insertion. Progressed
updates are sorted by the order in which they were applied during
reconciliation, which may not be by priority: if a component bails out
before the updates are committed, in the next render, the progressed
updates are applied in the same order that they were previously, even if
a higher priority update comes in.

Once a progressed update is flushed/committed, it's removed from
the queue.
2016-12-15 09:12:12 -08:00
Andrew Clark
bb844a03b2 Use lastProgressedUpdate pointer instead of firstPendingUpdate
We need to be able to access both, and since the list uses forward
pointers, it makes more sense to point to the one that comes first.
Otherwise to get the last progressed update you have to start at the
beginning of the list.
2016-12-15 09:12:12 -08:00
Andrew Clark
94011e98a6 Separate priority for updates
When resetting the priority in the complete phase, check the priority of
the update queue so that updates aren't dropped.

Updates inside render, child cWRP, etc are no longer dropped.

The next step is sort the queue by priority and only flush updates that
match the current priority level.
2016-12-15 09:12:12 -08:00
Andrew Clark
cb1ef03df9 Replace .hasForceUpdate with ForceUpdate effect
Removes another field from the update queue
2016-12-15 09:12:12 -08:00
Andrew Clark
6301086c35 Schedule callback effects while merging updates
This allows us to remove the hasCallback flag.
2016-12-15 09:12:12 -08:00
Andrew Clark
cbba5ef9cc Don't drop updates until they are committed
Restructures the update queue to maintain a pointer to the first
pending update, which solves a few problems:

- Updates that occur during the begin phase (e.g. in cWRP of a child)
aren't dropped, like they are currently. This isn't working yet because
the work priority is reset during completion. The following item will
fix it.
- Sets us up to be able to add separate priorities to each update in
the queue. I'll add this in a subsequent commit.
2016-12-15 09:12:12 -08:00
Dan Abramov
e36b38c1ca [Fiber] Fix some of the warnings (#8570)
* Implement component stack for some warnings in Fiber

* Keep Fiber debug source up to date

When an element changes, we should copy the source and owner again.
Otherwise they can get stale since we're not reading them from the element.

* Remove outdated TODOs from tests

* Explicitly specify Fiber types to include in the stack

Fixes an accidental omission when both source and owner are null but displayName exists.

* Fix mised Stack+Fiber test to not expect extra warnings

When we're in Fiber mode we don't actually expect that warning being printed.

* Warn on passing different props to super()

* Implement duplicate key warnings

We keep known keys in a set in development. There is an annoying special case where we know we'll check it again because we break out of the loop early.

One test in the tree hook regresses to the failing state because it checks that the tree hook works without a Set available, but we started using Set in this code. It is not essential and we can clean this up later when we decide how to deal with polyfills.

* Move ReactTypeOfWork to src/shared

It needs to be available both to Fiber and Isomorphic because the tree hook lives in Isomorphic but pretty-prints Fiber stack.

* Add dev-only ReactDebugCurrentFiber for warnings

The goal is to use ReactCurrentOwner less and rely on ReactDebugCurrentFiber for warning owner name and stack.

* Make Stack invariant messages more consistent

Fiber used a helper so two tests had the same phrasing.
Stack also used a helper for most invariants but hardcoded a different phrase in one place.
I changed that invariant message to use a helper which made it consistent with what it prints in Fiber.

* Make CSSPropertyOperations use getCurrentFiberOwnerName()

This gets mount-time CSS warnings to be printed.

However update-time warnings are currently ignored because current fiber is not yet available during the commit phase.

We also regress on HostOperation hook tests but this doesn't matter because it's only used by ReactPerf and it doesn't work with Fiber yet anyway. We'll have to think more about it later.

* Set ReactDebugCurrentFiber during the commit phase

This makes it available during updates, fixing the last failing test in CSSPropertyOperations.

* Add DOM warnings by calling hooks directly

It is not clear if the old hook system is worth it in its generic incarnation. For now I am just hooking it up to the DOMFiber renderer directly.

* Add client-side counterparts for some warning tests

This helps us track which warnings are really failing in Fiber, and which ones depend on SSR.
2016-12-15 08:36:58 -08:00
Brian Vaughn
ab72f626de Merge pull request #8560 from bvaughn/react-native-fiber
ReactNative fiber renderer
2016-12-14 20:05:17 -08:00
Brian Vaughn
5266ca9312 Added new fiber-based renderer for native dubbed ReactNativeFiber 2016-12-14 18:39:22 -08:00
Ben Alpert
ac241972bd mockImpl -> mockImplementation
D4329549
2016-12-14 14:21:51 -08:00
Ben Alpert
ba8f24ba99 Prepare new composite child before removing old (#8572)
This matches what we do in Fiber -- and doing it this way is the only way we can prepare new views in the background before unmounting old ones.

In particular, this breaks this pattern:

```js
class Child1 extends React.Component {
  render() { ... }
  componentWillMount() {
    this.props.registerChild(this);
  }
  componentWillUnmount() {
    this.props.unregisterChild();
  }
}

class Child2 extends React.Component {
  render() { ... }
  componentWillMount() {
    this.props.registerChild(this);
  }
  componentWillUnmount() {
    this.props.unregisterChild();
  }
}

class Parent extends React.Component {
  render() {
    return (
      showChild1 ?
        <Child1
          registerChild={(child) => this.registered = child}
          unregisterChild={() => this.registered = null}
        /> :
        <Child2
          registerChild={(child) => this.registered = child}
          unregisterChild={() => this.registered = null}
        />
    );
  }
}
```

Previously, `this.registered` would always be set -- now, after a rerender, `this.registered` gets stuck at null because the old child's componentWillUnmount runs *after* the new child's componentWillMount.

A correct fix here is to use componentDidMount rather than componentWillMount. (In general, componentWillMount should not have side effects.) If Parent stored a list or set of registered children instead, there would also be no issue.
2016-12-14 11:14:50 -08:00
Gaëtan Renaudeau
931cad5aae Fix test renderer unmount (#8512)
* [react-test-renderer] unmount the inner instances

Fixes https://github.com/facebook/react/issues/8459

* add a test for https://github.com/facebook/react/issues/8459

* add new test in tests-passing.txt
2016-12-14 10:57:21 -05:00
Brian Vaughn
3def431543 Merge pull request #8568 from bvaughn/top-level-context-push-pop
HostRoot no longer pops context provider during complete phase
2016-12-13 17:27:47 -08:00
Brian Vaughn
b4745ca72b HostRoot no longer pops context provider in complete phase
Also added an invariant warning to guard against context being popped too many times.
2016-12-13 17:26:19 -08:00
Andrew Clark
480e404fc8 Merge pull request #8528 from acdlite/callbacksemantics
Give setState callbacks componentWillUpdate semantics
2016-12-13 17:22:41 -08:00
Andrew Clark
97b7d0eff5 Test top-level callback when re-rendering with same element 2016-12-13 16:28:06 -08:00
Andrew Clark
a930f09dfe Give setState callbacks componentWillUpdate semantics
This matches the behavior in Fiber. Normally we would change Fiber
to match Stack to minimize breaking changes for the initial release.
However, in this case it would require too large a compromise to change
Fiber to act like Stack.
2016-12-13 15:50:33 -08:00
Sebastian Markbåge
bd425837a4 Merge pull request #8563 from sebmarkbage/enforcelowercasetags
Drop runtime validation and lower case coercion of tag names
2016-12-13 14:54:21 -08:00
Sebastian Markbage
6c1592f384 Pass type to the relevant host config methods
Instead of reading it from the DOM node.
2016-12-13 14:53:36 -08:00
Sebastian Markbage
db489a4ade Only do runtime validation of tag names when createElement is not used
We introduced runtime validation of tag names because we used to generate
HTML that was supposed to be inserted into a HTML string which could've
been an XSS attack.

However, these days we use document.createElement in most cases. That
already does its internal validation in the browser which throws. We're now
double validating it. Stack still has a path where innerHTML is used and
we still need it there. However in Fiber we can remove it completely.
2016-12-13 14:53:36 -08:00
Sebastian Markbage
3092f63c6b Warn if upper-case tags are used
In #2756 we ended up using toLowerCase to allow case insensitive HTML tags.
However, this requires extra processing every time we access the tag or
at least we need to process it for mount and store it in an extra field
which wastes memory.

So instead, we can just enforce case sensitivity for HTML since this might
matter for the XML namespaces like SVG anyway.
2016-12-13 14:53:29 -08:00
Ben Alpert
ec8b94e847 Disable coverage on PRs on Circle (#8569) 2016-12-13 14:27:25 -08:00
Brian Vaughn
369769aed4 Merge pull request #8558 from bvaughn/rename-initialize-core
Renamed InitializeJavaScriptAppEngine to InitializeCore
2016-12-12 21:32:53 -08:00
Dan Abramov
0f34bdc622 [Fiber] Remove array indirection in host context (#8544)
* Remove array indirection in host context

* Keep a single context stack with a null sentinel

This lets us keep subtrees separated without maintaining independent context arrays for subtrees.

* There is always exactly one null by the time we pop a portal

I was trying to be smart but didn't need to.

* Cache current context
2016-12-12 15:20:40 -08:00
Dan Abramov
ef532fd4a4 [Fiber] Fix portal bugs (#8532)
* Enable additional (failing) portal tests

* Fix portal unmounting

When unmount a portal, we need to unmount *its* children from itself.
This is similar to what we would do for a root if we allowed deleting roots.

* Skip portals when looking for host siblings

A portal is not part of that host tree despite being a child.

* Fix comment typo

* Add a failing test for portal child reconciliation

It is failing because portal bails out of update, seeing null in pendingProps.
It is null because we set pendingProps to nextPortal.children, which is null in this test.

* Fix the bug when switching to a null portal child

If pendingProps is null, we do a bailout in beginWork.
This prevents unmounting of the existing child when the new child is null.

We fix this by changing portal fiber's pendingProps to be the portal object itself instead of its children.
This way, it is never null, and thus doesn't cause a false positive in the bailout condition.

* Add a comment about HostPortal in getHostSibling

* Revert the fix because I don't know why it worked

unmountHostComponents() should have worked despite finding the wrong parent because it should have changed the parent when pushing and popping the portals.

* Don't call commitDeletion recursively

This leads to a "Cannot find host parent" bug because commitDeletion() clears the return field.
When we're inside the loop, we assign node.sibling.return to node.return but by this moment node.return has already been nulled.
As a solution we inline code from commitDeletion() without the nulling.

It still fails tests but for a different reason (unrelated bug).

* Skip portal children in commitNestedUnmounts()

We are currently already visiting them in commitUnmount() portal case since it's recursive.
This condition avoids visting them twice.

* Set node.child.return before going deeper

It doesn't seem to influence existing tests but we have this protection in all other similar places.
It protects against infinite loops.

* Revert "Fix the bug when switching to a null portal child"

This reverts commit ed9747deedf11455ba3eb65648007ab99c26ea58.

I'll solve this by using an array in place of null instead.

* Use [] for empty Portal pendingProps

This avoids a false positive bailout with pendingProps == null when portal is empty.
2016-12-12 14:18:55 -08:00
Brian Vaughn
cdb38c1478 Renamed InitializeJavaScriptAppEngine mock to InitializeCore. 2016-12-12 13:55:58 -08:00
Brian Vaughn
7b7c0e4af5 Renamed InitializeJavaScriptAppEngine to InitializeCore 2016-12-12 11:23:25 -08:00
Brian Vaughn
0a3256ac15 Merge pull request #8557 from bvaughn/add-create-text-instance-param
Add rootContainerInstance param to createTextInstance
2016-12-12 11:20:46 -08:00
Brian Vaughn
f8cb22ad83 Add rootContainerInstance param to createTextInstance.
This mirrors a recent change in params passed to  and cleans up a HACK currently required for the native fiber renderer to create text views.
2016-12-12 10:12:43 -08:00
comerc
92665e2cb1 Fix casing typo in jsx-in-depth.md (#8542) 2016-12-11 07:43:40 -06:00
Chris
39695dcd36 update example to use this.state (#8425)
- In the previous example, the code works even without using bind(this) in the constructor.
- the reason being handleClick doesn't even use `this` and its just calling the global function alert.
- this change make use of this via access this.state.
2016-12-11 07:41:48 -06:00
Sebastian Markbåge
14f05bfa89 ReactDOMFiber-test Rename portal -> usePortal (#8535)
Fixes lint since I used portal as a variable name.
We typically use a verb for functions.
2016-12-08 14:22:53 -08:00
Sebastian Markbåge
6c785ed524 Add unit tests for event bubbling in portals (#8509)
These bubble through the portal and up to the parent that rendered
the portal.
2016-12-08 13:51:21 -08:00
Sebastian Markbåge
3937bca8a2 Merge pull request #8491 from sebmarkbage/fibercurrenteventhandlers
[Fiber] Read Event Handlers from the "Current" Fiber
2016-12-08 13:49:51 -08:00
Dan Abramov
c87ffc0beb [Fiber] Support SVG (#8490)
* Test that SVG elements get created with the right namespace

* Pass root to the renderer methods

* Keep track of host instances and containers

* Keep instances instead of fibers on the stack

* Create text instances in begin phase

* Create instance before bailing on offscreen children

Otherwise, the parent gets skipped next time.
We could probably create it later but this seems simpler.

* Tweak magic numbers in incremental tests

I don't understand why they changed but probably related to us moving some work into begin phase?

* Only push newly created nodes on the parent stack

Previously I was pushing nodes on the parent stack regardless of whether they were already in current or not.
As a result, insertions during updates were duplicated, and nodes were added to existing parents before commit phase.
Luckily we have a test that caught that.

* Fix lint

* Fix Flow

I had to wrap HostContext API into a closure so that it's parameterizeable with I and C.

* Use the same destructuring style in scheduler as everywhere else

* Remove branches that don't seem to run anymore

I'm not 100% sure this is right but I can't get tests to fail.

* Be explicit about the difference between type and tag

I was confused by th HACK comment so I learned how DOM and SVG work with casing and tried to write a more descriptive comment.
It also seems like passing fiber.type into finalizeInitialChildren() is a potential problem because DOM code assumes tag is lowercase.
So I added a similar "hack" to finalizeInitialChildren() that is identical to the one we have prepareUpdate() so if we fix them later, we fix both.

* Save and restore host context when pushing and popping portals

* Revert parent context and adding children in the begin phase

We can address this later separately as it is a more hot path.
This doesn't affect correctness of SVG container behavior.

* Add a test for SVG updates

This tests the "jump" reuse code path in particular.

* Record tests

* Read ownerDocument from the root container instance

This way createInstance() depends on the innermost container only for reading the namespace.

* Track namespaces instead of creating instances early

While we might want to create instance in the begin phase, we shouldn't let DOM guide reconciler design.
Instead, we are adding a new concept of "host context". In case of ReactDOMFiber, it's just the current namespace.
We are keeping a stack of host context values, ignoring those that are referentially equal.
The renderer receives the parent context and type, and can return a new context.

* Pop child context before reading own context and clarify API

It wasn't quite clear from the API which context was being returned by the renderer. Changed the API to specifically ask for child context, and thus to pop it before getting the current context.

This fixes the case with <foreignObject> to which I intended to give SVG namespace.

* Give SVG namespace to <svg> itself

* Don't allocate unnecessarily when reconciling portals

We create stacks lazily so that if portal doesn't contain <svg>s, we don't need to allocate.
We also reuse the same object for portal host context state instead of creating a new one every time.

* Add more tests for edge cases

* Fix up math namespace

* Maintain a separate container stack

* Fix rebase mistakes

* Unwind context on errors

* Reset the container state when reusing the object

* Add getChildHostContext() to ReactART

* Record tests
2016-12-08 13:10:47 -08:00
Charlie Garcia
d77c42a26d Update CHANGELOG.md (#8518)
* Update CHANGELOG.md

* Update CHANGELOG.md
2016-12-08 12:07:53 -06:00
Ben Alpert
2161a6c92f Fix indentation for lint 2016-12-07 23:16:47 -08:00
Andrew Clark
f56eb89389 Add additional scheduling tests
Tests whether certain types of work can be performed after the deadline
has expired.
2016-12-07 23:09:08 -08:00
Andrew Clark
3a7844cabb Consolidate workLoop and deferredWork loop
Solves a few things:

- Moves code out of performWork into workLoop so that it can
be optimized.
- errorLoop (now clearErrors) is no longer called recursively.
- Removes a while (true) loop inside performWork (not that it really
matters for optimization, since performWork contains a try block and
will be deopted, anyway).
2016-12-07 23:09:08 -08:00
Andrew Clark
24a83a5eeb Extract commit phase passes into separate functions
By splitting these out, we ensure that they can be optimized by the
JS engine.
2016-12-07 23:09:08 -08:00
Andrew Clark
dcc17a966e Don't check for a pendingCommit on every iteration
Only check if we're in a deferred work batch and performUnitOfWork
returns null.
2016-12-07 23:09:08 -08:00
Andrew Clark
2508888a2b Errors thrown when detaching a ref should not interrupt unmount
If a ref throws while detaching, it should not prevent
componentWillUnmount from being called.

Additionally, errors thrown by removeChild should not be ignored, even
as the result of unmounting a failed subtree.
2016-12-07 23:09:08 -08:00
Andrew Clark
7e82214717 Error boundaries can only capture errors once per batch
Subsequent failures should propagate the error to the next boundary.
The conceptual model for this is

try {
  render();
} catch (error) {
  setStateToRecover();
  render();
}

Closes #8485
2016-12-07 23:09:08 -08:00
Andrew Clark
701d128fd1 Error recovery should have task priority
This uncovered a separate issue where some errors were being unscheduled
and rescheduled multiple times before flushing. Turns out we need to
check both a fiber and its alternate when determining if it represents a
failed unit of work. I didn't notice this before because we were
scheduling a new update on *every* boundary at the end of the commit
phase, not just the ones that captured an error during that commit. I
updated the unit tests to catch this in the future.
2016-12-07 23:09:08 -08:00
Andrew Clark
d4dd3408bd Remove tryComponentDidMount/Update in favor of commit phase try block
We still need tryComponentWillUnmount because deletion should be non-
interruptible.

Refactoring the commit phase to better handle errors also allows us
to switch between fast and slow versions of the work loop. The slower
version runs whenever there are captured errors; it must check each
unit of work to see if it has failed. The faster version runs in the
normal case where there are no errors. Whenever an error is thrown, we
switch from the fast work loop to the slow work loop.
2016-12-07 23:09:08 -08:00
Andrew Clark
db8539a47d Consolidate work loops
This makes it easier to track when we enter and exit a batch of work.

Further steps needed in this refactor:
- Get rid of tryComponentDidMount, tryComponentDidUpdate, etc. in
favor of the try-catch blocks that wrap each pass of the commit phase.
- Need to be able to switch between performing work that is possibly
failed (slower because it requires an extra check on each iteration) and
work that we know for sure has no errors.
2016-12-07 23:09:08 -08:00
Andrew Clark
5fcdebf712 Move commit phase outside of performUnitOfWork
This gives us the ability to complete a tree without having to commit it
within the same frame.
2016-12-07 23:09:08 -08:00
Brian Vaughn
9510ecfc5e Merge pull request #8521 from bvaughn/react-art-fiber
New fiber-based ReactART renderer
2016-12-07 18:35:48 -08:00
Ben Alpert
fccebad780 Don't set innerHTML if content is empty (#8526)
From D4296244:

> Each [...] had a component with innerHTML = '', causing us to go into HTML parsing code in the browser. Doing this takes 0.03ms per parse call which was 10x slower than skipping it.
2016-12-07 17:20:57 -08:00
Ben Alpert
4d71a9c580 Probably fix facts tracker 2016-12-07 16:04:47 -08:00
Brian Vaughn
81cb216288 Imported new ReactART fiber renderer
Split ReactART into stack and fiber targets. Added new ReactART test case for recently-fixed bug.
2016-12-07 15:35:53 -08:00
Brian Vaughn
9a3139121c Merge pull request #8520 from bvaughn/do-not-reset-inner-html-for-null-children
Do not reset inner html for null children
2016-12-07 15:35:13 -08:00
Brian Vaughn
bbdfc28002 Updated tests-passing 2016-12-07 15:34:32 -08:00
Sebastian Markbåge
343fb958f1 Add test for componentDidUpdate with a bailout in the middle (#8525)
This is one of the cases where Fiber diverges.
2016-12-07 15:14:32 -08:00
Liz
17f8e947fb 👏 designers are friends, not fodder for jokes (#8523) 2016-12-07 15:09:37 -08:00
Ben Alpert
29a1707911 Support parallelism on Circle (#8511) 2016-12-07 14:55:34 -08:00
Brian Vaughn
ae752dd550 Added additional test case for ReactFiberBeginWork reset-text 2016-12-07 13:54:39 -08:00
Ben Alpert
d8b591d584 Fix pull request detection on Circle 2016-12-07 13:45:06 -08:00
Brian Vaughn
f90e208849 Fixed linting error 2016-12-07 13:13:04 -08:00
Brian Vaughn
2533fa8d35 Do not reset innerHTML for elements with null children
This is required to support certain third party scripts as well as other fiber renderers (eg the new ReactART renderer)
2016-12-07 12:06:06 -08:00
Ben Alpert
6ca66f70ca Update facts-tracker for Circle (#8510) 2016-12-06 22:24:19 -08:00
Sebastian Markbåge
facce3d736 Use Portals to test batching across roots (#8508)
This doesn't work by default in Fiber, you have to opt-in with a Portal to
get the explicit ordering guarantees.
2016-12-06 13:46:36 -08:00
Sebastian Markbåge
48c7bbd980 [Fiber] Nits (#8507)
Some best practices.
2016-12-06 11:15:46 -08:00
Tom Occhino
2be0d93c77 Tweak Yarn installation to not run if it's already installed (#8496)
https://circleci.com/docs/install-and-use-yarn/
2016-12-04 11:00:30 -08:00
Sebastian Markbage
ee4984980e Get the "current" Fiber from each node along the path
This fixes the issue where using the .return pointer isn't guaranteed to
return the current Fiber so we might read the wrong props when we try
to get the current event.
2016-12-02 20:03:09 -08:00
Sebastian Markbage
2336b8183d Remove forwarding from tree traversal in EventPluginUtils
This is unnecessary forwarding since this is no longer injectable.
However, I'd like to use the injectable getInstanceFromNode from
TreeTraversal so this avoids a cyclic dependency.
2016-12-02 19:52:56 -08:00
Sebastian Markbage
910044a41d Add failing event handler test
When we perform an update to the event handler we properly update the
immediate Fiber pointer of a child to be the current. However, when we
bubble events we use the return pointer which is not guaranteed to point
to the current Fiber even if we start from the current.

This manifests itself when we bailout in a parent. So I made the tests
use a PureComponent to illustrate this scenario. There is already a failing
case but I'm adding another one too.
2016-12-02 19:33:24 -08:00
Tom Occhino
e44b526999 Add CircleCI badge to the Readme 2016-12-02 17:43:16 -08:00
Sebastian Markbåge
7169c515aa Fix lint (#8489) 2016-12-02 16:53:42 -08:00
Sebastian Markbåge
0723007e1e Merge pull request #8450 from sebmarkbage/fiberfinddomnode
[Fiber] Fix findDOMNode and findAllInRenderedTree
2016-12-02 16:34:46 -08:00
Ben Alpert
a104525e7f Only upload build if server exists (#8488) 2016-12-02 14:31:17 -08:00
Tom Occhino
153fe38403 Add circle.yml / CircleCI support (#8486) 2016-12-02 14:18:12 -08:00
Brandon Dail
33198b78c5 Merge pull request #8476 from AlanBreck/patch-1
Update reference-react.md
2016-12-02 09:16:39 -06:00
Brandon Dail
1cabbc2fd7 Merge pull request #8478 from lucas-aragno/add-return-to-render
Add return to render
2016-12-02 09:11:37 -06:00
Sebastian Markbage
a434f9e7af Fix findDOMNode and findAllInRenderedFiberTreeInternal
This strategy finds the current fiber. It traverses back up to the root if
the two trees are completely separate and determines which one is current.
If the two trees converge anywhere along the way, we assume that is the
current tree. We find the current child by searching the converged child
set.

This could fail if there's any way for both return pointers to point
backwards to the work in progress. I don't think there is but I could be
wrong.

This may also fail on coroutines where we have reparenting situations.
2016-12-01 21:21:05 -08:00
Sebastian Markbage
4fd1802ddf Additional findDOMNode tests
This is failing in Fiber without the fix. Because we have no deletions to rely
on in this case and the placement effects have already happened.
2016-12-01 21:03:24 -08:00
lucas
01eb94f04b Add return to render 2016-12-01 19:21:40 -03:00
Ben Alpert
361ce5c00b Add test for unmount/remount in a single batch (#8470)
Fails in Fiber.
2016-12-01 14:19:00 -08:00
Jacob Lamont
469d3c6461 Update reference-react.md 2016-12-01 14:35:48 -05:00
Dan Abramov
df9dc89333 Rename HostContainer => HostRoot, Portal => HostPortal (#8474) 2016-12-01 18:36:28 +00:00
Kurt Weiberth
7cd26024ce add dependencies to react-test-renderer and react-addons (#8467)
**What** and **Why**:

* When using npm version 2, `object-assign` and `fbjs` were not getting properly installed
* This PR adds `object-assign` and `fbjs` as explicit dependencies to both `react-test-renderer` and `react-addons`
2016-12-01 16:37:14 +00:00
Ben Alpert
981f461b70 Merge pull request #8463 from spicyj/travis
Update Travis config for new token
2016-11-30 21:03:01 -08:00
Ben Alpert
cb2927665c Fix insecure shell escaping in facts tracker 2016-11-30 21:02:44 -08:00
Andrew Clark
aa6279c41a Clear existing text content before inserting children (#8331)
Fixes a bug when updating from a single text child (or
dangerouslySetInnerHTML) to regular children, where the previous
text content never gets deleted.
2016-11-30 18:08:41 -08:00
Ben Alpert
06e8cedc0d Update Travis config for new token 2016-11-30 17:17:04 -08:00
Andrew Clark
e7eed5874f [Fiber] New error boundary semantics (#8304)
* Exit early in scheduleUpdate if a node's priority matches

This is a performance optimization and is unobservable. However, it
helps protect against regressions on the following invariants on which
it relies:

- The priority of a fiber is greater than or equal to the priority of
all its descendent fibers.
- If a tree has pending work priority, its root is scheduled.

* New error boundary semantics

- Recovering from an error boundary no longer uses Task priority by
default. The work is scheduled using whatever priority created the
error.
- Error handling is now a side-effect that happens during the
commit phase.
- The default behavior of an error boundary is to render null. Errors
do not propagate except when an boundary fails. Conceptually, this would
be like throwing an error from a catch block.
- A host container is treated like a no-op error boundary. The first
error captured by a host container is thrown at the end of the batch.
Like with normal error boundaries, the entire tree is unmounted.

* Fix broken setState callback test

* Add test for "unwinding" context when an error interrupts rendering

* Switch over primary effect types only

This avoids the need to create an export for every combination of bits.

* Only continue the work loop if the error was successfully captured

* Add more tests for incremental error handling

These tests are currently failing:

  ✕ catches render error in a boundary during partial deferred mounting
  ✕ catches render error in a boundary during animation mounting
  ✕ propagates an error from a noop error boundary during full deferred mounting
  ✕ propagates an error from a noop error boundary during partial deferred mounting
  ✕ propagates an error from a noop error boundary during animation mounting

The observed behavior is that unstable_handleError() unexpected gets called twice:

      "ErrorBoundary render success",
      "BrokenRender",
      "ErrorBoundary unstable_handleError",
  +   "ErrorBoundary render success",
  +   "BrokenRender",
  +   "ErrorBoundary unstable_handleError",
      "ErrorBoundary render error"

* Verify batched updates get scheduled despite errors

* Add try/catch/finally blocks around commit phase passes

We'll consolidate all these blocks in a future PR that refactors the
commit phase to be separate from the perform work loop.

* NoopBoundary -> RethrowBoundary

* Only throw uncaught error once there is no more work to perform

* Remove outdated comment

It was fixed in #8451.

* Record tests

* Always reset nextUnitOfWork on error

This is important so that the test at the end of performAndHandleErrors() knows it's safe to rethrow.

* Add a passing test for unmounting behavior on crashed tree

* Top-level errors

An error thrown from a host container should be "captured" by the host
container itself

* Remove outdated comment

* Separate Rethrow and Noop scenarios in boundary tests

* Move try block outside the commit loops
2016-11-30 16:54:20 -08:00
Ben Alpert
705c9bcfd2 Refs between fiber and stack (#8458)
I feel gross. Better ideas welcome.
2016-11-30 12:17:03 -08:00
Ben Alpert
545a193ef9 Fix isFiberMounted exports (#8465)
This got messed up in a merge conflict. It's only used for one invariant in renderSubtreeIntoContainer.
2016-11-30 12:04:00 -08:00
Dan Abramov
b1c988d0de Add tests for recovery from errors thrown in the reconciler (#8462)
Test that errors in the reconciler can be caught by error boundaries, and that we can still schedule updates if they are uncaught.
2016-11-30 17:00:14 +00:00
Dan Abramov
623f608aab [Fiber] Make bad element type message same as in Stack (#8460)
* Make bad element type message same as in Stack

This makes Fiber emit the same message as Stack (aside from the missing owner information).

* Add a separate test verifying error includes owner name

Fiber currently doesn't pass it. This is just to keep track of it as a todo.
2016-11-30 16:29:42 +00:00
Ben Alpert
6110c58584 Fix reordering of bailed out children (#8457) 2016-11-29 14:57:04 -08:00
cloudy1
150e4e8be6 Update tutorial.md (#8328)
* Update tutorial.md

fix "unknown: Unexpected token" in "codepen.io".

* tweaks per suggestion
2016-11-29 13:00:33 -08:00
Andrew Clark
ce3b7ca475 Add a document on higher-order components (#7869) 2016-11-29 10:47:54 -08:00
Ben Alpert
16bf429029 Fix fiber feature flag for ReactDOMProduction-test (#8451) 2016-11-28 23:36:05 -08:00
Ben Alpert
cbe59521af Add test for updating parent state in cWRP (#8448)
Fails in Fiber.
2016-11-28 19:05:24 -08:00
Ben Alpert
492057c76f Fix context getting (#8407) 2016-11-28 18:33:46 -08:00
Ben Alpert
a98e8227b8 Update release checklist (#8389) 2016-11-28 17:57:37 -08:00
Sebastian Markbåge
f634b813e1 Handle Bailed Out HostText update and MultiChildText test (#8371)
This handles the case where a host text bails out. In that case we need to
reuse its previous memoizedProps. We should also only schedule an actual
update if it did actually change its text content.

I updated the unit test to ignore comment nodes if we're using Fiber.
2016-11-28 17:26:49 -08:00
Dan Abramov
c74034589e [Fiber] Support iterables (#8446)
* Add iterable cases to MultiChildReconcile test

Stack currently supports rendering iterables, but Fiber does not.

Previously we didn't have any public API tests for iterables. We have tests for traverseAllChildren() which is shared between React.Children and Stack. However Fiber doesn't currently use it, and likely won't. So this commit is a first step towards actually testing iterable support via public API. The next step will be to port traverseAllChildren() tests to test React.Children API instead.

* Implement iterable reconciliation in Fiber

This uses the same exact algorithm as array reconciliation but uses iterator to step through.

This gets reconcile tests to pass again but introduces a regression in ReactMultiChildText case which uses Maps as children. It passed before because Maps were ignored, but now it's failing because this actually runs the Map code path in Fiber. We can throw early in this case when we want to follow up on this.

* Rewrite traverseAllChildren() tests against React.Children API

This function was used in React.Children and Stack.

The corresponding reconciliation functionality is being tested by ReactMultiChild tests.

So we can move these tests to ReactChildren and test its public API.
2016-11-28 23:44:56 +00:00
Ben Alpert
f1f07c4a23 Use latest instance when restoring controlled state (#8443) 2016-11-28 14:00:50 -08:00
Ben Alpert
a1feccd9e8 Record tests (#8444) 2016-11-28 11:37:21 -08:00
Sebastian Markbåge
a63cee8e24 Merge pull request #8441 from sebmarkbage/movefromstack
Move shared files out of stack folder
2016-11-28 10:59:11 -08:00
Sebastian Markbage
2faca7c13e Use public API in React Mount 2016-11-28 10:55:36 -08:00
Sebastian Markbage
af618cb84c Move setInnerHTML/setTextContent to shared 2016-11-28 10:55:36 -08:00
Sebastian Markbage
e2b9882a79 Move tests out of the Stack folder
So that we can share them with Fiber.

Also Server Rendering tests.
2016-11-28 10:55:28 -08:00
Daniela Borges
5545d43bc4 remove output field from debugger (#8440) 2016-11-28 18:19:49 +00:00
Brandon Dail
6947db1529 Use a closure to bind argument to callback in ReactErrorUtils (#8363)
* Use a closure to bind gaurded callback

This way the fake event isn't being implicitly passed into the event handler

* Add tests for ReactErrorUtils

Add fiber test report

Linting fixes
2016-11-28 16:54:57 +00:00
Christopher Chedeau
e24ec4a1b4 test 2016-11-26 17:08:10 -08:00
Christopher Chedeau
00c3ee40c2 Do not forward stderr 2016-11-26 16:53:05 -08:00
Dan Abramov
e34b995f84 Fix portal unmounting (#8422)
We used to terminate the search on host nodes, and then use the nested unmount algorithm.
However this means we didn't unmount portals inside the host nodes.

We will probably need to restructure this somehow but for now I just added a recursive call to unblock myself.
2016-11-25 21:43:56 +00:00
Dan Abramov
9c87506ad9 Update Flow to 0.36 (#8420) 2016-11-25 16:25:09 +00:00
Dan Abramov
a4dd68fb3d Add a test for nested portals (#8416) 2016-11-24 18:43:45 +00:00
Sebastian Markbåge
0ba8434a33 [Fiber] Remove output field (#8406)
* Remove output field

The idea was originally that each fiber has a return value. In practice
most of what we're modelling here are void functions and we track side
effects instead of return values.

We do use this for coroutines to short cut access to terminal yields.
However, since this can be nested fragments we end up searching the tree
anyway. We also have to manage this in transferOutput so it ends up being
as expensive. Maybe we can save some traversal for updates when coroutine
branches bail out but meh.

* Unmount child from the first phase of a coroutine
2016-11-24 10:03:14 -08:00
Fatih
2c17f47ac2 fix typo 'miss-configured' to 'misconfigured' (#8412) 2016-11-24 14:52:53 +00:00
brillout
8d291e91e6 remove dead link (#8411) 2016-11-24 14:35:48 +00:00
Sebastian Markbåge
7d2be2c9a7 Merge pull request #8400 from sebmarkbage/fibercontainerchildren
[Fiber] Update root children using appendChild/insertBefore/removeChild
2016-11-23 18:09:50 -08:00
Ben Alpert
8791325db0 Finish ReactGenericBatching (#8405) 2016-11-23 17:40:20 -08:00
Sebastian Markbage
ea3420471f Split initial children out of createInstance
The goal of this is to avoid passing an opaque data structure that needs
to be recursively searched by the host.

I considered having some helper for doing the recursion but I figured it
might be helpful to let the reconciler move this around. For example we
might want to create an instance in beginWork and add to it as we go.
This would let us avoid traversing the tree twice and would solve the IE11
perf issue.

So instead, we create the instance first then call appendChild. I could
just call the normal one but I figured that I would make a special one
just in case. For example if you wanted to perform commits on a separate
thread from creation. This turned out to be useful in ReactNoop where I
can avoid searching the array for an existing one since I know the child
isn't there already. (Although splitting placement into insertion/move
might be better.)

Finally, we need the ability to update an instance after all the children
have been insertion. Such as `<select value={...} />`. I called this
finalizeInitialChildren.
2016-11-23 17:38:35 -08:00
Dan Abramov
024e2a0259 Remove recursion from unmounting portals (#1) 2016-11-23 17:38:35 -08:00
Sebastian Markbage
fde18a4562 Assert that we always find a parent for DOM mutations 2016-11-23 17:38:35 -08:00
Sebastian Markbage
78add2dc63 Update root children using the appendChild/insertBefore/removeChild methods
This removes updateContainer and instead uses the regular child mutation
methods to insert into the root container and portals.

Since we're no longer clearing out the container DOM in updateContainer
we have to do that manually during initial mount. This now works on a
document and one of the tests end up unmounting the body when you render
into the document so I had to work around that bit since we don't yet
properly support rendering into the document root.
2016-11-23 17:38:35 -08:00
Ben Alpert
13cb540bda Lint 2016-11-23 17:31:41 -08:00
Ben Alpert
c5b6601536 Fix traversal up when unmounting (#8404)
Previously you could get an alternate when following .return in unmountHostComponents and this could revisit a node twice.
2016-11-23 16:07:25 -08:00
Ben Alpert
af659a2544 Re-record 2016-11-23 15:22:35 -08:00
Ben Alpert
1095d3f965 Preserve scroll position when restoring focus (#8401)
This misbehavior is particularly egregious because of our current strategy for updating a container in Fiber, but regardless -- if we restore focus to an offscreen node (ex: because it was reordered among its siblings) then we should not scroll the page to reveal it.

We could check the `overflow` computed style values before saving the scroll positions but that's unlikely to be any faster.
2016-11-23 14:55:17 -08:00
Sebastian Markbåge
224bdd8883 Remove config.beginUpdate (#8402)
I only used this to visualize changes when there were bugs in the
incremental reconciliation. We don't need it anymore.
2016-11-23 14:44:17 -08:00
Ben Alpert
53cdc4b288 Cleanup after #8353 (#8403) 2016-11-23 14:43:52 -08:00
Ben Alpert
caa01d498d Fix renderSubtreeIntoContainer with non-context-provider parent (#8399) 2016-11-23 14:23:45 -08:00
Ben Alpert
0c885af183 Restore DOM selection and suppress events (#8353)
This makes Draft mostly work.
2016-11-23 13:43:00 -08:00
Ben Alpert
7ac2044bce Fix queueing updates in cWM/cWRP when batching (#8398)
I tried to add a temporary check for the correct state in https://gist.github.com/spicyj/338147e989215b6eeaf48a6ce2d68d93 and run our test suites over it, but none of our existing test cases would have triggered that invariant. The new one I added does.
2016-11-23 13:00:49 -08:00
Sebastian Markbåge
7ef856aa36 Change the behavior to always fail childContextTypes if there is a method (#8391)
Even if that method returns falsy values.
2016-11-23 10:59:49 -08:00
Paul O’Shannessy
a3ba48bf72 Fix browser bundle for AMD (#8374)
* Fix browser bundle for AMD

* Final fix for standalone browser build.

Much more scientific than the rest so it should stick.

* Throw when we can't find code we need to replace.
2016-11-22 17:16:45 -08:00
Sebastian Markbåge
6beb87eb73 Merge pull request #8365 from sebmarkbage/fiberdom
[Fiber] Fix more tests
2016-11-22 16:19:15 -08:00
Sebastian Markbage
d71bd59a4e Passing disabled events 2016-11-22 16:16:47 -08:00
Sebastian Markbage
475a6492c7 Utilize the backtracking during events to figure out if a Fiber was unmounted
We're walking backwards up to the root to find the parent so that we can
propagate events further up to nested React parents. If we don't find a
root, that means that the tree was unmounted and we shouldn't send any
events to it.
2016-11-22 16:16:47 -08:00
Sebastian Markbage
a481016883 Preserve the original object when using replaceState
When we use only replace state we don't need to clone the object.
2016-11-22 16:16:46 -08:00
Sebastian Markbage
a489e3f057 Disable one irrelevant test for Fiber
We don't use transaction objects.
2016-11-22 16:16:46 -08:00
Sebastian Markbage
826e90f5a0 Don't test for comments in empty components for Fiber
Fiber doesn't use comments in empty components.
2016-11-22 16:16:46 -08:00
Sebastian Markbage
7dd8fc549e Implement the same search strategy in ReactTestUtils as findDOMNode
This was supposed to fix an issue in refs-test but instead it revealed that
this strategy is broken.

The problem is that Placement effect is not sufficient when the insertion
is completed since the effect flag is reset then and the previous tree
has no effects in it to indicate that this is the wrong tree.
2016-11-22 16:16:46 -08:00
Sebastian Markbage
be2ec3d5b8 Fix findDOMNode for empty children
If there is no child there is nothing to tell us that this was the
workInProgress branch. Therefore, we need to look at the other branch
if there are children in it to see if *that* was the workInProgress branch.
2016-11-22 16:16:46 -08:00
Sebastian Markbage
977357765b Drop "previous style" copy from Stack to bring it inline with Fiber
We've already been warning for mutating styles so now we'll freeze them
in DEV instead. This isn't as good because we don't have more specific
warnings than the generic error that doesn't even fire in sloppy mode.

This lets Fiber pass the same tests.
2016-11-22 16:16:46 -08:00
Sebastian Markbage
9ceed8d69b Track inputs after setting its properties
This used to be done at the end of the transaction but I made it synchronous.

For this to work it needs to be applied after we have already set the .type
property since it is read by inputValueTracker.
2016-11-22 16:16:45 -08:00
Sebastian Markbage
075f3043a7 Update the internal Fiber on the DOM node to always be the current
We need this to safely extract the current event listeners from the props.
Unfortunately, we are still not safe to use the return pointer since it
may not point to the current tree when the Fiber is reused. So this is not
fully done yet.
2016-11-22 16:16:45 -08:00
Sebastian Markbage
7149a26eba Allow EventListener to traverse up the tree until it hits the root
We use this to find the root node so that we can look for outer React
subtrees if this is nested.
2016-11-22 16:16:45 -08:00
Benoit Girard
9da0bf53f7 Include ReactDebugTool from inside __DEV__ to save 1.5KB (#8322) 2016-11-22 16:08:45 -08:00
Sebastian Markbåge
4358ff08bf Nit in regexp (#8388) 2016-11-22 16:06:31 -08:00
Sebastian Markbåge
f38c355cba [Fiber] Make server rendering tests pass (#8372)
* Use the public ReactDOMServer in tests

We need this because it runs the injection.

* Let Fiber skip react data attributes and comments in SSR tests

This markup is testing implementation details rather than behavior.
2016-11-22 16:03:50 -08:00
Ben Alpert
c7129ce1f0 Stopgap fix for element disabling (#8387)
Fix for #8308. This is a bad hack -- EventPluginHub.getListener isn't even DOM-specific -- but this works for now and lets us release 15.4.1.
2016-11-22 14:39:30 -08:00
Dan Abramov
6434c37649 [Fiber] Add ReactDOMFiber.unstable_createPortal() (#8386)
* [Fiber] Add ReactDOMFiber.unstable_createPortal()

While #8368 added a version of `ReactDOM.unstable_renderSubtreeIntoContainer()` to Fiber, it is a bit hacky and, more importantly, incompatible with Fiber goals. Since it encourages performing portal work in lifecycles, it stretches the commit phase and prevents slicing that work, potentially negating Fiber benefits.

This PR adds a first version of a declarative API meant to replace `ReactDOM.unstable_renderSubtreeIntoContainer()`. The API is a declarative way to render subtrees into DOM node containers.

* Remove hacks related to output field
2016-11-22 22:08:13 +00:00
Ben Alpert
8334bb088a Lint (#8385) 2016-11-22 12:04:40 -08:00
Richard Maisano
b59fb796ea Add a couple missing SVG tags to DOM Elements docs (#8383)
My first contribution to React!

While upgrading a React project, I found some suspect SVG that needed updating, so I dug in after checking the docs. I knew that support for some SVG properties had been added (namely `xmlns` and `xmlnsXlink`), but I noticed them missing from the reference's attribute list. This pull request updates `reference-dom-elements.md` by adding said properties.
2016-11-22 18:50:11 +00:00
Ben Alpert
cb6da8e922 Fiber: renderSubtreeIntoContainer (#8368) 2016-11-22 09:57:13 -08:00
Dan Abramov
f686218268 Revert "Stop relying on variable hoisting" (#8381) 2016-11-22 15:19:45 +00:00
Linus Unnebäck
93042c277e Stop relying on variable hoisting (#8380)
Only declare the variable once in this scope, instead of declaring them multiple times in the same scope.

This fixes #8318, even though it might technically be a shortcoming in Rollup.
2016-11-22 15:18:10 +00:00
Mikhail Osher
e958cdbd36 Fix object spread operator (#8378)
Object spread operator performs shallow copy of object's arguments, so it should be placed before new properties are assigned.
2016-11-22 15:01:23 +00:00
Simen Bekkhus
e64510ab21 Fix link to PureComponent in docs (#8375) 2016-11-22 11:09:07 +00:00
Robin Ricard
9334b771c2 Change test assertion depending on a feature flag (#8306)
Instead of a private API (see https://github.com/facebook/react/pull/8150#discussion_r88280994)
2016-11-22 00:17:13 +00:00
Ben Alpert
3438d503db Make findDOMNode generic (#8348) 2016-11-21 17:13:26 +00:00
Evan Scott
77c890dfa2 Update all Jest packages to 17.x (#8327)
* Update all Jest packages to 17.x, cache babel-jest transforms

* Remove the caching

Looking at the other builds it doesn't seem to actually be that necessary.  The bottleneck is executors, not build time.

* Remove unnecessary package, fix fiber test runner

* Regenerate yarn lockfile
2016-11-20 16:10:08 +00:00
Michael Sinov
501ac150f6 update react-without-es6.md (#8351) 2016-11-19 18:19:16 +00:00
Tom Occhino
dfdff2b61a Move all dev *Hook tests and ComponentTreeTestUtils to expectDev (#8350) 2016-11-18 18:53:48 +00:00
Sebastian Markbåge
0deb71223d Fix ReactDOMFiberSelect to set the initial values (#8349)
I forgot that the normal properties route doesn't do this. We also have
to make sure that the order is 1) insert children (options), 2) set
multiple 3) update the options.
2016-11-18 18:52:15 +00:00
Sebastian Markbåge
6741703fbf Merge pull request #8347 from sebmarkbage/fiberdom
[Fiber] Handle controlled components
2016-11-18 18:35:26 +00:00
Dan Abramov
12ef47ba8f Merge pull request #8346 from shubheksha/docs/improve-state-and-lifecycle
Improved sections of state and lifecycle docs
2016-11-18 18:24:27 +00:00
Dan Abramov
a0044be99d Minor changes, make it more verbose 2016-11-18 18:24:15 +00:00
Sebastian Markbage
c1daa6f2c1 Record tests and fix BrowserEventEmitter test to not crash jest 2016-11-18 18:08:40 +00:00
Sebastian Markbage
e06b335588 Add some Flow types to inputValueTracking
Not perfect but better.
2016-11-18 17:59:37 +00:00
Sebastian Markbage
9b6738805a Exclude data-reactroot from tests when using Fiber 2016-11-18 17:59:36 +00:00
Sebastian Markbage
6e04bd758e Apply @spicyj's SelectEventPlugin fix
This fixes some tests with Fiber since we no longer rely on Stack
internals for this.
2016-11-18 17:59:36 +00:00
Sebastian Markbage
632ae806e8 Give wrappers the raw props object
Wrappers operate on the raw props object instead of the processed one.

We should probably clean this up a bit since it is very confusing and
unnecessary allocations to have two separate objects for props.
2016-11-18 17:59:36 +00:00
Sebastian Markbage
a2ca759dfd Handle controlled components in Fiber
We need to adjust inputValueTracking a bit to handle the fact that
Fiber attaches wrapper state on nodes.
2016-11-18 17:59:36 +00:00
Sebastian Markbage
cd0f963fa3 Fix up Flow annotations to be a bit more explicit where the unsoundness is 2016-11-18 17:59:36 +00:00
Shubheksha Jalan
730dae1df6 Improved sections of state and lifecycle docs 2016-11-18 22:14:27 +05:30
Dan Abramov
57f0cf376f Merge pull request #8345 from shubheksha/docs/improve-introducing-jsx
Improved some sections of the introducing JSX docs
2016-11-18 16:20:48 +00:00
Dan Abramov
c47340acfb Small nit: add a sentence about readability back 2016-11-18 16:20:17 +00:00
Shubheksha Jalan
e4432c7f76 Improved some sections of the introducing JSX docs 2016-11-18 21:09:34 +05:30
Sebastian Markbåge
751b76e351 Merge pull request #8319 from sebmarkbage/fiberdom
[Fiber] Fork ReactDOMComponent
2016-11-18 13:39:50 +00:00
Dan Abramov
919aa36d69 Merge pull request #8339 from nolanlawson/patch-1
Update 2016-11-16-react-v15.4.0.md
2016-11-18 12:27:16 +00:00
Dan Abramov
1c861a0d48 Merge pull request #8332 from gaearon/prod-dev
[Docs] Expand Installation and clarify why use bundlers
2016-11-18 12:26:22 +00:00
Dan Abramov
0b1d56399b Nits 2016-11-18 12:26:06 +00:00
Dan Abramov
c91cc4d11a Nit 2016-11-18 12:25:23 +00:00
Sebastian Markbage
7246659f4d Consistent method vs function 2016-11-18 12:20:25 +00:00
Sebastian Markbage
836331ba5f Wire up ReactDOMFiberComponent in ReactDOMFiber
We'll need to do the DOM injection now.
2016-11-18 12:01:22 +00:00
Sebastian Markbage
61a1a50955 Split mountComponent into create and set initial properties
This lets us insert children in between these two steps.
2016-11-18 00:26:26 +00:00
Sebastian Markbage
4b017507e2 Don't pass the Fiber around instead use the DOM node
To avoid exposing the implementation details of fibers we'll just pass the
DOM node around instead. We'll attach any additional wrapper state on it.
We don't have to do it that way. We can also just invert the relationship
and put the node in the wrapper state.

I'll probably just get rid of the wrapper object and just put them as
expandos on the DOM.
2016-11-18 00:26:26 +00:00
Sebastian Markbage
e962e97f75 Satisfy Flow by assuming value is an array for multi-select 2016-11-18 00:26:26 +00:00
Sebastian Markbage
6dc04b73a7 Assert that this is a script tag
Also, use a fixed string for the HTML since this is always a script tag.
2016-11-18 00:26:26 +00:00
Sebastian Markbage
e58b050773 Pass the tag explicitly instead of reading it from the internal instance 2016-11-18 00:26:26 +00:00
Sebastian Markbage
2defc83f34 Stop using host parent/container internal objects
Instead we extract the namespace from the root element.
2016-11-18 00:26:26 +00:00
Sebastian Markbage
d2888a7dea Get rid of server side support for <option />
We read the wrapper state during initial mount for server rendering support
but Fiber doesn't use it and we don't need it. We also can't because we
haven't yet completed the parent that has the selected.

I will need to remember to always insert children before setting the
selected value on the parent <select />. That way the DOM will deal with
the `selected` property of option properly.
2016-11-18 00:26:26 +00:00
Sebastian Markbage
2ef2a8e6f5 Pass props explicitly instead of getting them off currentElement
We don't store currentElement and I'm trying to get rid of accessing the
Fiber directly inside the host config.
2016-11-18 00:26:25 +00:00
Sebastian Markbage
e42842f2cd getCurrentOwnerName
Instead of passing around the owner and the internal fiber everywhere we
can set current owner during each commit. That way we have it available
globally where ever we need it.

That way we don't have to pass it as a DEV only argument nor expose the
internal representation to the host config.

This doesn't actually get the current owner yet. Will do that in a follow
up.
2016-11-18 00:26:25 +00:00
Sebastian Markbage
43f07779c4 We only need the root attribute for warnings and server-side rendering
We don't need this for Fiber yet. We can possibly add an expando to check
if this is rendered with React or not.
2016-11-18 00:26:25 +00:00
Sebastian Markbage
a1645322a7 Lint issues
Most dead code
2016-11-18 00:26:25 +00:00
Sebastian Markbage
3a856091be Add some Flow and get rid of the typecheck annotations 2016-11-18 00:26:25 +00:00
Sebastian Markbage
aea55609bf No need for unmounting DOM components
We'll stop tracking the input value tracking. We'll also stop uncaching the
node because we can just let the garbage collector take care of that. This
makes it easier to release components in trees that never mounted.

This also removes an invariant error which is covered by unit tests.
This is necessary to separate regardless because we don't want this to
fire for a component that was started but was thrown away because it never
mounted. We can come back to that later.
2016-11-18 00:26:25 +00:00
Sebastian Markbage
77de47e378 Stop tracking event listeners on DOM nodes
Basically, we don't need to remove the event listeners because we can just
check if something is still mounted when they fire instead. We'll rely on
garbage collection to clean them up.
2016-11-18 00:26:25 +00:00
Sebastian Markbage
e1ed610740 Remove the notion of transactions
We don't need to wait for the commit phase to start listening to events
since we have the node.

Next we'll stop unlistening to events too and instead just check isMounted.
2016-11-18 00:26:24 +00:00
Sebastian Markbage
7cd26b9c71 Manage children inside DOM properties
Fiber manages children separately so we don't need to do it here.
However, we special case the text content children and
dangerouslySetInnerHTML.

This reveals a bug that we currently don't handle the case where we switch
from dangerouslySetInnerHTML or text children to element children, because
child insertions are handled before the parent updates. We could possibly
handle this case by removing all nodes before the first host child but
that is a bit unfortunate.
2016-11-18 00:26:24 +00:00
Sebastian Markbage
7c5ec42350 Remove _domID
Not used by Fiber
2016-11-18 00:26:24 +00:00
Sebastian Markbage
4073dc79d7 Remove instrumentation and nesting warning
The nesting warning isn't as important now that we use createElement and
I don't want to deal with this just yet.
2016-11-18 00:26:24 +00:00
Sebastian Markbage
447e0a12b5 Get rid of the previousStyleCopy
We have warned about not mutating styles already. At this point we can just
freeze the style object in DEV.

That way we can read it from the previous props object without storing
another copy of it.

Also delete the associated warning.
2016-11-18 00:26:24 +00:00
Sebastian Markbage
151094ce03 Rely on lazy listeners 2016-11-18 00:26:24 +00:00
Sebastian Markbage
82e1d7dac3 Remove child nodes flag
We're always eager in Fiber.
2016-11-18 00:26:24 +00:00
Sebastian Markbage
c8d877a4c4 Remove rootNodeID
We only use this to determine if something is mounted or not but I don't
think we really need to.
2016-11-18 00:26:24 +00:00
Sebastian Markbage
e34e8974db Remove markup related paths 2016-11-18 00:26:24 +00:00
Sebastian Markbage
ec178acf15 Turn ReactDOMFiberComponent into a singleton
And turn on Flow.
2016-11-18 00:26:23 +00:00
Sebastian Markbage
9c3e9fbb05 Fork ReactDOMComponent and the wrappers to Fiber
From now on any change to these have to be replicated to these files.

I will next start changing the implementation to work with Fiber.
2016-11-18 00:26:23 +00:00
Nolan Lawson
1ff4158fa0 Update 2016-11-16-react-v15.4.0.md
Edge and IE11 both show user marks and measures in the Dev Tools, so it's technically not accurate to say that only Chrome has this feature.
2016-11-17 15:53:41 -08:00
Tom Occhino
32f5b034ed Upgrade ESLint and dependencies, fix new lint errors, switch Travis to Yarn (#8309)
* Update ESLint to 3.10.2

Also pull in fbjs for extending properly, per @zpao. This also disables consistent-return, which has about 80 failing cases in React currently. If we'd like to turn this back on, we should do it separately and fix all the call sites properly (rather than just adding 'return undefined;' everywhere, which adds no value.

Fixes to all existing lint errors plus an update for yarn.lock to follow.

* Update yarn.lock after the eslint update.

* Fix all new eslint failures

Unfortunately I had to add three eslint-disable-next-line instances. All have explanations inline.

* Switch Travis to use yarn instead of npm
2016-11-17 22:16:44 +00:00
Dan Abramov
bd529a0237 Merge pull request #8335 from lacker/newlink
add link to useful doc
2016-11-17 19:09:04 +00:00
Ben Alpert
8ecb248e6d Make numerical refs work in Fiber (#8334) 2016-11-17 18:56:33 +00:00
Kevin Lacker
02966c7945 add link to useful doc 2016-11-17 10:49:02 -08:00
Dan Abramov
3d52856bb6 Update installation instructions on the blog 2016-11-17 16:05:49 +00:00
Dan Abramov
db140c887f Explain Installation in more detail 2016-11-17 15:55:56 +00:00
Dan Abramov
862cedee94 Merge pull request #8317 from marcysutton/master
docs(forms): add missing labels to forms doc
2016-11-17 14:25:03 +00:00
Dan Abramov
3186a8b984 Tweak examples 2016-11-17 14:23:20 +00:00
Kevin Lacker
ad347a3b92 include the version number in the header (#8315) 2016-11-16 16:26:21 -08:00
Marcy Sutton
e08be27b0c fix(a11y): add missing labels to forms doc
Showing how to create a form without labeling inputs is an accessibility anti-pattern. This change adds labels to the examples to address that. Codepen may still need to be updated depending on how that example is created.
2016-11-16 14:32:42 -08:00
Dave Voyles
b20b99eb26 Clarity on constructor of Board object for tutorial.md (#8224)
* Update tutorial.md

Is it possible to be more clear here?
 This implies that we are removing the constructor from GAME, and not board (which is what I believe the author is trying to say).
It took me several reads to understand. 

With this edit, it is now clear that the adjustment is being made to -Board- and not to -Game-

* also remove "for Board earlier"
2016-11-16 13:24:45 -08:00
Tanner
6cbdf90f19 Remove spread operator (#8273)
* Remove spread operator

I believe what was meant here was to express that you would create the new player object with all the previous properties of the existing player object in addition to now updating the score value. That being said, this is a simple example, and the player object clearly has no other values. Objects are not (by default) iterable using this operator, so this little piece does more harm than good. I believe the new example to be much clearer.

* Using Object.assign()

* Tweak wording
2016-11-16 11:59:16 -08:00
Sebastian Markbåge
aca2e04036 Merge pull request #8232 from sebmarkbage/treetraversal
Add support for Fibers in ReactDOMComponentTree and ReactTreeTraversal
2016-11-16 16:59:32 +01:00
Sebastian Markbage
4e2688db4a Extract event listener from memoizedProps on Fiber instances
This makes some basic events work with Fiber.

This is however not a complete solution since we may be reading the wrong
Fiber.
2016-11-16 15:56:13 +00:00
Sebastian Markbage
b3af02a3cd Add Fibers to ReactTreeTraversal
This traverses parent based on the type of internal instance it is passed.
If it is a Fiber it may have to traverse multiple steps until it finds a
HostComponent.

This will allow us to use the event system with Fiber.
2016-11-16 15:43:55 +00:00
Sebastian Markbage
57cc182f26 Add Fibers to ReactDOMComponentTree
This adds precaching to ReactDOMFiber. I.e. adding a handle from the DOM
node to the internal Fiber. This means that we need to expose an internal
handle to the reconciler.

We use duck typing to figure out if it is a Fiber or Stack instance.

The new failing tests are failing because this is now able to actually
fire events onto Fibers and then the result of those events are
incorrect where as they were ignored before.
2016-11-16 15:42:39 +00:00
tomocchino
d1a003ee72 Update website for 15.4.0
(cherry picked from commit 5ce8853ccb)
2016-11-16 14:51:47 +00:00
tomocchino
66ee428a61 Update Changelog & Readme for 15.4.0
(cherry picked from commit 443683525f)
2016-11-16 14:51:38 +00:00
Dan Abramov
203d3fb25e Merge pull request #8293 from gaearon/154-post
Add 15.4.0 blog post
2016-11-16 14:45:26 +00:00
Dan Abramov
e8c07b0a45 Add 15.4.0 blog post 2016-11-16 14:36:20 +00:00
Tom Occhino
9589c726da Fix a line-length warning (#8298)
Test Plan: npm run lint / yarn run lint
2016-11-16 10:33:16 +00:00
Sebastian Markbåge
dde670fd36 Reapply Check for event listener in props instead of bank (#8292)
* Reapply Check for event listener in props instead of bank (#8192)

This reverts the previous revert.

* Don't throw on falsy event listeners

Some code relies on passing null. This restores the earlier behavior.
2016-11-15 18:16:27 +01:00
Dan Abramov
4029ccd650 Merge pull request #8272 from gaearon/fiber-context
[Fiber] Initial implementation of context
2016-11-15 17:14:12 +00:00
Dan Abramov
2397f1fce6 Use empty object if context does not exist
This matches Stack behavior.
Had to rewrite a test that used Simulate because Fiber doesn't support events yet.
Also changed tests for componentDidUpdate() since Fiber intentionally doesn't pass prevContext argument.
2016-11-15 16:35:00 +00:00
Dan Abramov
1e42c1833c Add explicit tests for intermediate components 2016-11-15 16:08:15 +00:00
Dan Abramov
fd8c8038f0 Update passing tests 2016-11-15 14:49:54 +00:00
Dan Abramov
a6ee5b876a Memoize merged child context when possible
We can avoid recreating the merged context object if the context provider work was reused. This is essential to avoid allocations for deep setState() calls.
2016-11-15 14:41:59 +00:00
Dan Abramov
299009c41f Add test cases for context below and above setState 2016-11-15 13:23:29 +00:00
Andrew Clark
4528cddf51 Removes UpdateQueueNode.callbackWasCalled (#8290)
Tracking this isn't necessary.
2016-11-15 09:52:05 +00:00
Brandon Dail
024f62ecfe Merge pull request #8277 from qiuyuntao/master
docs: delete unnecessary brackets
2016-11-14 17:37:02 -06:00
Brandon Dail
cdcbf2f39b Update reference-react-dom.md (#8285)
Add missing closing bracket
2016-11-14 17:35:32 -06:00
Dan Abramov
137029be31 Catch first error from setState callbacks (#8287)
* Catch first error from setState updaters

* Minor style tweaks
2016-11-14 18:27:38 +00:00
Dan Abramov
eedca6f641 Disable memoized props bailout when context might have changed 2016-11-14 18:24:32 +00:00
Dan Abramov
56e1c126c5 Move context handling back into Begin and Complete phases
As per discussion, this is better because then this code only runs for the class type of work. We will still need to fix bailouts for deep setState calls.
2016-11-14 16:22:10 +00:00
Dan Abramov
f9e1bc9c97 Move context management into scheduler
It is error-prone to push and pop context in begin or complete phases because of all the bailouts. Scheduler has enough knowledge to see if pushing is necessary because it knows when we go inside or outside the tree.
2016-11-14 13:32:09 +00:00
Dan Abramov
c22b7a001c Add a failing test for context when reusing work
We mistakingly forget to push the context if the parent is being reused but the child is not.
2016-11-14 13:32:09 +00:00
Dan Abramov
4ba0eb9158 Add a test for recursive context 2016-11-14 13:32:09 +00:00
Dan Abramov
e6a0de5463 Fix bad ops.length assignment in tests 2016-11-14 13:32:09 +00:00
Dan Abramov
b8cca3711e Update passing tests 2016-11-14 13:32:09 +00:00
Dan Abramov
a05d1abee8 Minor style tweaks 2016-11-14 13:29:42 +00:00
Dan Abramov
12bee76ff7 Implement basic support for context 2016-11-14 13:29:42 +00:00
Dan Abramov
9a42f8a0c5 Update passing tests 2016-11-14 13:22:47 +00:00
Ben Alpert
4aa9cfb6ba Change warnings to use expectDev 2016-11-14 13:22:41 +00:00
Dan Abramov
69fc4d32b5 Minor style tweaks 2016-11-14 12:56:11 +00:00
Dan Abramov
c8451bd0d8 Catch first error from setState updaters 2016-11-14 12:55:59 +00:00
Anastasia A
3a7b3b070b Update reference-react-dom.md
Add missing closing bracket
2016-11-14 10:33:07 +03:00
Ben Alpert
64cba04bf9 Build infra for tracking dev-specific failures (#8228)
I'll plan to change all of our console.error and component-tree expects to expectDev. It's a little annoying that we need to make sure tests don't throw (see my change to normalizeCodeLocInfo) but any alternative would seem to require two separate test runs or a much more cumbersome syntax.
2016-11-13 14:00:07 -08:00
Dan Abramov
c6f10e2cee Change a test to be relevant in Fiber (#8281)
Fiber supports fragments so we will use undefined instead.
This test is then valid both in Stack and in Fiber.
2016-11-13 10:40:21 -08:00
yuntao.qyt
41b4d3958c docs: delete unnecessary brackets 2016-11-13 16:29:18 +08:00
Ankeet Maini
077822e9d0 Handles risky callbacks on setState. Fixes #8238 (#8242)
* Handles risky callbacks on setState. Fixes #8238

* Updates try-catch to cover `callback` when context is not present.

* Updates code to trapErrors instead of swallowing them.

* Fixes flow errors

* Incorporates review comments

* Traps only the first error.

Removes `callbackWasCalled` and updates fiber tests.
2016-11-12 12:51:36 -08:00
Samuel Scheiderich
9d201918bf Add freenode #reactjs link to support.md (#8270)
* Add freenode #reactjs link to support.md

* Changed irc link to http webchat link.
2016-11-11 13:21:46 -08:00
Dan Abramov
b9f65d9b1d Fix reactComponentExpect.toBeDOMComponentWithChildCount(0) regression (#8271)
This should fix 3e2680411e (commitcomment-19788988).
2016-11-11 17:26:19 +00:00
Sebastian Markbåge
4804518c26 Handle nested controlled events (#8251)
I came up with a contrived case of where nested controlled events could
fire within the same batch - but on different targets.

I think we came to the conclusion that controlled values typically cannot
use preventDefault so it is ok that they don't flush until after the event
has finished. So therefore we accumulate a queue of all the nested targets
within a batch and then restore state on all of them.

I'm still skeptical that this is the correct way to do controlled values.
The reason we have to do them in a single event loop is because when you
type, the sequence of values that get accepted or not can matter. I wonder
if there is a scenario we can come up with where you can fire multiple
inner events in an event loop and end up with batching causing problems.

This effectively just reimplements asap again but with no allocations for
a single target and no closure allocations.
2016-11-11 16:49:59 +00:00
Michele Bertoli
53e45e78e4 Make the Shallow Rendering example clearer (#8269)
* Make the Shallow Rendering example clearer

I was reading through the documentation, and I found that the `render` call on the `renderer` was missing.

* Use a regular function to define MyComponent
2016-11-11 15:34:11 +00:00
Brandon Dail
e43aaab254 Use _hostContainerInfo to track test renderer options (#8261)
* Use _hostContainerInfo to track test renderer options

The transaction is not available when unmounting or updating the
instance, so we track it using _hostContainerInfo

* Throw if hostContainerInfo is not populated in getPublicInstance

* Linting fixes

* Remove transaction from ref lifecycle code path

We don't need to pass the transaction around anymore since we store the
test options on _hostContainerInfo instead

* Remove unused argument
2016-11-11 14:35:18 +00:00
Dan Abramov
da021ca4ae Use ReactDOM.unstable_batchedUpdates in Fiber tests (#8263) 2016-11-10 21:28:49 +00:00
Dan Abramov
a9fa135fd8 [Fiber] Fix reactComponentExpect (#8258) (#8257)
* Add more reactComponentExpect tests

* Implement reactComponentExpect in Fiber
2016-11-10 21:27:07 +00:00
Dan Abramov
3e2680411e [Fiber] Fix reactComponentExpect (#8258)
* Add more reactComponentExpect tests

* Implement reactComponentExpect in Fiber
2016-11-10 21:19:57 +00:00
Ben Alpert
67dcc5861c Flow 0.34 (#8259) 2016-11-10 11:52:32 -08:00
Dan Abramov
e612826650 Revert "temporary compatibility fix" (#8256)
This reverts commit bba0d992d8.
2016-11-10 16:03:22 +00:00
Eoin Hennessy
6ce8f1f93c Refactor precacheChildNodes slightly (#8018)
This ‘fixes’ a bizarre IE9 script engine issue. #7803
2016-11-10 16:02:48 +00:00
Shuhei Kagawa
fa4710fe51 Correct a method param in Implementation Notes (#8252) 2016-11-10 14:19:27 +00:00
Satoshi Nakajima
3e708497d2 Replaced old refs with new callback refs (#8254) 2016-11-10 14:13:56 +00:00
Arni Fannar
f4059e5e5b Update refs-and-the-dom.md (#8250)
Since a lot of projects use [airbnb eslint config](https://www.npmjs.com/package/eslint-config-airbnb) where [this rule](http://eslint.org/docs/rules/no-return-assign) is enabled (and its a good rule) some people might get confused when they are trying this out in their project.
2016-11-09 14:45:21 -08:00
Guilherme Oenning
b847226ec4 fix broken docs links (#8163)
* fix broken links to outdated code

* another broken links to outdated code

* update hash commit & folder structure to current
2016-11-09 18:06:35 +00:00
jddxf
8267e1152e #8021 (#8241)
Fix gulp tasks: eslint and flow error on Windows
2016-11-09 16:51:02 +00:00
Ville Immonen
3668a2e678 Remove string ref from function component example (#8244)
Refs can't be attached to stateless functional components.
2016-11-09 16:38:36 +00:00
Toru Kobayashi
d0a8d8b951 [Fiber]Warn when shoulcComponentUpdate returns undefined (#8243)
* [Fiber]Warn when shoulcComponentUpdate returns undefined

* Remove unnecessary fallback
2016-11-09 16:30:41 +00:00
Sebastian Markbåge
84b8bbdfc9 Fixed batching reentrant controlled events (#8240)
If a controlled target fires within another controlled event, we should not
restore it until we've fully completed the event. Otherwise, if someone
reads from it afterwards, they'll get the restored value.

Not super happy with this particular solution.
2016-11-08 17:42:53 -08:00
Andrew Clark
f829e2f1f1 Meant to commit these changes with #8206... oops. 2016-11-08 13:47:31 -08:00
Kevin Lacker
3a09f4bf30 forms breakup 2016-11-08 21:38:03 +00:00
Andrew Clark
c33230e563 Merge pull request #8206 from acdlite/fibertasklifecycleupdates
[Fiber] Updates from inside componentDidMount/Update should have Task priority
2016-11-08 13:28:29 -08:00
Andrew Clark
d9d4ad60c5 Updates from inside componentDidMount/Update should have Task priority.
This is only observable in incremental mode.
2016-11-08 13:27:31 -08:00
Samer Buna
e25d899d23 Remove unnecessary findDOMNode calls (#8198) 2016-11-08 21:15:01 +00:00
Nate
2317fcaccb Fix typos in Shallow Rendering Documentation (#8226)
* Fix typos in Shallow Rendering Documentation

* Fix another occurrence
2016-11-08 20:29:27 +00:00
Keyan Zhang
46609cb95c Fix error codes (#7999)
* took codes.json from the 15-dev branch

* fixed react:extract-errors task in gulpfile

* generated error codes

* Revert "generated error codes"

This reverts commit b8f3aeed9d8f0d469edd5f6623fa6090930594d8.

* Added a README for the error code system
2016-11-08 20:20:46 +00:00
iurii kucherov
a0c510adaf Cleanup ReactErrorUtils (#8145)
Remove 'b' argument from Flow annotation
2016-11-08 20:16:20 +00:00
Sebastian Markbåge
b2eaafaf3b Revert "Check for event listener in props instead of bank (#8192)" (#8239)
This reverts commit a878c3056d.

The previous stuff that this builds on didn't successfully land fully. Since I
want to measure this in isolation, I'll revert this for now.
2016-11-08 11:32:54 -08:00
Kevin Lacker
d885894c6e Docs: add a bunch of redirects (#8137)
* add a bunch of redirects

* add more redirects
2016-11-08 19:32:02 +00:00
Robert Haritonov
ccf6f5922e Add React Amsterdam 2017 (#8235)
We've recently announced the dates for our next React Amsterdam edition, looking forward on adding it to the list.
2016-11-08 09:20:22 -06:00
Sebastian Markbåge
a878c3056d Check for event listener in props instead of bank (#8192)
This just reads events from the props instead of storing them in a
listener back.

I had to rewrite a bunch of tests to cover this model.
I removed the tests that just test the adding and removing over listeners
since there is no equivalent behavior anymore.
2016-11-07 20:36:58 -08:00
Sebastian Markbåge
2f893b5914 Revert normalized text node fix (#8231)
This reverts the implementation in 33325ad009.

I didn't mean to merge the implementation since it is incorrect and incomplete.
I meant to just merge the unit test.
2016-11-07 18:27:58 -08:00
Sebastian Markbåge
75691af209 Rerun tests (#8230)
* Ensure that we're listening to all onChange dependencies for controlled inputs

When there is no onChange event handler, we should still listen to it to
ensure controlled values get reset.

There is warning associated with this but the prod behavior should still be
respected.

* Rerun tests
2016-11-07 16:49:43 -08:00
Sebastian Markbåge
a93ab6b1af Ensure that we're listening to all onChange dependencies for controlled inputs (#8229)
When there is no onChange event handler, we should still listen to it to
ensure controlled values get reset.

There is warning associated with this but the prod behavior should still be
respected.
2016-11-07 16:47:10 -08:00
Sebastian Markbåge
a92b83033a Fix lint in ReactUpdates (#8225)
I was a bit too trigger happy.
2016-11-07 13:35:17 -08:00
Sebastian Markbåge
90878df08d Use explicit pass for restoring controlled state instead of asap (#8176)
* Use explicit pass for restoring controlled state instead of asap

This gets rid of the first class ReactUpdates.asap scheduling. Instead of
scheduling a first class function to invoke later, I introduce an explicit
phase for restoring controlled state after dispatching events.

We assume that the deepest event target is the thing that needs its state
restored.

* Drop special cases for onChange in wrappers

We're now not using anything special about onChange handling in the
wrappers. Yay!
2016-11-07 13:31:33 -08:00
Ben Alpert
75ff12e984 Run fiber tests just once on Travis (#8221)
Consolidate facts tracking with the other script.
2016-11-07 11:43:29 -08:00
Ben Alpert
c4b9330f2a Hide detailed failure output in scripts/fiber/record-tests (#8214)
![image](https://cloud.githubusercontent.com/assets/6820/20033841/a55fefa4-a367-11e6-99c0-44dfe38e1db7.png)
2016-11-07 11:43:02 -08:00
Ben Alpert
84c57ddc6d Fix errors in ReactNativeMount (#8223) 2016-11-07 11:42:39 -08:00
Robin Ricard
33325ad009 [Fiber] Attempt to fix ReactDOMTextComponent test in Fiber (#8146)
* Attempt to fix ReactDOMTextComponent test in Fiber

Obviously, some tests pass but the reconciliation is still incomplete on this in Fiber.

Those changes just ignore reconciliation Comments while asserting (this fixes 2 tests already) but now shows that Fiber lacks some reconciliation features.

* Transmit a parentInstance to commitTextUpdate

This is done in case a Node#normalize() was performed on the parent instance and that the TextInstance got desolidarized from the parent. We provide the parent known by the parent Fiber to reattach the DOM node in this case.

* Added a more complex case around split nodes

This test does not assume one split node substitution alone but also some non-split nodes.

* Fiber supports split text nodes

This is done by suppressing nodes appearing during the split. this is based by comparing against the old value known by the Fiber.

* Simplify siblings cleaning in commitTextUpdate

No need to assert instanceof Text since the length comparator will work correctly.

* Ensure non-text nodes won't be removed

* Fix flow for Fiber Text reconciliation additions

Mostly define types as optionals. Respects the strict DOM API around Node & Element.

* Append at any stack stage only if necessary

The direct parent of the TextNode fiber may not contain the host node. We have to go through the hierarchy. However, since this work may be expensive, we only do it if absolutely necessary!

* Use tag & ReactTypeOfWork to find an HostComponent

* Addfailing scenario when running Node.normalize()

It happens when non-text-elements are added in the mix. @sebmarkbage seems to have an idea on how to fix it. This is just a repro of the bug!

* Register failing/passing fiber tests
2016-11-07 11:39:52 -08:00
Sebastian Markbåge
95334fada0 Track if SelectEventPlugin is attached on a per document basis (#8190)
This gets rid of the global flag on if something has listened to onSelect
and instead reads the isListening map if all the events are covered.
This is required if we want to attach events locally at roots.

Could be slower perf wise to handle events. An alternative solution would
be to attach a special flag on the listener map for the document so we
don't have to check the full dependency list.

However, my favorite solution would be to just eagerly attach all event
listeners (except maybe wheel). Then we don't have to do any of this stuff
on a per element basis.
2016-11-07 11:30:34 -08:00
Alex Baumgertner
5166a1b446 Fix method markdown highlight (#8218) 2016-11-07 11:57:23 -06:00
Ben Alpert
f705adb599 Re-record tests 2016-11-05 14:59:22 -07:00
Ben Alpert
ef99e7e096 Call setState callbacks enqueued in cWM (#8207)
Also fixes return value of ReactNativeMount and moves that callback to be after cDM instead of after all updates.
2016-11-05 14:38:24 -07:00
Ben Alpert
5f49b63bde Move setState callback to right after didUpdate (#8204)
It's much easier to do it this way in Fiber and there shouldn't be much observable difference.
2016-11-05 14:37:43 -07:00
Robin Ricard
ba6b53afba [Fiber] Complete ES6 Class related errors support (#8156)
* Print a warning in fiber for lacking render method

* Reject initial non-object state in Fiber

Rejects Arrays, Strings & Numbers. Allows nulls.

* Centralize fiber checks on ES6 Classes

* Add classic & instance property checks on fiber

- check the absence of getInitialState & getDefaultProps as methods
- check the absence of propTypes & contextTypes at instance-level

* Convert to normalized React `warning` calls

* Support lifecycle typo detection in fiber

* Get the complete warnings from the existing code

* Only check classInstance once

Avoid rechecking while resuming

* Can warn component while resuming but only once

This is achieved by tracking the warning state in the Fiber structure.

* Remove warning deduplication

* Factor name retrieval in a getName helper

* Use invariant instead of throw

* Read inst.state only once for the invariant

* Fix condition on the instance state

* Register failing/passing fiber tests
2016-11-05 11:19:48 -07:00
Brandon Dail
e644faa610 Correctly render placeholder for textarea in IE11 (#8020)
* Check if textContent should be set for textarea

shouldSetNodeTextContent returns whether a node.textContent should be
updated. Currently it only covers one case, which is to avoid setting
the textContent if the text is empty and a placeholder exists.

* Only set node.value if it's equal to initialValue

In IE11 textContent is populated when the placeholder attribute is set.
Without this check, we end up setting node.value equal to the
placeholder text, causing the textarea to actually render with the text
inside.

This check makes sure that textContent is equal to our expected
initialValue, which should be the case when using defaultValue.

* Remove placeholder/textarea check, use contentToUse instead
2016-11-05 11:47:54 -05:00
Martin Hochel
346d50e2ba support slot attribute on DOM elements for V1 shadowDom named slots p… (#8061)
* support slot attribute on DOM elements for V1 shadowDom named slots projection

Closes #7784

* fix(test): fix lint errors
2016-11-05 11:34:54 -05:00
Andrew Clark
c1cca0c7d8 Don't need to keep track of rootsWithUncaughtErrors
Just give it NoWork priority and findNextUnitOfWork will handle the rest
2016-11-04 17:58:57 -07:00
Andrew Clark
c0c2455643 Merge pull request #8210 from gaearon/fiber-error-boundaries-fatal
[Fiber] Make error handling more resilient
2016-11-04 17:41:04 -07:00
Andrew Clark
ef14324441 Remove unscheduleWork
We can use the existing unscheduling logic in findNextUnitOfWork.
2016-11-04 17:37:09 -07:00
Dan Abramov
c80f390823 Make error handling more resilient
* Ensure that errors in one root don't prevent work on another root
* Fix an issue where boundary state change would get ignored in incremental mode
2016-11-04 23:35:50 +00:00
Dan Abramov
e2be9830b8 Create a separate test file for incremental error handling 2016-11-04 19:48:36 +00:00
Andrew Clark
4266f08e48 [Fiber] "Task" priority for error boundaries and batched updates (#8193)
* Refactor scheduling functions and introduce Task priority

There was lots of duplication across all the scheduling functions. I
think we're far enough along that we can start trying to clean some
stuff up.

Also introduces a new priority level provisionally called Task priority.
This is for work that completes at the end of the current tick, after
the current batch of work has been committed. It's different from
Synchronous priority, which needs to complete immediately.

A full implementation of Task priority will follow. It will replace
the current batching solution.

* Implement Task priority

Task priority is similar to Synchronous priority. Both are flushed in
the current tick. Synchronous priority is flushed immediately (e.g. sync
work triggered by setState will flush before setState exits), where as
Task is flushed after the current batch of work is committed.

Currently used for batchedUpdates and nested sync updates. Task should
also be used for componentDidUpdate/Mount and error boundary work. I'll
add this in a later commit.

* Make error boundaries use Task Priority

I have all but one error fixed. Not sure how tricky the last one is,
but I'm cautiously optimistic. Pushing to show my current progress.

* Remove recursion from handleErrors

Changed the algorithm of handleErrors a bit to ensure that boundaries
are not revisited once they are acknowledged.

* Add incremental error boundary test

Discovered an edge case: a noop error boundary will break in incremental
mode unless you explicitly schedule an update.

* Refactor error boundaries in Fiber

* Simplify trapError() calls

The existing logic was written before we had a proper error handling system.

* Remove unnecessary flags

* Prevent performTaskWork recursion

* Be stricter about preventing recursion
2016-11-04 19:40:50 +00:00
Ben Alpert
f4a42b872b Fiber: Fix reconciling after null (#8202)
Before, this code was bailing out after encoutering a null child because it thought it was out of old children. Seen when reconciling [null, <span />, <Image />] with [null, <span />, <Image />] in XUISelector.
2016-11-03 23:56:29 -07:00
Sebastian Markbåge
b20e3afbf5 Move Safari onClick hack into ReactDOMComponent (#8189)
This is already where we trap non-bubbling events. We also already branch
on the tag type so we know if it is interactive or not.

This will let us get rid of the didPutListener and willDeleteListener
abstractions.

I use a simple onclick = emptyFunction to avoid the need for a bookkeeping
map.
2016-11-03 15:26:23 -07:00
Brent Vatne
09ce083c4c Add Agent Conference to conferences docs (#8196)
* Add Agent Conference to conferences docs

* Move Agent Conference to upcoming conferences
2016-11-03 15:18:48 -05:00
Dan Abramov
857672f7e7 Update passing tests 2016-11-03 14:41:39 +00:00
Andrew Clark
29dbbc31c9 UpdateQueue fixes
- Incorrect comparison when computing hasUpdate
- isReplace should be a property of the node, not the queue
2016-11-02 23:00:00 -07:00
Sebastian Markbåge
3410ecadd1 ES import -> require (#8185)
Not all of our downstream build chains don't support ES imports yet.
2016-11-02 13:48:29 -07:00
Dan Abramov
c894679b75 [Fiber] Schedule animation regardless of deferred work (#8187)
* Remove comments about implementation details

* Schedule animation regardless of deferred work
2016-11-02 20:46:20 +00:00
Dan Abramov
eb674e47c8 [Fiber] Add tests for scheduling inside callbacks (#8186)
* Add tests for scheduling inside callbacks

* Don't test implementation details
2016-11-02 20:11:27 +00:00
Andrew Clark
75f4ab2206 Merge pull request #8127 from facebook/fibersynchronouswork
[Fiber] Use synchronous scheduling by default
2016-11-02 12:46:38 -07:00
Dan Abramov
95084bedbb Fix lint by removing unneeded type import 2016-11-02 12:45:15 -07:00
Andrew Clark
c3ab541e0f New effect type: Callback
This solves the problem I had with enqueueSetState and enqueueCallback
being separate.
2016-11-02 12:40:21 -07:00
Andrew Clark
2182b69004 batchedUpdates tests
Covers some bugs I encountered while working on this feature.

Introduces a syncUpdates API to ReactNoop. Is this something we'd want
to expose to the reconciler?
2016-11-02 12:40:21 -07:00
Andrew Clark
da45010cb7 Remove first-class function
Instead we'll branch on the priority level, like in scheduleWork.
2016-11-02 12:40:21 -07:00
Andrew Clark
3121e051a8 At the end of a batch, perform any sync work that was scheduled 2016-11-02 12:40:21 -07:00
Andrew Clark
26731ea967 unstable_batchedUpdates should return value of callback 2016-11-02 12:40:21 -07:00
Andrew Clark
2e5e88c750 Don't need defaultPriorityContext
Turns out this isn't necessary. Simpler to keep it as one field.
2016-11-02 12:40:21 -07:00
Andrew Clark
b41883fc70 unstable_batchedUpdates
Implements batchedUpdates and exposes as unstable_batchedUpdates. All
nested synchronous updates are automatically batched.
2016-11-02 12:40:21 -07:00
Andrew Clark
d153b1e27b Enqueue update and callback simultaneously
Without this fix, in non-batched mode, the update is scheduled first and
synchronously flushed before the callback is added to the queue. The
callback isn't called until the next flush.
2016-11-02 12:40:21 -07:00
Andrew Clark
ecf468e556 Batch nested updates when in sync mode
Almost working...
2016-11-02 12:40:21 -07:00
Andrew Clark
78aef38bfa Add config to enable sync scheduling by default
I'll turn this on in ReactDOMFiber once I figure out batchedUpdates.
2016-11-02 12:40:20 -07:00
Andrew Clark
7b9ae92058 Updates should use the same priority context as top-level render
A bit of restructuring so that setState uses whatever the current
priority context is, like top-level render already does.

Renamed defaultPriority to priorityContext, and added a new variable
called defaultPriorityContext. Having two separate variables allows the
default to be changed without interfering with the current context.
2016-11-02 12:40:20 -07:00
Andrew Clark
a07f5eede0 Synchronous work 2016-11-02 12:40:20 -07:00
Andrew Clark
ab920970ae Ensure first iteration of performAnimationWork loop has right priority
I don't think this actually changes any behavior because of the way
findNextUnitOfWork works, but I think this is easier to follow.
2016-11-02 12:40:20 -07:00
Dan Abramov
2b26ea614d Fix the build (these tests were renamed) 2016-11-02 19:28:26 +00:00
Dan Abramov
99be3781ef [Fiber] Add more tests for scheduling (#8183)
* Add more tests for scheduling

* Remove ambiguous terms
2016-11-02 17:49:22 +00:00
Sebastian Markbåge
e5d85fbe04 Remove pendingUpdate optimization in ReactDOMSelect (#8175)
This removes an optimization that avoids call update on ReactDOMSelect
twice in an onChange event.

2601b6a0b0 (commitcomment-19643403)

None of the other controlled components do this. The only reason to do it
here is because of the loop.

I'd like to remove this because I'd like to remove all the side-effects
that happen in onChange, other than user defined behavior. I'd also like to
get rid of state that track sequences. It is easier if everything is just
diffing.

Alternatively I can store the previous value that we processed and only
reprocess if the value has changed. However, that would requires the array
for multiple values to be immutable and I don't think we enforce that
right now.

In Fiber, I believe that we'll be able to batch both these updates into a
single commit.
2016-11-01 18:54:20 -07:00
Sebastian Markbåge
576542d0cf Handle the radio button case completely in the asap case (#8170)
Instead of scheduling individual callbacks to asap, we schedule one and
then do all the work in that one.

I'm doing this for architectural refactoring reasons.

Nevertheless, I'm adding a contrived unit test that this fixes. :)
2016-11-01 18:54:11 -07:00
Tetsuharu OHZEKI
33ac5e8e4b [Fiber] Assign ReactTypeOfSideEffect to ReactFiber.Fiber.effectTag correctly (#8173)
The type of `ReactFiber.Fiber.effectTag` is `TypeOfSideEffect`.
Thus we should assign `ReactTypeOfSideEffect.NoEffect` value instead of
`ReactPriorityLevel.NoWork` even if they are same values.
2016-11-01 23:24:55 +00:00
Dan Abramov
1a49b5f563 [Fiber] Fix infinite loop in scheduler and add more tests (#8172)
* Make test more complete

* Add a failing test for scheduling in reverse order

It hangs forever because we don't clear next pointer when unscheduling a root. Therefore, when it's scheduled again, it brings all its previous chain with it, potentially creating a cycle.

* Clear the next pointer when unscheduling a root

Fixes a potential infinite cycle when we reschedule a root.

* Add new tests to Fiber test tracker
2016-11-01 17:44:57 +00:00
Dan Abramov
ab02a03cad [Fiber] Add some scheduling tests (#8171)
* Extend ReactNoop to handle multiple roots

This lets us test scheduling between the roots.

* Add a few first tests for scheduler
2016-11-01 14:35:01 +00:00
Ben Alpert
08b4cc53b8 Track passing/failing tests in fiber (#8169)
* Work around jest toEqual bug in ReactTreeTraversal

![image](https://cloud.githubusercontent.com/assets/6820/19879640/1cd7595a-9fb2-11e6-94ac-8c38bdfc90d3.png)

* Track passing/failing tests in fiber

Run scripts/fiber/record-tests to re-record, then check git diff to see what you changed.
2016-10-31 23:26:38 -07:00
Yura Chuchola
abeae306e5 Update forms.md (#8136)
The component Form in "Uncontrolled Radio Button" example doesn't need state, because it does not used in render() method.
2016-10-31 17:35:20 -07:00
Sebastian Markbåge
34fd4f4aa0 Kill ReactLink, LinkedStateMixin, valueLink and checkedLink (#8165)
This should be safe because we've been warning for this. The LinkedStateMixin is technically exposed on React.addons without a warning but presumably you wouldn't be using it without a valueLink or checkedLink.

I do this primarily to clear up what the custom onChange listeners are doing.

Renamed the final prop type helper to ReactControlledValuePropTypes.
2016-10-31 16:45:01 -07:00
Damien Soulard
f53854424b update-unknown-warning-page - add a reason for the warning (#8131)
* update-unknown-warning-page - add a reason for this warning

* Minor tweaks
2016-10-31 13:01:06 +00:00
Skasi
abf37ea484 Remove duplicated word in doc (#8157)
Gets rid of an obsolete word in the documentation for "State and Lifecycle":

"Consider the ticking clock example from the one of the previous sections."
->
"Consider the ticking clock example from one of the previous sections."
2016-10-31 11:42:02 +00:00
bel3atar
980cb01a84 add missing verb (#8139)
`why is an` should be `why it is an`
2016-10-31 11:41:43 +00:00
Dan Abramov
264bed13ba [Fiber] Miscellaneous fixes to get more tests passing (#8151)
* Reset current owner when handling an error

* Make string ref deletion tests accept null

* Relax requirements on ref and render interleaving
2016-10-30 22:15:34 +00:00
Dan Abramov
c567b6e618 Remove use of reactComponentExpect in our tests (#8148) 2016-10-30 00:44:33 +01:00
Dan Abramov
c17bf38035 Get a few more Fiber tests passing (#8149)
* Get a few more Fiber tests passing

* Fix Flow and wrap in __DEV__
2016-10-30 00:43:34 +01:00
Robin Ricard
6d747a7426 [Fiber] Fix tests for Fiber in ReactElement-test (#8150)
* Test Fiber internals differently in ReactElement

Instead of being able to access the owner's instance via getPublicInstance(), we use the Fiber's stateNode. (Fiber does not have methods, it's just a structure!)

* Fix isCompositeComponentWithType for fiber

In ReactTestUtils.isCompositeComponentWithType, we provide a way to walk through Fiber's internals in place of using _currentElement.type. We keep support for non-fiber though.

* Test fiber reconciler consistently

Use typeof instance.tag to test if we're using the fiber reconciler

* Remove unnecessary comment
2016-10-30 00:42:59 +01:00
Dan Abramov
928541dc9e [Fiber] Fix TestUtils.findAllInRenderedTree (#8147)
* [Fiber] Fix TestUtils.findAllInRenderedTree

* Add a comment about coroutines
2016-10-29 22:02:13 +01:00
Lee Sanghyeon
f29a7bac0e Update codebase-overview.md (#8142)
* Update codebase-overview.md

Fix the broken source code URL in 'Event System' section.

* Update codebase-overview.md

Re-fix link name
2016-10-29 13:01:41 +01:00
Maksim Shastsel
9dc7a9594a Add support for node v7 (#8135) 2016-10-29 11:24:12 +01:00
Andrew Lo
1efb7a4e35 In the community support doc, I noticed that the React Facebook (#8138)
page link is broken since it's missing '.com'.
2016-10-29 00:31:01 +01:00
Andrew Clark
1152ced3dc Merge pull request #8133 from gaearon/error-boundaries-more
[Fiber] Error boundaries should handle errors independently
2016-10-28 14:58:54 -07:00
Dan Abramov
ed11b35302 The issue with tests is solved now 2016-10-28 21:48:37 +01:00
Dan Abramov
d8441cd725 Handle multiple errors in boundaries 2016-10-28 21:22:59 +01:00
Dan Abramov
c08469a7d6 Add tests verifying we don't swallow exceptions 2016-10-28 21:22:59 +01:00
Dan Abramov
f51abe0b55 Add a failing test for multiple independent boundaries
Now that commits are treated as atomic, it is possible that componentDidMount, componentDidUpdate, or componentWillUnmount threw in multiple places during the commit. We need to make sure we notify all affected boundaries of the first errors in them.
2016-10-28 21:22:58 +01:00
Dan Abramov
bd3c90ac6f Add more tests for error boundaries 2016-10-28 21:22:58 +01:00
Gant Laborde
6825773882 Organize and add confs (#8129)
Upcoming proximity followed by past chronological.
2016-10-28 11:21:21 -07:00
mfijas
4bca777131 Updated tutorial.md (#8054)
Fixed method name (renderStep -> renderSquare).
Removed <li>'s key to present the warning described below the code fragment.
2016-10-28 10:28:44 -07:00
Dan Abramov
3c6abbfff7 [Fiber] Error Boundaries (#8095) 2016-10-28 10:29:14 +01:00
Sebastian Markbåge
308e0b7786 Merge pull request #8128 from sebmarkbage/fiberdom
[Fiber] Some early refactoring to be able to reuse the event system
2016-10-27 23:18:43 -07:00
Sebastian Markbage
ea47782aaa Create ReactGenericBatching injection wrapper around BatchedUpdates
This moves calls that don't know if they're in a Fiber or Stack
context to use ReactGenericBatching.batchedUpdates.

The corresponding one will be injected from either the stack
reconciler and/or the fiber reconciler if they're loaded at the
same time.

This lets them share the event system when they're both used
at once.

This can also be useful for libraries that call
unstable_batchedUpdates today but don't know which renderer to
use.
2016-10-27 18:57:30 -07:00
Sebastian Markbage
2f8d1689db Refactor ResponderEventPlugin to not rely on _rootNodeID
Instead of relying on IDs, we now use instances for everything so
this should be reflected by the test.

This still has a _rootNodeID to store the listeners which I will
remove next.
2016-10-27 18:54:15 -07:00
Eugene
0e23880d22 Update reference-react-component.md (#8126)
line 320: For example, this code ensures that the `color` prop is a string
2016-10-27 19:25:43 +01:00
Rick Beerendonk
346dcaacfa Add React Remote Conf 2016. (#8094)
Add video links to some conferences.
2016-10-27 11:25:14 -07:00
Sebastian Markbage
2633a4284f Move more files into stack reconciler
CallbackQueue and Transaction are specific to the stack
reconciler.
2016-10-27 11:04:23 -07:00
Dan Abramov
e1b140225a Clarify how transition props work (#8124) 2016-10-27 14:21:34 +01:00
Ivan Zotov
b3b13919c7 Improve devtools image size for the tutorial (#8114) 2016-10-27 13:54:18 +01:00
Andreas Möller
1e126c29dd Fix: Remove unneeded else branches from documentation examples 2016-10-27 13:12:37 +01:00
Dan Abramov
a4b9abff42 Consistent CodePen links in docs 2016-10-27 13:06:09 +01:00
Ivan Zotov
6fec6507ed Fix lint errors (#8113) 2016-10-27 13:03:32 +01:00
Varun Bhuvanendran
603b7194dc added word break (#8120) 2016-10-27 13:01:51 +01:00
Lewis Blackwood
dba8f25854 Correct usage of formatName() function in docs (#8122)
The code section above these changes defines a `formatName` function
that expects a parameter `user`. The code section containing these
changes incorrectly called `formatName(user.name)`. For those following
along with CodePen, this section should correctly call
`formatName(user)`.
2016-10-27 13:01:04 +01:00
Josh Perez
6eebed0535 Shares debugID information across modules (#8097)
Prior to this, React was using a nextDebugID variable that was locally
scoped to both `instantiateReactComponent` and `ReactShallowRenderer`.
This caused problems when the debugIDs would collide, the `itemMap` in
`ReactComponentTreeHook` would be overwritten and tests would fail
with the message "Expected onBeforeMountComponent() parent and
onSetChildren() to be consistent".

This change shares the debugID with both modules thus preventing any
collisions in the future.
2016-10-27 10:31:10 +01:00
王晓勇
e3688d1fa3 Update forms.md (#8121) 2016-10-27 10:26:31 +01:00
Andrew Clark
e031e0be3c Merge pull request #8118 from facebook/fiberpurecomponent
[Fiber] PureComponent
2016-10-26 21:13:43 -07:00
Andrew Clark
59c94648c4 PureComponent in Fiber
Passes existing PureComponent tests
2016-10-26 21:02:39 -07:00
Dan Abramov
cc3dc21be0 Tweak Forms 2016-10-27 02:02:29 +01:00
Eric Nakagawa
552033e33b Docs update - Additional (#8115)
* Reapplied fixes to updated docs from master

* Reapplied fixes to Forms, removed ES2016 function includes()

* Missing carriage return

* Adding back some line breaks

* Making requested changes.

* Making space changes

* Fixed typo and removed unnecessary hyphen.

* Reworded select, and highlighted line

* Fixed string styles

* Refactored <label> to use htmlFor

* Another refactor of <label>

* Removed name prop from radiobutton
2016-10-27 00:14:08 +01:00
Eric Nakagawa
47e665a2fc Forms Update (#8112)
* Reapplied fixes to updated docs from master

* Reapplied fixes to Forms, removed ES2016 function includes()

* Missing carriage return

* Adding back some line breaks

* Making requested changes.

* Making space changes
2016-10-26 13:45:25 -07:00
Toru Kobayashi
2ef12084e4 [Fiber] Add top level render callbacks into ReactDOMFiber and ReactNoop (#8102)
* [Fiber] Add top level render callbacks into ReactDOMFiber and ReactNoop

* [Fiber] Support multiple render callbacks

* [Fiber] `this` in render callbacks are public instances

* [Fiber] commitLifeCycles move to behind the effectTag check
2016-10-26 13:19:19 -04:00
Alex Katopodis
2ba571c246 Fix typo in reconciliation.md (#8110) 2016-10-26 17:13:55 +01:00
Lutz Rosema
42465eefed Use const instead of var (#8107)
It clarifies that `history` and `current` won't be reassigned.
2016-10-26 15:20:09 +01:00
Andrew Clark
d5eff3b0eb [Fiber] String refs and owner tracking (#8099)
* Implement string refs using callback closures

* Merge Fiber type to avoid Flow intersection bugs

Still one remaining type error that I'm not sure how to fix

* Fix Flow issue with an unsafe cast

* Fix missing semicolon

* Add a type import I missed earlier
2016-10-26 14:37:32 +01:00
Jae Hun Lee
ce2dee32fd Update lists-and-keys.md (#8090)
There is mismatching variable name both definition and usage.
In line 156, an argument name called item is change to match the usage in line 158.
2016-10-26 14:17:21 +01:00
Toru Kobayashi
d49dfe7da4 Fix an argument name of TestUtils.renderIntoDocument (#8104) 2016-10-26 13:44:46 +01:00
Sebastian Markbåge
7bcad0a6aa Merge pull request #8083 from sebmarkbage/fiberfinddomnode
[Fiber] Implement findDOMNode and isMounted
2016-10-26 02:52:20 -04:00
Sebastian Markbåge
51e1937dd6 Merge pull request #8028 from sebmarkbage/nodidupdateforbailout
[Fiber] Don't call componentDidUpdate if shouldComponentUpdate returns false
2016-10-25 18:21:40 -04:00
Sebastian Markbage
46bde58486 Don't call componentDidUpdate if shouldComponentUpdate returns false
This fix relies on the props and state objects being different
to know if we can avoid a componentDidUpdate. This is not a great
solution because we actually want to use the new props/state
object even if sCU returns false. That's the current semantics
and it can actually be important because new rerenders that are
able to reuse props objects are more likely to have the new props
object so we won't be able to quickly bail out next time.
I don't have a better idea atm though.
2016-10-25 15:21:05 -07:00
Sebastian Markbåge
3d48139dd7 Merge pull request #8096 from sebmarkbage/fiberdom
Merge React[DOM/Native]TreeTraversal
2016-10-25 17:52:16 -04:00
Sebastian Markbage
8df7afc689 Merge React[DOM/Native]TreeTraversal
These two implementations are identical. Except for some
invariants for some reason.

Since this relies on an implementation detail of the internal
component tree rather than an implementation detail of the
renderer, we might as well merge them and remove the injection.
2016-10-25 14:37:46 -07:00
Sebastian Markbage
8e2d7f8d27 Add tests for findDOMNode on fragment and text
These are new features that aren't covered by existing tests.

It is now possible to use findDOMNode to find a text node.

When a component returns a fragment, it will search to find the
first host component just like element.querySelector does.
2016-10-25 13:59:34 -07:00
Sebastian Markbage
d5752aca0d findDOMNode when a component is not yet mounted or unmounted
First we need to check if a component subtree is mounted at all.

If it is, we need to search down the fiber for the first host
node. However, we might be searching the "work in progress"
instead of current.

One realization is that it doesn't matter if we search work in
progress or current if they're the same. They will generally be
the same unless there is an insertion pending or something in
the alternate tree was already deleted. So if we find one of
those cases, we switch to look in the alternate tree instead.
2016-10-25 13:59:34 -07:00
Sebastian Markbage
1914f94041 Handle unmounted and not-yet-inserted subtrees in isMounted
There are two cases where we have a Fiber that is not actually
mounted. Either it is part of a tree that has not yet been
inserted or it is part of a tree that was unmounted.

For the insertion case, we can check the parents to see if there
is any insertion effect pending along the parent path.

For deletions, we can now check if any of the return pointers
is null without actually being the root.
2016-10-25 13:59:34 -07:00
Sebastian Markbage
1376048bd9 Clear effectTag and return pointers after side-effects
This will let us use these pointers to reason about a tree.
Whether if it is "current" or "work in progress".
2016-10-25 13:59:33 -07:00
Sebastian Markbage
2e040fc2c1 Implement isMounted for Fiber
This is the naive implementation that doesn't cover the case
where it has completed but not yet committed. It also doesn't
deal with unmounts since they currently don't clean up the item
in the ReactInstanceMap.
2016-10-25 13:59:33 -07:00
Sebastian Markbage
298d0c3e05 Implement findDOMNode for Fiber
This is the naive implementation that doesn't cover the case where there are
two diverging fibers, or if this tree is unmounted.
2016-10-25 13:59:31 -07:00
Sebastian Markbåge
e3131c1d55 Merge pull request #8086 from sebmarkbage/fiberdom
[Fiber] Reorganize files for DOM renderer to make overlap between fiber/stack clearer
2016-10-25 15:56:30 -04:00
Sebastian Markbage
a3fb0310ca Reorganize files
This is just moving a bunch of DOM files.

It moves things into dom/stack and dom/fiber respectively. The
dom/stack folder remains split into client/server.

Mainly the shared folder is now my best guess for files that
we can reuse in fiber. Everything else will get forked or
reimplemented.

Also moved the event system out of renderers/shared/stack and
into renderers/shared/shared.
2016-10-25 10:54:14 -07:00
Sebastian Markbåge
ea8cf7fbff Delete child when the key lines up but the type doesn't (#8085)
When keys line up in the beginning but the type doesn't
we don't currently delete the child. We need to track that this
fiber is a not a reuse and if so mark the old one for deletion.
2016-10-25 12:51:53 +01:00
Dan Abramov
225325eada Add Fiber Debugger (#8033)
* Build react-noop as a package

This lets us consume it from the debugger.

* Add instrumentation to Fiber

* Check in Fiber Debugger
2016-10-25 08:36:37 +01:00
Sebastian Markbage
b26168cadb DefaultEventPluginOrder -> DOMEventPluginOrder
This is not a generic plugin order. It's DOM specific. Unlike
say DefaultBatchingStrategy which is used by Native too.
2016-10-24 19:59:04 -07:00
Sebastian Markbage
4ba8bef19a Split DefaultInjection into two files
This splits DefaultInjection into one with all the properties
and event configuration and a separate one for the things that
are relevant to he stack reconciler.

That way we can reuse the property and event system for Fiber
without pulling in all the other stuff.
2016-10-24 19:44:55 -07:00
Sebastian Markbage
b0ccf62ea3 Get rid of ReactInjection
We don't use this indirection. It'll easier to break these apart
without it.
2016-10-24 19:16:56 -07:00
Dan Abramov
265ab83667 Respect state set in componentWillMount() on resuming (#8079)
When resuming creating new instance after resuming work, we should set the `state` on the newly creating instance rather than the old one.
2016-10-25 00:21:56 +01:00
Sergey Rubanov
9626c838cb Add npm v4.0.0 support (#8082) 2016-10-24 23:57:12 +01:00
Constantin Gavrilete
82d592a0fa removed duplicated 'the' (#8081) 2016-10-24 17:34:58 -05:00
Sebastian Markbåge
06e3b03132 Merge pull request #8078 from sebmarkbage/rmcomment
Remove copypasta comment
2016-10-24 13:49:51 -04:00
Sebastian Markbage
7991a00dcc Remove copypasta comment
Caught by @gaearon
2016-10-24 10:49:10 -07:00
Antti Ahti
954a70e591 Remove deprecated function from tests (#6536)
This has been deprecated since 2013 so it's about time to remove it.
2016-10-24 18:46:38 +01:00
Dan Abramov
14156e56b9 Strip PropTypes checkers in production build (#8066)
* Strip PropTypes in production build

* Revert "Warn if PropType function is called manually (#7132)"

This reverts commit e75e8dcbeb.
2016-10-24 18:43:31 +01:00
Dan Abramov
e1ee94ca17 Add more highlighting to docs (#8076)
* Tweak JSX in Depth

* Add highlighting to Refs and the DOM

* More tweaks
2016-10-24 15:48:46 +01:00
Toru Kobayashi
6cdc610bcc [Fiber] Add types for ReactFiber and ReactChildFiber (#8072)
* Add Types for ReactFiber

* Add Types for ReactChildFiber
2016-10-24 14:20:44 +01:00
Marcio Puga
6fa1ddbdb4 Fix typos (#8067) 2016-10-24 13:50:04 +01:00
Ashish
8333b891e4 Docs : Fix createClass reference (#8073)
Currently react.createClass is wrongly referenced to #react.createclass. Changed it to #createclass!
2016-10-24 13:34:17 +01:00
Sebastian Markbåge
69d725f764 Merge pull request #8055 from sebmarkbage/fiberclassname
Accept className in ReactDOMFiber
2016-10-23 17:04:03 -04:00
Dan Abramov
156639241e Remove references to createClass in createElement docs (#8064) 2016-10-23 15:48:58 +01:00
Dan Abramov
46eca10046 Link to lifecycle methods from Context doc (#8062) 2016-10-23 14:35:23 +01:00
Andrew Poliakov
4e98dba6d3 Update tutorial.md, Taking Turns (#8058) 2016-10-23 13:49:55 +01:00
Alireza Mostafizi
e527b3a464 Update handling-events.md (#8057) 2016-10-23 13:44:29 +01:00
William Hoffmann
29f5da8de4 Fix typo (#8056) 2016-10-23 13:44:08 +01:00
Giuseppe
74026fd9ea Docs replace reference to 'getInitialState' with 'state' instance property in "Thinking in React" (#8059) 2016-10-23 13:41:37 +01:00
Sebastian Markbage
51f1205fb4 Accept className in ReactDOMFiber
This isn't a complete solution to all attributes. It's just that
we run a lot of unrelated unit tests by testing className so
we need it for the tests.
2016-10-22 17:57:33 -07:00
Jason Grlicky
952bdca020 Fix for typos (#8046) 2016-10-22 16:50:24 -07:00
Jun Kim
284a96b9a6 Fix illogical code in tutorial.md (#8048)
The tutorial wants to throw a 'warning' and explains about 'key' of React's list, but it throws nothing since there is sensible key.
"key={move}" should be removed, and added after explaining about key.
2016-10-22 16:49:07 -07:00
Diego Muracciole
461a74115c Injected Host Component classes are not being considered by the reconciler (#8050)
* Consider Host Component classes when creating a new internal instance

* Remove unused tagToComponentClass & injectComponentClasses from ReactHostComponent
2016-10-22 17:28:37 -05:00
Phil Quinn
cf37402338 correct order of params in documentation (#7989) 2016-10-22 21:59:54 +01:00
Brad Vogel
01753cde85 "take part in" is the correct saying (#8013) 2016-10-22 21:57:57 +01:00
Sebastian Markbåge
57f07777ef Fix relative link in Hello World (#8041)
* Fix relative link in Hello World

This links https://facebook.github.io/docs/installation.html which redirects to https://code.facebook.com/

* Update hello-world.md

* Fix link
2016-10-22 21:56:53 +01:00
Oskari Mantere
38c22252f4 Replace vars with let and const (#8051) 2016-10-22 21:55:29 +01:00
Avinash Kondeti
6810627a91 Fix: updated with new docs links (#8049) 2016-10-22 21:53:52 +01:00
Jun Kim
37f94bd3bb Fix typo in tutorial.md (#8047)
changges -> changes
2016-10-22 21:52:29 +01:00
Taeho Kim
a5ff2f1e9c Fix typo in new tutorial code (#8045) 2016-10-22 21:46:51 +01:00
Nathan Hardy
f7cb6cbe15 Fix erroneous '}' in JSX examples (#8043) 2016-10-22 21:45:29 +01:00
Cody Reichert
4d3c5ea23c Fix anchor link for displayName (#8040) 2016-10-22 21:44:51 +01:00
Ragnar Þór Valgeirsson
7340fa9d93 Convert the Number component to ListItem (#8039)
* Convert the Number component to ListItem

* Add updated example CodePen

Also fixes typos.
2016-10-22 21:44:28 +01:00
BEAUDRU Manuel
54dfe0b43c Wrong library name reference in tutorial.MD (#8038)
* Update tutorial.md

Seems like you are talking about immutable.js and not immutability.js which doesn't exist :)

* Capitalize Immutable.js
2016-10-22 21:43:15 +01:00
Ben Alpert
fa82e3e9d6 Update website on Travis when only new files are added (#8037)
This build didn't commit the new files because no existing files were changed:

https://travis-ci.org/facebook/react/jobs/169622664

This should work better.
2016-10-22 21:41:29 +01:00
Christopher Chedeau
4812f26915 Update components-and-props.md
fb indent style
2016-10-21 18:30:25 -07:00
Christopher Chedeau
eb118b7037 Update react-without-jsx.md
Facebook codestyle
2016-10-21 14:30:35 -07:00
Dan Abramov
d1a61ee7f4 Fix redirects 2016-10-21 22:02:30 +01:00
Dan Abramov
1f818f2740 Minor doc tweaks 2016-10-21 21:47:43 +01:00
Kevin Lacker
455d2d1b48 New Documentation 2016-10-21 20:59:08 +01:00
Sebastian Markbåge
8cac523bea Merge pull request #8029 from sebmarkbage/fiberreturnfromtoprender
Quick fix to the return top level problem
2016-10-21 14:59:01 -04:00
Sebastian Markbage
6e7c89ed8a Quick fix to the return top level problem
This doesn't deal with the fact that work is usually deferred
so this will return null for first render (except in sync tests).
It also doesn't deal with top levels being fragments etc.
It doesn't deal with the host instance type being a wrapper
around the public instance. This needs to be unified with refs
and findDOMNode better.

However, this does expose that we reactComponentExpect and
ReactTestUtils doesn't work very well with Fiber.
2016-10-21 11:58:40 -07:00
Sebastian Markbåge
9b1b40ca93 Merge pull request #8015 from sebmarkbage/fiberclassinit
[Fiber] Add more life-cycles
2016-10-21 14:57:51 -04:00
Sebastian Markbage
37ca3874af Add unit tests for aborted life-cycles
This tests the life-cycles when work gets aborted.
2016-10-21 11:57:24 -07:00
Sebastian Markbage
c862ba719e Fallback to current props if memoizedProps is null
If work has progressed on a state update that gets resumed
because of another state up, then we won't have an new
pendingProps, and we also won't have any memoizedProps because
it got aborted before completing. In that case, we can just
fallback to the current props.

I think that they can't have diverged because the only way they
diverge is if there is new props.

This lets us bail out on state only updates in more cases which
the unit tests reflect.
2016-10-21 11:57:24 -07:00
Sebastian Markbage
b72c27ce5d Don't schedule NoWork as the next work
We currently only filter out "NoWork" in the beginning of this
function. If the NoWork root is after the one with work it will
show up in the second loop. There's probably a more efficient
way of doing this but this works for now.

This showed up in this PR because a new unit test gets unblocked
which ends up with this case.
2016-10-21 11:57:24 -07:00
Sebastian Markbage
a87ec42f2a Add more life-cycles to Fiber
This refactors the initialization process so that we can share
it with the "module pattern" initialization.

There are a few new interesting scenarios unlocked by this.
E.g. constructor -> componentWillMount -> shouldComponentUpdate
-> componentDidMount when a render is aborted and resumed.
If shouldComponentUpdate returns true then we create a new
instance instead of trying componentWillMount again or
componentWillReceiveProps without being mounted.

Another strange thing is that the "previous props and state"
during componentWillReceiveProps, shouldComponentUpdate and
componentWillUpdate are all the previous render attempt. However,
componentDidMount's previous is the props/state at the previous
commit. That is because the first three can execute multiple
times before a didMount.
2016-10-21 11:57:24 -07:00
Toru Kobayashi
a6728f961c [Fiber] Add unit tests for ReactDOMFiber (#8016) 2016-10-21 00:44:23 -04:00
Sebastian Markbåge
4132cc4d3e Fix lint with yarn (#7997)
I couldn't figure out how to do this yarn alone so I ended up
just manually hacking the yarn to force a downgrade of babylon
to 6.8.0 since otherwise it gets resolved to 6.12.0 which is
broken.
2016-10-20 17:49:40 -04:00
Ben Alpert
a8beab3341 Fix captured/bubbled in ReactNativeTreeTraversal (#8019)
Follow-up to #7741. Added a test for RN event bubbling that fails before the fix.
2016-10-20 11:17:06 -07:00
Sebastian Markbåge
a5195102d4 [Fiber] Some setState related issues (#8010)
* Use the memoized props/state from the workInProgress

We don't want to use the "current" props/state because if we have
started work, then pause and continue then we'll have the newer
props/state on it already. If it is not a resume, it should be the
same as current.

* Deprioritize setState within a deprioritized tree

Currently we flag the path to a setState as a higher priority
than "offscreen". When we reconcile down this tree we bail out
if it is a hidden node. However, in the case that node is already
completed we don't hit that bail out path. We end up doing the
work immediately which ends up committing that part of the tree
at a higher priority.

This ensures that we don't let a deprioritized subtree get
reconciled at a higher priority.

* Bump idx in unit test

This proves that this number is actually deprioritized.
2016-10-19 13:32:37 -04:00
Toru Kobayashi
3d7869ab0e [Fiber] Add a unit test for ReactTopLevelText (#8001) 2016-10-18 14:39:49 -04:00
Dan Abramov
9bfa45bd2d Update Flow and fix issues (#8006) 2016-10-18 15:26:40 +01:00
Dan Abramov
75367673cf Fix Haste header (#8005) 2016-10-18 14:06:08 +01:00
Andrew Clark
663d4a539b Merge pull request #8000 from piperchester/patch-1
Fix grammatical error
2016-10-17 21:26:22 -07:00
Piper Chester
31f5edc492 Fix grammatical error 2016-10-17 21:13:33 -07:00
Sebastian Markbage
fae3e5308b Use memoizedState in componentDidUpdate
We forgot to clone this value so it didn't work before.
This is covered by existing tests in ReactDOMProduction.
2016-10-17 16:21:06 -04:00
Sebastian Markbage
685d65bfb6 No duck typing on the root
The root is always a host container.
2016-10-17 16:21:06 -04:00
Sebastian Markbage
bc5dfd5358 Break out some Class Component logic into separate module
Refactors the class logic a bit.

I moved scheduleUpdate out into the scheduler since that's where
the scheduling normally happens. I also moved it so that we can
rely on hoisting to resolve the cycle statically.

I moved the updater to a new class component file. I suspect we
will need a bit of space in here since the class initialization
code is quite complex.

The class component dependency is currently fixed in BeginWork
so we can't move complete or commit phase stuff to it. If we need
to, we have to initialize it in the scheduler and pass it to the
other phases.
2016-10-17 16:21:06 -04:00
Sebastian Markbage
9c25538e13 Fix resuming bug
If we abort work but have some completed, we can bail out if
the shouldComponentUpdate returns true. However, then we have
a tree that is low priority. When we bailout we currently use
the "current" tree in this case. I don't think this is right.
I'm not sure why I did that.

Similarly, when we complete we use the "current" props if we
didn't have pending props to do. However, we should be using
the memoized props of that tree if it is a pending work tree.

Added a unit test that covers these two cases.
2016-10-17 16:17:30 -04:00
Sebastian Markbage
e59e5b280f Invoke all null ref calls before any new ref calls
This reorganizes the two commit passes so that all host
environment mutations happens before any life-cycles. That means
that the tree is guaranteed to be in a consistent state at that
point so that you can read layout etc.

This also lets us to detach all refs in the same pass so that
when they get invoked with new instances, that happens after it
has been reset.
2016-10-17 16:17:30 -04:00
Sebastian Markbage
3717b71c64 Resolve ref callbacks
During the deletion phase we call detachRefs on any deleted refs.

During the insertion/update phase we call attachRef on class
and host components.

Unfortunately, when a ref switches, we are supposed to call all
the unmounts before doing any mounts. This means that we have to
expact the deletion phase to also include updates in case they
need to detach their ref.
2016-10-17 16:17:30 -04:00
Sebastian Markbage
c44c7eaa1b Fire componentDidMount/componentDidUpdate life-cycles
These happen in the commit phase *before* the setState callback.

Unfortunately, we've lost the previous state at this point since
we've already mutated the instance. This needs to be fixed
somehow.
2016-10-17 16:17:30 -04:00
Sebastian Markbage
90993c5324 Call componentWillUnmount during deletion phase
While we're deleting nodes, we need to call the unmount
life-cycle. However, there is a special case that we don't want
to keep deleting every host node along the way since deleting the
top node is enough.
2016-10-17 16:17:30 -04:00
Sebastian Markbage
a98aba4d73 Always override priority level when visiting children
It is not possible for a child to have a higher priority level
than we're reconciling at, unless we intentionally want to
down-prioritize it.
2016-10-17 16:17:30 -04:00
Sebastian Markbage
43645a6586 Reset effect list when we recompute children
We only use the effect list when we reuse our progressed children.
Otherwise it needs to reset to null.

In all other branches, other than bailoutOnLowPriority, we
revisit the children which recreates this list.

We should also not add fibers to their own effect list since it
becomes difficult to perform work on self without touching the
children too. Nothing else does that neither.

Since that means that the root isn't added to an effect list we
need to special case the root.
2016-10-17 16:17:30 -04:00
Sebastian Markbage
1d437dc9ad Remove beginWork shortcut
This shortcut had a bug associated with it. If beginWork on this
child returns null, then we don't call completeWork on that fiber.

Since removing this short cut adds another time check, we have to
add a single unit of time in tests to account for the top level
call now taking one more unit.

This was also the only recursive call in all of fiber so it's nice
to get rid of it to guarantee that a flat stack is possible.
2016-10-17 16:17:30 -04:00
Sebastian Markbage
5de2821372 Move child updates to use the reconciled effects
Instead of passing the full list of children every time to
update the host environment, we'll only do inserts/deletes.

We loop over all the placement effects first and then later
we do the rest.
2016-10-17 16:17:30 -04:00
Sebastian Markbage
442ab71fc7 Append deletions to the effect list
First clear any progressed deletions for any case where we start
over with the "current" set of children.

Once we've performed a new reconciliation we need to add the
deletions to the side-effect list (which we know is empty because
we just emptied it).

For other effects, instead of just adding a fiber to an effect
list we need to mark it with an update. Then after completion
we add it to the the effect list if it had any effects at all.

This means that we lose the opportunity to control if a fiber
gets added before or after its children but that was already
flawed since we want certain side-effects to happen before others
on a global level.

Instead, we'll do multiple passes through the effect list.
2016-10-17 16:17:30 -04:00
Sebastian Markbage
901691eb92 Tag the fiber with the kind of side-effect that was applied to it
This allow us to track what kind of side-effect this was even
though we only have a single linked list for all side-effects.
2016-10-17 16:17:30 -04:00
Sebastian Markbage
e9e645a9b1 Deletion tracking
When we reconcile children we need to track the deletions that
happen so that we can perf side-effects later as a result. The
data structure is a linked list where the next pointer uses the
nextEffect pointer.

However, we need to store this side-effect list for reuse if we
end up reusing the progressedChild set. That's why I add a
separate first/last pointer into this list so that we can keep it
for later.
2016-10-17 16:17:30 -04:00
Sebastian Markbage
0dc840a2b9 Fast path for create child
When we don't have any previous fibers we can short cut this path
knowing that we will never have any previous child to compare to.

This also ensures that we don't create an empty Map in this case.
2016-10-17 16:17:30 -04:00
Sebastian Markbage
3979bb9e24 Don't track side-effects unless needed
We don't need to track side-effects for a parent that has never
been mounted before. It will simply inject all its children when
it completes.
2016-10-17 16:17:30 -04:00
Sebastian Markbage
cccc4ae2c6 Add index field to each fiber
We use this to track the index slot that this Fiber had at
reconciliation time. We will use this for two purposes:

1) We use it to quickly determine if a move is needed.

2) We also use it to model a sparce linked list, since we can have
null/false/undefined in our child set and these take up a slot for
the implicit key.
2016-10-17 16:17:30 -04:00
Sebastian Markbage
edaf08fcfe Fiber child reconciliation
This implements the first step to proper child reconciliation.
It doesn't yet track side-effects like insert/move/delete but has
the main reconciliation algorithm in place.

The goal of this algorithm is to branch early and avoid rechecking those conditions. That leads to some duplications of code.

There are three major branches:

- Reconciling a single child per type.
- Reconciling all children that are in the same slot as before from the beginning.
- Adding remaining children to a temporary Map and reconciling them by scanning the map.

Even when we use the Map strategy we have to scan the linked list to line up "same slot" positions because React, unlike Inferno, can have implicit keys interleaved with explicit keys.
2016-10-17 16:17:30 -04:00
Sebastian Markbage
13f01be64f Enable text updates in ReactNoop
We'll enable updating of text nodes. To be able to test that we
need the text nodes to be mutable. They're currently just strings
in the Noop renderer so this makes them an object instead.

That exposed a bug in ReactFiberCommitWork for text nodes.
2016-10-17 16:17:30 -04:00
Sebastian Markbage
362e56a1c1 Add comment about bug in yields
This needs to be fixed somehow. The reconciler could know if you
are mounting this continuation into the same spot as before and
then clone it. However, if the continuation moves, this info is
lost. We'd try to unmount it in one place and mount the same fiber
in another place.
2016-10-17 16:17:30 -04:00
Sebastian Markbage
c3310d3e32 Fix MultiChild tests so they work with Fiber
Dropped the unnecessary use of findDOMNode.
Dropped unnecessary arrow functions.
Math.random() -> id counter, since this used to be
non-deterministic which is not ideal for unit tests.

getOriginalKeys() used to rely on implementation details
to scan that the internal data structure maintained its
structure, however, since that is unobservable we don't
need to test the internal data structure itself. We're
already testing refs and dom structure which is the only
observable effect of the reorder.
2016-10-17 16:17:30 -04:00
Sebastian Markbage
8d3a58de62 Silence Fiber warning when the feature flag is on
When the feature flag is on, we should silence the warning since
we're explicitly testing it. This is needed when running unit
tests with the flag on.
2016-10-17 16:17:30 -04:00
Sebastian Markbage
cafa7b284a Add Text node types
These nodes rendering into Text nodes in the DOM.

There is a special case when a string is a direct child of a host
node. In that case, we won't reconcile it as a child fiber. In
terms of fibers, it is terminal. However, the host config special
cases it.

It is kind of unfortunate that we have to special case this kind
of child in the HostConfig. It would be nice to unify this with
other types of child instances. Text nodes have some weird special
cases, but those special cases tend to *vary* by environment.
They're not the same special cases so not sure how valuable it is
to have a special protocol and special types for it.
2016-10-17 16:17:30 -04:00
Sebastian Markbage
e0a305350b Add Fragment fiber type
We currently treat nested arrays as a unique namespace from top
level children. So that these won't share key namespaces. This
adds a new fiber type that will represent the position of a
fragment.

This is only used for nested arrays. Even if you return an array
from a composite component, we don't need this since they share
namespace with a single top level component.

This still doesn't implement the complete reconciliation
algorthim in child fiber. That's coming later.
2016-10-17 16:17:30 -04:00
Dan Abramov
7b7eddcc72 Add @preventMunge directives to classes (#7994) 2016-10-17 21:07:17 +01:00
Dan Abramov
c2d5833e98 Ignore root docs folder in Flow config
Otherwise Flow finds obscure files in docs/vendor.
Seems like you'd only get them if you have a local checkout of docs Ruby dependencies.
This explains why Travis didn't fail.
2016-10-17 16:12:07 +01:00
Dan Abramov
f33f03e357 Support passthrough updates for error boundaries (#7949)
* Initial pass at the easy case of updates (updates that start at the root).

* Don't expect an extra componentWillUnmount call

It was fixed in #6613.

* Remove duplicate expectations from the test

* Fix style issues

* Make naming consistent throughout the tests

* receiveComponent() does not accept safely argument

* Assert that lifecycle and refs fire for error message

* Add more tests for mounting

* Do not call componentWillMount twice on error boundary

* Document more of existing behavior in tests

* Do not call componentWillUnmount() when aborting mounting

Previously, we would call componentWillUnmount() safely on the tree whenever we abort mounting it. However this is likely risky because the tree was never mounted in the first place.

People shouldn't hold resources in componentWillMount() so it's safe to say that we can skip componentWillUnmount() if componentDidMount() was never called.

Here, we introduce a new flag. If we abort during mounting, we will not call componentWillUnmount(). However if we abort during an update, it is safe to call componentWillUnmount() because the previous tree has been mounted by now.

* Consistently display error messages in tests

* Add more logging to tests and remove redundant one

* Refactor tests

* Split complicated tests into smaller ones

* Assert clean unmounting

* Add assertions about update hooks

* Add more tests to document existing behavior and remove irrelevant details

* Verify we can recover from error state

* Fix lint

* Error in boundary’s componentWillMount should propagate up

This test is currently failing.

* Move calling componentWillMount() into mountComponent()

This removes the unnecessary non-recursive skipLifecycle check.
It fixes the previously failing test that verifies that if a boundary throws in its own componentWillMount(), the error will propagate.

* Remove extra whitespace
2016-10-15 18:13:56 +01:00
Héctor Ramos
1b7066ed6f Separate Ruby and Python instructions 2016-10-14 15:11:27 -07:00
Héctor Ramos
175fc4ae9b Add Windows-specific instructions 2016-10-14 15:10:16 -07:00
Sebastian Markbåge
fda7a673c1 Fix whitespace in headers (#7980)
The script that strips providesModule is very sensitive.

Test plan:

Searched for providesModule in build. No more.

reactComponentExpect used to have problems too but doesn't seem
to anymore. Don't know why.
2016-10-14 17:46:34 -04:00
Dan Abramov
14ec2c0c46 Add 15.4.0 RC3 to Downloads 2016-10-14 20:21:05 +01:00
Héctor Ramos
b59a8d94cc Add link to gulpjs 2016-10-13 15:48:16 -07:00
Dustan Kasten
91aa538221 build: strip @providesModule from output modules (#7968)
FB tools such as Flow and Jest are having issues finding duplicate modules
now that React internal modules are duplicated across packages.
2016-10-13 16:19:11 -04:00
CT Wu
836a054719 Fix a typo in the doc (#7969) 2016-10-13 16:58:57 +01:00
Nathan Hunzaker
0d20dcf910 Fix uncontrolled input decimal point "chopping" on number inputs, and validation warnings on email inputs (#7750)
* Only assign defaultValue if it has changed.

* Improve comment about reason for defaultValue conditional assignment
2016-10-13 08:20:14 -05:00
Giorgio Polvara
823dd3d65f Fix typo (#7953) 2016-10-12 21:29:37 -05:00
Sebastian Markbåge
f38e0cb6ac Check in yarn.lock file (#7957)
Because we have to keep up with the latest hotness
https://yarnpkg.com/
2016-10-12 16:07:25 -04:00
Ujjwal Ojha
575727100a Fix typo (#7909) 2016-10-12 09:49:56 -05:00
Kevin Huang
b728fa0c17 Add warning for shady-dom use with rendered react components in DEV (#7911)
* Add warning for shady-dom use with rendered react components in DEV

* Make shady dom warning emit only once regardless of number of components

* Use didWarnShadyDom as warning argument & add missing shadyRoot check to ReactDOMComponent

* Add check for shady dom test to run only when createElement flag is true

* Pass false to warning in shadyDom warning check

* Add consistent DOM phrasing for shady DOM warnings

* Reference component name in shady DOM warning if it exists

* Add check for if owner exists in shady dom warning

* Add test for named component using createClass for shady DOM warning

* Clean up named component test for shady DOM warning

* Fix trailing comma linting issue on named shady DOM warning test
2016-10-12 10:13:50 +01:00
Kevin Huang
3b708728b0 Declare type var higher up in mountComponent() in ReactDOMComponent for reuse (#7944) 2016-10-12 10:12:15 +01:00
Islam Sharabash
b77a96e496 Inject the previous batching strategy when rendering to string (#7930)
Before this change calling renderToStringImpl would inject
ReactDefaultBatchingStrategy after completion, even if a custom batching
strategy was injected before. This makes renderToStringImpl keep a reference to
the batching strategy before it runs and reinject it afterwards.
2016-10-11 12:57:22 -05:00
Colin Wren
7aa621daee Fix typo in more-about-refs.md (#7933) 2016-10-11 11:56:34 +01:00
Alex Babkov
deb4a5abee Typo fixes in codebase-overview.md (#7938) 2016-10-11 11:55:06 +01:00
Aesop Wolf
f00fbbd1ce Update codebase-overview.md (#7934)
Fix typo
2016-10-11 01:14:05 +01:00
Dan Abramov
d0cc73a957 Add Implementation Notes and amend Codebase Overview (#7830)
* Add more to Codebase Overview

* WIP

* Start a reconciler overview

* Add a few more sections

* todo

* WIP

* Finish it

* Whitespace

* Minor tweaks

* Minor tweaks
2016-10-10 17:29:48 +01:00
Toru Kobayashi
83381c1673 use npm-run-script in PULL_REQUEST_TEMPLATE (#7913) 2016-10-07 14:23:37 +01:00
Paul O’Shannessy
077d660a27 Fix npm package builds (#7888)
* Ensure lib/ is packaged for react-test-renderer

* Run npm pack from right working directory

We were running this on the original packages not the compiled ones, resulting in missing files
2016-10-05 15:32:38 -07:00
Sophia
2a2dd7689f removing parent/child references in props section of tutorial (#7887) 2016-10-05 22:29:55 +01:00
Tyler Buchea
e5b197cd94 Update README.md to use jsx for syntax highlighting (#7884)
Github now supports jsx syntax highlighting in their markdown documents. So I have updated the main README.md to use jsx instead of js.
2016-10-05 14:13:11 -05:00
Michael O'Brien
48ea2d4743 Update comment to refer to correct method name (#7873) 2016-10-04 22:53:26 +01:00
Dan Abramov
7b10b2b88d Update the homepage with ES6 (#7868)
* Update the homepage with ES6

* Avoid array spread and stale state
2016-10-04 19:33:09 +01:00
Kateryna
c9ec4bc445 Fix initial state example for Recat.createClass (#7867)
In the example there was a typo with setting initial state using `getInitialState` method
2016-10-04 18:43:49 +01:00
Toru Kobayashi
30067fa8ca Fix confusing variable names (#7863) 2016-10-04 12:53:29 +01:00
ankitml
eddcee9884 Use ES6 in Language Tooling doc 2016-10-04 12:51:42 +01:00
Toru Kobayashi
85b0377bfd Refactor ShallowRenderer (#7739)
* Separate ReactShallowRenderer from TestUtils

* Use ES classes to ReactShallowRenderer
2016-10-04 12:28:06 +01:00
KeicaM
f96237cdb8 Update 04-multiple-components.md (#7861)
added missing map bracket
2016-10-04 12:19:44 +01:00
Steve Mao
957f663513 simplify npm link script a little bit (#7862)
We don't need to remove the folders before linking the modules
2016-10-04 12:12:12 +01:00
Ben Alpert
be63afcb64 Make sure .createElement({}) warns (#7857)
This is common when forgetting to export anything from a file.
2016-10-03 17:24:57 -07:00
Marcelo Alves
23cd77b683 Fix minor typo in closing H1 tag (#7855) 2016-10-03 19:07:56 -05:00
Paul O’Shannessy
92c84a6f37 Fix UMD bundles, making safe to use as required modules (#7840) 2016-10-03 15:49:10 -07:00
Ben Alpert
f88c1d38be Update remarkable to 1.7.1 (#7851)
Fixes a subtle XSS hole.
2016-10-03 14:22:06 -07:00
ankitml
a6445a18f9 Keyed Fragment of AddOns ported to ES6 2016-10-03 21:45:27 +01:00
Alex Zherdev
1b02c731ce Add-Ons: Animation updated with ES6 examples 2016-10-03 21:30:22 +01:00
Rafael Angeline
9174c29acc Reusable Components ES6 Update 2016-10-03 21:02:32 +01:00
gillchristian
f5f1769583 Docs to ES6: Displaying data example. 2016-10-03 19:21:44 +01:00
hkal
f6fdfd1bf0 Add unknown property warning for use of autofocus (#7694) 2016-10-03 09:51:44 -05:00
Mark Penner
dae3043897 Fixes #7824 (#7832) 2016-09-30 19:03:49 -07:00
Eric Douglas
e32196222b Update babel link (#7837) 2016-09-30 13:39:23 -07:00
Ivan Zotov
16ac141f44 Fix mistakes in the codebase overview (#7834) 2016-09-29 22:38:14 +01:00
Dan Abramov
4f345e021a Add Codebase Overview (#7828)
* Add Codebase Overview

* Update codebase-overview.md

* Update codebase-overview.md
2016-09-29 11:33:57 +01:00
Gil Chen-Zion
a2bb55e3f4 Note that getInitialState is not used in ES6 classes in docs (#7748) 2016-09-28 19:07:29 -07:00
Kyle Mathews
87724bd875 typos fix (#7822) 2016-09-28 17:27:25 +01:00
Christopher Chedeau
cc00280aa6 Our first 50,000 stars blogpost 2016-09-28 10:21:29 +01:00
Christoph Pojer
0990c93806 Reduce confusion in testing documentation. (#7818)
* Reduce confusion in testing documentation.

Just wanted to add some clarity to this page and link to the react tutorial on Jest's website to give people more information. Also changed enzyme's definition from library to utility to help reduce the confusion. Hope this makes sense to everybody :)

See https://twitter.com/damusnet/status/780752042675597312

cc @lelandrichardson

* Update 10.4-test-utils.md
2016-09-27 19:08:02 -07:00
J. Renée Beach
59ff7749ed React dom invalid aria hook (#7744)
* Add a hook that throws a runtime warning for invalid WAI ARIA attributes and values.

* Resolved linting errors.

* Added a test case for many props.

* Added a test case for ARIA attribute proper casing.

* Added a warning for uppercased attributes to ReactDOMInvalidARIAHook
2016-09-27 20:53:14 -05:00
Christopher Chedeau
72ed5df5a4 Fix total count in flow tracker (#7813)
When you put the output of a bash command in a variable, it replaces the `\n` with a space. Using `ls` instead of `echo` fixes it

Test Plan:
Run

```
ALL_FILES=`find src -name '*.js' | grep -v umd/ | grep -v __tests__ | grep -v __mocks__`
COUNT_ALL_FILES=`ls $ALL_FILES | wc -l`
echo $COUNT_ALL_FILES
```

Make sure that it outputs 221
2016-09-27 16:20:50 -07:00
Dan Abramov
1c0b5dca5a Tweak the contributing wording in README 2016-09-27 23:32:57 +01:00
Dan Abramov
c82bcefa93 Move How to Contribute to documentation and update it (#7817)
* Move How to Contribute to documentation and update it

* Consistent formatting
2016-09-27 23:20:49 +01:00
Christopher Chedeau
84f8df1f89 Track fiber tests (#7812)
Use the newly added tracking system to track the number of fiber tests that are passing/failing.

I first tried to modify the grunt lint rule for it and send the output in stdout but unfortunately grunt displays the rule + done messages there. I had like 30 lines of js already and I figured I could just write 3 lines of bash and it would work the same. Let me know if you want me to use another approach for it.

Test Plan:
Run the commands that have been introduced in this commit but the facts-tracker one
Run `echo $FIBER_TESTS` and make sure it prints `666/1434`
2016-09-26 14:54:27 -07:00
Christopher Chedeau
fb1e7075ed Update travis.yml to use $GITHUB_USER_NAME and $GITHUB_USER_EMAIL (#7811)
See https://github.com/facebook/react/pull/7747#issuecomment-249677880 for discussions
2016-09-26 14:47:16 -07:00
imjanghyuk
6032491555 Update 07-forms.ko-KR.md (#7809)
fix spelling
2016-09-26 14:02:33 -07:00
Christopher Chedeau
dbd9c4b205 Introduce facts-tracker (#7747)
* Introduce facts-tracker

We want to be able to track various things like number of files that are flowified, number of tests passing with Fiber...

This introduces a tool that lets you do that. The API is very simple, you execute the script with a list of tuples [key value] and it's going to create a `facts` branch and put a txt file for each fact and values over time.

```
node scripts/facts-tracker/index.js \
  "flow-files" "$COUNT_WITH_FLOW/$COUNT_ALL_FILES"
```

Test Plan:
This is tricky to test because Travis only exposes the private variables (github token) when it processes a committed file and not on branches. The reason is that otherwise anyone could send a pull requests that does `echo $GITHUB_TOKEN` and steal your token.

Given this constraint, I did all the work using two of my repos:
- https://github.com/vjeux/facts-tracker
- https://github.com/vjeux/facts-tracker-test

and am sending this pull request that should work as is /fingers crossed/, but we won't be able to test it out until it is committed.

Note that once this lands, I'm going to kill those two repos.

* Update with all the suggested changes

* Branch on a flow type in travis.yml

* Use $GITHUB_TOKEN

* properly escape it
2016-09-26 12:58:51 -07:00
jinmmd
d9957ac075 Change [入门教程] from "tutorial.html" to "tutorial-zh-CN.html" (#7789) 2016-09-26 10:39:34 -07:00
jinmmd
5331dfd1a5 Change [API参考] from "top-level-api.html" to "top-level-api-zh-CN.html" (#7790) 2016-09-26 10:39:03 -07:00
Andy Edwards
b7c70b67af Clarify manual PropType calls warning (#7777) 2016-09-22 14:59:01 +01:00
Dan Abramov
13692d59ad Update broken JSFiddle in Why React blog post (#7783)
Fixes #7782
2016-09-21 13:42:49 +01:00
Paul O’Shannessy
00ac1797d7 Adjust code to handle more availability of function.name (#7670) 2016-09-20 14:23:46 -07:00
Paul O’Shannessy
2058d47e7b [docs] Update React Rally 2016 videos link (#7771) 2016-09-19 14:26:32 -07:00
Paul O’Shannessy
7b0d5d0e74 Update website for 15.3.2
(cherry picked from commit b52ea6bd8f)
2016-09-19 11:14:30 -07:00
Paul O’Shannessy
af28c5cd73 Update Changelog & Readme for 15.3.2
(cherry picked from commit 8c7bbbfc21)

Fix formatting of 15.3.2 changelog

(cherry picked from commit c2388bf09b)
2016-09-19 11:14:16 -07:00
Ivan Zotov
2ec2d8f7f7 Fix links and ids for tips in docs (#7766) 2016-09-19 17:50:26 +03:00
Ivan Zotov
4dd554c9b7 Russian translation for style props value px of tips (#7742)
* Russian translation for style props value px of tips

* Update 06-style-props-value-px.ru-RU.md
2016-09-19 13:57:42 +03:00
Ivan Zotov
8176f4970c Russian translation for max. numbers of jsx root nodes (#7738)
* Russian translation for max. numbers of jsx root nodes

* Update 05-maximum-number-of-jsx-root-nodes.ru-RU.md
2016-09-19 13:45:09 +03:00
Ivan Zotov
7d5c70d98c Russian translation for self-closing-tag of tips (#7729)
* Russian translation for self-closing-tag of tips

* Fix next link for inline styles tip

* Update 04-self-closing-tag.ru-RU.md
2016-09-19 13:39:46 +03:00
Brandon Dail
7dfa01f9fa Revert ReactMultiChild to plain object (#7757)
Since ReactART and RN extend ReactMultiChild, changing it to a class is
a breaking change. See
https://github.com/facebook/react/pull/7736/files#r79073698
2016-09-17 10:40:23 -05:00
Uladzimir Havenchyk
65870dcaee Simplify event phases. Use explicitly 'captured' and 'bubbled'. (#7741) 2016-09-15 23:24:56 -07:00
Brandon Dail
c78464f8ea Resolve flow errors with ReactTestRenderer (#7736)
* Resolve flow errors with ReactTestRenderer

* Add whitespace between types and methods

* extend ReactMultiChild instead of using Object.assign

* Use ReactElement type from ReactElementType

* Make ReactMultiChild a class
2016-09-15 11:44:56 -05:00
Paul O’Shannessy
864bc7b939 Update ignores in flowconfig (#7722)
This ensures we ignore relative to our project root and won't be tripped up by issues where checkouts in other places result in Flow passing when it shouldn't (eg on Travis CI where the checkout path is `/home/travis/build/facebook/react`)
2016-09-14 14:57:31 -07:00
Ivan Zotov
79367b09f7 Russian translation if-else in JSX of tips (#7726) 2016-09-14 15:05:21 +03:00
Ivan Zotov
fcc37ccaa2 Russian translation for inline styles of tips (#7717) 2016-09-14 13:26:36 +03:00
Ivan Zotov
7d76bdad69 Fix Russian translation of introduction to be more technical (#7727) 2016-09-14 13:23:57 +03:00
Brandon Dail
5a3abab660 Clean up ReactTestRenderer (#7716)
* create ReactTestTextComponent fil

* create ReactTestEmptyComponent

* Use class for ReactTestRenderer

* Add flow to ReactTestRenderer
2016-09-13 21:20:41 -05:00
Stephen John Sorensen
b2297ae6c3 remove plain object warning (#7724) 2016-09-13 19:15:07 -07:00
Ben Alpert
9eba80825f Unify branches in cloneFiber (#7723) 2016-09-13 17:42:15 -07:00
Andrew Clark
6144212a86 [Fiber] Animation priority work (#7466)
* High priority work

Adds the ability to schedule and perform high priority work. In the
noop renderer, this is exposed using a method `performHighPriWork(fn)`
where the function is executed and all updates in that scope are given
high priority.

To do this, the scheduler keeps track of a default priority level.
A new function `performWithPriority(priority, fn)` changes the default
priority before calling the function, then resets it afterwards.

* Rename overloaded priority terms

"High" and "low" priority are overloaded terms. There are priority
levels called HighPriority and LowPriority. Meanwhile, there are
functions called {perform,schedule}HighPriWork, which corresponds
to requestAnimationFrame, and {perform,schedule}LowPriWork, which
corresponds to requestIdleCallback. But in fact, work that has
HighPriority is meant to be scheduled with requestIdleCallback.
This is super confusing.

To address this, {perform,schedule}HighPriWork has been renamed
to {perform,schedule}AnimationWork, and
{perform,schedule}LowPriWork has been renamed to
{perform,schedule}DeferredWork. HighPriority and LowPriority
remain the same.

* Priority levels merge fix
2016-09-13 16:46:32 -07:00
Sebastian Markbåge
3e54b28c20 Merge pull request #7344 from acdlite/fibersetstate
[Fiber] setState
2016-09-13 15:31:14 -07:00
Sebastian Markbage
27d1210c1d Log the updateQueue in dumpTree
This also buffers all rows into a single console.log call.
This is because jest nows adds the line number of each console.log
call which becomes quite noisy for these trees.
2016-09-13 15:26:48 -07:00
Sebastian Markbage
f3a2dc252e Check for truthiness of alternate
This is unfortunate since we agreed on using the `null | Fiber`
convention instead of `?Fiber` but haven't upgraded yet and this
is the pattern I've been using everywhere else so far.
2016-09-13 15:26:48 -07:00
Andrew Clark
0ca1cea26a Don't mutate current tree before work is committed.
We should be able to abort an update without any side-effects to the
current tree. This fixes a few cases where that was broken.

The callback list should only ever be set on the workInProgress.
There's no reason to add it to the current tree because they're not
needed after they are called during the commit phase.

Also found a bug where the memoizedProps were set to null in the
case of an update, because the pendingProps were null. Fixed by
transfering the props from the instance, like we were already doing
with state.

Added a test to ensure that setState can be called inside a
callback.
2016-09-13 15:26:48 -07:00
Andrew Clark
f514662ca0 forceUpdate
Adds a field to the update queue that causes shouldComponentUpdate to
be skipped.
2016-09-13 15:26:48 -07:00
Andrew Clark
d8c24cfa78 replaceState
Adds a field to UpdateQueue that indicates whether an update should
replace the previous state completely.
2016-09-13 15:26:48 -07:00
Andrew Clark
1d49237299 Update callbacks
Callbacks are stored on the same queue as updates. They care called
during the commit phase, after the updates have been flushed.

Because the update queue is cleared during the completion phase (before
commit), a new field has been added to fiber called callbackList. The
queue is transferred from updateQueue to callbackList during completion.
During commit, the list is reset.

Need a test to confirm that callbacks are not lost if an update is
preempted.
2016-09-13 15:26:47 -07:00
Andrew Clark
c6db7f73be Rename stateQueue -> updateQueue
Also cleans up some types.
2016-09-13 15:26:47 -07:00
Andrew Clark
f7dab22ac9 Ensure that setState update function's context is undefined 2016-09-13 15:26:47 -07:00
Andrew Clark
97dac74c40 Use ReactInstanceMap
Move ReactInstanceMap to src/renderers/shared/shared to indicate that
this logic is shared across implementations.
2016-09-13 15:26:47 -07:00
Andrew Clark
d218158d22 Clean up
Use a union type for the head of StateQueue.
2016-09-13 15:26:47 -07:00
Andrew Clark
691e053650 Fix stateQueue typing 2016-09-13 15:26:47 -07:00
Andrew Clark
909caccebd Clean up
Rather than bubble up both trees, bubble up once and assign to the
alternate at each level.

Extract logic for adding to the queue to the StateQueue module.
2016-09-13 15:26:47 -07:00
Andrew Clark
25d199abe0 Updater form of setState
Add support for setState((state, props) => newState).

Rename pendingState to stateQueue.
2016-09-13 15:26:47 -07:00
Andrew Clark
8b200c5e78 Use queue for pendingState
Changes the type of pendingState to be a linked list of partial
state objects.
2016-09-13 15:26:47 -07:00
Andrew Clark
94d2317b4b setState for Fiber
Updates are scheduled by setting a work priority on the fiber and bubbling it to
the root. Because the instance does not know which tree is current at any given
time, the update is scheduled on both fiber alternates.

Need to add more unit tests to cover edge cases.
2016-09-13 15:26:46 -07:00
Sebastian Markbåge
a19fede67c Merge pull request #7636 from sebmarkbage/fiberrefactor
[Fiber] Refactor Pending Work Phase and Progressed Work
2016-09-13 15:24:52 -07:00
Sebastian Markbage
52011d58b0 Restructure clone child fiber a bit to make it clearer 2016-09-13 14:58:00 -07:00
Sebastian Markbage
a7afc064bd Pass current instead of picking it up from alternate
This colocates the reliance on alternate with the scheduler, so
that we have the option to not use this, or more easily break
apart the initial mount phase into an optimized path.
2016-09-13 14:57:59 -07:00
Sebastian Markbage
8b0be68eee Progressed work 2016-09-13 14:57:59 -07:00
Sebastian Markbage
b717db00fb Add shouldComponentUpdate to functional components
I'll probably end up reverting this before the bigger release
since it is not part of the official public API. However,
it is useful to be able to compare the performance between
functional components and classes.
2016-09-13 14:57:59 -07:00
Sebastian Markbage
cc259a29e3 Explain why ReactFiber is a POJO instead of constructor 2016-09-13 14:57:59 -07:00
Sebastian Markbage
49f0c952b5 Drop childInProgress
I will try a slightly different but similar strategy.
2016-09-13 14:57:59 -07:00
Sebastian Markbage
b63cda6e85 Drop Separate findPendingWork Phase
The findPendingWork phase is the same as just walking the tree the
normal way effectively. It only makes things more complex to
think about. We might possibly be able to write a few special
branches to optimize it but for now it doesn't seem necessary.
2016-09-13 14:57:59 -07:00
Sebastian Markbage
9e52130fb7 Move priority reset to the end and search pending work in work tree
The priority level gets reset at the wrong time because I rely
on mutating it at the wrong point. This moves it to the end of
completed work as a second pass over the children to see what
the highest priority is. This is inefficient for large sets but
we can try to find a smarter way to do this later. E.g. passing
it down the stack.

This bug fix revealed another bug that I had flagged before that
we're finding work to do in the "current" tree instead of the
working tree. For trees that were paused, e.g. childInProgress
trees, this won't work since don't have a current tree to search.

Therefore I fixed findNextUnitOfWorkAtPriority to use
workInProgress instead of current.
2016-09-13 14:57:59 -07:00
tokikuch
a64ca9b697 BeforeInput is fired with a wrong text at a wrong time on IE (#7107) 2016-09-13 11:15:18 -07:00
Brandon Dail
f3569a2c31 Implement createNodeMock for ReactTestRenderer (#7649)
* Implement optional mockConfig and getMockRef

* default mockConfig, walk render tree

* Pass mockConfig to transaction

* Attach mockConfig to transaction

* type mockConfig in ReactRef

* Expect object in native component ref test

* Fix argument name for attachRefs

* Add mockConfig support to legacy refs

* Pass transaction to getPublicInstance

* Implement getMockConfig on ReactTestReconcileTransaction

* Merge defaultMockConfig and mockConfig options

* Rename mockConfig to testOptions

* Break getPublicInstnce into three lines

* createMockRef -> createNodeMock
2016-09-13 09:09:20 -05:00
Keyan Zhang
38c4ade6cc changed ReactChildrenMutationWarningHook to Object.freeze (#7455)
- only freeze children array created by createElement
2016-09-13 16:25:31 +03:00
Amanvir Sangha
616e468987 Update OWASP link in docs for dangerous innerHTML (#7710) 2016-09-13 05:29:09 -07:00
Ivan Zotov
4dd44e77f8 Add Russian translation for introduction of tips (#7690) 2016-09-13 13:36:16 +03:00
Michał Pierzchała
b87bcb96ac Proper font-family for docs input fields (#7706) (#7708) 2016-09-12 16:29:46 -07:00
Dan Abramov
3fcba2044a Fix benchmarks (#7704) 2016-09-12 21:58:00 +03:00
Flarnie Marchan
54cbe29262 Fix Flow errors in Event Plugins (#7698)
Due to a typo in PR#7667 where I put 'DispatchConfig' when the type was
'EventTypes', there were some flow errors being thrown.

Then PR#7642 fixed a bug in SimpleEventPlugin and added some untyped
methods, which threw more flow errors.

Last, while fixing this, I fixed two eslint errors in the
SimpleEventPlugin test.
2016-09-10 16:44:08 -07:00
Dmitrii Abramov
e3e03b30b2 jest@15.1.1 (#7693) 2016-09-10 15:09:14 -07:00
Ray Dai
2fc7125d49 Update 14-communicate-between-components.ko-KR.md (#7686)
Apply the same change made in #7680.
2016-09-09 11:22:56 -07:00
Paul O’Shannessy
8debf524df Revert "Add unknown property warning for use of autofocus" (#7684) 2016-09-08 13:43:57 -07:00
Nathan Hunzaker
73c50e7d00 Move mouse event disabling on interactive elements to SimpleEventPlugin. Related perf tweak to click handlers. (#7642)
* Cull disabled mouse events at plugin level. Remove component level filters

* DisabledInputUtils tests are now for SimpleEventPlugin

* Add click bubbling test

* Add isInteractive function. Use in iOS click exception rules

* Invert interactive check in local click listener. Add test coverage

* Reduce number of mouse events disabable. Formatting in isIteractive()

* Switch isInteractive tag order for alignment

* Update formatting of isInteractive method
2016-09-08 11:47:52 -07:00
Toru Kobayashi
df033180f0 Run codemod react-codemod/transforms/class again (#7679)
ref. #7321
2016-09-08 10:38:44 -07:00
Ray Dai
05cbc93401 Update 14-communicate-between-components.md (#7680)
To demonstrate multiple arguments `bind(this, arg1, arg2, ...)`, also not to pass in for than what `handleClick` needed, namely props, or maybe even pass item itself, etc.
Going to change the kor file after review.
2016-09-08 10:20:25 -05:00
Gant Laborde
90a120c603 Adding the published ReactRally videos section (#7681)
ReactRally came and went, and it was splendid.
2016-09-08 10:17:39 -05:00
Christopher Chedeau
eaefd9052a Type ReactHostOperationHistoryHook (#7672)
In order to properly type an `Operation`, we need to change the call site from having two arguments: one for `type` and one for `payload` into an object that contains both. This isn't a perf regression because we were already constructing this object in the first place and doesn't change the emitted event so shouldn't affect the dev tools.

None of the call sites are actually flow-ified so it isn't technically used but once we will, it'll make sure that we don't send random strings and payload through those very generic methods.
2016-09-07 20:08:09 -07:00
Christopher Chedeau
82598eec79 Trim and inline ReactInstanceHandles (#7676)
React IDs have been killed and there was one call site left in a test. I trimmed down the implementation to keep only what is actually used and inlined it inside of the test so we don't get more people using it in the future.
2016-09-07 20:03:56 -07:00
Flarnie Marchan
7b2d9655da Flow type event plugins (#7667)
* Type SimpleEventPlugin and TapEventPlugin

- Renamed file from 'ReactSynteticEvent' to 'ReactSyntheticEventType'
- Fills in the 'any' holes that were left in DispatchConfig type and the
  type annotations in EventPluginRegistry.
- Adds polymorphic PluginModule type and related types
- Uses hack to support indexable properties on 'Touch' type in
  TapEventPlugin

The issue in TapEventPlugin is that the code is accessing one of four
possible properties on the 'Touch' type native event using the bracket
accessor. Classes in Flow don't support using the bracket accessor,
unless you use a declaration and the syntax `[key: Type]: Type`.[1] The
downside of using that here is that we create a global type, which we
may not need in other files.

[1]: https://github.com/facebook/flow/issues/1323

Other options:
- Use looser typing or a '@FixMe' comment and open an issue with Flow to
  support indexing on regular classes.
- Rewrite TapEventPlugin to not use the bracket accessor on 'Touch'. I
  thought the current implementation was elegant and didn't want to
  change it. But we could do something like this:
```
 if (nativeEvent.pageX || nativeEvent.pageY) {
   return axis.page === 'pageX' ? nativeEvent.pageX : nativeEvent.pageY;
 } else {
   var clientAxis = axis.client === 'clientX' ? nativeEvent.clientX : nativeEvent.clientY;
   return nativeEvent[axis.client] + ViewportMetrics[axis.envScroll];
 }
```
2016-09-07 12:40:45 -07:00
Christopher Chedeau
334b8bdf16 I wrote it live! (#7663) 2016-09-06 15:18:42 -07:00
Kite
ed8a753346 Fix the HTML for package management (#7656) 2016-09-06 09:58:17 -07:00
Filip Spiridonov
0c77b2f3eb Remove unnecessary var declaration (#7666) 2016-09-06 18:31:47 +03:00
Brandon Dail
06ea71d3fd Use compositeType in warning invariant for refs (#7658) 2016-09-06 11:49:20 +03:00
hkal
6a525fdc4c Add unknown property warning for use of (#6461) 2016-09-03 18:48:23 -05:00
Dan Abramov
a09d158a7c Don't bundle ReactComponentTreeHook in production (#7653)
Fixes #7492.
This was a build size regression introduced in #7164.
2016-09-03 22:32:20 +01:00
Dan Abramov
9d9af63a6a Link to Create React App (#7654)
* Link to Create React App

* Reword
2016-09-03 18:13:30 +01:00
Nathan Hunzaker
40c90a6499 Use proper render method in static markup event listener test (#7652) 2016-09-03 17:29:12 +01:00
Paul O’Shannessy
7b247f3609 Flow: bool -> boolean (#7650) 2016-09-02 17:35:14 -07:00
Christopher Chedeau
2559030c34 Type ReactCurrentOwner (#7648)
Simpler than ReactOwner :)
2016-09-02 16:29:24 -07:00
Christopher Chedeau
a70acb37d9 Convert CallbackQueue to a class (#7647)
It turns out that flow cannot type `this` with a function constructor + prototype overrides. Turning it to a class makes flow happy and has minimal impact on the output.

In open source, we already use the loose version of the class transform and internally we have one that's outputting even less code if you have `@preventMunge` in the header.

See discussion in https://www.facebook.com/groups/2003630259862046/permalink/2098480820376989/
2016-09-02 15:27:44 -07:00
Christopher Chedeau
839697f60c Restore coverage in Travis (#7628)
We disabled coverage in Travis because the implementation was crashing ( https://github.com/facebook/react/issues/6290 ). Since we upgraded to Jest 15, the entire coverage implementation is brand new so we should give it another try.
2016-09-02 14:23:58 -07:00
Christopher Chedeau
31dd6944d3 Type ReactRef (#7600)
Nothing out of the ordinary on this one.
2016-09-02 14:16:32 -07:00
Flarnie Marchan
9a88e593ed Merge pull request #7644 from flarnie/flowifyEventPluginRegistry
Type EventPluginRegistry
2016-09-02 13:53:44 -07:00
Flarnie Marchan
3c980aaf30 Type EventPluginRegistry
This commit takes the first incremental step towards adding type checks
to the React event code. A couple of issues came up.

There is an issue with the SyntheticEvent type: Flow declares a
SyntheticEvent type[1] that lacks the non-public properties which are
used in React internals. To solve this I declared a class that extends
SyntheticEvent. This class can be expanded as we add Flow types to more
places where SyntheticEvent instances are referenced.

I'm happy to change this if folks prefer a different approach.
Some options I considered:
- Override the SyntheticEvent declaration with our own declaration
  - Pro: We can use 'SyntheticEvent' as a type just like we are used to
    when working in any other codebase.
  - Pro: No need to import any type since it's a declaration
  - Pro: Only one version of SyntheticEvent; less confusion.
  - Con: Could get out of sync with real implementation.
  - Con: Duplicates part of the type declared in Flow.
- Import the SyntheticEvent class and use that as the type
  - Pro: Keeps type definition in sync with the real implementation.
  - Con: Declaration overrides implementation so I'm not sure this would
    work.
  - Con: Have to remember to import the type.
- Declare a separate type called ReactSyntheticEvent that extends
  SyntheticEvent
  - Pro: Stays in sync with the Flow SyntheticEvent type;
    less duplication.
  - Pro: Differentiates this type from the Flow SyntheticEvent type;
    less confusion.
  - Pro: No need to import any type since it's a declaration
  - Con: Could get out of sync with real implementation.

I also ran into an issue where a variable was only non-null when
'__DEV__' is true, similar to PR #7586.[2] The work-around is to force
it to be typed non-null and add a comment documenting the reason. At
this time Flow doesn't have a better way to deal with the situation.

Next steps:
- Specific type for the 'dispatchConfig' property of SyntheticEvent
- More detailed types for PluginName and PluginModule

Lastly; note that I renamed some variables to follow the convention of
reserving PascalCase for classes, enums, and Flow types.

[1]: https://github.com/facebook/flow/blob/master/lib/react.js#L277-L293
[2]: b99eb5087b
2016-09-02 13:13:48 -07:00
Christopher Chedeau
1229a238c4 Generate SimpleEventPlugin data structures at runtime (#7616)
We used to copy and paste the same big blob many times in order for it to work with keyOf which is no longer a constraint. This pull request takes a list of all the events as string and generate those data structures at runtime.

It reduces the size of React by 1k post gzip and flow is able to extract the structure out of it :)
2016-09-02 12:57:18 -07:00
却痕
4c365ea957 docs:translate doc 11-advanced-performance to chinese (#7584) 2016-09-01 22:59:30 -04:00
Ben Alpert
0c62d121c5 Merge pull request #7634 from spicyj/flowfix
Small flow fixes
2016-09-01 17:26:08 -07:00
Ben Alpert
0722b15752 Small flow fixes 2016-09-01 15:52:29 -07:00
Kent C. Dodds
34761cf9a2 add events code walkthrough video link (#7633)
I think if we do another one of these it'd be good to turn this into a list, but this is good for now.

Thanks @spicyj!
cc @gaearon
2016-09-01 14:23:40 -05:00
Guillaume Claret
355c490653 Remove the Flow experimental.strict_type_args option (#7631) 2016-09-01 11:40:08 -07:00
Nathan Hunzaker
5c47920384 Remove String.prototype.split polyfill warning (#7629) 2016-09-01 08:44:36 -05:00
Christoph Pojer
1bd55c8cbd Merge pull request #7625 from vjeux/jest15
Update to jest 15
2016-09-01 02:56:54 +01:00
Christopher Chedeau
1a113a15c9 Update to jest 15
Jest 15 has just been released and is way more awesome: http://facebook.github.io/jest/blog/2016/09/01/jest-15.html

This pull request updates jest from version 12 to 15. Right now there's a fix in jest around Symbol that hasn't been released yet, so this will break CI and cannot be merged it. But once it ships by the end of the day, we'll be good to go :)

See comments inline for all the changes I've done.
2016-08-31 18:25:03 -07:00
Paul O’Shannessy
2e38fcf355 Add more specific link to react-addons-shallow-compare readme (#7608) 2016-08-31 15:53:30 -07:00
Paul O’Shannessy
c73d8633c3 Copy all SVG child nodes when using setting innerHTML in IE (#7618) 2016-08-31 11:50:58 -07:00
Mateusz Burzyński
51476de913 Guarded ensureScrollValueMonitoring against some malicious script on the Internet overriding native document.createEvent (fixes #6887) (#7621) 2016-08-31 15:25:18 +01:00
Ben Alpert
7d7defe30f Improve error boundaries tests (#7569) 2016-08-30 20:02:56 -07:00
Miller Medeiros
51f04fdbc1 Add checkpoint/rollback to ReactNativeReconcileTransaction (#7619) 2016-08-30 15:42:36 -07:00
Kevin Lin
c85f46320e Add 'as' keyword (#7543) (#7582)
* Add 'as' keyword (#7543)

* fix commenting to adhere to styling

* fix grammar in comment
2016-08-30 15:14:46 -07:00
Miller Medeiros
0c031c55b8 Improve error boundaries tests 2016-08-30 14:59:17 -07:00
Christopher Chedeau
f7076b7759 Kill keyOf :) (#7615) 2016-08-30 11:03:05 -07:00
Christopher Chedeau
2f9a9dc4c5 Remove keyMirror in TopLevelTypes (#7597)
This is the last callsite of keyMirror! It removes 0.5k gzipped :)

The only trick with this one is that ReactTestUtils actually iterates over the list of all the events. Instead of duplicating the logic, I used the $Enum feature of flow that lets us statically extract out the type from the dynamic value. Inside of react-dom we're no longer requiring the file directly so it doesn't bloat the file size, and we still get to have static typing, best of both worlds!
2016-08-30 09:50:16 -07:00
Christopher Chedeau
738a9e3ef2 Remove keyMirror in PropagationPhases (#7596)
See rationale in https://www.facebook.com/groups/2003630259862046/permalink/2097088000516271/
2016-08-30 09:44:14 -07:00
Paul O’Shannessy
395888435b Cleanup ReactErrorUtils (#7610)
This cleans up the Flow annotations and brings the implementations in line.
2016-08-29 20:44:47 -07:00
Michael Jackson
9fd42264fe s/npmcdn/unpkg/g (#7609)
npmcdn.com is moving to unpkg.com. Same backend, one less letter in the
domain name. Boom.
2016-08-29 19:45:31 -07:00
Duke Pham
3071f31d04 Add line breaks to examples on 10.1-animation docs per (#7606)
comments to issue #7317.
Updated JP doc examples to match other languages
Reformat to match JSX multi-line style #7550
2016-08-29 15:50:23 -07:00
Robert Kielty
ee199381de Adds minor additions clarifying questions I had reading intro tutorial (#7595) 2016-08-29 15:34:48 -07:00
Marcin Mazurek
ba84b5b0a7 Warn if input changes controlledness - also for null (#7544) (#7603) 2016-08-29 11:23:30 -07:00
Nick Raienko
5331fd00bc Ignore bundle.js for examples (#7498)
* Ignore bundle.js for examples

* Move ignored bundle.js under examples directory
2016-08-29 10:34:46 -07:00
Clay Miller
3c73463eb1 Remove non-standard 'icon' property (fixes #7430) (#7508) 2016-08-29 10:33:28 -07:00
Nik Nyby
9511b4fe29 docs: re-position comments to account for code sample width (#7602) 2016-08-29 10:08:07 -07:00
TedPowers
8397ef58db Changed to !document.documentMode (#7594) 2016-08-29 04:33:36 -07:00
Christopher Chedeau
a3e576e1bb Type Transaction (#7581)
This one is interesting because we have transaction objects being passed around everywhere in the codebase but there's actually no Transaction class. It's a "mixin" that comes to life by being Object.assigned to the prototype of a real "class" (before class was cool!). Therefore, we can't just say `var Transaction = require('Transaction'); (transaction: Transaction) => { }` because it would be the object that contains a mixin and not an instance of a transaction.

The trick I use is to export `TransactionType` and alias it to `Transaction` in the file as it doesn't actually require transaction. In case they do, we'll figure it out, but in the few files I looked at, it doesn't seem to be the case.

For the perform function, it actually typechecks pretty well!
2016-08-28 16:47:27 -07:00
Christopher Chedeau
dd0c65c6aa Remove the Mixin layer of indirection on ReactCompositeComponent (#7599)
As mentioned in https://github.com/facebook/react/pull/7581#issuecomment-242952042 we can remove the Mixin layer of indirection as it only exports a Mixin and I find it confusing.
2016-08-28 16:46:53 -07:00
Christopher Chedeau
dbe3584340 Remove the Mixin layer of indirection on ReactMultiChild (#7598)
As mentioned in https://github.com/facebook/react/pull/7581#issuecomment-242952042 we can remove the Mixin layer of indirection as it only exports a Mixin and I find it confusing.
2016-08-28 16:46:39 -07:00
Christopher Chedeau
19b8eadb24 Type PooledClass (#7578)
This one was really interesting to type as it's doing a lot of unusual JavaScript. Fortunately flow is now pretty kick ass and I've been able to mostly type it. The only missing piece is that it won't check the constructor arguments.

If you are a fb employee, you can follow the discussion here: https://www.facebook.com/groups/flowtype/permalink/1132359430146004/
2016-08-28 10:43:13 -07:00
Christopher Chedeau
fa9869b5a0 Type ReactOwner (#7587)
Incrementally type ReactInstance by adding the types of attach/detachRef.

I moved isValidOwner as a function inside of the file since it's never used externally.
2016-08-28 10:31:49 -07:00
Christopher Chedeau
c9e03f0a85 Type ReactMultiChildUpdateTypes (#7589)
As mentioned in https://www.facebook.com/groups/2003630259862046/permalink/2097088000516271/ I'm going to kill this instance of keyMirror and use a plain string instead with a type union.

The current type union is unused right now but when I type ReactMultiChild I will use it.
2016-08-28 10:31:30 -07:00
Christopher Chedeau
e3b2c6e650 Remove keyMirror in SpecPolicy (#7590)
As discussed in my RFC: https://www.facebook.com/groups/2003630259862046/permalink/2097088000516271/
2016-08-28 10:30:59 -07:00
Christopher Chedeau
a35387c030 Remove keyMirror in ComponentLifeCycle (#7591)
See rationale in https://www.facebook.com/groups/2003630259862046/permalink/2097088000516271/
2016-08-28 10:30:33 -07:00
Christopher Chedeau
84084153ed Remove keyMirror in ReactPropTypeLocations (#7592)
This one involves a bit more work as I added "phantom" flow types to a bunch of places where the type is a ReactPropTypeLocations even though those files are not `@flow` yet.

A good side effect is that `ReactPropTypeLocationNames` keys are now correctly typed, this means that they cannot go out of sync without breaking flow :)
2016-08-28 10:30:15 -07:00
Christopher Chedeau
0d927844fb Type ReactDebugTool (#7586)
Flow doesn't really support the concept of variables that are non-null but only inside of a `__DEV__` block. There's an internal post about it ( https://www.facebook.com/groups/flowtype/permalink/1132437726804841/ ) and the conclusion is that we should force it to be non-null and trust the developer to put the proper DEV checks in place.
2016-08-27 14:13:18 -07:00
Christopher Chedeau
2fb5eae372 Type ReactPerf (#7585)
We need to export FlushHistory type and I submitted a PR on flow to fix the type of console.table which is too restrictive.

I'm already starting to see the benefits of flow, I can look at random variables in the code and flow knows what shape the objects are! It's really useful to try and understand what's going on :)
2016-08-27 14:12:54 -07:00
Christophe Hurpeau
517a0dc051 doc: npm ls react is a better advice (#7513)
Refs Must Have Owner Warning
`npm ls react` is a better advice than `npm ls | grep react`
2016-08-26 23:04:00 -07:00
Christopher Chedeau
c086e5f94e Type ReactDebugTool (#7576) 2016-08-26 14:47:59 -07:00
Christopher Chedeau
09887e0311 Type ReactInvalidSetStateWarningHook (#7572) 2016-08-26 14:47:15 -07:00
Christopher Chedeau
e2ddbac35e Type ReactChildrenMutationWarningHook (#7571) 2016-08-26 14:46:57 -07:00
Christopher Chedeau
b977cf13c4 Remove unneeded declare (#7570)
It turns out that we don't need it, flow is smart enough to realize that the function is declared in the two branches :)
2016-08-26 08:42:03 -07:00
Christopher Chedeau
f784a2d50a Type ReactComponentEnvironment (#7566) 2016-08-25 20:08:20 -07:00
Christopher Chedeau
66e77f696a Fix lint errors (#7568)
In Type ReactComponentTreeHook #7504, I merged even though travis didn't report green (travis for all the fb repos has been backlogged like crazy since this morning) by manually doing `npm test` and `npm run flow` but I didn't ensure that lint was all green.

@millermedeiros pinged me about it so here's a quick fix
2016-08-25 19:16:34 -07:00
Miller Medeiros
38f74bcaf4 Support error boundaries on ReactTestRenderer (#7558) 2016-08-25 16:35:55 -06:00
Christopher Chedeau
ea494a2c10 Type ReactComponentTreeHook (#7504)
For this one, I wanted to type a non-trivial piece of the codebase and ran into the fact that we do not have types for ReactElement nor ReactInstance, so I had to create them.

I'll add comments inline
2016-08-25 15:27:03 -07:00
Christopher Chedeau
563f3bbab4 Type ReactPropTypesSecret (#7501) 2016-08-25 15:26:38 -07:00
Christopher Chedeau
a72a156f58 Type ReactElementSymbol (#7564) 2016-08-25 15:23:29 -07:00
Christopher Chedeau
03e8c0eb75 Type ReactErrorUtils (#7565) 2016-08-25 15:23:13 -07:00
Christopher Chedeau
18003578b1 Type canDefineProperty (#7500) 2016-08-25 10:46:49 -07:00
Christopher Chedeau
ad3c65186e Type ReactPropTypeLocations (#7502) 2016-08-25 10:46:26 -07:00
Christopher Chedeau
7f64baad78 Type ReactPropTypeLocationNames (#7503) 2016-08-25 10:46:15 -07:00
Christopher Chedeau
08614db025 Update flow to 0.31 (#7557) 2016-08-25 09:43:28 -07:00
Dan Abramov
a229cdba7f Ensure lifecycle timers are stopped on errors (#7548)
* Ensure lifecycle timers are stopped on errors

Fixes #7349

* Address review feedback and add an extra test
2016-08-24 19:18:32 +01:00
Dan Abramov
0a248ee7b9 Show React events in the timeline when ReactPerf is active (#7549)
* Show React events in the timeline when ReactPerf is active

This currently only seems to work on Chrome.

* Address Chrome issue
2016-08-24 18:40:16 +01:00
Paul Kehrer
7b11aa9450 Add playsInline as an allowed HTML property (#7519)
The WHATWG has unprefixed `-webkit-playsinline` as `playsinline` (see: https://github.com/whatwg/html/pull/1444) and iOS 10 intends to use it (https://webkit.org/blog/6784/new-video-policies-for-ios/).
2016-08-23 10:47:51 -07:00
NestorTejero
32e60fecdc add explicit link to http://bower.io/ (#7546) 2016-08-23 09:30:12 -07:00
Lucas
56e20b4ab5 Fix minor typo in README.md (#7540) 2016-08-21 18:36:54 -07:00
Lucas
869cb05b76 Add missing KeyUp eventType (#7533)
Fixes #7222.
2016-08-19 18:03:35 -07:00
Paul O’Shannessy
077d32cebb Update website for 15.3.1
(cherry picked from commit 199056cf1b)
2016-08-19 14:20:02 -07:00
Paul O’Shannessy
e10f83de12 Update readme for 15.3.1
(cherry picked from commit cc41ec258f)
2016-08-19 14:20:02 -07:00
Paul O’Shannessy
9af8be654b Update changelog for 15.3.1
(cherry picked from commit 3c0906ca24)
2016-08-19 14:20:01 -07:00
Greg Palmer
a8741963dc Avoid "Member not found" error in IE (#7411)
Explanation, discussion, and similar change as #7343

Addresses #7320
2016-08-19 14:43:34 -06:00
Ben Alpert
6a65960641 Improve validateDOMNesting message for whitespace (#7515)
For #5071.
2016-08-19 11:45:14 -07:00
Paul O’Shannessy
944be18357 Upgrade to fbjs v0.8.4 (#7532) 2016-08-19 10:40:03 -07:00
Alex Zherdev
11c0adcc95 Fix header link generation for non-English docs (#7497) 2016-08-18 14:55:50 -07:00
Alexandre Kirszenberg
9f5b009f05 Fix ReactTestInstance::toJSON() with empty top-level components (#7523) 2016-08-18 13:02:09 -07:00
龙海燕
db6f36bdce Update 09.2-package-management.md (#7520) 2016-08-18 08:52:07 -06:00
ventuno
a9e681a828 Warn if using React.unmountComponentAtNode on a different React instance's tree. (#7456)
* Warn when using React.unmountComponentAtNode on a different React instance's tree

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

* Adding tests.

* Implementing recommended changes.

https://github.com/facebook/react/issues/3787
2016-08-17 17:20:36 -07:00
Ben Alpert
921d8c151b Update onlyChild invariant message (#7514) 2016-08-17 13:03:31 -07:00
Dan Abramov
680685bec4 Fix slow performance of PropTypes.oneOfType() on misses (#7510)
It used to be slow whenever a type miss occurred because expensive `Error` objects were being created. For example, with `oneOfType([number, data])`, passing a date would create an `Error` object in `number` typechecker for every item.

The savings depend on how much commonly you used `oneOfType()`, and how often it had “misses”. If you used it heavily, you might see 1.5x to 2x performance improvements in `__DEV__` after this fix.
2016-08-17 10:04:56 +01:00
Jess Telford
aa48c82b0d React.Children.toArray() changes keys (#7495)
As noted by @spicyj in #5541
2016-08-15 23:43:33 -07:00
Troy DeMonbreun
3013afe2d5 Fix for #7170 (#7486)
* Write failing test

* Ensure .min and .max are set before .value

* Adjusting test for false negative

* Revert test adjustment (apparently it was only failing locally)
2016-08-15 13:38:53 -05:00
Christopher Chedeau
9a48b5ca7b Fix flow (#7499)
ReactElement requires a generic argument now and the return function of render is a ReactTestInstance and not a ReactElement.
2016-08-15 18:04:22 +01:00
Dan Abramov
48475787b4 Avoid indexOf() during unmounting a root in the hook (#7496)
* Avoid indexOf() during unmounting a root in the hook

* Check for (Map|Set).prototype.keys
2016-08-15 15:47:54 +01:00
Tanase Hagi
09f0a06b8a Add propsTypes and defaultProps example for stateless functions (#7458)
* Add propsTypes and defaultProps example for stateless functions

* Update 05-reusable-components.md

* Update 05-reusable-components.md
2016-08-14 12:04:47 -05:00
Andres Suarez
8d1e416d9a Remove last use of mapObject (#7494) 2016-08-13 20:13:56 -07:00
Andres Suarez
e5f9ae2705 Avoid object iteration when creating DOM factories (#7493) 2016-08-13 19:30:06 -07:00
Dan Abramov
db452bd20b Use ES6 Map in ReactComponentTreeHook if available (#7491)
* Use ES6 Map in ReactComponentTreeHook if available

* Make getRootIDs fast again

* Only use native Map
2016-08-13 21:43:18 +01:00
jaaberg
fdc91e016f Fix typo in changelog (#7468) 2016-08-13 13:45:04 -05:00
Dan Abramov
a56e105081 Don't define key or ref dummy props if none were provided (#7488)
* Don't define key or ref dummy props if none were provided

This fixes a performance regression.

* Style nit
2016-08-13 19:36:57 +01:00
Dan Abramov
a73886456e Fix ReactComponentTreeHook.getRegisteredIDs() to work with inlined content (#7490)
I broke this in #7463: parseInt() cuts off #text at the end.
Changing to just use negative numbers instead.
2016-08-13 19:36:21 +01:00
Dan Abramov
cba2b19b84 Remove ReactDOMInstrumentation (#7481)
Its events are not being used anywhere.
2016-08-12 20:09:27 +01:00
Dan Abramov
4b734f7a02 Improve DEV performance in Chrome (#7483)
* Ensure this._domID is always a number

* Ensure this._rootNodeID is always a number
2016-08-12 18:34:46 +01:00
Sebastian Markbåge
c8f7215b20 Use aliasify everywhere instead of browserify-global-shim (#7476)
I already had to aliasify to have better control over the requires
so we might as well do it everywhere for consistency.

This probably makes it easier to rebase the rollup work too
because aliases seems to be how you solve this in that world.
2016-08-11 20:17:37 -07:00
Sebastian Markbåge
1c5a639c37 Require the isomorphic React instead of internals from renderers (#7473)
This is needed for flat builds. It also lets us get rid of a bunch
of special cases in the build scripts.

It also allow us to just copy the source files into React Native
instead of having to build first to resolve the special cases.
2016-08-11 18:56:55 -07:00
Dan Abramov
0e976e136c Consolidate hook events (#7472)
* Remove onBeforeMountComponent hook event

It is unnecessary.
We now pass the element as part of onInstantiateComponent, and it can't change before mounting.

* Remove onComponentHasMounted hook event

It is unused after #7410.

* Replace on(Begin|End)ReconcilerTimer hook events

We already have onBeforeUpdateComponent.
Let's just have on(Before?)(Mount|Update|Unmount)Component and stick with them.

This removes double event dispatches in some hot spots.

* Remove onComponentHasUpdated hook

The tests still pass so presumably it was not necessary.

* Add missing __DEV__ to TestUtils code

* Replace on(InstantiateComponent|SetParent) with onBeforeMountComponent

This lets us further consolidate hooks.
The parent ID is now passed as an argument to onBeforeMountComponent() with the element.

* Remove onMountRootComponent hook event

It is unnecessary now that we pass the parent ID to onBeforeMountComponent.

* Use parentDebugID = 0 both for roots and production

This removes some awkward branching.
2016-08-11 19:35:50 +01:00
Sebastian Markbåge
f7e0db9a18 Build React DOM Fiber package (#7173)
This builds a `react-dom-fiber.js` bundle which exposes ReactDOMFiber.
This allows early experiments with the new Fiber reconciler.

I also expose it in the npm package through `react-dom/fiber`.
2016-08-10 18:45:14 -07:00
Sebastian Markbåge
0f004efce2 Build renderers into their individual npm packages (#7168)
This copies modules into three separate packages instead of
putting it all in React.

The overlap in shared and between renderers gets duplicated.

This allows the isomorphic package to stay minimal. It can also
be used as a direct dependency without much risk.

This also allow us to ship versions to each renderer independently
and we can ship renderers without updating the main react package
dependency.
2016-08-10 18:17:49 -07:00
Sebastian Markbåge
c06a68a10b Mock ReactDOM for Fiber Tests (#7206)
We currently write all our tests against the DOM implementation.
I need a way to run the Fiber tests against it. But I don't want
to take on any package dependencies on Fiber modules yet.

There's a problem with jest right now where you can't globally
mock modules that already exist. So I have to add a global call
to jest.mock.

Luckily we already have a way to test the useCreateElement paths
using a feature flag. I won't activate this flag in travis until
it passes, but the idea is to run all three variants in travis.

I'm not sure that invoking rAF and rIC synchronously is the best
way to test this since it doesn't capture the backwards
compatibility aspect. I.e. the fact that people might be relying
on the synchronous nature in real apps too. It's a start.

Ideally, jest would have these built-in.
2016-08-10 17:44:36 -07:00
Dan Abramov
1f31357a2e Remove unnecessary indirection and events from the hooks (#7464)
* Remove unnecessary indirection from the tree hook

* Replace onSetDisplayName, onSetOwner, onSetText with one event

Less events is better.
onSetDisplayName, onSetOwner, and onSetText only existed because we didn't initially track elements.

* Remove unused variables
2016-08-11 00:19:09 +01:00
Dan Abramov
afa27bc4d5 Fix unmounting performance regression in __DEV__ (#7463)
* Comment previous occurrences of this issue

* Fix DEV performance regression in V8

* Extract try/catch into a separate function when calling hooks
2016-08-10 20:14:59 +01:00
Dan Abramov
178cb7d339 Prevent performance regression in DEV due to warning arguments (#7461)
* Prevent internal performance regression

This only affects Facebook website, not open source version of React.

On the Facebook website, we don't have a transform for warnings and invariants.
Therefore, expensive arguments will be calculated even if the warning doesn't fire.
This fixes a few cases where that calculation might be more expensive than usually.

In my testing, this brings down average row click time in Power Editor from ~300ms to ~220ms in __DEV__ (vs ~40ms in prod).

* Put warning() that shows up in profile behind condition
2016-08-10 19:52:46 +01:00
Keyan Zhang
5514ea369d Fix memory leak in ReactChildrenMutationWarningHook for SSR (#7410)
* corrected ReactChildrenMutationWarningHook's name

* changed `onComponentHasMounted` to `onMountComponent`

and get element from `ReactComponentTreeHook` instead of keeping an internal store
2016-08-10 19:50:18 +01:00
Paul O’Shannessy
c848b65378 Remove unused createHierarchyRenderer (#7454) 2016-08-09 16:03:24 -07:00
Sebastian Markbåge
ca9167c202 Include React itself in the list of shims (#7453)
Without this we end up bundling all of the isomorphic React into
the DOM bundle. This was fixed in #7168 too but I'll just do an
early fix to ensure that #7168 is purely an npm change.
2016-08-09 15:33:34 -07:00
Sebastian Markbåge
34c4474472 Fix trailing build issues (#7450)
Use relative path for addons UMD shim module

Use explicit top level wrapper marker for top level elements
2016-08-09 12:52:15 -07:00
Sebastian Markbåge
8ef00dbb7d Bundle DOM renderers into their individual UMD bundles (#7164)
* Cut out isomorphic dependencies from the renderers

These files reaches into isomorphic files.

The ReactElement functions are exposed on the React object anyway
so I can just use those instead.

I also found some files that are not shared that should be in
renderers shared.

* Found a few more shared dependencies

renderSubtreeIntoContainer is only used by the DOM renderer.
It's not an addon.

ReactClass isn't needed as a dependency since injection doesn't
happen anymore.

* Use a shim file to load addons' dependencies on DOM

By replacing this intermediate file we can do the lazy loading
without needing any lazy requires. This set up works with ES
modules.

We could also replace the globalShim thing with aliased files
instead for consistency.

* Bundle DOM renderers into their individual UMD bundles

Instead of exposing the entire DOM renderer on the react.js
package, I only expose CurrentOwner and ComponentTreeDevtool which
are currently the only two modules that share __state__ with the
renderers.

Then I package each renderer in its own package. That could allow
us to drop more server dependencies from the client package. It
will also allow us to ship fiber as a separate renderer.

Unminified DEV            after     before
react.js                  123kb     696kb
react-with-addons.js      227kb     774kb
react-dom.js              668kb     1kb
react-dom-server.js       638kb     1kb

Minified PROD             after     before
react.min.js               24kb     154kb
react-with-addons.min.js   37kb     166kb
react-dom.min.js          149kb     1kb
react-dom-server.min.js   144kb     1kb

The total size for react.min.js + react-dom.min.js is +19kb larger
because of the overlap between them right now. I'd like to see
what an optimizing compiler can do to this. Some of that is fbjs
stuff. There shouldn't need to be that much overlap so that's
something we can hunt. We should keep isomorphic absolutely
minimal so there's no reason for other React clones not to use it.
There will be less overlap with Fiber.

However, another strategy that we could do is package the
isomorphic package into each renderer bundle and conditionally
initialize it if it hasn't already been initialized. That way
you only pay an overlap tax when there are two renderers on the
page but not without it. It's also easier to just pull in one
package. The downside is the versioning stuff that the separate
npm package would solve. That applies to CDNs as well.

ReactWithAddons is a bit weird because it is packaged into the
isomorphic package but has a bunch of DOM dependencies. So we have
to load them lazily since the DOM package gets initialized after.
2016-08-09 12:39:03 -07:00
B.Orlov
7d57c1f0c1 Fix batchedUpdates return value (#7444) 2016-08-09 10:26:29 -07:00
Robert Martin
43674d989d Capitalize AJAX (#7435) 2016-08-08 16:24:30 -07:00
Robert Chang
0833d89783 change a word in performance docs (#7442) 2016-08-08 16:10:28 -07:00
Joseph Savona
ba2230df29 Fix link formatting on Relay blog post (#7434) 2016-08-05 14:54:34 -07:00
Sebastian Markbåge
a8c8191264 Merge pull request #7248 from sebmarkbage/fibercleanup
[Fiber] Various minor tweaks and a few big ones
2016-08-05 14:40:27 -07:00
Sebastian Markbage
af7dd8e0a1 Move wip fibers to childInProgress
This took a while to figure out, but we need to be able to store
children that are currently being worked on separately from the
current children. We always need a canonical "current" children
so that we can update them. However, we also need a different set
that we're currently working on so that we have a way to get to
already progressed work.

This solve the starvation problem in the first render because now
we can reach children that were never rendered and have a place
to store their progressed work on. The unit test changes tests
this.

This lets us get rid of the hasWorkInProgress flag.

When we reconcile new children we need to reconcile them against
progressed work so that we can reuse it. The progressed work is
"work in progress" nodes. So in that case we need to mutate
instead of clone, to preserve the invariant that only two versions
exist at any given point. This effectively forks the
ReactChildFiber implementation.
2016-08-05 14:33:48 -07:00
Sebastian Markbage
94ed00740b Introduce shouldComponentUpdate in Fiber
It is important to be able to use this since it avoids starvation
problems if you can reuse partially completed work.
2016-08-05 14:31:47 -07:00
Sebastian Markbage
de6069e550 Reuse the correct child and side-effects when reusing partial work
We need to use the *other* child because we reset it to the
current one on the way up.

We also need to reset the first/last side-effects to that of the
children so that we're committing the right thing.
2016-08-05 14:31:46 -07:00
Sebastian Markbage
9fca812139 Fix NoWork bug
Thanks @acdlite. Add comment about future unit test coverage.

This was actually hiding the fact that we are only able to reuse
existing work if it was marked as completely finished which it
won't be if we reuse its pending priority.

However, we should be able to bail out even if there is work
remaining in a subtree.
2016-08-05 14:31:46 -07:00
Sebastian Markbage
48b7b2c67c Add note about potential future bugs 2016-08-05 14:31:46 -07:00
Sebastian Markbage
5ac87e0d0f When a reconciliation gets down prioritized, reuse children
When we downprioritize children we need to remember to reuse the
old children in the update side-effect.

This whole set up is very unfortunate since we can have children
in our active tree that never actually finished rendering. This
strategy might be fundamentally flawed, not sure.
2016-08-05 14:31:46 -07:00
Sebastian Markbage
d0838797a3 Set pendingProps in cloneFiber for symmetry
This might become confusing later but is unreachable today. That's
because existing pendingProps only matter when a clone is updated,
but this path can only matter when it is created.
2016-08-05 14:31:46 -07:00
Sebastian Markbage
5c094fb5d1 Don't reset next work pointer for lower priority work
If the current work is higher priority than the new work, then
don't bother resetting the unit of work pointer since it won't
affect the execution order.
2016-08-05 14:31:46 -07:00
Sebastian Markbage
7e9b958662 Reuse old props for the update if there are no new props 2016-08-05 14:31:46 -07:00
Sebastian Markbage
de4a7b972b Move all imports to closures in Fiber
I'm paranoid about inline-ability so I use this pattern of adding
a constant to the closure everywhere.

ES6 modules help avoid that but we can't use that consistently
because of the dependency injection so instead I opt for making
this explicit everywhere.

Grep: \b[a-zA-Z_$\d]+\.[a-zA-Z_$\d]+\(
2016-08-05 14:31:46 -07:00
Sebastian Markbage
e0e4954061 Remove console.logs from Fiber
The code is sufficiently complex now that this is more noise than
helpful. Will just temporary explicit logs in the future.
2016-08-05 14:31:46 -07:00
Sebastian Markbage
00084f5503 [Fiber] Rudimentary class support
Mostly just to get started with unit testing.
2016-08-05 14:31:46 -07:00
Sebastian Markbage
28dc560d0f [Fiber] unmountComponentAtNode
Add unmounting hook.
2016-08-05 14:31:45 -07:00
Joseph Savona
aca62e7d24 Relay blog post (#7433) 2016-08-05 10:55:06 -07:00
Paul O’Shannessy
b910a1478d [docs] Use appropriately sized og:image (#7417)
Also runs through Imageoptim for smaller size.
2016-08-03 14:08:44 -07:00
Paul O’Shannessy
d1cff59ddc Fix JSON in package.json (#7408) 2016-08-02 16:05:03 -07:00
Paul O’Shannessy
c5cb5b8bd8 Specify "files" field for npm packages (#7396) 2016-08-02 15:11:45 -07:00
Paul O’Shannessy
1bb257de93 [docs] Use npmcdn (#7394) 2016-08-02 13:44:06 -07:00
Keyan Zhang
8af6f9e5a2 Fix <input> with type date/time/etc. issue on mobile browsers (#7397)
Fix <input> with type date/time/etc. issue on mobile browsers
2016-08-02 12:56:05 -07:00
Timothy Yung
0fb8febd0a Change trackedTouchCount invariant into a console.error (#7400)
* Change `trackedTouchCount` invariant into a console.error

* Fix ResponderEventPlugin lint warning
2016-08-01 22:42:30 -07:00
Nathan Hunzaker
8aed0cd67e Add some semicolons for linting. (#7390) 2016-08-01 21:17:58 +01:00
Keyan Zhang
328fc75bc9 Merge pull request #7381 from keyanzhang/rename-hooks
Rename Devtool to Hook
2016-08-01 11:42:33 -07:00
Nathan Hunzaker
2823dfcbfb Avoid "Member not found exception" in IE10 (#7343)
'change' custom events raise "Member not found" in <= IE10. To
circumvent this, the SyntheticEvent class now checks for "typeof
event.cancelBubble !== 'unknown'". This eliminates this exception and
maintains the expected bubbling functionality.

Addresses #7320.
2016-07-31 13:59:51 -07:00
Keyan Zhang
bba0d992d8 temporary compatibility fix 2016-07-29 16:49:44 -07:00
Paul O’Shannessy
57ae3b389d [docs] add permalink for newly translated page (#7380) 2016-07-29 16:24:43 -07:00
Keyan Zhang
81f554817c renamed methods (devtool -> hook) 2016-07-29 16:12:23 -07:00
Keyan Zhang
f2fc182250 renamed modules (devtool -> hook) 2016-07-29 16:12:23 -07:00
Paul O’Shannessy
092f5ae867 Update website for 15.3.0
(cherry picked from commit cc01d1be33)
2016-07-29 12:17:41 -07:00
Paul O’Shannessy
7d4e97f9e5 Update readme for 15.3.0
(cherry picked from commit 7251f6a6e9)
2016-07-29 12:17:41 -07:00
Paul O’Shannessy
26f55b4dbb Changelog for 15.3.0
(cherry picked from commit f7837682b4)
2016-07-29 12:17:41 -07:00
Paul O’Shannessy
25aa5e36c9 [docs] Add permalink to PropTypes warning page (#7377)
Followup to #7219, which was created before the Jekyll 3 upgrade, which needs the permalink field.
2016-07-29 12:14:01 -07:00
Dan Abramov
8329856a3f Add “Don't Call PropTypes” warning (#7219) 2016-07-29 12:04:33 -07:00
Dustan Kasten
7e874f59f5 ReactTestRenderer package (#7362) 2016-07-28 21:39:05 -07:00
Keyan Zhang
c9dc2ab0ec fixed incorrect doc location (#7365) 2016-07-28 11:03:07 -07:00
Cheng Lou
0292d34047 PropTypes: distinguish nullable from optional object field (#7291)
* PropTypes: distinguish nullable from optional object field

This gives a more precise message (no type semantics change) to the case of passing a field in an object, but whose value is `null`:

Before:

```js
propTypes: {
  foo: React.PropTypes.number.isRequired
}
```

Would scream "Required prop `foo` was not specified in `MyComp`".

Now it'll be "Required prop `foo` was specified in `MyComp`, but its value is `null`.".

Works as expected in nested objects.

This fixes the issue of a component transitively passing a `null`, specifying the correct field to the child but have the child tell it that it didn't provide the prop.

Optional field and nullable are two different things anyway.

* Add missing test case.

* Reword messages.
2016-07-26 16:26:51 -07:00
Jackson Huang
fe5128fe8f Create 02-displaying-data.zh-TW.md (#7284)
* Create 02-displaying-data.zh-TW.md

* Update 02-displaying-data.zh-TW.md
2016-07-26 13:45:12 -07:00
Ben Alpert
30aa84181d Remove unused unmountIDFromEnvironment (#7259)
I got rid of the need for this a few months ago.
2016-07-25 23:34:22 -07:00
Patrick Finnigan
85dcbf83c5 fix doc for React Native mountComponent (#7313) 2016-07-25 16:19:15 -07:00
Gert Hengeveld
9d33fb0b76 Added ReactNL conference (#7342) 2016-07-25 16:17:05 -07:00
Amjad Masad
d157827311 "transient dependencies" -> "transitive dependencies" (#7341)
I think that's what you meant -- although with npm dependencies are kind of transient :P
2016-07-25 16:16:11 -07:00
scloudyy
5b06667efd Update docs zh cn (#7254)
* update 03-interactivity-and-dynamic-uis.zh-CN

* update 04-multiple-components.zh-CN

* update 05-reusable-components.zh-CN

* updat 06-transferring-props.zh-CN

* update 07-forms.zh-CN

* update 08-working-with-the-browser.zh-CN

* update 08 and 08.1

* update 09-tooling-integration.zh-CN

* revise

* don't use ES6
2016-07-25 12:23:45 -07:00
Veljko Tornjanski
0805921883 Wording change in doc (#7348) 2016-07-25 11:59:15 -07:00
Keyan Zhang
484f96bb61 Merge pull request #7321 from keyanzhang/codemod-es6-component
Codemod tests from createClass to ES2015 classes
2016-07-23 15:22:35 -07:00
Keyan Zhang
4d8a5bcd5c codemodded tests from createClass to ES2015 classes
- reverted more files under classic
2016-07-23 15:16:12 -07:00
Keyan Zhang
bf26e70374 upgraded babel-plugin-transform-class-properties
- babel/babel#3589 fixed inferring class name
2016-07-23 15:16:12 -07:00
Nathan Hunzaker
08a0895887 Avoid validation warning when inputs change type (#7333)
For controlled inputs, `updateWrapper` was getting called before the
`type` prop had a chance to update. This could lead to a case where
switching from the `text` to `number` type caused a validation error
that would prevent the proper input value from being assigned.

This commit moves the call to `ReactDOMInput.updateWrapper` below
`_updateProperties` to avoid this situation.
2016-07-22 18:38:29 -07:00
Seyi
1fc5f284c0 Blog post: Fixed typo in post (#7336) 2016-07-22 12:40:46 -07:00
Paul O’Shannessy
7614c12ed7 Host our own images for the blog, use https links (#7339) 2016-07-22 12:36:07 -07:00
Steven Syrek
c0b7d81872 Correct grammatical error (subject-verb agreement) (#7338)
"It is worth repeating: there is no configuration files or complicated folder structures." > "It is worth repeating: there are no configuration files or complicated folder structures."
2016-07-22 19:13:11 +01:00
Dan Abramov
6e3b69f055 Add blog post 2016-07-22 16:58:33 +01:00
Keyan Zhang
3fd582643e improved warning in ReactUpdateQueue (#7326) 2016-07-21 12:41:31 +01:00
Keyan Zhang
fc04e853f8 Add babel-plugin-transform-class-properties (#7322)
* added babel-plugin-transform-class-properties

* removed babel-plugin- prefix
2016-07-20 17:39:10 -07:00
Paul O’Shannessy
5ac1bae58e Switch Travis CI to Trusty Beta (#7309) 2016-07-20 11:47:16 -07:00
Alex Zherdev
8bcea5310e Mention actual prop type in element type checker (#7319) 2016-07-20 19:16:55 +01:00
Paul O’Shannessy
5e3959e071 Merge pull request #7308 from zpao/jekyll3
Upgrade to Jekyll 3
2016-07-19 16:33:59 -07:00
Paul O’Shannessy
5e18eb3487 Finish Jekyll 3 Upgrade
- Reverts change to use sectionid on layouts (was unreliable), using config to make sure that's specified on all pages that need it
- Adds permalinks to all other pages so that og data is correct
- Corrects some permalinks that were in correct (translations)
2016-07-19 15:08:58 -07:00
Daniel Lo Nigro
6d537e939f Upgrade to Jekyll 3
Full list of changes is at https://jekyllrb.com/docs/upgrading/2-to-3/. The tl;dr of it is:
 - Relative permalinks were removed, so all the files in the `docs` subdirectory need their permalink to be prefixed with `docs/`
 - `post` and `page` types were renamed to `posts` and `pages` respectively
 - `jekyll-paginate`, `pygments` and `redcarpet` are all now optional, so I needed to explicitly add it to the Gemfile. Jekyll now uses `rouge` rather than `pygments` for syntax highlighting, but rouge does not support highlighting individual lines (`hl_lines`) so we need to continue using Pygments.
 - Layout metadata (eg. `sectionid`) is now on a `layout` variable rather than `page`

Tested the following pages and confirmed that they all work:
 - "Docs" link (getting started page): http://127.0.0.1:4000/react/docs/getting-started.html
 - Downloads: http://127.0.0.1:4000/react/downloads.html
 - Tutorial: http://127.0.0.1:4000/react/docs/tutorial.html
 - A few pages under the "docs" subdirectory, to confirm they're working properly:
    - http://127.0.0.1:4000/react/docs/addons.html
 - http://127.0.0.1:4000/react/docs/why-react.html
 - http://127.0.0.1:4000/react/docs/create-fragment.html
 - A few tips:
    - http://127.0.0.1:4000/react/tips/false-in-jsx.html
 - http://127.0.0.1:4000/react/tips/style-props-value-px.html
 - Non-English versions of the page:
    - http://127.0.0.1:4000/react/docs/getting-started-it-IT.html
    - http://127.0.0.1:4000/react/docs/getting-started-ja-JP.html
2016-07-19 12:18:49 -07:00
Paul O’Shannessy
c3ce0f24c9 Update website for 15.2.1
(cherry picked from commit ea880f2e2c)
2016-07-19 12:17:34 -07:00
Paul O’Shannessy
1252739c84 Update readme for 15.2.1
(cherry picked from commit 5597ca70be)
2016-07-19 12:17:34 -07:00
Paul O’Shannessy
cae816cf09 changelog for 15.2.1
(cherry picked from commit 6b19617333)

Changelog fixes

(cherry picked from commit dfb5cc306f)

Fix typo in previous changelog update

(cherry picked from commit 57a1ebb809)
2016-07-19 12:17:20 -07:00
Sassan Haradji
1cc9a5dc71 prevent spamming warnings related to performance measurement code (#7299)
* prevent spamming warnings related to performance measurement code

* minor changes in names and such

* -

* -
2016-07-19 11:46:12 +01:00
Dan Abramov
15ae5857f6 Eagerly evaluate inline requires in Jest (#7245)
* Eagerly evaluate inline requires in Jest

I inlined some requires in #7188 to fix the build size regression.
However this caused an issue with Jest due to it resetting module registry between tests.

This is a temporary fix to #7240.
It should be reverted as part of #7178.

* Make the hack work in all environments
2016-07-16 20:51:25 +01:00
Dan Abramov
6c9da39514 Clarify the section about dogfooding (#7292) 2016-07-16 15:02:20 +01:00
Dan Abramov
dc11e615ad Minor tweaks to Design Principles (#7283) 2016-07-14 21:29:11 +01:00
Dan Abramov
9d995720da Add Design Principles to the docs (#7282) 2016-07-14 20:37:28 +01:00
Dan Abramov
27d7592cf6 Fix TestUtils crash with NODE_ENV=production (#7246)
I caused it with #7189.
We generally don’t recommend running TestUtils in production environment but this is technically a regression.

Fixes #7231.
2016-07-14 12:02:39 +01:00
Fernando Alex Helwanger
f6d4293003 Add mixins property to context example (#7277) 2016-07-14 10:43:47 +01:00
Troy DeMonbreun
fc04310792 Fix #7099 (#7251)
* Set step prop before value prop

* Embed comments on .step sequence behavior
2016-07-13 13:28:14 -07:00
Paul O’Shannessy
0bfaf5156d [docs] Follow up to 6972 - update docs code (#7278) 2016-07-13 13:17:09 -07:00
segmentationfaulter
bf0572dde7 Update 03-interactivity-and-dynamic-uis.md (#6972) 2016-07-13 13:14:41 -07:00
Mert Kahyaoğlu
2da50a0f18 Renaming: ReactDOM (#7265)
Rename React with ReactDOM
2016-07-13 12:59:02 -07:00
Brandon Dail
cccef3c683 Add referrerPolicy to HTMLDOMPropertyConfig (#7274) 2016-07-13 11:56:57 -07:00
Dan Abramov
f02cbba9fd Fix typos in “Mixins Considered Harmful” (#7275)
* Fix typos in “Mixins Considered Harmful”

* Use consistent code style
2016-07-13 18:46:21 +01:00
Dan Abramov
b0136b37c5 Add a new blog post about mixins (#7273) 2016-07-13 17:40:53 +01:00
Keyan Zhang
5103e1d6a1 warn for using maps as children with owner info (#7260) 2016-07-13 08:29:42 -07:00
Ben Alpert
caec8d5ce7 Test renderer improvements (#7258)
Adds `.update(newElement)` and `.unmount()` and makes children reorders and composite type swapping work.

Part of #7148.
2016-07-12 22:35:31 -07:00
Ben Alpert
e5513eceff Update benchmarks to be more realistic polymorphically (#7255)
Previously, the extract-components script would create the same number of layers of composites as the page it captures, but it would output a new class for each time any composite is used (since we don't want to replicate all the component logic).

I changed the script to output a single type for each type in the input -- and each generated component takes an index for which output it should return. This should be closer to how the original code behaves, especially with respect to VM function call lookups where the amount of polymorphism makes a difference.

I re-recorded the benchmarks with the new scripts. They run significantly faster:

```
Comparing old.txt (control) vs new.txt (test)
Significant differences marked by ***
% change from control to test, with 99% CIs:

* ssr_pe_cold_ms_jsc_jit
    % change: -41.73% [-43.37%, -40.09%]  ***
    means: 39.3191 (control), 22.9127 (test)
* ssr_pe_cold_ms_jsc_nojit
    % change: -44.24% [-46.69%, -41.80%]  ***
    means: 45.8646 (control), 25.5764 (test)
* ssr_pe_cold_ms_node
    % change: -45.61% [-47.38%, -43.85%]  ***
    means: 90.1118 (control), 49.0116 (test)
```

This is probably in part due to the changes here, but also the page I captured has changed somewhat in the meantime and there seem to be slightly fewer components in the hierarchy, so they're not really comparable. But going forward we can use this benchmark which should be more accurate. I also included an identical copy that uses stateless functional components so we can test optimizations to those later.
2016-07-12 19:32:51 -07:00
Kent C. Dodds
12bc80a6dc Add link to video chat with @spicyj (#7252) 2016-07-12 14:42:19 -07:00
Zac Smith
473097144c Remove uneccesary colon (#7238)
Only use a colon after a statement that is a complete sentence, like [Grammer Girl says](http://www.quickanddirtytips.com/education/grammar/colons).
2016-07-12 11:19:07 -07:00
Varayut Lerdkanlayanawat
45223dc8bf Reformat event names in Media Events section (#7250) 2016-07-12 10:10:29 -07:00
Usman
c52a2b9ab0 Fixed all eslint warnings (#7230) 2016-07-11 17:47:41 -07:00
Paul O’Shannessy
92492e08b2 Merge pull request #7229 from zpao/blog-post-errorcodes
Blog post for error codes
2016-07-11 17:41:41 -07:00
Keyan Zhang
f5a11dcc3a Blog post for error codes 2016-07-11 17:39:12 -07:00
Samy Al Zahrani
9a80d42817 Add xmlns and xmlns:xlink attributes (#6471) 2016-07-09 13:32:53 +01:00
Dan Abramov
64e7602b3b Fix unmounting performance regression in V8 (#7232)
As reported in #7227, unmounting performance regressed with React 15.
It seems that `delete` has become much slower since we started using numeric keys.
Forcing dictionary keys to start with a dot fixes the issue.
2016-07-09 01:32:20 +01:00
Brandon Dail
b6e1eb2718 Inject default batching after pending transactions (#7033) 2016-07-08 18:52:14 +01:00
Dan Abramov
1a0e3a3215 Make ReactPerf.start() work during reconciliation (#7208)
* Add failing test demonstrating a ReactPerf warning

* Make the failing ReactPerf test more precise

* Make ReactPerf.start() work during reconciliation

* Reorder lifecycle methods for greater clarity

* Fix memory leak

* Error boundaries should not break ReactPerf

* Put onBeginFlush/onEndFlush into transaction wrappers

This looks cleaner even though it is not strictly necessary.
We still call them manually for unmounting because it doesn't have a transaction.
2016-07-07 19:41:30 +01:00
saiyagg
21ce27161d Remove duplicate line (#7210) 2016-07-07 13:26:17 +01:00
Ben Alpert
c8fbdac227 Add React.PureComponent (#7195)
This provides an easy way to indicate that components should only rerender when given new props, like PureRenderMixin. If you rely on mutation in your React components, you can continue to use `React.Component`.

Inheriting from `React.PureComponent` indicates to React that your component doesn't need to rerender when the props are unchanged. We'll compare the old and new props before each render and short-circuit if they're unchanged. It's like an automatic shouldComponentUpdate.
2016-07-06 13:24:44 -07:00
Andrey Okonetchnikov
0d892c03da Do not render name attribute on INPUT if it is not supplied. Closes #7198. (#7199) 2016-07-06 10:11:46 -07:00
Paul O’Shannessy
5c737b9550 Don't detach value from defaultValue for submit/reset inputs (#7197) 2016-07-05 16:39:43 -07:00
Dan Abramov
d2ff462b79 Pass shouldHaveDebugID flag to instantiateComponent (#7193)
* Add failing tests for #7187 and #7190

* Pass shouldHaveDebugID flag to instantiateComponent

This allows us to remove a hack that was added in #6770 and caused #7187 and #7190.

* Move logic for choosing whether to use debugID outside instantiate
2016-07-06 00:22:24 +01:00
Brandon Dail
2c93a41580 Use hardcoded value for PropType secret (#7194)
Rename secret!
2016-07-06 00:22:01 +01:00
Sebastian Markbåge
4f7a38c3b7 Move error boundaries test into reconciler (#7166)
The src/core folder moved while this PR was pending so this file
didn't move with it.

Let's get rid of this annoying top level folder.
2016-07-05 15:09:13 -07:00
Paul O’Shannessy
26ed910f28 Import warnings that currently live in gists. (#7175) 2016-07-05 13:52:58 -07:00
Marshall Bowers
69703e04d5 Gulp: lint, flow, and version-check (#7174)
* Add plugin loading for gulp

* Convert `lint` task to gulp

* Convert `flow` task to gulp

* Convert `version-check` task to gulp

* Add missing semicolons
2016-07-05 13:30:09 -07:00
Timothy Yung
2b226f5fa6 Revise ResponderTouchHistoryStore Error Handling (#7143)
Touch behavior is inconsistent across different platforms, and ResponderTouchHistoryStore currently fatals when assumptions are broken. In addition, the behavior differs between development and production.

This pull request does a few things to make ResponderTouchHistoryStore easier to deal with:

Adds Flow to keep the TouchEvent, Touch, and TouchRecord types straight.
Changes behavior to be consistent across environments. This means either always throwing or never throwing (and making use of warning and console.error as appropriate).
When an orphaned move or end event is received, print debug information and ignore it instead of crashing and burning.
2016-07-05 13:15:58 -07:00
Brandon Dail
95ac239cf3 Warn if PropType function is called manually (#7132)
* Warn if PropType function is called in production

* Check if console is undefined before warning

* Randomize value of ReactPropTypesSecret

* Remove dev environment tests

* Rename typeCheckPass to productionWarningCheck

* Rename productionWarningCheck to expectWarningInProduction

* Call toString on Math.random()

* Rename test block for React type checks

* Make sure warning isnt emitted for failing props

* Cache warning by component and prop, warn in dev

* Pass ReactPropTypesSecret to internal checks

* Move tests to ReactPropTypes-test.js

* Update the warning message to include link

* Do not test warning for unions  with invalid args
2016-07-05 20:02:50 +01:00
Dan Abramov
5d31ebcf5f Disable DebugTools in production (#7189) 2016-07-05 19:41:45 +01:00
Keyan Zhang
48ccab788b Fixed PR link 2016-07-05 11:21:31 -07:00
Dan Abramov
4aa860e1bb Mention @Aweary’s #6933 in 15.2.0 changelog 2016-07-05 19:10:38 +01:00
Dan Abramov
36734f4d37 Add link to @troydemonbreun’s contribution
We missed this PR in the changelog
2016-07-05 18:54:36 +01:00
Christopher Chedeau
309215fc40 [flow] isTextInputElement (#7075)
Summary:

I had to cast into any because flow doesn't think that checking the lowercase version of nodeName is a valid way to refine the variable from HTMLElement to HTMLInputElement. I'm also not confident enough in changing the implementation to an instanceof HTMLInputElement to please flow. It also takes care of the null check in the process.

The `nodeName &&` condition wasn't useful since the two branches are checking it against concrete values and actually makes the type different since nodeName is not a boolean per se. I replaced them with if conditions to make it clearer what it actually did instead of doing boolean logic tricks.

It is unclear why I had to type supportedInputTypes, see this internal post for a discussion: https://www.facebook.com/groups/flowtype/permalink/1084168611631753/

The only difference in behavior is that I now explicitely convert to boolean the object dereference via `!!`.

Test Plan:
npm run flow
Careful inspection of the code

Reviewers: @zpao @spicyj
2016-07-05 10:22:56 -07:00
Dan Abramov
8fe6b5fb46 Inline dev-only requires (#7188)
* Inline dev-only requires

This reduces the production bundled build size.

* Use new references after resetting module registry in tests

This fixes the tests which were broken due to inlining some requires.
2016-07-05 18:20:12 +01:00
Christopher Chedeau
07cfba17a9 [flow] fix flattenChildren type (#7110)
Summary:
Make the debug attribute optional

Test Plan:
npm run flow

Reviewers: @keyanzhang @chicoxyzzy
2016-07-05 09:18:49 -07:00
Dan Abramov
7d0801e1a0 Remove Danger.dangerouslyRenderMarkup as it is dead code (#7185) 2016-07-05 03:25:06 +01:00
Dan Abramov
24dfb56113 Remove unnecessary Flow annotation
It was added in #7127 but this file isn’t type checked anyway.
2016-07-04 15:48:41 +01:00
Robin Ricard
dbdddf1c82 Trigger a proper no-op warning for async state changes on server (#7127)
This commit fixes #5473: ReactDOMServer.renderToString: presence of onClick
handler causes errors on async update

This commit performs the following changes:

- Adds a getUpdateQueue method to ReactServerRenderingTransaction,
  ReactReconcileTransaction, ReactNativeReconcileTransaction and
  ReactTestReconcileTransaction
- Make the ReactCompositeComponent call this getUpdateQueue instead of using
  ReactUpdateQueue that was unwanted at certain moments on server
- On ReactServerRenderingTransaction, dispatch ReactUpdateQueue's methods
  while rendering and warning methods afterwards. This is done through the new
  ReactServerUpdateQueue class
- Added a series of tests that mimics the case presented in #5473 with setState,
  forceUpdate and replaceState
- Add flow typechecking on concerned files
2016-07-04 15:47:00 +01:00
Richard Roncancio
6e5dd8926c Removed transitionAppearTimeout to remove warning (#7165)
- Removed the prop transitionAppearTimeout from
addons/transitions/ReactTransitionGroup in order to remove a warning
when passing unknown props to DOM elements.
2016-07-02 23:25:12 +01:00
Samuel Reed
3946ac33b8 Add PropTypes.symbol to reusable components doc (#7171) 2016-07-02 20:54:47 +01:00
Sebastian Markbåge
4bc1048e0d Unshare not actually shared files (#7167)
This moves some files out of shared that are not actually shared
with isomorphic. They're specific to the renderers.
2016-07-01 19:16:52 -07:00
Paul O’Shannessy
23cfe03c99 Changelog for 15.2.0
(cherry picked from commit 74c29b391a and  bc1d59ee19)
2016-07-01 12:23:01 -07:00
Paul O’Shannessy
f40e6dbc76 Update website for 15.2.0
(cherry picked from commit 3a6584b2ee)
2016-07-01 12:21:56 -07:00
Paul O’Shannessy
7ef584b2c3 Update readme for 15.2.0
(cherry picked from commit 516aa96419)
2016-07-01 12:21:48 -07:00
Sebastian Markbåge
cf259a4ff8 Merge pull request #7154 from sebmarkbage/sideeffects
[Fiber] Host Side Effects
2016-06-30 16:35:38 -07:00
Griffin Michl
39265cb892 Group warnings for unknown DOM properties (#7153) 2016-07-01 00:13:32 +01:00
Sebastian Markbage
e60fb7eca0 Nits 2016-06-30 15:55:09 -07:00
Sebastian Markbage
05c6925282 Rudimentary DOM Renderer with Example 2016-06-30 14:30:16 -07:00
Sebastian Markbage
c6b5622bff Schedule side-effects to parents before their children
This is only for host nodes so that the DOM tree is fully updated
by the time we've flushed.

Classes will schedule their life-cycles *after* their children's
side-effects.
2016-06-30 14:29:17 -07:00
Sebastian Markbage
2f0ff6e974 Apply side-effects to host containers
This updates the host container root with new children.
Currently, this is always called for updates because we don't
track if any children reordered.
2016-06-30 14:29:17 -07:00
Sebastian Markbage
62d4561910 Host environment side-effects
This creates a new API for processing side-effects on the host
environment.

During initial reconciliation host instances are created during
the time sliced periods.

During updates there is an opportunity for the host
to prepare something on the instance during the time slicing, and
to determine whether there were any changes. The could be thrown
away.

At the commit phase, these changes are finally committed to the
host instance.
2016-06-30 14:29:17 -07:00
Sebastian Markbage
a4b8bebe18 Dependency injection in the begin/complete/commit phases
This just makes them instantiable so that we can get access to the
host config in these.
2016-06-30 14:29:17 -07:00
Sebastian Markbage
f84a8eabc7 Fiber side-effects
This adds tracking of side-effects that gets scheduled during an
update.

As the tree gets reconciled, the side-effectful fibers are linked
together in an ordered singly linked list. That way we can walk
the linked list to commit only the work that needs to be
synchronous - quickly.

We also store first and last nodes within a fiber. That
way when we reuse an already processed subtree, we can reuse that
subset of the linked list.
2016-06-30 14:29:16 -07:00
Sebastian Markbåge
291f8e30a9 Merge pull request #7034 from sebmarkbage/newreconciler
[Fiber] Host Container Fiber and Priority Levels
2016-06-30 14:28:05 -07:00
Sebastian Markbage
6a8cedf985 Remove unreachable code
This should've been caught above.
2016-06-30 12:55:55 -07:00
Sebastian Markbage
4a8651412d Renamed fiber.parent -> fiber.return
This is not just the parent Instance but also the return Fiber for
some piece of work. This clarifies and buys into this definition.

Basically, in the current model you will always pass into a fiber
from the parent that you're going to return to. Even if you get
aborted and reused this will be updated to the correct return
fiber before you get back here.

I don't have any guarantees in place to enforce this right now. I
don't really know how to, but seems safe. :)

I confirmed that the use of keyword properties work for old
engines because we have the transform enabled in our build system.
2016-06-30 12:55:55 -07:00
Sebastian Markbage
385d085886 Feedback on style 2016-06-30 12:55:55 -07:00
Sebastian Markbage
d8f785165c Reuse work that was preempted if it was untouched
This tries to reuse work that was completed but another higher
priority event came in. This tries to avoid starvation when high
priority events causes low pri work to keep rerendering from
scratch.
2016-06-30 12:55:54 -07:00
Sebastian Markbage
6b86764ac1 Use a recursive algorithm for dumpTree
The parent pointer is updated to one of the two versions during
work so if you log in the middle of work, it gets confused.
2016-06-30 12:55:54 -07:00
Sebastian Markbage
ea08c0020c Resume work deep in a bailed out child immediately in same pri
I found a way to test this case without any need for setState.
2016-06-30 12:55:54 -07:00
Sebastian Markbage
5971411e87 Don't block deep low pri updates when bailing out
First I fix a bug where host components didn't properly bail out
although this was unobservable.

When we bail out, we need to ensure that we preserve the highest
remaining priority work that is left to do for that subtree.

This still isn't properly handling the case when that work has the
*same* priority as the current one. That work will be flushed the
*next* tick instead of the current pass.

I can't create a test for that yet since I need setState to get to
that state.
2016-06-30 12:55:54 -07:00
Sebastian Markbage
285e661757 dumpTree helper for debugging
It is helpful to be able to dump information about the current
tree for debugging issues in unit tests.
2016-06-30 12:55:54 -07:00
Sebastian Markbage
97cd8e179a Attack of the Clones!
This fixes some bugs with the clones and traversing backwards
through them. It is important that we maintain the correct parent
at all times and that clones have the correct values.

We need to carefully clone everything on the way up to the the
fiber with the next work to do.

This code is a bit messy and fragile now. I'm sure I didn't get it
all right but I want to get the basics in place first. Then we can
structure this part better. I think the general algorithm is sound
though.
2016-06-30 12:55:54 -07:00
Sebastian Markbage
986c63c6d4 Extract scheduler into its own module
The scheduler is getting quite complicated. I'll extract it into
its own module.
2016-06-30 12:55:54 -07:00
Sebastian Markbage
7d028fd8cc Reorganize the top level around a FiberRoot
We need a canonical stateful root for each. I don't really want to
overload the HostContainer for this purpose since it makes the
fiber code more specialized.

Instead I create a root which represents an actual stateful root.

When these get scheduled they get chained together in a linked
list. However, we don't hold onto anything that doesn't have
scheduled work. This will help us release everything automatically
in the GC, as long as there are no subscriptions nor scheduled
work.
2016-06-30 12:55:54 -07:00
Sebastian Markbage
5e65f2f622 Bubble up pending work priority to the top level
This is a bit poorly structured. I'll restructure when the pieces
are better in place.

Basically we reset the priority of a node before work on the
children. The children then bump their parent if they end up
having work left.

This is the first time we're seeing deep updates happening. The
new unit test demonstrates this.

There is an interesting case that happens when we fall back out of
a deep update. We end up "completing" a node that we didn't begin.
This probably breaks in coroutines. When that completes, it'll try
to render the sibling next but that should bail out so we check
for any pending work on the sibling. That one I'm not sure about.
2016-06-30 12:55:54 -07:00
Sebastian Markbage
8ad8bd1939 Automatically downgrade an update to a hidden node
This automatically downgrades the priority of a hidden node. Its
children won't be reconciled until they come around the next time.
2016-06-30 12:55:54 -07:00
Sebastian Markbage
e53f0dc4b4 Pass the priority level along to children 2016-06-30 12:55:53 -07:00
Sebastian Markbage
f04c38ed65 Create HostContainer Component Type
This is essentially equivalent to the current top level wrappers.
They contain the next children to be mounted into a container node
from the host.

It is the responsibility of the host to retain references to them
for updates.

I expect them to be able to exist in the middle of the tree in
the future, for renderSubtreeIntoContainer.
2016-06-30 12:55:53 -07:00
Sebastian Markbage
61fe5e11dc Test ability to abort work 2016-06-30 12:55:53 -07:00
Sebastian Markbage
81537c3e51 Rename input -> props
I tried to be clever and generalize it but this is currently only
props and there are other assumptions that might break down if it
isn't.
2016-06-30 12:55:53 -07:00
Sebastian Markbage
5e0ff5f966 Add Priority Levels Enum
This flag on fibers will be used to track what priority of work is
needed by that subtree, if any at all.

Also fix up the TypeOfWork to have consistent naming and typing.
2016-06-30 12:55:53 -07:00
Sebastian Markbage
ed215634be Get rid of ugly and difficult to follow breaks in switch
Because pattern matching or something.
2016-06-30 12:55:53 -07:00
Troy DeMonbreun
6cc037bd0d Fix for #5468: Validate PropTypes.oneOf(Type) arguments early (#6316)
* Fix for 5468: Validate proptype definitions sooner

Added typeCheckWarn() func and updated the oneOf/oneOfType tests
Added __DEV__ warning for invalid oneOf/OneOfType args

* Suppress redundant error on warn; typeCheckWarn() removed

* Return no-op

* Using emptyFunction module for consistency

* Remove createChainableTypeChecker() call

* Adjust test to assert type check passes when warned
2016-06-29 01:30:41 +01:00
starkch
f94912516f Reword invariant message about empty tags (fixes #7065) (#7066)
* addresses issue #7065

* fix test to use new message

* fix string in tests

* fix test string

* Update error message and tests
2016-06-27 23:30:09 +01:00
Dan Abramov
25f9f4563e Fix renderSubtreeIntoContainer to update context (#7125)
* create failing test case

* Fix renderSubtreeIntoContainer to update context

Fixes #6599

* Also test re-rendering due to prop update

* Address review feedback
2016-06-27 23:29:43 +01:00
Ben Alpert
abcd567325 Make "unexpected batch number" a warning (#7133)
This was added to catch internal errors in React but doesn't seem to be doing much good except frustrating people more when their apps throw (#6895, FB-internal t11950821). Until more proper error boundaries land, let's make this a warning.
2016-06-27 13:39:23 -07:00
Dan Abramov
a49b7a2dfb Fix tests from #6158 to use Jasmine 2 (#7126) 2016-06-27 01:38:45 +01:00
Esteban
752e1595fc Remove comment about PooledClass destructors being optional (#6560)
They are no longer optional since #4720
2016-06-26 21:52:12 +01:00
Swaroop SM
18bad0669f Warn if the included mixin is undefined (#6158) 2016-06-26 20:14:08 +01:00
Evan Jacobs
5a20d449f6 [TestUtils] Copy type to nativeEvent in Simulate.<eventName> (#6154)
Although it is unreasonable to set every possible property for
simulated events, `type` is useful for event handlers that are shared
between types and potentially have different behaviors.
2016-06-26 20:11:37 +01:00
Brandon Dail
60760eb915 Clarify purpose of state property in ES6 classes (#7109) 2016-06-23 12:44:36 -07:00
Sergey Rubanov
3b5c756c7a [flow] add some typings to utils (#7104)
* add some typings to utils

* add typing of flattenChildren

* more accurate typings for flattenChildren
2016-06-23 18:16:37 +02:00
Christopher Chedeau
9342c2f02f [flow] type deprecated (#7076)
Summary:

Test Plan:
npm run flow

Reviewers: @zpao @spicyj @gabelevi
2016-06-23 17:46:24 +02:00
Jim
416b5ef173 Remove dead HAS_SIDE_EFFECTS logic (#6987) 2016-06-22 16:12:32 -07:00
Jim
b4fc27357c Add autoFocus to list of whitelisted dom element props. (#7098) 2016-06-22 14:30:16 -07:00
Dan Abramov
83cbc3e5fb Resolve refs in the order of the children (#7101)
* Resolve refs in the order of the children

React makes no guarantees about ref resolution order. Unfortunately, some of the internal Facebook component APIs (specifically, layer dialogs) currently depend on the ref resolution order. Specifically, the assumption is that if the layer dialog is placed as a last child, by the time it mounts or updates, the refs to any previously declared elements have been resolved.

With the current `ReactMultiChild`, this is *usually* the case but not always. Both initial mount and an update of all components satisfy this assumption: by the time a child mounts or updates, the previous children’s refs have been resolved. The one scenario where it isn’t true is when **a new child is mounted during an update**.

In this case, the `mountComponent()` call used to be delayed until `ReactMultiChild` processes the queue. However, this is inconsistent with how updates normally work: unlike mounting, updating and unmounting happens inside `ReactChildReconciler.updateChildren()` loop.

This PR changes the `mountComponent()` to be performed inside `ReactChildReconciler`, just like `receiveComponent()` and `unmountComponent()`, and thus ensures that `attachRef()` calls are enqueued in the order the children were processed, so by the time the next child flushes, the refs of the previous children have been resolved.

This is not ideal and will probably be broken by incremental reconciler in the future. However, since we are trying to get rid of mixins in the internal codebase, and layered components are one of the biggest blockers to that, it’s lesser evil to temporarily make ref resolution order more strict until we have time to fix up the layer APIs to not rely on it, and are able to relax it again (which would be a breaking change).

* Use array instead of object to avoid lookups
2016-06-22 22:28:06 +01:00
Jim
c7ba16fbbf webcomponents should use attachedCallback instead of createdCallback. (#7102) 2016-06-22 12:42:50 -07:00
Jared Fox
cd9ad90d05 fix webcomponent example issue #7056 (#7057)
* fix webcomponent example issue #7056

* update fix issue #7056, remove unused web component  callbacks
2016-06-22 10:30:04 -07:00
Paul O’Shannessy
4f00553c15 [docs] Update share button (#7097) 2016-06-21 16:21:10 -07:00
Christopher Chedeau
b0732ef881 [cleanup] Move ReactStateSetters inside of addons/link (#7085)
Summary:
The only callsite of ReactStateSetters is in LinkedStateMixin which lives in addons/link. Better move it there to avoid cluttering the other folder.

Test Plan:
None

Reviewers: @zpao @spicyj
2016-06-21 16:09:09 +02:00
Christopher Chedeau
489caeb2d7 [flow] type adler32 (#7080)
This one is trivial

Test Plan:
npm run flow

Reviewers: @zpao @spicyj
2016-06-20 15:35:59 +02:00
Christopher Chedeau
12a6ad1ef5 [flow] type KeyEscapeUtils (#7079)
Summary:

The only call site ensures that the value is not null: dc6fc8cc07/src/shared/utils/traverseAllChildren.js (L44)

key is stringified inside of createElement, so we are guaranteed to receive a string right now: dc6fc8cc07/src/isomorphic/classic/element/ReactElement.js (L142)

Test Plan:
npm run flow

Reviewers: @zpao @spicyj
2016-06-19 21:58:21 +02:00
Christopher Chedeau
5a21d49e3b Remove injectMixin (#6831)
Summary:
The only callsite left was removed here: e8af100849 (commitcomment-17570210) but the code to handle it remained.

Test Plan:
tbgs and ibgs, make sure there's no callsites.

Reviewers: @jimfb, @spicyj, @sebmarkbage
2016-06-19 21:57:27 +02:00
Christopher Chedeau
5b4dad31f8 Merge pull request #7053 from vjeux/flow_accumulate
[flow] annotate accumulate, accumulateInto and forEachAccumulated
2016-06-17 22:07:39 +02:00
Paul O’Shannessy
4886e028bf Specify possible need for C++ compiler (#7064) 2016-06-17 11:34:04 -07:00
Nik Nyby
a8d8210222 update babel-core to 5.8.34 in tutorial docs (#7059) 2016-06-16 20:50:14 -07:00
Claudio Brandolino
5bca3773ab Standardise format of the three "state" questions. (#7046)
* Standardise format of the three "state" questions.

The original format follows the template:

 > 1. x? if `x` then probably isn't state
 > 2. y? if `!y` then probably isn't state
 > 3. z? if `z` then it's not state

This caused both me and a hallway tester to do a double take.

The proposed reformulation allows the answers to follow the same template.

In the same spirit, it uses the same contraction pattern in the last answer (`it's not state`-> `it isn't state`). This has the welcome side effect to make the lack of "probably" stand out more.

* Update phrasing in thinking in reacr
2016-06-16 10:35:18 -07:00
Christopher Chedeau
1c71970431 [flow] annotate accumulate and accumulateInto
Summary:
Trying to start adding flow types to files in React. I needed to add a script to package.json in order to run flow, flow-bin is already a dependency.

I had to rewrite the implementation a bit. Flow doesn't recognize

```
var currentIsArray = Array.isArray(current);
if (currentIsArray) {
  // not refined
}
```

but the following does work

```
if (Array.isArray(current)) {
  // refined
}
```

Test Plan:
npm run-script flow
npm run-script test accumulate

Reviewers: @zpao @spicyj
2016-06-16 17:33:32 +02:00
Jim
49238b9440 Warn if people mutate children. (#7001) 2016-06-15 22:22:31 -07:00
Toru Kobayashi
718c07c915 Remove setProps and replaceProps from docs (#7044) 2016-06-14 22:13:26 -07:00
Toru Kobayashi
e8fa464d6f Remove setProps and replaceProps from src (#7045) 2016-06-14 22:11:37 -07:00
Jim
97d89fa5bf Move null-input-value-prop warning into devtool, add stack trace (#7040) 2016-06-14 16:34:38 -07:00
Paul O’Shannessy
6e8c2fb828 Revert "Remove setProps and replaceProps completely" (#7039) 2016-06-14 15:02:01 -07:00
Juan
b618b786a9 Update readme to latest React description (#7014)
* Update readme to latest React description

* Update readme to latest wordsmithing
2016-06-14 12:46:21 -07:00
Qin Junwen
a394ed6a6c Update 10.4-test-utils.md (#6971)
The find/scry methods which returns DOM component in react@0.13 now returns DOMElement in react@0.14 and later.
2016-06-14 14:09:20 -04:00
Robert Haritonov
4577db6d3c Add React Amsterdam conference to the list (#7028) 2016-06-14 11:02:13 -07:00
nhducit
eda159cd28 Update 03-interactivity-and-dynamic-uis.md (#7015) 2016-06-14 13:55:38 -04:00
Christoph Pojer
6b8db0e111 Add symbol to identify a ReactTestComponent instance. (#7035) 2016-06-13 22:50:28 -07:00
Ben Alpert
96d2a30c25 Wordsmith the homepage (#7022) 2016-06-13 12:40:18 -07:00
Ryo Shibayama
e487c36ec0 Fix Japanese/Italian/Korean tutorials (#7020)
* Fix japanese tutorial

* Fix Italian tutorial as same as e4fe662

* Fix Korean tutorial as same as e4fe662
2016-06-12 00:03:13 -07:00
Ben Alpert
c7868cc741 New marketing copy on homepage (#7012) 2016-06-10 19:47:23 -07:00
inkinworld
665633a1b7 Update 12-context.md (#6973)
Modify a clerical error
2016-06-10 11:52:10 -07:00
Dominic Gannaway
40f6d3eaca Performance: setTextContent should attempt to set TextNode nodeValue where possible (#7005) 2016-06-10 09:57:31 -07:00
Keyan Zhang
46cd6a0b62 pinned babylon version for eslint to work (#7008) 2016-06-09 16:14:44 -07:00
Jim
2282894d52 Remove console.log from test (#7006) 2016-06-09 09:24:03 -07:00
Jim
0bb0fe8d00 Fix controlled/uncontrolled validation for radio+checkbox inputs (#7003) 2016-06-09 07:58:42 -07:00
Toru Kobayashi
731e42998a Remove setProps and replaceProps completely (#6921) 2016-06-09 03:53:52 -07:00
ogom
9c7f895783 Updte tutorial to ja-JP (#6967) 2016-06-08 19:20:20 -07:00
Jim
f0b140d726 Fix IE11 placeholder textContent value bug. (#7002) 2016-06-08 18:58:37 -07:00
Brandon Dail
c47830d12c Warn if childContextType is defined on SFC (#6933)
Add console.error message content check

Use appropriate name in warning/test
2016-06-08 13:32:43 -07:00
Hiroyuki Wada
518336e2fb Fix #5839 Add error event to source element (#6941)
* Fix #5839 Add error event to source element

* Add test case for <source onError={callback}>
2016-06-08 13:30:27 -07:00
Josh Hunt
99d8524d23 Fix #6950, work around IE missing innerHTML on SVG nodes (#6982)
* Workaround IE lacking innerHTML on SVG elements

* Add tests for setInnerHTML

* Correctly check if node has innerHTML property

* Ensure tests for setInnerHTML actually tests both codepaths

* Provide mock element for setInnerHTML tests

* Only use SVG setInnerHTML workaround for SVG elements
2016-06-08 10:00:03 -07:00
Yusong Liu
5331323cd2 Fix the typo in the documentaion pages for shallowCompare (#6980)
* fix the typo for the docs of shallowCompare at:
https://facebook.github.io/react/docs/shallow-compare.html

* change "value" to "values" to match the two objects.
2016-06-07 23:09:50 -07:00
Sebastian Markbåge
0cafd83834 Merge pull request #6988 from sebmarkbage/newreconciler
[Fiber] Minimize abuse of .alternate
2016-06-07 18:42:18 -07:00
Timothy Yung
7988acaa95 Improve error message for components in bad states (missing instance) (#6990) 2016-06-07 17:23:40 -07:00
Keyan Zhang
1abce1630c Add reactProdInvariant and corresponding babel rewrite pass (#6948) 2016-06-07 17:11:04 -07:00
Sebastian Markbage
40180c4b26 Get rid of ugly and difficult to follow breaks in switch
Because pattern matching or something.
2016-06-07 17:05:25 -07:00
Sebastian Markbage
c83a0428f1 Minimize abuse of .alternate
This avoids using .alternate as much as possible and isolates it
to the root. For anything that is "work in progress" this happens
to be the same as the alternate field. To avoid an extra "current"
field on work in progress fibers, we can just use the alternate.

The timing for when this is true might be a bit tricky to reason
about so I explicitly pass the current value everywhere from the
top. That way we can always change this in the future to use an
explicit field or we can try to maintain a parallel data
structure that remembers which was the "current" fiber for each
wip child.
2016-06-07 15:03:32 -07:00
Sebastian Markbåge
ccd26ee020 Merge pull request #6981 from sebmarkbage/newreconciler
[Fiber] Add support for simple updates and fiber pooling
2016-06-07 14:30:07 -07:00
Sebastian Markbage
3a32d2642f Rename unitOfWork -> workInProgress
These values represent fibers that are incomplete. In the current
model they're mutated in place. In a completely immutable model
they would need to be cloned for every step they make progress.
I.e. one where the child is still in this WIP state and one when
it is complete.

To clarify this I'll name them workInProgress while they're in
that state, which is also what Jordan did in his prototype.
2016-06-07 13:49:12 -07:00
Sebastian Markbage
cce58ffd62 Simple updates using alternate fibers
This splits the Fiber type into Fiber and Instance. This could be
two different object instances to save memory. However, to avoid
GC thrash I merge them into one.

When ReactChildFiber reconciles children, it clones the previous
fiber. This creates a new tree for work-in-progress. The idea is
that once flushed, this new tree will be used at the root.

However, we know that we'll never need more than two trees
at a time. Therefore my clone function stores the clone on the
original. Effectively this creates a fiber pool.

Ideally, the .alternate field shouldn't be used outside of clone
so that everything can work with pure immutability. I cheat a bit
for now so I don't have to pass both trees everywhere.

ReactChildFiber is a bit hacky for reuse and doesn't solve all
cases. Will fix that once I try to get parity.
2016-06-07 13:49:11 -07:00
Jim
eb705d1448 Fix autofocus for input and textarea (#6986) 2016-06-07 12:50:37 -07:00
Dan Abramov
d101f68bce Tweak ReactPerf warning message and code style (#6977) 2016-06-06 20:59:28 +02:00
Ben Alpert
8c60aaf430 Revert "Fallback to legacy set/get in old versions of FF" (#6976) 2016-06-06 11:49:43 -07:00
Alexander
2a46103ac8 Warn that ReactPerf does not work in the production build (#6884)
Fixes #6871
2016-06-06 20:46:57 +02:00
Dan Abramov
afe483790b Revert "Warn that ReactPerf does not work in the production build (#6884, #6975)"
This reverts commit f71dfbcbf0.

Reverting because GitHub stripped the original PR author.
2016-06-06 19:44:40 +01:00
Dan Abramov
f71dfbcbf0 Warn that ReactPerf does not work in the production build (#6884, #6975)
Fixes #6871
2016-06-06 20:37:46 +02:00
Keyan Zhang
cf73de9459 [Docs] Error Decoder Page (#6946) 2016-06-04 14:43:56 -07:00
Ben Alpert
3c3c30a19a Fix function declaration in if statement (#6963)
Firefox doesn't like these and throws.
2016-06-04 13:37:57 -07:00
Keyan Zhang
96994c20b8 added instruction for downloading babel-browser (#6960) 2016-06-03 15:43:32 -07:00
Ben Alpert
1801d56500 Use remarkable instead of marked (#6961)
https://github.com/reactjs/react-tutorial/issues/139
2016-06-03 14:41:38 -07:00
Keyan Zhang
c9eb572a6f Fix null node issue in ReactCSSTransitionGroup (#6958) 2016-06-03 13:42:45 -07:00
Paul O’Shannessy
d3b36d5524 Merge pull request #6957 from zpao/flow026
Upgrade Flow
2016-06-03 13:17:15 -07:00
Paul O’Shannessy
dd093faadf Add <any> type args for ReactElement,Class,Component 2016-06-03 13:13:20 -07:00
Paul O’Shannessy
2efc7186fe Fix $FlowFixMe broken by comment spanning multiple lines 2016-06-03 13:13:19 -07:00
Paul O’Shannessy
36d1a271c4 Upgrade to flow 0.26 & match internal config with strict args
Also ignore examples, important because react can be installed by the commonjs
one and the modules will get detected there too, resulting in duplicate
definitions
2016-06-03 13:12:47 -07:00
Daniel Rosenwasser
6b3f11cdd7 Update link and description of TypeScript support. (#6953) 2016-06-03 10:27:39 -07:00
Andrew Imm
8216125d82 Fallback to legacy set/get in old versions of FF (#6930) 2016-06-02 11:35:21 -07:00
Sasha Aickin
d6e70586b7 Replace the implementation of escapeTextContentForBrowser with escape-html (#6862)
* Replacing the implementation of escapeTextContentForBrowser with escape-html for performance

* Addressing @spicyj's code review comment here: https://github.com/facebook/react/pull/6862#issuecomment-223102868 . Pulled the code of escape-html in to react and changed the encoding of single quote to &#x27.

* Addressing code review comment https://github.com/facebook/react/pull/6862#discussion_r65462074 to make code more inlinable for v8. Thanks, @spicyj.
2016-06-01 17:14:30 -07:00
Ben Alpert
9498747606 Remove Flux from docs nav (#6945)
Most people don't use the official Flux implementation or docs so I think this is likely to be more confusing than helpful. Maybe later we can add a better comparison of data management solutions.
2016-06-01 11:41:35 -07:00
Keyan Zhang
bfd1531eca Add a gulp script for extracting error codes (#6882) 2016-06-01 11:21:26 -07:00
Ben Alpert
50982cea99 Add rudimentary test renderer (#6944) 2016-06-01 11:17:10 -07:00
Jim
51f8b1b40c Remove css px warning, stop appending px to strings (#6899) 2016-05-31 14:32:27 -07:00
Sebastian Markbåge
dc5686a42f Merge pull request #6931 from sebmarkbage/newreconciler
[Fiber] Simple test assertions
2016-05-31 14:20:18 -07:00
Sebastian Markbage
8056fbc2c9 [Fiber] Simple test assertions
I'll split the coroutine and incremental testing into their own
tests so that I can expand them with more edge cases.
2016-05-31 13:52:28 -07:00
Sebastian Markbåge
7de23758f1 Merge pull request #6903 from sebmarkbage/newreconciler
[Fiber] Transfer everything from Element onto the Fiber and use Tag instead of Stage
2016-05-31 13:39:59 -07:00
Sebastian Markbage
811084d74e Use the tag instead of stage field for coroutine stages
This gets rid of a field that we only need for coroutines.

We might need this if we have multi phase handlers in the future
but then maybe we can just use multiple tags.
2016-05-31 13:34:19 -07:00
Sebastian Markbage
aa14d89c7d Transfer everything from Element onto the Fiber
This has a few benefits:

1) This allows the element to always remain on the young generation.
2) The key can be accessed on the fiber which is easier to keep as the
same class and is directly accessible in the child reconciliation of every
object.
3) This conveniently means that we don't have to create a fake element for
continuations which was really hacky.

We can still do the quick bailout of rerendered things using the props
object which is also unique.
2016-05-31 13:34:19 -07:00
hjmoss
4e82e8b6e6 Grammar: less dependencies -> fewer dependencies (#6917)
* Grammar: less dependencies -> fewer dependencies

* changelog.md grammar: less dependencies -> fewer dependencies
2016-05-31 09:17:13 -07:00
Toru Kobayashi
97b44085ff Remove getDOMNode from docs (#6919) 2016-05-30 09:16:15 -07:00
Alex Jacobs
29ed7c6c8c Fix minor lint warnings (#6909) 2016-05-28 22:04:32 +01:00
Ben Alpert
e62384bca4 Fix style test for Jasmine 2 (#6913) 2016-05-28 12:58:08 -07:00
Nate Norberg
38900cc7ca Added more specific warning for using onDblClick instead of onDoubleClick (#6881) 2016-05-27 15:23:05 -07:00
Jim
ba3bfe3e31 Followup to 6896, add explanation of workaround. (#6905) 2016-05-27 09:19:25 -07:00
Bruce Harris
f329099831 Update tutorial with reference to autobinding docs (#6870)
* Update tutorial with reference to autobinding docs

* Update tutorial to clarify that autobinding happens specifically with createClass() API
2016-05-27 04:07:00 -07:00
Paul O’Shannessy
d87005e0b6 [docs] Use existing layout for redirecting html-jsx (#6904) 2016-05-26 23:50:55 -07:00
Ilya Gelman
b0cb4e850d Add ReactNext 2016 conference (#6833) 2016-05-26 23:43:00 -07:00
Daniel Lo Nigro
871116f001 Move HTMLtoJSX page off React site. References https://github.com/reactjs/react-magic/issues/52 (#6608) 2016-05-26 23:39:28 -07:00
Daniel Lo Nigro
d81f3297aa Add link to ReactJS.NET on server-side environments page (#6607) 2016-05-26 23:36:56 -07:00
Keyan Zhang
c8bab76091 switched to codemirror's jsx mode (#6898) 2016-05-26 23:33:04 -07:00
Paul O’Shannessy
5c6f9d31bd Merge pull request #6677 from zpao/dont-warn-css-0-string
Don't warn when style value is '0'
2016-05-26 20:05:32 -07:00
Sebastian Markbåge
0f4a4df12e Merge pull request #6859 from sebmarkbage/newreconciler
[Fiber] Child Reconciler + New Coroutines Primitive
2016-05-26 18:21:08 -07:00
Sebastian Markbage
fd4f74ef95 Coroutines 2016-05-26 18:13:21 -07:00
Sebastian Markbage
7c8a090994 Child Fiber 2016-05-26 17:27:19 -07:00
Robin Berjon
263615573c Stop passing null as second argument to document.createElement() (#6896)
* Stop passing null as second argument to document.createElement()

* rewrap check for props.is to make it more readable
2016-05-26 21:51:15 +01:00
Dan Abramov
ca5a0dad16 Merge pull request #6886 from Weizenlol/patch-1
Added own property check when deleting listeners.
2016-05-26 21:14:50 +01:00
Dan Abramov
1d3aceb6c3 Merge pull request #6890 from grgur/patch-1
Added React Europe 2015 videos
2016-05-26 13:50:55 +01:00
Grgur Grisogono
c5d4978f23 Added React Europe 2015 videos
Linking to the official channel that contains separate playlists for Day 1, Day 2, and Lightning talks
2016-05-26 14:29:48 +02:00
Weizenlol
b1882f870a Added own property check when deleting listeners.
React crash when default object prototype is modified.
2016-05-26 11:30:36 +03:00
Dan Abramov
2d74280679 Merge pull request #6880 from gaearon/clone-key-ref-props-2
Fix issues introduced by createElement() warning
2016-05-26 01:41:24 +01:00
Dan Abramov
58c9fda946 Inline expectations in tests as they are used once 2016-05-26 01:29:54 +01:00
Dan Abramov
55a0e4bf80 Infer displayName in more cases for props.ref/key warning 2016-05-26 01:21:28 +01:00
Ben Alpert
21d271f6d0 Warn when element is missing in devtool (#6869) 2016-05-25 17:11:57 -07:00
Dan Abramov
919eba3c99 Correctly check that element and props are frozen
This fixes an incorrect way of checking introduced in 95373ce769 (it had no effect).
2016-05-26 01:08:29 +01:00
Dan Abramov
a432afa750 Ignore specifically React warning getter in ReactElement
We don’t want to have different behavior in development and production.
Previously, we used to ignore getters on key/ref in dev, but we’d read them in prod.
Now, we only ignore the getters that we *know* we created so the production logic doesn’t differ.
2016-05-26 01:01:15 +01:00
Dan Abramov
e822cbd183 Make sure cloneElement() supports prototype-less config (#6878)
This brings createElement() fix from #6855 to cloneElement().
2016-05-26 00:37:18 +01:00
Dan Abramov
d9ae319821 Move tests concerned with cloning into ReactElementClone-test 2016-05-26 00:27:57 +01:00
Dan Abramov
c77411b1af Short-circuit the check just for getters
This way in other cases both DEV and PROD falls through to the check for undefined.
This fixes #6879 and a similar bug introduced for cloneElement() in 94d0dc68c8.
2016-05-26 00:21:18 +01:00
Dan Abramov
1b802fbd65 Add a test verifying undefined key and ref are ignored
It currently fails in `createElement` because of #6879 which was introduced in #5744.
It also fails in `cloneElement` because the code with that bug was extracted and shared in 94d0dc68c8.
2016-05-26 00:10:10 +01:00
Dan Abramov
15cd66b91b Tweak whitespace 2016-05-25 23:21:29 +01:00
Dan Abramov
f846edcbea Remove indirection when determining valid config and ref 2016-05-25 23:17:20 +01:00
Eric Matthys
94d0dc68c8 Do not clone key and ref getters 2016-05-25 23:02:56 +01:00
Andrew Clark
d7ced68dce Clarify that string refs are considered legacy. (#6692) 2016-05-25 22:47:34 +01:00
Ben Alpert
eb050727ee Revert "Update shallowCompare to accept nextContext" (#6877) 2016-05-25 14:37:48 -07:00
Dan Abramov
c0ecde687a Merge pull request #6872 from gaearon/jest-cli@12
Update to Jest 12.1.1 and Jasmine 2
2016-05-25 22:07:50 +01:00
Dan Abramov
5c509b150d Update Jasmine 2 PR with changes from master 2016-05-25 21:55:35 +01:00
Dan Abramov
9c22ef7e50 Update jest bin command 2016-05-25 21:49:32 +01:00
Dmitrii Abramov
00bc8ceaad jest@12.1.1 2016-05-25 21:49:31 +01:00
Dmitrii Abramov
5d332f22b4 ReactClassEquivalence 2016-05-25 21:49:31 +01:00
Dmitrii Abramov
517ed859b4 Upgrade to Jasmine 2 2016-05-25 21:48:32 +01:00
Paul O’Shannessy
d8a0b9a662 Upgrade to jest-cli@0.9 and use Jasmine2 2016-05-25 21:48:32 +01:00
Ben Alpert
510155e027 Fix instrumentation in shallow rendering (#6867)
Previously, this threw:

```
 FAIL  src/test/__tests__/ReactTestUtils-test.js (7.291s)
● ReactTestUtils › it can fail context when shallowly rendering
  - TypeError: Cannot read property '_source' of null
        at describeID (src/renderers/shared/devtools/ReactComponentTreeDevtool.js:70:46)
        at Object.ReactComponentTreeDevtool.getStackAddendumByID (src/renderers/shared/devtools/ReactComponentTreeDevtool.js:203:15)
        at checkReactTypeSpec (src/isomorphic/classic/types/checkReactTypeSpec.js:76:58)
        at ReactCompositeComponentMixin._checkContextTypes (src/renderers/shared/stack/reconciler/ReactCompositeComponent.js:668:5)
        at ReactCompositeComponentMixin._processContext (src/renderers/shared/stack/reconciler/ReactCompositeComponent.js:607:14)
        at ReactCompositeComponentMixin.mountComponent (src/renderers/shared/stack/reconciler/ReactCompositeComponent.js:191:30)
        at ReactShallowRenderer._render (src/test/ReactTestUtils.js:483:14)
        at _batchedRender (src/test/ReactTestUtils.js:460:12)
        at ReactDefaultBatchingStrategyTransaction.Mixin.perform (src/shared/utils/Transaction.js:140:20)
        at Object.ReactDefaultBatchingStrategy.batchedUpdates (src/renderers/shared/stack/reconciler/ReactDefaultBatchingStrategy.js:65:19)
        at Object.batchedUpdates (src/renderers/shared/stack/reconciler/ReactUpdates.js:112:20)
        at ReactShallowRenderer.render (src/test/ReactTestUtils.js:453:16)
        at Spec.eval (src/test/__tests__/ReactTestUtils-test.js:289:34)
        at jasmine.Block.execute (node_modules/jest-jasmine1/vendor/jasmine-1.3.0.js:1067:17)
        at jasmine.Queue.next_ (node_modules/jest-jasmine1/vendor/jasmine-1.3.0.js:2100:31)
        at jasmine.Queue.start (node_modules/jest-jasmine1/vendor/jasmine-1.3.0.js:2053:8)
        at Spec.jasmine.Spec.execute (node_modules/jest-jasmine1/vendor/jasmine-1.3.0.js:2380:14)
        at jasmine.Queue.next_ (node_modules/jest-jasmine1/vendor/jasmine-1.3.0.js:2100:31)
        at onComplete (node_modules/jest-jasmine1/vendor/jasmine-1.3.0.js:2096:18)
        at Spec.jasmine.Spec.finish (node_modules/jest-jasmine1/vendor/jasmine-1.3.0.js:2354:5)
        at eval [as onComplete] (node_modules/jest-jasmine1/vendor/jasmine-1.3.0.js:2381:10)
        at jasmine.Queue.next_ (node_modules/jest-jasmine1/vendor/jasmine-1.3.0.js:2110:14)
        at eval (node_modules/jest-jasmine1/vendor/jasmine-1.3.0.js:2090:18)
        at Timeout.e [as _onTimeout] (node_modules/jsdom/lib/jsdom/browser/Window.js:440:19)
        at tryOnTimeout (timers.js:224:11)
        at Timer.listOnTimeout (timers.js:198:5)
```
2016-05-25 09:46:50 -07:00
Dan Abramov
8d7161e004 Don't count the time inside flushes towards lifecycle hooks (#6860)
* Don't count the time inside flushes towards lifecycle hooks

Fixes #6842.

We keep the existing behavior of testing for matching `onBeginLifeCycleTimer`/`onEndLifeCycleTimer` calls, but we push the current timer onto the stack if we enter a flush.
This solves an issue with portals which cause updates while a lifecycle timer is already running.

I chose to subtract the time spent in the flush from the time counted towards the lifecycle method because it would artificially inflate the “total” time of the component due to all the components inside the portal, so it would skew the exclusive table.

* Fix up the comment
2016-05-25 17:39:05 +01:00
Jim
de1de9e18f Add warning for unknown properties. (#6800) 2016-05-25 06:58:41 -07:00
Jim
4338c8db4b Properly set value and defaultValue for input and textarea (#6406)
* Have `defaultValue` reach DOM node for html input box for #4618

* Cleanup and bug fixes for merge.
2016-05-24 18:28:01 -07:00
Ben Alpert
cb4a0af7dd Remove unknown props in ART (#6861) 2016-05-24 17:04:18 -07:00
Ben Alpert
531a6b3265 Merge pull request #6775 from spicyj/fix-art
Copy React ART tests and add hacks to fix them
2016-05-24 16:47:54 -07:00
Ben Alpert
769ab715c2 Fix ART after Native -> Host rename 2016-05-24 16:44:33 -07:00
Ben Alpert
7ecff6a437 Add hacks to make React ART not warn from devtools 2016-05-24 16:44:33 -07:00
Ben Alpert
5cbb68258b Add (failing) React ART tests
This helps us make sure we don't break React ART in a minor or patch release. The idea is to not change these files when making minor or patch changes. Copied directly from react-art with requires fixed. (I also picked a different haste name just in case.)
2016-05-24 16:44:33 -07:00
Dan Abramov
9ba5668d18 Fix componentWillUnmount() not counted by ReactPerf (#6858)
* Fix componentWillUnmount() not counted by ReactPerf

* Test that functional component render() time shows up in ReactPerf

* Test for setState() code path updates being included
2016-05-24 20:50:08 +01:00
Alex Zherdev
6a101b6c10 Context docs updated with ES6 examples (#6852) 2016-05-24 11:27:38 -07:00
Ben Alpert
43b63995a8 Point people to prod build in perf docs (#6857) 2016-05-24 11:08:51 -07:00
Ali Taheri Moghaddar
c313baa0ca Avoid directly calling hasOwnProperty (#6855)
* Avoid directly calling hasOwnProperty

* Fix failing test case
2016-05-24 18:55:51 +01:00
Ben Alpert
fe2002c3d8 Add test to ensure 'undefined' children is used (#6853) 2016-05-23 17:22:05 -07:00
Keyan Zhang
db6ac5c01c Extract the type checker into a separate module (#6851)
The type checker is now a separate module under `isomorphic/classic/types`
2016-05-23 17:12:13 -07:00
Jim
799eae2faf Removed unnecessary null check (#6841) 2016-05-23 11:25:02 -07:00
Keyan Zhang
c136369a81 Remove prop types checking in ReactCompositeComponent (#6824)
Remove prop types checking in ReactCompositeComponent
2016-05-23 11:13:09 -07:00
Vedat Mahir YILMAZ
c7ef0af54b Interactivity and Dynamic UIs Docs page updated with ES6 Example (#6832)
* Interactivity and Dynamic UIs Pages ES6 Example

* Change bind handler
2016-05-22 02:32:14 -07:00
Rui Araújo
d955ee9fae Move ReactElementValidator to __DEV__ block (#6830)
It saves some more bytes in production mode.
2016-05-22 02:01:21 -07:00
Roderick Hsiao
fd589fc8dd Support onLoad event on link element (#6815) 2016-05-20 17:12:00 -07:00
Paul O’Shannessy
09075f8bab Update website for 15.1.0
(cherry picked from commit 7842c19934)
2016-05-20 16:34:56 -07:00
Paul O’Shannessy
015833e594 Update readme for 15.1.0
(cherry picked from commit b7d480986a)
2016-05-20 16:34:56 -07:00
Paul O’Shannessy
619b3e8509 Changelog for 15.1.0
(cherry picked from commit bca912f91e)
2016-05-20 16:34:56 -07:00
Keyan Zhang
47e49ae8b7 Add component stack info to key validation warnings (#6799)
* Add component stack info to key validation warnings

* Add `ReactComponentTreeDevtool.getStackAddendumByID`
2016-05-20 14:19:31 -07:00
Paul O’Shannessy
6a3e9d583b Merge pull request #6804 from dmitriiabramov/update_typescript
Update typescript
2016-05-20 11:09:27 -07:00
Keyan Zhang
e1e34274f6 Merge pull request #6814 from Ivanwangcy/master
Update 03-interactivity-and-dynamic-uis.zh-CN.md
2016-05-20 00:26:53 -07:00
Ivan
c36f5a087f Update 03-interactivity-and-dynamic-uis.zh-CN.md 2016-05-20 14:25:07 +08:00
hao.huang
09fdd1d578 Add permalink (#6813)
Add permalink to this doc,so we can access with 'prev' and 'next'
2016-05-19 19:54:42 -07:00
Dmitrii Abramov
efb6d80e60 match jest.d.ts by regex 2016-05-19 19:24:40 -07:00
chico
655ac0f0dd update typescript 2016-05-19 19:24:40 -07:00
Ben Berman
eda08d9656 Minor comment typo (#6808) 2016-05-19 14:21:59 -07:00
Dan Abramov
d1256825bc Merge pull request #6801 from iamdustan/instrumentation-to-shared
Move instrumentation to renderers/shared. Closes #6797
2016-05-19 13:24:06 +01:00
Dustan Kasten
d51981eeea Move instrumentation to renderers/shared. Closes #6797 2016-05-18 22:34:09 -04:00
Tony Rossi
8ea1cf4ee0 Update shallowCompare to accept nextContext (#6661)
* Update shallowCompare to accept nextContext

Across our application we are using immutable objects as properties and thus using shallowCompare for all our {{shouldComponentUpdate}}.  Because of this children with contextTypes don't get updates when the context on the parent changes.  Adding an additional comparison for context (when it is provided) fixes this problem.

* Remove the undefined check

* Add nextContext
2016-05-17 16:50:23 -07:00
Dan Abramov
7f08961604 Merge pull request #6789 from gaearon/tree-devtool-fixes
Make sure element is reported correctly by tree devtool
2016-05-17 23:34:58 +01:00
Dan Abramov
1070b4aa6c Make sure element is reported correctly by tree devtool
This adds some tests for getElement() and verifies that it works for text components too.
The code that calls the instrumentation is fixed where necessary so that the tests pass.
2016-05-17 23:07:35 +01:00
Jim
2e881aa4b4 Fire unknown prop warning when rendering client side. (#6693) 2016-05-17 15:06:31 -07:00
Dan Abramov
4ab203cd73 Test that elements are tracked by tree devtool
The test is currently failing because text elements are not reported in some cases.
2016-05-17 22:16:53 +01:00
Dan Abramov
503cbd3356 Merge pull request #6787 from gaearon/tree-devtool-test-tweaks
Refactor ReactComponentTreeDevtool test
2016-05-17 21:15:49 +01:00
Dan Abramov
9301cfbc80 Refactor ReactComponentTreeDevtool test
We extract common logic between DOM and native tests so they don't diverge.

Also, rather than build a tree object in advance for testing, we will walk the tree on the go.
This lets us have much more specific error messages with a clear path when something goes wrong.
2016-05-17 20:51:00 +01:00
David Aurelio
151e1d7014 Require modules from React Native as node modules. (#6715) 2016-05-16 13:03:38 -07:00
Ben Alpert
6afd51061a Embed JSX filename paths relative to repo root (#6778)
Test Plan: Changed the preprocessor to log the output of babel.transform and saw

```
var _jsxFileName = 'src/isomorphic/modern/element/__tests__/ReactJSXElementValidator-test.js';
```

in the resulting output, instead of an absolute path.
2016-05-16 11:15:12 -07:00
Sebastian McKenzie
3703b63a11 Remove unnecessary require causing excess memory usage (#6781) 2016-05-16 08:52:05 -07:00
Rachel D. Cartwright
207fe0b478 make test utils format consistent (#6777) 2016-05-15 13:46:03 -07:00
Ben Alpert
378c879a6a Show component stack in PropTypes warnings (#6771) 2016-05-14 17:40:39 -07:00
Ben Alpert
3cc733add4 Fix severe perf problems in component tree devtool (#6770)
One of the ReactMultiChildText tests renders 2145 roots (and even more components) and unmounts none of them. Now we don't loop through them all a bunch of times so the test takes 20 seconds instead of 60.

We should clean up instantiateReactComponent somehow so that the onSetDisplayName call isn't produced for the TopLevelWrapper, which should allow us to just store an array of unmountedIDs instead of a hash map so we at least don't have double maps. This change mirrors the old logic though.

Reviewers: @gaearon, @sebmarkbage
2016-05-14 12:13:48 -07:00
Ben Alpert
5b5bd5eb75 Print stack in devtool exception warning (#6768) 2016-05-14 12:12:19 -07:00
Ben Alpert
03f4ba260b Track source more generically in ReactComponentTreeDevtool (#6765)
Being able to get the source for your parent components seems useful, and ReactComponentTreeDevtool is best poised to be able to do that.

I'm also not sure it makes sense to have separate DOM-specific `onMountDOMComponent` and `onUpdateDOMComponent` events, so I removed them for now. Even if we want them, their timing seemed sort of arbitrary.

I also made it so DOM devtools can listen to non-DOM events too. Willing to change that if people think it's ugly though.
2016-05-14 12:12:12 -07:00
Ben Alpert
c0007d56e9 Interleave trials in benchmark script
This should be more of a fair A/B test so the timings aren't affected by having different load on your system when testing the two alternatives.
2016-05-14 12:04:25 -07:00
Ben Alpert
cab835d3a0 Make benchmark script work in React 15 2016-05-14 12:03:51 -07:00
Nima Jahanshahi
32c750de5c Fixed an invalid escape char in attribute name regexp (#6772)
more info: https://www.w3.org/TR/xml/#NT-Name
2016-05-14 10:10:30 -07:00
Dan Abramov
74cce27fe0 Merge pull request #6767 from gaearon/fix-broken-master
Fix remaining onNativeOperation => onHostOperation rename
2016-05-14 01:47:31 +01:00
Dan Abramov
dea7cafd9d Fix remaining onNativeOperation → onHostOperation rename
We renamed it in #6754 but #6748 got merged after that referencing the old name.
2016-05-14 01:09:53 +01:00
Dan Abramov
5569d1d40e Merge pull request #6763 from nfcampos/is-running
added isProfiling() to ReactDebugTool and isRunning() to PerfTools
2016-05-13 20:50:38 +01:00
Nuno Campos
5b93a2bdbe added tests for repeated calls to ReactPerf.start/stop 2016-05-13 20:28:14 +01:00
Nuno Campos
201d03268e changed test 2016-05-13 08:24:25 +01:00
Ben Alpert
20bcabb1ea Remove some dead code (#6764) 2016-05-12 17:10:18 -07:00
Chad Fawcett
5d64199bb6 Add information on JSX element keys (#6751) 2016-05-12 17:02:07 -07:00
Dmitriy Kubyshkin
0e889d7c72 Fixed removing attributes during custom element update. Fixes #6747 (#6748) 2016-05-12 17:00:04 -07:00
Nuno Campos
a027d15aff added isProfiling() to ReactDebugTool and isRunning() to PerfTools 2016-05-12 19:27:05 +01:00
hao.huang
92bebcad5f Add permalink (#6713)
Add permalink to docs, so we can access with 'prev' and 'next'
2016-05-12 08:57:45 -07:00
djskinner
712b1f75bf Refer to correct example (#6760)
I *think* this should refer to the second example, where the instance to the ref is stored. In any case please can someone confirm for my own understanding?
2016-05-12 07:49:02 -07:00
Ben Alpert
ba9b985406 Rename host-y things to be "host" not "native" (#6754)
For clarity.

I left "native event" as-is because there's a lot of it, it's not particularly ambiguous, and SimulateNative/nativeTouchData are public API in ReactTestUtils.
2016-05-11 23:22:59 -07:00
Dan Abramov
de1bb7a71f Merge pull request #6753 from facebook/fix-6750
Fix a memory leak in ReactComponentTreeDevtool
2016-05-12 03:41:55 +01:00
Dan Abramov
3779a5d18c Fix a memory leak in ReactComponentTreeDevtool
`ReactDebugTool` used to only call `purgeUnmountedComponents()` while profiling, so information about unmounted instances kept accumulating when not profiling.

Additionally, unmounting in React Native and rendering to string did not correctly clean up the devtool.

Finally, the tests tested the wrong behavior and relied on explicit `purgeUnmountedComponent()` calls.

To fix this, we:

* Test specifically that unmounting is enough to clean up the tree devtool.
* Add missing `onBeginFlush` and `onEndFlush` calls to server and native rendering so `ReactDebugTool` knows when to copy the tree.

Fixes #6750
2016-05-12 03:19:55 +01:00
Dan Abramov
027d9a919b Merge pull request #6752 from facebook/fix-6742
Fix ReactPerf.printOperations() crash
2016-05-12 02:59:46 +01:00
Dan Abramov
9cebc26638 Fix a failing test and count IDs from one 2016-05-12 02:45:09 +01:00
Dan Abramov
f0594d2792 Remove the protective clause that is now unnecessary
Instead, we fixed the callsites to stop emitting events for empty components.
2016-05-12 00:50:18 +01:00
Dan Abramov
d80723b237 Check for missing debugID in ReactDebugTool
TopLevelWrapper and empty components have ID of 0.
These are implementation details and we don't want to leak them to devtools.
2016-05-12 00:45:07 +01:00
Dan Abramov
1559111bf9 Switching between null and a native should not be counted as a waste 2016-05-12 00:05:32 +01:00
Dan Abramov
0cd1d3b5a2 Allow empty components in the native operation logs
Fixes #6742
2016-05-11 23:31:50 +01:00
Marshall Bowers
6b1232aa86 Add basic issue and PR templates (#6597)
Issue template adapted from the Angular template, and PR template
adapted from the PR guidelines in CONTRIBUTING.md.
2016-05-11 15:30:25 -07:00
Dan Abramov
c8a7988bf9 Add a failing test case for #6742
getOperations() blows up when replacing null with a native because the null component has debugID of 0 that isn’t registered in the component tree.
2016-05-11 23:27:48 +01:00
Jarrod Mosen
01b060d7dc Fix grammar on homepage (#6746)
* Fix grammar in README

* Change DOM abstraction grammar on homepage
2016-05-11 15:03:05 -07:00
yiminghe
b11540ccb2 consistent owner for stateless component (#6534) 2016-05-10 22:21:16 -07:00
Sebastian Markbåge
cf157886e9 React Fiber Reconciler (#6690)
This is an outline for the new reconciler infrastructure.

I created a noop renderer to have something to get started from.

I split the reconciler folder into old and new, as well as shared.
I put shouldUpdateReactComponent in shared as an example of a
utility that can easily be shared between both. I plan on breaking
out more utilities like these.
2016-05-10 18:24:57 -07:00
Sebastian Markbåge
069f8099d6 Fix flow errors (#6719)
The new flow somehow found these on my machine but nowhere else
and not previously.
2016-05-10 11:56:32 -07:00
Ben Alpert
98cb2f8507 Revert "Don't wrap drag events in IE/Edge in dev builds" (#6741) 2016-05-10 10:58:35 -07:00
Dan Abramov
7bf96c08e6 Merge pull request #6377 from puradox/proptypes-symbol
Add new primitive PropType `Symbol`
2016-05-10 15:09:12 +01:00
Bradford
25be6dc027 fix minor capitalzation typo (#6736) 2016-05-09 21:41:40 -07:00
Dan Abramov
c3d52d8ec1 Fix zh-TW permalink 2016-05-10 02:21:10 +01:00
Dan Abramov
a95494d635 Fix ru-RU doc page permalinks
Fixes #6735
2016-05-10 01:39:15 +01:00
yiminghe
904ee9a678 allow to ignore value attribute for option (#5362) 2016-05-09 09:22:50 -07:00
Dan Abramov
982e096eb5 Merge pull request #6730 from elas7/fix-docs
[docs] Remove mention of 'nested object' as an allowed children in React.Children.map
2016-05-09 02:35:48 +01:00
Seba
46e658711e [docs] add link to create-fragment from React.Children.map docs 2016-05-08 22:12:07 -03:00
Seba
2fa52f375b [docs] Remove mention of 'nested object' as an allowed children in React.Children.map
Replace it with 'keyed fragment', since ReactFragments were made a replecement for Objects as allowed children in #4700
2016-05-08 21:26:40 -03:00
Yaxian
9ddf9e137e refine the translation of chapter 12-context (#6665) 2016-05-07 09:47:38 -07:00
Jim
96cb8c5fc4 Basic SSR support for error boundaries (#6694) 2016-05-06 16:54:06 -07:00
Sebastian Markbåge
700b7148ef Get patch versions of Flow (#6716)
Best practice or whatever.
2016-05-06 14:48:56 -07:00
Ben Alpert
82ab58ea03 Disable coverage on Travis (#6712) 2016-05-05 17:14:26 -07:00
Paul O’Shannessy
873369cc7c Cleanup: remove @nolint (#6703) 2016-05-05 16:12:17 -07:00
Andreas Svensson
2af4765a2a DOMLazyTree, populate <object> before insertion into DOM (#6691) 2016-05-05 15:12:11 -07:00
Ben Alpert
e01bf78a79 Move dev-only flags to only exist on composites (#6709)
_isOwnerNecessary was unused.
2016-05-05 15:07:04 -07:00
Dan Abramov
b6a6078167 Merge pull request #6647 from gaearon/bye-bye-reactperf
Replace ReactPerf with new implementation
2016-05-05 02:57:13 +01:00
Jay Phelps
fbe900265f [DOCS] ReactTextComponent was renamed ReactDOMTextComponent a while ago (#6700) 2016-05-04 14:44:53 -07:00
Dan Abramov
590ee490f9 Merge pull request #6696 from dotu/patch-3
Create 03-interactivity-and-dynamic-uis.ru-RU.md
2016-05-04 20:22:50 +01:00
Andrey Safronov
bbaf02950e Update 03-interactivity-and-dynamic-uis.ru-RU.md 2016-05-04 22:53:39 +04:00
Andrey Safronov
afc032b0a0 Update 03-interactivity-and-dynamic-uis.ru-RU.md
надо ли менять в заголовках слова "помещать в состояние" на "хранить в состоянии" ?
2016-05-04 19:04:26 +04:00
Keyan Zhang
9ce54210ea fixed transform-react-jsx-source devDep (#6697) 2016-05-03 23:50:27 -07:00
Andrey Safronov
dc60780d49 Create 03-interactivity-and-dynamic-uis.ru-RU.md 2016-05-04 10:01:40 +04:00
Paul O’Shannessy
c9504d99a5 Setup grunt flow task and run on travis (#6684) 2016-05-03 18:16:38 -07:00
Troy DeMonbreun
7cf61db257 Fix for #6062 : Show source line number on unknown property warning (#6398)
* New approach for 6062 fix : Show source line number on unknown property warning

* WIP: ReactDebugToolEventForwarderDevTool

* Update event signature to debugID

* Trigger events in ReactDOMComponent

* Renamed to onMountDOMComponent; passing in element directly

* Added debugID; updated simple test

* Added test for multi-div JSX to ref exact line

* Added test for composite component
2016-05-03 15:51:07 -07:00
Paul O’Shannessy
f25a88e965 grunt jest tasks shouldn't use watchman (#6675) 2016-05-03 14:39:11 -07:00
Sebastian Markbåge
771d938fc0 Set up Flow - Yay! (#6682)
This just configures flow to be checked and fixes our existing
Flow typed files.

Possible enhancements:

Export .js.flow declarations from the build. Unclear whether this
will be a supported workflow in the future or not, so let's wait
on that.

We should fail builds and CI on Flow errors.

Ideally we should lint for Flow style guides (like no space before
colon).
2016-05-03 14:37:13 -07:00
Paul O’Shannessy
48f4684b5f Ensure babelrc gets added to zipfile too (#6688) 2016-05-03 13:58:06 -07:00
Kevin Suttle
3370db14bb Fix broken link to TypeScript docs (#6687) 2016-05-03 10:56:01 -07:00
Pieter De Baets
760b1ef4c3 Remove some mocks that are already packaged by InitializeJavaScriptAppEngine (#6642) 2016-05-03 16:46:51 +01:00
Dan Abramov
82e363c464 Fix displayName in ReactPerf.getInclusive() output 2016-05-03 14:21:30 +01:00
Dan Abramov
7b241d1d7f Add tests and fix wasted render calculation 2016-05-03 14:21:30 +01:00
Dan Abramov
bc241bfcfe Add getUpdateCount() to ReactComponentTreeDevtool
It is necessary to exclude just mounted components from wasted calculation.
2016-05-03 14:21:30 +01:00
Dan Abramov
e187affcaf Make stats less noisy for top-level components 2016-05-03 14:21:29 +01:00
Dan Abramov
abe9a0ce94 Ignore lifecycle events outside batches
Technically this shouldn't happen but it seems possible with ReactNativeMount.unmountComponentAtNode().
For now, let's just ignore these lifecycle events because ReactPerf makes a hard assumption that all lifecycle hooks happen inside batches.
We can revisit later when we have a comprehensive test suite for ReactPerf itself.
2016-05-03 14:21:29 +01:00
Dan Abramov
8b9b79eb6b Fix incorrect onBegin/onEnd timer pair 2016-05-03 14:21:29 +01:00
Dan Abramov
103ca4b406 Use performanceNow() instead of performance.now() 2016-05-03 14:21:29 +01:00
Dan Abramov
49a1542c9f Emit flush events on React Native for ReactPerf 2016-05-03 14:21:29 +01:00
Dan Abramov
f22e54a947 Add getLastMeasurements() as it is documented as public API 2016-05-03 14:21:29 +01:00
Dan Abramov
411fc9ca7d Rename the new ReactPerfAnalysis to ReactPerf 2016-05-03 14:21:29 +01:00
Dan Abramov
5f8f1f6c16 Delete the old ReactPerf 2016-05-03 14:21:28 +01:00
Pieter De Baets
222f5087fe Move ReactIOS components to native subfolder (#6643)
* Move ReactIOS components to ReactNative
* Drop ReactNative subfolder
2016-05-03 14:05:33 +01:00
Tanase Hagi
83521bddb0 Update examples/basic-commonjs/package.json (#6685) 2016-05-02 20:50:25 -07:00
Jim
1d49baff63 fixed minor typo (#6568) 2016-05-02 17:59:03 -07:00
Dan Abramov
4ed46ec52f Merge pull request #6669 from dotu/patch-2
Create 02-displaying-data.ru-RU.md
2016-05-03 01:56:27 +01:00
Jake Boone
393a1798fa Grammar correction in ReactDOMInput.js warning (#6657)
Changed "a uncontrolled input" to "an uncontrolled input".
2016-05-02 15:23:22 -07:00
Brandon Dail
eb116482a3 Return early from enqueuePutListener for SSR (#6678) 2016-05-02 14:26:35 -07:00
Paul O’Shannessy
fa89cf53f2 Don't warn when style value is '0' 2016-05-02 13:23:35 -07:00
Paul O’Shannessy
468901c336 Ensure we're using latest object-assign (#6681)
This picks up the change to feature test against order bugs.
2016-05-02 13:16:25 -07:00
Andrey Safronov
d9bc567f77 Update 02-displaying-data.ru-RU
dot
2016-05-03 00:15:14 +04:00
Andrey Safronov
be9f9071d4 Update 02-displaying-data.ru-RU
исправил ошибки
2016-05-02 23:03:34 +04:00
Paul O’Shannessy
be78a41892 Revert "Merge pull request #6458 from mondaychen/master"
This reverts commit 25481083b0, reversing
changes made to 09022b165f.
2016-05-02 11:22:55 -07:00
Paul O’Shannessy
261bf28a99 Update website for 15.0.2
(cherry picked from commit 846b5ea252)
2016-05-02 10:16:03 -07:00
Paul O’Shannessy
9d14cce62f Update readme for 15.0.2
(cherry picked from commit 4dec99c61e)
2016-05-02 10:15:57 -07:00
Paul O’Shannessy
06f538a61e Changelog for 15.0.2
(cherry picked from commit a157791264)
2016-05-02 10:15:45 -07:00
Andrey Safronov
b6c2973b55 Update 02-displaying-data.ru-RU
Многие предложения перестроены, добавлены запятые
2016-05-02 18:43:26 +04:00
Desmond Brand
db175052c0 Add links to docs for addons and top level API (#6555)
This makes it easier to figure out where the docs live.

Googling for e.g. `react-addons-update` also works, but this should
make things easier for people that hyperclick directly to the source.
2016-05-02 06:14:28 -07:00
Andrey Safronov
eeb59246b2 Create 02-displaying-data.ru-RU.md
Translation for language code ru-RU
2016-05-01 15:52:42 +04:00
Sasha Aickin
256753b830 Add test logic to make sure that events get tested when rendering on top of server-generated markup. (#6668) 2016-04-30 11:21:34 -07:00
Greg Hurrell
4f01b4b186 Remove errant console.log (#6664)
That crept in in c1e3f7ec14.
2016-04-30 07:45:23 -07:00
Andrey Safronov
08e568cfc8 Create 01-why-react.ru-RU.md (#6659)
* Create 01-why-react.ru-RU.md

* Create 01-why-react.ru-RU.md

Translation for language code [ru-RU](https://en.wikipedia.org/wiki/Russian_language)

* Create 01-why-react.ru-RU.md

Errors fixes

* Update 01-why-react.ru-RU.md

исправил "чтобы решить".
спасибо за отзывчивость. надеюсь дальнейшие переводы хоть немного помогут распространению React в России :)
2016-04-30 07:43:25 -07:00
Sebastian Markbåge
0e4b046634 Get rid of transformMatrix/decomposeMatrix special case (#6660)
This is no longer needed on the native side.

This is also the last use of the Platform flag. React Core is now
platform agnostic with regard to React Native. So I'll remove
the mocks and dependency.
2016-04-29 15:57:12 -07:00
Jason Quense
a02eeb59f5 Bail out of dedupe logic in cases where there is an incomplete value descriptor (#6648) 2016-04-29 15:21:01 -07:00
Jan Schär
3d31361cfb Allow custom elements extending native ones (#6570)
...by passing the `is` attribute as the second param to `createElement`.
See http://webcomponents.org/polyfills/custom-elements/
2016-04-29 15:05:33 -07:00
Ben Alpert
c1e3f7ec14 Fix bug with double updates in a single batch (#6650)
Fixes #2410. Fixes #6371. Fixes #6538.

I also manually tested the codepen in #3762 and verified it now works.
2016-04-29 14:02:51 -07:00
Jackson Huang
44f84634d7 Create 01-why-react.zh-TW.md (#6470)
* Create 01-why-react.zh-TW.md

Translation for language code [zh-TW](https://en.wikipedia.org/wiki/Zh-TW)

* Update 01-why-react.zh-TW.md

change "封裝性非常好" to "封裝性高"
2016-04-29 08:55:50 -07:00
Dan Abramov
45ec1265eb Merge pull request #6633 from gaearon/native-tree-devtool
Make ReactComponentTreeDevtool work with React Native
2016-04-29 16:20:58 +01:00
Dan Abramov
b7f6a642f6 Make ReactComponentTreeDevtool work with React Native 2016-04-29 16:13:21 +01:00
Dan Abramov
98a8f49068 Merge pull request #6046 from gaearon/new-perf
Add new ReactPerf
2016-04-29 15:35:53 +01:00
Dan Abramov
67b1dbf75f Add new ReactPerf 2016-04-28 20:45:57 +01:00
Ryan Lahfa
9d201abb2b package(node-engine-version): accept 6.x versions (#6645) 2016-04-28 11:33:26 -07:00
Simen Bekkhus
772468183f Add note on how to submit a form (#6594) 2016-04-28 08:42:29 -07:00
Dan Abramov
af1a21289b Merge pull request #6628 from sheerun/patch-1
Document stateless components in formal types
2016-04-28 13:28:06 +01:00
Adam Stankiewicz
16f64c4499 Document stateless components in formal types 2016-04-28 13:47:59 +02:00
Paul O’Shannessy
096e5c7cf7 Ensure babelrc file gets packaged for starter kit (#6617) 2016-04-28 00:24:58 -07:00
Christoph Pojer
64401150a0 Merge pull request #6638 from cpojer/master
Update Jest’s grunt task.
2016-04-28 16:21:54 +09:00
cpojer
681a463240 Update Jest’s grunt task. 2016-04-28 16:08:20 +09:00
Christoph Pojer
d07b554291 Merge pull request #6620 from cpojer/master
Update to Jest 12. Codemod to new Jest APIs.
2016-04-28 15:03:20 +09:00
cpojer
8e34514096 Update to Jest 12. Codemod to new Jest APIs. 2016-04-28 14:54:57 +09:00
Sebastian Markbåge
72ba5971ae Use spread instead of deprecated merge utility (#6634) 2016-04-27 19:54:40 -07:00
Dan Abramov
b8f8360b5c Merge pull request #6388 from gaearon/bye-bye-deprecated-utils
Remove OrderedMap and ReactPropTransferer
2016-04-27 20:36:39 +01:00
Dan Abramov
3bdf09e86f Merge pull request #6612 from gaearon/instrumentation-new-operations
Add ReactNativeOperationHistoryDevtool to track native operations
2016-04-27 19:03:55 +01:00
Dan Abramov
2723323006 Remove OrderedMap and ReactPropTransferer
These are not exposed publicly and have been deprecated.
2016-04-27 17:44:02 +01:00
Dan Abramov
aaadb31827 Add ReactNativeOperationHistoryDevtool to track native operations 2016-04-26 23:50:58 +01:00
Yan Li
71179459de adds ReactRally & Reactive 2016 + conf locations (#6623) 2016-04-26 15:12:13 -07:00
Dan Abramov
f5b20bf79c Try enabling coverage again
It was disabled in d138b286db.
We should have more Travis instances now so it shouldn't run out of memory.
2016-04-26 13:21:41 +01:00
Jim
8dfdac6780 ComponentWillUnmount should only ever be invoked once (#6613) 2016-04-25 18:06:30 -07:00
Dan Abramov
76a4c46dba Merge pull request #6549 from gaearon/instrumentation-new
Provide info about component tree to devtools
2016-04-26 01:12:23 +01:00
Dan Abramov
a9e0896af8 Mute devtool events for TopLevelWrapper and empty components 2016-04-26 01:02:45 +01:00
Stolenkid
aeda84602f fixed a minor typo (#6600) 2016-04-25 14:37:52 -07:00
Dan Abramov
7dbc95f379 Merge pull request #6605 from gaearon/fix-warning-condition
Fix the warning condition in ReactDebugTool and ReactDOMDebugTool
2016-04-25 20:16:52 +01:00
z.ky
f4e608fc2e Update tutorial - add link for starting server (#6602)
To be extra helpful to beginners, and avoid questions like this: http://stackoverflow.com/questions/35758956/react-tutorial-how-do-i-start-the-server
2016-04-25 11:20:47 -07:00
Dan Abramov
1f97103d7b Flip the warning condition in ReactDebugTool and ReactDOMDebugTool
The current warning condition caused the first error to be swallowed, and all the next errors to be logged. I believe the intention was the opposite: to log the first error, and to ignore any next errors for the same method.
2016-04-25 00:41:53 +01:00
Dan Abramov
f89f94d145 Add tests for ReactDebugTool and ReactDOMDebugTool 2016-04-25 00:41:32 +01:00
Dan Abramov
acd67c368d Remove isComposite and hide TopLevelWrapper 2016-04-25 00:05:04 +01:00
Dan Abramov
9f16003e69 Assert that unmounted instances are in the tree until purged 2016-04-24 01:53:53 +01:00
Dan Abramov
829558b8b0 Refactor how native container ID is stored 2016-04-23 22:27:40 +01:00
Sebastian Markbåge
69b6869a3e Ignore events fired on missing React Native instances
This can happen if something gets unmounted before the event gets
dispatched. I'm not sure how this works out exactly but this
preserves previous behavior in this scenario.
2016-04-23 13:10:00 -07:00
Dan Abramov
900a588f63 Add safeguards to ReactComponentTreeDevtool 2016-04-23 02:23:16 +01:00
Sebastian Markbåge
2f2ed71bd0 Merge pull request #6588 from sahrens/patch-3
Delete ReactNativeGlobalInteractionHandler.js
2016-04-22 16:55:08 -07:00
Sebastian Markbåge
aacb5467a0 Merge pull request #6584 from sahrens/patch-1
[RN] Don't hold interaction handles for all touches
2016-04-22 16:54:59 -07:00
Spencer Ahrens
63fbc3f72e Delete ReactNativeGlobalInteractionHandler.js
Depends on https://github.com/facebook/react/pull/6584 to no longer reference is. See FB task #10926500
2016-04-22 16:53:34 -07:00
Sebastian Markbåge
ea504521d5 Merge pull request #6587 from sahrens/patch-2
Move PanResponder back to react-native repo temporarily.
2016-04-22 16:44:26 -07:00
Spencer Ahrens
1fc7487eaa Move PanResponder back to react-native repo temporarily.
We have some more work to do with this before we can pull it out of react-native.  FB Task #10926500
2016-04-22 16:37:00 -07:00
Spencer Ahrens
983a365f74 [RN] Don't hold interaction handles for all touches
We don't want to hold handles while doing native scrolling, etc.

FB Task: #10926500
2016-04-22 16:22:44 -07:00
Paul O’Shannessy
5ddfee8cfe Merge pull request #6576 from yuji0602/tutorial_md_sample_json_change
Changed example json value.
(cherry picked from commit ec036ed185)
2016-04-22 13:08:48 -07:00
Dan Abramov
df3c85886e Stop exposing ReactComponentTreeDevtool internal tree directly 2016-04-22 15:45:35 +01:00
Dan Abramov
1ebffa59fe ReactComponentTreeDevtool should ignore TopLevelWrapper 2016-04-22 02:42:29 +01:00
Ike Peters
9df54e0fce properly handling invalid scryRenderedDOMComponentsWithClass args (#6529)
properly handling invalid scryRenderedDOMComponentsWithClass args

properly handle invalid scryRenderedDOMComponentsWithClass args
2016-04-21 17:09:04 -07:00
Esteban
416f315c96 Fix return type in onlyChild's JSDoc (#6573)
The return type is a 'ReactElement' instead of a 'ReactComponent'.
2016-04-21 16:02:20 -07:00
Ben Alpert
0dc9b91017 Merge pull request #6572 from spicyj/rn-batch
Batch event handling in React Native
2016-04-21 15:14:56 -07:00
Ben Alpert
9f11f8c263 Batch event handling in React Native
This fixes an issue where handling events on a node that was just removed threw a "All native instances should have a tag." error and matches what we do in the DOM renderer in ReactEventListener.
2016-04-21 15:06:48 -07:00
Esteban
9462d0d040 Fix mapFunction parameters in mapChildren's JSDoc (#6569)
Remove 'key' parameter from 'mapFunction(child, key, index)'. It is no longer called with 'key'.
2016-04-21 14:28:08 -07:00
Dan Abramov
e20d366ea8 Fix expect() slipping into the non-test code 2016-04-21 22:23:35 +01:00
Dan Abramov
1f2e78359f No need for a special case here 2016-04-21 18:56:42 +01:00
Dan Abramov
ab0ef89ec7 Track parentID for ReactPerf 2016-04-21 17:59:31 +01:00
Dan Abramov
f530b977ec Test ReactComponentTreeDevtool specifically 2016-04-21 17:32:56 +01:00
Dan Abramov
b5997c8e7b Extract ReactComponentTreeDevtool 2016-04-21 17:31:04 +01:00
Minwei Xu
b7a2409919 ref-09-webcomponents.zh-CN.md (#6561) 2016-04-20 20:07:02 -07:00
Dan Abramov
835ca9bca3 Clean up the devtool tree on server rendering 2016-04-21 02:37:58 +01:00
Dan Abramov
af3603ea2f Devtools should be able to clean up the tree on client rendering 2016-04-20 19:11:38 +01:00
Paul O’Shannessy
bddecc9696 Merge pull request #6553 from zpao/cleanuppkg
Clean up package.json after #6338
2016-04-20 10:34:44 -07:00
Paul O’Shannessy
9354751dc9 Clean up package.json after #6338 2016-04-20 10:29:39 -07:00
Dan Abramov
367594a213 Enforce that info about children is available by the time onSetChildren() fires 2016-04-20 18:20:14 +01:00
Dan Abramov
1587abf6f0 Don't report children for empty and text nodes 2016-04-20 18:12:40 +01:00
Dan Abramov
804c680f06 Report dangerouslySetInnerHTML as no children 2016-04-20 18:01:52 +01:00
Dan Abramov
7884606fdb Handle updates to natives and composites 2016-04-20 17:39:33 +01:00
Dan Abramov
e9f8d57c70 Add an initial implementation of ReactDebugTool events 2016-04-20 16:59:13 +01:00
Dan Abramov
b692893640 Revert "Add ReactDebugInstanceMap"
This reverts commit 575fb79162.
2016-04-20 16:59:13 +01:00
Sebastian Markbåge
c84ad52ddb Merge pull request #6338 from sebmarkbage/reactnative2
Move React Core Integration and Injection to the Core Repo
2016-04-20 03:41:20 +01:00
Sebastian Markbage
ada60c4fd8 Remove ReactDOM.native shim
This is causing build errors.

This should be in the downstream repo if anything.

Relay has its own shim that should be preferred.
2016-04-20 03:35:31 +01:00
Sebastian Markbage
744548ad14 Fix lint for moved ReactNative 2016-04-20 03:35:31 +01:00
Sebastian Markbage
5470972f6a Update devtools injection
This isn't actually used right now so I can't test it. Because the
Chrome devtools are broken for React Native. The Nuclide integration
is in the react-native repo.
2016-04-20 03:35:31 +01:00
Sebastian Markbage
c7d90e2b35 Ensure react-native-renderer package gets copied 2016-04-20 03:35:31 +01:00
Sebastian Markbage
22a8f9964e Don't try to get the target node for responder if there is no listener
This can happen in edge cases where he listeners are already
unmounted or not mounted yet or something.
2016-04-20 03:35:31 +01:00
Sebastian Markbage
064092102d Bump package versions 2016-04-20 03:35:31 +01:00
Sebastian Markbage
dc188dd521 Update ReactNativeDOMIDOperations to deal with a single parent node
This is the new protocol.
2016-04-20 03:35:31 +01:00
Sebastian Markbage
4fcdf02068 Listeners are not attached by ID in the API
...even though they technically still are attached by.
2016-04-20 03:35:31 +01:00
Sebastian Markbage
3287d93235 Build up a native component cache for event dispatching
Changes to event overloading structure
2016-04-20 03:35:31 +01:00
Sebastian Markbage
75cec60e48 Get rid of rootNodeIDs they're just tags now 2016-04-20 03:35:30 +01:00
Sebastian Markbage
97b079b364 Fix ReactNativeComponentEnvironment providesModule
This has a different file name from its providesModule. Screws up
our build scripts.
2016-04-20 03:35:30 +01:00
Sebastian Markbage
f8335168b6 Fix 0.15 compatibility 2016-04-20 03:35:30 +01:00
Sebastian Markbage
d8e8ea5cbb Add test and mocks
Mock UIManager

Comment out dontMock that actually needs mocking
2016-04-20 03:35:30 +01:00
Sebastian Markbage
91e62c718b Strip isomorphic stuff from the ReactNative module
Also, add a shim for the isomorphic module for ios and android so that
react-native doesn't pull in react-dom when React is required.
2016-04-20 03:35:30 +01:00
Sebastian Markbage
240dfae28c Add React Native Modules to module map + fix fbjs
Our module rewrite whitelist needs to ignore providesModule files
that are going to be required from the global React Native
environment.

We also need to add ReactDOM to providesModule since we removed it
from React Native.
2016-04-20 03:35:30 +01:00
Sebastian Markbage
caa6abaecf Build an dedicated npm package for react-native-renderer 2016-04-20 03:35:30 +01:00
Sebastian Markbage
8806463a66 Add Object Spread Support to Our Babel Config
Won't really use this in prod code yet but I have a benchmark that
uses it.
2016-04-20 03:35:30 +01:00
Sebastian Markbage
fe395def65 Move React Native platform files back
These files are really only related to the platform itself and not
the React integration so I'll move them back.
2016-04-20 03:35:30 +01:00
Sebastian Markbage
6c885d28c5 Remove duplicates and move files out of native/vendor
Moving the event plugins into their dedicated folder

Removing the ExecutionEnvironment override. I will just have to fix where needed. Probably related to the Chrome debugger?
2016-04-20 03:35:30 +01:00
Sebastian Markbage
f463b731ee Copy files from the react-native repo 2016-04-20 03:35:30 +01:00
Adrian Sieber
8156ee0cab Minor fixes (#6527)
* Fix typos in CHANGELOG.md

* Fix typos in 2014-11-24-react-js-conf-updates.md
2016-04-19 14:41:42 -07:00
Denis Laxalde
de7d1da997 Remove mention of deprecated ReactLink add-on (#6535) 2016-04-18 06:26:10 -07:00
hkal
dc6fc8cc07 Helper for escaping and unescpaing component keys (#6500)
- Abstract escaping
- Provide human readible same key warnings
2016-04-15 20:55:37 -07:00
Jim
a12aab10cb Mention Enzyme on the test utils page. (#6523) 2016-04-15 16:20:43 -07:00
Jason Quense
045f1a791c Only fire input value change events when the value changes (#5746)
* Only fire input value change events when the value changes

fixes #554, fixes #1471, fixes #2185 (still trying to figure out why)

* catch programmatic value changes

* move value tracking to seperate module
2016-04-15 14:37:26 -07:00
Ben Alpert
4016e71609 Merge pull request #6469 from keyanzhang/validate-foreignObject-children
Ensure validateDOMNesting catches nested body elements
2016-04-14 18:27:13 -07:00
Keyan Zhang
6cf77ef55e Ensure validateDOMNesting catches nested body elements 2016-04-14 20:14:45 -04:00
Dan Abramov
6a93137f0e Merge pull request #6516 from gaearon/ignore-dom-writes-outside-batch
Ignore DOM writes outside the batch in ReactPerf
2016-04-15 00:03:17 +01:00
Paul O’Shannessy
befb70e42f Merge pull request #6519 from zpao/envdocsfixup
Cleanup environments doc
2016-04-14 14:44:25 -07:00
Paul O’Shannessy
bcad0a2973 Cleanup environments doc
- Use correct "Note" formatting so they render correctly
- reordered sections so Node is first
- Use "Node.js" consistently (it is a product name just like Nashorn)
- added/tweaked some of the text
- simplified the Java code so it doesn't hit the internet.
2016-04-14 14:17:44 -07:00
Dan Abramov
3b28602220 Ignore DOM writes outside the batch in ReactPerf
ReactDOMInput and a few other classes handle change event by scheduling updateWrapper() in an asap().
It gets executed after the batch, which confuses ReactPerf that expects all DOM writes to happen during a batch.
Since this implementation of ReactPerf relying on the stack is going away, let's plug the hole temporarily by ignoring DOM writes that occur during postponed updateWrapper(). In any case, they have no relation to actual calculations of wasted renders, as they don't occur due to updateComponent(), but rather due to onChange() special DOM behavior.

This fixes #5548
2016-04-14 20:57:44 +01:00
Jim
6a8c7518d3 Merge pull request #6510 from jimfb/ssr-environment-docs
Added docs for environment integration.
2016-04-14 12:27:59 -07:00
Jim
66bfee6543 Added docs for environment integration. 2016-04-14 12:25:17 -07:00
Dan Abramov
36e4fe54a8 Merge pull request #6215 from nhunzaker/nh-fix-disabled-inputs
Disabled inputs should not respond to clicks in IE
2016-04-14 19:40:21 +01:00
Dan Abramov
ae56910573 Merge pull request #6362 from gaearon/no-owner-in-test-utils
Elements from functional components in TestUtils should have no owner
2016-04-14 18:54:10 +01:00
Jim
0b1fd18685 Merge pull request #6462 from Wildhoney/master
Re-added support for attaching events to document fragments
2016-04-14 10:17:57 -07:00
Paul O’Shannessy
932334d3d4 Merge pull request #6504 from alexlur/patch-1
Replaces Array#map with Array#forEach
2016-04-13 10:43:13 -07:00
Alex
9d94d003a9 Replaces Array#map with Array#forEach 2016-04-13 17:11:08 +08:00
Jim
5785a418a2 Merge pull request #6148 from jimfb/node-package-manager
Create section on using React with package managers.
2016-04-12 22:33:47 -07:00
Jim
c01c46b88a Create section on using React with package managers. 2016-04-12 12:39:49 -07:00
Sam Balana
6e4f3eab84 Merge pull request #3 from RaitoBezarius/fork/proptypes-symbol
Remove unused ES6 Symbol dependency
2016-04-11 14:36:19 -07:00
Raito Bezarius
95fed01634 package(dependency): remove unused es6-symbol dependency 2016-04-11 20:19:09 +02:00
Nate Hunzaker
ec2c542f28 Flip conditional in DisabledInputUtils to cut hasOwnProperty calls 2016-04-08 19:47:40 -04:00
Nate Hunzaker
fc23239b67 Follow style conventions 2016-04-08 19:47:40 -04:00
Nate Hunzaker
0200946112 Move getNativeProps usage inline 2016-04-08 19:47:40 -04:00
Nate Hunzaker
fe739c2883 Disabled inputs should not respond to clicks in IE
This commit migrates over the disabled property behavior from
ReactDOMButton into a general purpose disabled event filter. It also
applies that behavior to inputs, selects, and textareas.
2016-04-08 19:47:40 -04:00
Dan Abramov
6c11bb65e1 Use the same changelog format as 15.0 post 2016-04-08 23:00:20 +01:00
Paul O’Shannessy
0a8f7329b4 Update react-linked-input
- Restores React dep to 15
- Bumps version to 1.0.1 for publishing
2016-04-08 14:53:37 -07:00
Paul O’Shannessy
dc0bea7a52 Fix extraneous markup in changelog 2016-04-08 14:41:20 -07:00
Paul O’Shannessy
44a0bd7478 Actually bump version on website
(cherry picked from commit d72885b383)
2016-04-08 14:39:03 -07:00
Paul O’Shannessy
42c0d4199b Update website for 15.0.1
(cherry picked from commit fd1476e3aa)
2016-04-08 14:39:03 -07:00
Paul O’Shannessy
a7e0da588a 15.0.1 blog post
(cherry picked from commit 142e4ebb57)
2016-04-08 14:39:03 -07:00
Paul O’Shannessy
9bbe80a6cc Update changelog & readme for 15.0.1
(cherry picked from commit a6179d03f3)
2016-04-08 14:39:03 -07:00
Wildhoney
167c27e188 Re-added support for attaching events to document fragments 2016-04-08 19:31:14 +01:00
Jim
5ac51c39a0 Merge pull request #6442 from trevorsmith/master
Correctly select options when nested inside an optgroup
2016-04-08 09:55:43 -07:00
Jim
25481083b0 Merge pull request #6458 from mondaychen/master
No unit-less CSS value warning for `value: "0"`
2016-04-08 09:20:39 -07:00
Jim
09022b165f Merge pull request #6443 from Aweary/patch-1
Grammar fix for 15.0 blog post
2016-04-08 09:09:43 -07:00
Brandon Dail
0149e8a4a9 Grammar fix for 15.0 blog post
Since "This" is the subject and singular, "have" should be "has"

New wording explaining implementation details

Grammar fix for 15.0 blog post

Since "This" is the subject and singular, "have" should be "has"

Fix wording for 15.0 blog post

nitpicks
2016-04-08 11:04:06 -05:00
Dan Abramov
08fd7d4a48 Fix extra parens in CHANGELOG 2016-04-08 17:03:44 +01:00
mondaychen
4e81eb4403 "0" can be the only valid unitless number string 2016-04-08 11:55:31 -04:00
Ben Alpert
2b1bd1d7fe Merge pull request #6449 from spicyj/option-value
Set value using attribute only on initial option render
2016-04-07 21:19:37 -07:00
Ben Alpert
5cb4a620e7 Set value using attribute only on initial option render
Tested that you can now type in the middle of a controlled input in Chrome which previously jumped your cursor to the end.

Fixes #6445.
2016-04-07 19:04:30 -07:00
Sam Balana
ad94295f13 Removed test support for medikoo/es6-symbol
There seems to be a bug with medikoo/es6-symbol where the global state
affects the implementation of the polyfill. I found this by running the
individual test file alone then running all the tests using `grunt
test`. I found that it passes when ran alone and failed when ran
collectively.

I did not find this buggy behavior with zloirock/core-js's
implementation of a polyfill for Symbol. Thus, removing I will keep the
more popular polyfill (core-js) and remove the buggy polyfill
(es6-symbol).

If you are reading this and can think of a confounding factor that is
causing this bug, please let me know and we can try to work together to
add support for medikoo/es6-symbol.
2016-04-07 17:41:42 -07:00
Paul O’Shannessy
516c1d809e Merge pull request #6444 from zpao/re__spreadwarn
Add back React.__spread and make it warn
2016-04-07 17:30:44 -07:00
Paul O’Shannessy
fc1cfb6225 Make React.__spread warn 2016-04-07 17:30:23 -07:00
Sam Balana
05820f89c1 More specific typeof check for polyfilled Symbol
Let's get more specific with our tests. Symbol has to be a function if
it's a polyfill. There are no object polyfills out there. (If there is,
ping me and I'll add support)

Instead of checking if Symbol is undefined, let's check if it's a
function instead since instanceof is depending that Symbol is already a
function.
2016-04-07 16:57:11 -07:00
Paul O’Shannessy
f02d87bdb5 Revert "Merge pull request #6431 from sebmarkbage/killspread"
This reverts commit a37e4e94fc, reversing
changes made to 411951d5b8.
2016-04-07 16:16:37 -07:00
Trevor Smith
f7181e089c Remove an unnecessary call to findDOMNode in the select optgroup test. 2016-04-07 16:43:35 -06:00
Trevor Smith
8577600a61 Add a null check when checking for the native parent of an option element. 2016-04-07 16:42:50 -06:00
Trevor Smith
b102e25663 Correctly select options when nested inside an optgroup 2016-04-07 16:30:51 -06:00
Paul O’Shannessy
6fd2b29ec8 [docs] Clarify data-reactid in v15 post 2016-04-07 15:27:05 -07:00
Paul O’Shannessy
3ed07aca5f Update readme for v15
(cherry picked from commit c49166401a)
2016-04-07 15:15:45 -07:00
Paul O’Shannessy
85372964e5 Update Changelog for v15
(cherry picked from commit 500c0003b2)
2016-04-07 15:15:44 -07:00
Paul O’Shannessy
b2bce139a4 [docs] Update site for v15
(cherry picked from commit 0275d77fc0)
2016-04-07 15:15:44 -07:00
Dan Abramov
75f4925074 Add React 15 post
(cherry picked from commit 67a4b12e27)
2016-04-07 15:15:44 -07:00
Paul O’Shannessy
3abc1f4a88 [docs] Update acknowledgements for v15
(cherry picked from commit 40c0867f63)
2016-04-07 15:15:44 -07:00
Dan Abramov
4537860f7e Add the missing download
(cherry picked from commit 1aee28ef1b)
2016-04-07 14:35:00 -07:00
Jim
2e8f28c29f Merge pull request #6364 from p-jackson/issue-5700
Don't wrap drag events in IE/Edge in dev builds
2016-04-07 14:11:12 -07:00
Jim
7b47e3e537 Merge pull request #6134 from richardscarrott/master
Warn if props obj passed into createElement / cloneElement inherits from anything other than Object
2016-04-07 14:09:18 -07:00
Jim
006058daa5 Merge pull request #6341 from borisyankov/master
Add more information to warning 'Input elements must be either controlled or uncontrolled'
2016-04-07 14:08:03 -07:00
Jim
1dc7c581db Merge pull request #6400 from jimfb/return-value-legacy
Document legacyness of the return value of ReactDOM.render()
2016-04-07 14:03:56 -07:00
Jim
62f64a84a4 Merge pull request #6419 from IvanVergiliev/master
Add documentation about empty functional components
2016-04-07 14:03:21 -07:00
Paul O’Shannessy
caa78f7985 Bump version for v16 development 2016-04-07 11:27:28 -07:00
Jim
ceb377254a Document legacyness of the return value of ReactDOM.render() 2016-04-06 16:30:25 -07:00
Ivan Vergiliev
ead6c9323b Document that stateless functional components can return null in v15 2016-04-06 20:19:14 +03:00
Ivan Vergiliev
85e01a1455 Add documentation about empty functional components 2016-04-06 01:29:59 +03:00
Sam Balana
ced7a3da90 Merge pull request #2 from RaitoBezarius/fork/proptypes-symbol
Fix code-style issue with React guidelines
2016-04-05 13:19:23 -07:00
Raito Bezarius
a98e2cb8b1 prop-types(tests,code-style): fix missing semicolon, unexpected spaces and trailing comma 2016-04-05 22:01:37 +02:00
Sam Balana
f846b54aa2 Merge pull request #1 from RaitoBezarius/fork/proptypes-symbol
Improve symbol check for (local) polyfills
2016-04-05 12:33:55 -07:00
Raito Bezarius
c291f8a81e prop-types(symbols,tests): test for polyfilled Symbol and non-Symbol elements 2016-04-02 14:28:08 +02:00
Raito Bezarius
4239f8ac3b prop-types(symbols): rewrite isSymbol to be simpler
1) If it is a native Symbol
2) If it is spec-compliant
3) Try to match non-spec compliant polyfill by a instanceof check on Symbol if it exists in the global namespace
2016-04-02 14:27:02 +02:00
Raito Bezarius
0d8ab0efa3 devDependencies: add core-js and es6-symbol polyfill for tests 2016-04-02 14:26:35 +02:00
Raito Bezarius
13d9720804 prop-types(symbols): add a helper is-symbol function 2016-04-02 10:10:05 +02:00
Sam Balana
5485ac8f6c Support for ES6 polyfills
Most ES6 polyfills will add support by implementing `Symbol` as a
function. This causes `typeof` to return `function` rather than `symbol`
for polyfilled clients.
2016-03-31 13:47:03 -07:00
Sam Balana
75c4e03718 Added tests for the new primative, Symbol.
I believe that I covered all the typical use cases for Symbols.
If you think that I missed one, feel free to contribute.
2016-03-29 17:21:24 -07:00
Sam Balana
97bcce5214 Added Symbol primative PropType.
With the edition of ECMA-262, we now have a new primative type called
Symbol. This primative type should be added to the PropTypes, as users
will eventually be using Symbols in their props for describing unique
and immutable data, such as identifiers.
2016-03-29 17:18:34 -07:00
Richard
17683e0410 Warn if props obj passed into createElement / cloneElement inherits from anything other than Object 2016-03-29 20:21:39 +01:00
Dan Abramov
291379c272 Elements from functional components in TestUtils should have no owner
Fixes #5292 and #6194
2016-03-28 21:46:33 +01:00
Philip Jackson
4687a03f54 Don't wrap drag events in IE/Edge in dev builds
Dev builds wrap synthetic events inside other events for a better debug
experience. However IE/Edge won't allow access to the
DataTransfer.dropEffect property if it's wrapped in this way.
The first time a drag event is fired, test if we're in an environment
that behaves this way and disable React's improved development
experience if we are.
2016-03-28 00:29:46 +13:00
Boris Yankov
1018e50a1a Add more information to 'Input elements must be either controlled or uncontrolled' warning 2016-03-25 16:36:48 +02:00
2055 changed files with 253699 additions and 185591 deletions

View File

@@ -2,8 +2,9 @@
"presets": ["react"],
"ignore": ["third_party"],
"plugins": [
"transform-class-properties",
"syntax-trailing-function-commas",
"babel-plugin-transform-object-rest-spread",
["transform-object-rest-spread", { "useBuiltIns": true }],
"transform-es2015-template-literals",
"transform-es2015-literals",
"transform-es2015-arrow-functions",
@@ -17,11 +18,6 @@
["transform-es2015-spread", { "loose": true }],
"transform-es2015-parameters",
["transform-es2015-destructuring", { "loose": true }],
"transform-es2015-block-scoping",
"transform-es2015-modules-commonjs",
"transform-es3-member-expression-literals",
"transform-es3-property-literals",
"./scripts/babel/transform-object-assign-require",
"transform-react-jsx-source"
["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

@@ -1,17 +1,14 @@
# We can probably lint these later but not important at this point
src/renderers/art
src/shared/vendor
# But not in docs/_js/examples/*
docs/_js/*.js
docs/js/
docs/_site/
# gems
docs/vendor/bundle/
# This should be more like examples/**/thirdparty/** but
# we should fix https://github.com/facebook/esprima/pull/85 first
examples/
# Ignore built files.
# Third party
**/node_modules
# Not written by hand
packages/react-art/npm/lib
# Build products
build/
coverage/
scripts/bench/bench-*.js
vendor/*
fixtures/
scripts/bench/benchmarks/**/*.js
# React repository clone
scripts/bench/remote-repo/

View File

@@ -1,19 +1,33 @@
'use strict';
const {
es5Paths,
esNextPaths,
} = require('./scripts/shared/pathsByLanguageVersion');
const OFF = 0;
const WARNING = 1;
const ERROR = 2;
module.exports = {
parser: 'babel-eslint',
extends: 'fbjs',
extends: './node_modules/fbjs-scripts/eslint/.eslintrc.js',
// Stop ESLint from looking for a configuration file in parent folders
'root': true,
plugins: [
'jest',
'no-for-of-loops',
'react',
'react-internal',
],
ecmaFeatures: {
modules: false
parser: 'espree',
parserOptions: {
ecmaVersion: 2017,
sourceType: 'script',
ecmaFeatures: {
experimentalObjectRestSpread: true,
},
},
// We're stricter than the default config, mostly. We'll override a few rules
@@ -22,13 +36,14 @@ module.exports = {
'accessor-pairs': OFF,
'brace-style': [ERROR, '1tbs'],
'comma-dangle': [ERROR, 'always-multiline'],
'consistent-return': ERROR,
'consistent-return': OFF,
'dot-location': [ERROR, 'property'],
'dot-notation': ERROR,
'eol-last': ERROR,
'eqeqeq': [ERROR, 'allow-null'],
'indent': [ERROR, 2, {SwitchCase: 1}],
'indent': OFF,
'jsx-quotes': [ERROR, 'prefer-double'],
'keyword-spacing': [ERROR, {after: true, before: true}],
'no-bitwise': OFF,
'no-inner-declarations': [ERROR, 'functions'],
'no-multi-spaces': ERROR,
@@ -36,39 +51,88 @@ module.exports = {
'no-shadow': ERROR,
'no-unused-expressions': ERROR,
'no-unused-vars': [ERROR, {args: 'none'}],
'quotes': [ERROR, 'single', 'avoid-escape'],
'space-after-keywords': ERROR,
'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': [ERROR, {anonymous: 'never', named: 'never'}],
'space-before-keywords': ERROR,
'strict': [ERROR, 'global'],
'space-before-function-paren': OFF,
'valid-typeof': [ERROR, {requireStringLiterals: true}],
// We apply these settings to files that should run on Node.
// They can't use JSX or ES6 modules, and must be in strict mode.
// They can, however, use other ES6 features.
// (Note these rules are overridden later for source files.)
'no-var': ERROR,
strict: ERROR,
// React & JSX
// Our transforms set this automatically
'react/display-name': OFF,
'react/jsx-boolean-value': [ERROR, 'always'],
'react/jsx-no-undef': ERROR,
// We don't care to do this
'react/jsx-sort-prop-types': OFF,
'react/jsx-sort-props': OFF,
'react/jsx-space-before-closing': ERROR,
'react/jsx-uses-react': ERROR,
'react/jsx-uses-vars': ERROR,
// It's easier to test some things this way
'react/no-did-mount-set-state': OFF,
'react/no-did-update-set-state': OFF,
// We define multiple components in test files
'react/no-multi-comp': OFF,
'react/no-unknown-property': OFF,
'react/no-is-mounted': OFF,
// This isn't useful in our test code
'react/prop-types': OFF,
'react/react-in-jsx-scope': ERROR,
'react/self-closing-comp': ERROR,
// We don't care to do this
'react/sort-comp': OFF,
'react/wrap-multilines': [ERROR, {declaration: false, assignment: false}],
'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/no-primitive-constructors': ERROR,
'react-internal/no-to-warn-dev-within-to-throw': ERROR,
'react-internal/warning-and-invariant-args': ERROR,
}
},
overrides: [
{
// We apply these settings to files that we ship through npm.
// They must be ES5.
files: es5Paths,
parser: 'espree',
parserOptions: {
ecmaVersion: 5,
sourceType: 'script',
},
rules: {
'no-var': OFF,
strict: ERROR,
},
},
{
// We apply these settings to the source files that get compiled.
// They can use all features including JSX (but shouldn't use `var`).
files: esNextPaths,
parser: 'babel-eslint',
parserOptions: {
sourceType: 'module',
},
rules: {
'no-var': ERROR,
strict: OFF,
},
},
{
files: ['**/__tests__/*.js'],
rules: {
// https://github.com/jest-community/eslint-plugin-jest
'jest/no-focused-tests': ERROR,
}
}
],
globals: {
spyOnDev: true,
spyOnDevAndProd: true,
spyOnProd: true,
__PROFILE__: true,
__UMD__: true,
},
};

View File

@@ -1,37 +0,0 @@
[ignore]
.*/examples/.*
.*/build/.*
.*/node_modules/y18n/.*
.*/__mocks__/.*
.*/__tests__/.*
# Ignore Docs
.*/docs/.*
[include]
[libs]
./node_modules/fbjs/flow/lib
./flow
[options]
module.system=haste
esproposal.class_static_fields=enable
esproposal.class_instance_fields=enable
experimental.strict_type_args=true
munge_underscores=false
suppress_type=$FlowIssue
suppress_type=$FlowFixMe
suppress_type=$FixMe
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-4]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-4]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*\\)?)\\)? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
[version]
^0.27.0

14
.github/ISSUE_TEMPLATE.md vendored Normal file
View File

@@ -0,0 +1,14 @@
<!--
Note: if the issue is about documentation or the website, please file it at:
https://github.com/reactjs/reactjs.org/issues/new
-->
**Do you want to request a *feature* or report a *bug*?**
**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. 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?**
**Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?**

14
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View File

@@ -0,0 +1,14 @@
**Before submitting a pull request,** please make sure the following is done:
1. Fork [the repository](https://github.com/facebook/react) and create your branch from `master`.
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. 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

16
.gitignore vendored
View File

@@ -1,23 +1,17 @@
.DS_STORE
node_modules
scripts/flow/*/.flowconfig
*~
*.pyc
static
.grunt
_SpecRunner.html
__benchmarks__
build/
remote-repo/
coverage/
.module-cache
*.gem
docs/.bundle
docs/code
docs/_site
docs/.sass-cache
docs/js/*
docs/downloads
docs/vendor/bundle
examples/shared/*.js
fixtures/dom/public/react-dom.js
fixtures/dom/public/react.js
test/the-files-to-test.generated.js
*.log*
chrome-user-data
@@ -26,3 +20,5 @@ chrome-user-data
.idea
*.iml
.vscode
*.swp
*.swo

View File

@@ -11,8 +11,6 @@ Andrew Kulakov <avk@8xx8.ru>
Andrew Sokolov <asokolov@atlassian.com>
Anto Aravinth <anto.aravinth.cse@gmail.com>
Baraa Hamodi <bhamodi@uwaterloo.ca> <baraa@optimizely.com>
Ben Alpert <ben@benalpert.com> <balpert@fb.com>
Ben Alpert <ben@benalpert.com> <spicyjalapeno@gmail.com>
Ben Halpern <bendhalpern@gmail.com>
Ben Newman <bn@cs.stanford.edu> <benjamn@fb.com>
Benjamin Woodruff <github@benjam.info> <bgw@fb.com>
@@ -137,6 +135,10 @@ Sebastian Markbåge <sebastian@calyptus.eu> <sema@fb.com>
Sergey Rubanov <chi187@gmail.com>
Shogun Sea <shogunsea08@gmail.com> <xxin@groupon.com>
Soichiro Kawamura <mail@w-st.com>
Sophie Alpert <git@sophiebits.com> <balpert@fb.com>
Sophie Alpert <git@sophiebits.com> <ben@benalpert.com>
Sophie Alpert <git@sophiebits.com> <sophiebits@fb.com>
Sophie Alpert <git@sophiebits.com> <spicyjalapeno@gmail.com>
Sota Ohara <ohrst.18@gmail.com>
Steven Luscher <react@steveluscher.com> <github@steveluscher.com>
Steven Luscher <react@steveluscher.com> <steveluscher@fb.com>

1
.nvmrc Normal file
View File

@@ -0,0 +1 @@
v8.4.0

21
.prettierrc.js Normal file
View File

@@ -0,0 +1,21 @@
'use strict';
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',
},
},
],
};

View File

@@ -1,114 +0,0 @@
---
sudo: required
dist: trusty
language: node_js
node_js:
- 4
rvm:
- 2.2.3
cache:
directories:
- docs/vendor/bundle
- node_modules
before_install:
- |
if [ "$TEST_TYPE" != build_website ] && \
! git diff --name-only $TRAVIS_COMMIT_RANGE | grep -qvE '(\.md$)|(^(docs|examples))/'
then
echo "Only docs were updated, stopping build process."
exit
fi
npm install -g npm@latest-2
npm --version
script:
- |
if [ "$TEST_TYPE" = build_website ]; then
if [ "$TRAVIS_BRANCH" = "$REACT_WEBSITE_BRANCH" ] && [ "$TRAVIS_PULL_REQUEST" = false ]; then
set -e
GH_PAGES_DIR="$TRAVIS_BUILD_DIR"/../react-gh-pages
echo "machine github.com login reactjs-bot password $GITHUB_TOKEN" >~/.netrc
git config --global user.name "Travis CI"
git config --global user.email "travis@reactjs.org"
git clone --branch gh-pages --depth=50 \
https://reactjs-bot@github.com/facebook/react.git \
$GH_PAGES_DIR
pushd docs
bundle install --jobs=3 --retry=3 --path=vendor/bundle
bundle exec rake release
cd $GH_PAGES_DIR
git status
if ! git diff-index --quiet HEAD --; then
git add -A .
git commit -m "Rebuild website"
git push origin gh-pages
fi
popd
fi
elif [ "$TEST_TYPE" = build ]; then
if [ "$SERVER" ]; then
set -e
./node_modules/.bin/grunt build
curl \
-F "react=@build/react.js" \
-F "react.min=@build/react.min.js" \
-F "react-with-addons=@build/react-with-addons.js" \
-F "react-with-addons.min=@build/react-with-addons.min.js" \
-F "react-dom=@build/react-dom.js" \
-F "react-dom.min=@build/react-dom.min.js" \
-F "react-dom-server=@build/react-dom-server.js" \
-F "react-dom-server.min=@build/react-dom-server.min.js" \
-F "npm-react=@build/packages/react.tgz" \
-F "npm-react-dom=@build/packages/react-dom.tgz" \
-F "npm-react-native=@build/packages/react-native-renderer.tgz" \
-F "commit=$TRAVIS_COMMIT" \
-F "date=`git log --format='%ct' -1`" \
-F "pull_request=$TRAVIS_PULL_REQUEST" \
-F "token=$SECRET_TOKEN" \
-F "branch=$TRAVIS_BRANCH" \
$SERVER
fi
elif [ "$TEST_TYPE" = test ]; then
set -e
# Disabling coverage because it's broken:
# https://travis-ci.org/facebook/react/jobs/128163922
if false; then
./node_modules/.bin/grunt jest:coverage
cat ./coverage/lcov.info | ./node_modules/.bin/coveralls
else
./node_modules/.bin/grunt jest:normal
fi
echo 'Testing in server-render (HTML generation) mode...'
printf '\nmodule.exports.useCreateElement = false;\n' \
>> src/renderers/dom/shared/ReactDOMFeatureFlags.js
./node_modules/.bin/grunt jest:normal
git checkout -- src/renderers/dom/shared/ReactDOMFeatureFlags.js
./node_modules/.bin/gulp react:extract-errors
else
./node_modules/.bin/grunt $TEST_TYPE
fi
env:
matrix:
- TEST_TYPE=build
- TEST_TYPE=test
- TEST_TYPE=lint
- TEST_TYPE=flow
- TEST_TYPE=build_website
global:
# SERVER
- secure: qPvsJ46XzGrdIuPA70b55xQNGF8jcK7N1LN5CCQYYocXLa+fBrl+fTE77QvehOPhqwJXcj6kOxI+sY0KrVwV7gmq2XY2HZGWUSCxTN0SZlNIzqPA80Y7G/yOjA4PUt8LKgP+8tptyhTAY56qf+hgW8BoLiKOdztYF2p+3zXOLuA=
# SECRET_TOKEN
- secure: dkpPW+VnoqC/okhRdV90m36NcyBFhcwEKL3bNFExAwi0dXnFao8RoFlvnwiPlA23h2faROkMIetXlti6Aju08BgUFV+f9aL6vLyU7gUent4Nd3413zf2fwDtXIWIETg6uLnOpSykGKgCAT/hY3Q2oPLqOoY0OxfgnbqwxkxljrE=
# GITHUB_TOKEN
- secure: EHCyCSKMwKlLHNtcj9nmkRzmiiPE3aDGlPcnEyrDJeRI0SeN/iCXHXfFivR0vFq3vr+9naMBczAR2AEidtps5KbJrKqdZnjPFRbmfVtzWr/LlvVCub3u13Pub6TdKIVBTny1PuZ5X8GvdxMNVig89jGjvzhhWuQRaz3VhJnTra4=
# COVERALLS_TOKEN
- secure: h/cUq+TrUMZOQmkFD7CvuwX0uAwmjIfKZ4qSUzY+QzUtDzOzA0L/XF84xTBq1Q5YYsEiaoF6GxxGCdrLQiBA/ZTd+88UHgeZPMRvi0xG9Q+PeePVOsZMTxy4/WWFgOfSQCk49Mj9zizGgO78i6vxq+SDXMtFHnZ+TpPJIEW6/m0=
notifications:
irc:
use_notice: true
skip_join: true
on_success: change
on_failure: change
channels:
- chat.freenode.net#reactjs

0
.watchmanconfig Normal file
View File

437
AUTHORS

File diff suppressed because it is too large Load Diff

View File

@@ -1,11 +1,739 @@
## [Unreleased]
<details>
<summary>
Changes that have landed in master but are not yet released.
Click to see more.
</summary>
</details>
## 16.6.1 (November 6, 2018)
### React DOM
* Fallback should not remount every time a promise resolves. ([@acdlite](https://github.com/acdlite) in [#14083](https://github.com/facebook/react/pull/14083))
* Fix bug where Suspense keeps showing fallback even after everything finishes loading. ([@acdlite](https://github.com/acdlite) in [#14083](https://github.com/facebook/react/pull/14083))
* Fix unresolved default props in lifecycle methods of a lazy component. ([@gaearon](https://github.com/gaearon) in [#14112](https://github.com/facebook/react/pull/14112))
* Fix bug when recovering from an error thrown during complete phase. ([@gaearon](https://github.com/gaearon) in [#14104](https://github.com/facebook/react/pull/14104))
### Scheduler (Experimental)
* Switch from deadline object to `shouldYield` API. ([@acdlite](https://github.com/acdlite) in [#14025](https://github.com/facebook/react/pull/14025))
## 16.6.0 (October 23, 2018)
### React
* Add `React.memo()` as an alternative to `PureComponent` for functions. ([@acdlite](https://github.com/acdlite) in [#13748](https://github.com/facebook/react/pull/13748))
* Add `React.lazy()` for code splitting components. ([@acdlite](https://github.com/acdlite) in [#13885](https://github.com/facebook/react/pull/13885))
* `React.StrictMode` now warns about legacy context API. ([@bvaughn](https://github.com/bvaughn) in [#13760](https://github.com/facebook/react/pull/13760))
* `React.StrictMode` now warns about `findDOMNode`. ([@sebmarkbage](https://github.com/sebmarkbage) in [#13841](https://github.com/facebook/react/pull/13841))
* Rename `unstable_AsyncMode` to `unstable_ConcurrentMode`. ([@trueadm](https://github.com/trueadm) in [#13732](https://github.com/facebook/react/pull/13732))
* Rename `unstable_Placeholder` to `Suspense`, and `delayMs` to `maxDuration`. ([@gaearon](https://github.com/gaearon) in [#13799](https://github.com/facebook/react/pull/13799) and [@sebmarkbage](https://github.com/sebmarkbage) in [#13922](https://github.com/facebook/react/pull/13922))
### React DOM
* Add `contextType` as a more ergonomic way to subscribe to context from a class. ([@bvaughn](https://github.com/bvaughn) in [#13728](https://github.com/facebook/react/pull/13728))
* Add `getDerivedStateFromError` lifecycle method for catching errors in a future asynchronous server-side renderer. ([@bvaughn](https://github.com/bvaughn) in [#13746](https://github.com/facebook/react/pull/13746))
* Warn when `<Context>` is used instead of `<Context.Consumer>`. ([@trueadm](https://github.com/trueadm) in [#13829](https://github.com/facebook/react/pull/13829))
* Fix gray overlay on iOS Safari. ([@philipp-spiess](https://github.com/philipp-spiess) in [#13778](https://github.com/facebook/react/pull/13778))
* Fix a bug caused by overwriting `window.event` in development. ([@sergei-startsev](https://github.com/sergei-startsev) in [#13697](https://github.com/facebook/react/pull/13697))
### React DOM Server
* Add support for `React.memo()`. ([@alexmckenley](https://github.com/alexmckenley) in [#13855](https://github.com/facebook/react/pull/13855))
* Add support for `contextType`. ([@alexmckenley](https://github.com/alexmckenley) and [@sebmarkbage](https://github.com/sebmarkbage) in [#13889](https://github.com/facebook/react/pull/13889))
### Scheduler (Experimental)
* Rename the package to `scheduler`. ([@gaearon](https://github.com/gaearon) in [#13683](https://github.com/facebook/react/pull/13683))
* Support priority levels, continuations, and wrapped callbacks. ([@acdlite](https://github.com/acdlite) in [#13720](https://github.com/facebook/react/pull/13720) and [#13842](https://github.com/facebook/react/pull/13842))
* Improve the fallback mechanism in non-DOM environments. ([@acdlite](https://github.com/acdlite) in [#13740](https://github.com/facebook/react/pull/13740))
* Schedule `requestAnimationFrame` earlier. ([@acdlite](https://github.com/acdlite) in [#13785](https://github.com/facebook/react/pull/13785))
* Fix the DOM detection to be more thorough. ([@trueadm](https://github.com/trueadm) in [#13731](https://github.com/facebook/react/pull/13731))
* Fix bugs with interaction tracing. ([@bvaughn](https://github.com/bvaughn) in [#13590](https://github.com/facebook/react/pull/13590))
* Add the `envify` transform to the package. ([@mridgway](https://github.com/mridgway) in [#13766](https://github.com/facebook/react/pull/13766))
## 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.
### All Packages
* Fix an accidental extra global variable in the UMD builds. ([@gaearon](https://github.com/gaearon) in [#10935](https://github.com/facebook/react/pull/10935))
### React
* Add support for portals in `React.Children` utilities. ([@MatteoVH](https://github.com/MatteoVH) in [#11378](https://github.com/facebook/react/pull/11378))
* Warn when a class has a `render` method but doesn't extend a known base class. ([@sw-yx](https://github.com/sw-yx) in [#11168](https://github.com/facebook/react/pull/11168))
* Improve the warning when accidentally returning an object from constructor. ([@deanbrophy](https://github.com/deanbrophy) in [#11395](https://github.com/facebook/react/pull/11395))
### React DOM
* Allow `on` as a custom attribute for AMP. ([@nuc](https://github.com/nuc) in [#11153](https://github.com/facebook/react/pull/11153))
* 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](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](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](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))
* Deduplicate other warnings about updates. ([@anushreesubramani](https://github.com/anushreesubramani) in [#11216](https://github.com/facebook/react/pull/11216))
* Include component stack into the warning about `contentEditable` and `children`. ([@Ethan-Arrowood](https://github.com/Ethan-Arrowood) in [#11208](https://github.com/facebook/react/pull/11208))
* 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](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
* 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](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
* Fix multiple `setState()` calls in `componentWillMount()` in shallow renderer. ([@Hypnosphi](https://github.com/Hypnosphi) in [#11167](https://github.com/facebook/react/pull/11167))
* Fix shallow renderer to ignore `shouldComponentUpdate()` after `forceUpdate()`. ([@d4rky-pl](https://github.com/d4rky-pl) in [#11239](https://github.com/facebook/react/pull/11239) and [#11439](https://github.com/facebook/react/pull/11439))
* Handle `forceUpdate()` and `React.PureComponent` correctly. ([@koba04](https://github.com/koba04) in [#11440](https://github.com/facebook/react/pull/11440))
* Add back support for running in production mode. ([@gaearon](https://github.com/gaearon) in [#11112](https://github.com/facebook/react/pull/11112))
* Add a missing `package.json` dependency. ([@gaearon](https://github.com/gaearon) in [#11340](https://github.com/facebook/react/pull/11340))
### React ART
* Add a missing `package.json` dependency. ([@gaearon](https://github.com/gaearon) in [#11341](https://github.com/facebook/react/pull/11341))
* Expose `react-art/Circle`, `react-art/Rectangle`, and `react-art/Wedge`. ([@gaearon](https://github.com/gaearon) in [#11343](https://github.com/facebook/react/pull/11343))
### React Reconciler (Experimental)
* First release of the [new experimental package](https://github.com/facebook/react/blob/master/packages/react-reconciler/README.md) for creating custom renderers. ([@iamdustan](https://github.com/iamdustan) in [#10758](https://github.com/facebook/react/pull/10758))
* Add support for React DevTools. ([@gaearon](https://github.com/gaearon) in [#11463](https://github.com/facebook/react/pull/11463))
### React Call Return (Experimental)
* 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))
## 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)
### New JS Environment Requirements
* React 16 depends on the collection types [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) and [Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set), as well as [requestAnimationFrame](https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame). If you support older browsers and devices which may not yet provide these natively (e.g. <IE11), [you may want to include a polyfill](https://gist.github.com/gaearon/9a4d54653ae9c50af6c54b4e0e56b583).
### New Features
* Components can now return arrays and strings from `render`. (Docs coming soon!)
* Improved error handling with introduction of "error boundaries". [Error boundaries](https://reactjs.org/blog/2017/07/26/error-handling-in-react-16.html) are React components that catch JavaScript errors anywhere in their child component tree, log those errors, and display a fallback UI instead of the component tree that crashed.
* First-class support for declaratively rendering a subtree into another DOM node with `ReactDOM.createPortal()`. (Docs coming soon!)
* Streaming mode for server side rendering is enabled with `ReactDOMServer.renderToNodeStream()` and `ReactDOMServer.renderToStaticNodeStream()`. ([@aickin](https://github.com/aickin) in [#10425](https://github.com/facebook/react/pull/10425), [#10044](https://github.com/facebook/react/pull/10044), [#10039](https://github.com/facebook/react/pull/10039), [#10024](https://github.com/facebook/react/pull/10024), [#9264](https://github.com/facebook/react/pull/9264), and others.)
* [React DOM now allows passing non-standard attributes](https://reactjs.org/blog/2017/09/08/dom-attributes-in-react-16.html). ([@nhunzaker](https://github.com/nhunzaker) in [#10385](https://github.com/facebook/react/pull/10385), [10564](https://github.com/facebook/react/pull/10564), [#10495](https://github.com/facebook/react/pull/10495) and others)
### Breaking Changes
- There are several changes to the behavior of scheduling and lifecycle methods:
* `ReactDOM.render()` and `ReactDOM.unstable_renderIntoContainer()` now return `null` if called from inside a lifecycle method.
* To work around this, you can either use [the new portal API](https://github.com/facebook/react/issues/10309#issuecomment-318433235) or [refs](https://github.com/facebook/react/issues/10309#issuecomment-318434635).
* Minor changes to `setState` behavior:
* Calling `setState` with null no longer triggers an update. This allows you to decide in an updater function if you want to re-render.
* Calling `setState` directly in render always causes an update. This was not previously the case. Regardless, you should not be calling `setState` from render.
* `setState` callback (second argument) now fires immediately after `componentDidMount` / `componentDidUpdate` instead of after all components have rendered.
* When replacing `<A />` with `<B />`, `B.componentWillMount` now always happens before `A.componentWillUnmount`. Previously, `A.componentWillUnmount` could fire first in some cases.
* Previously, changing the `ref` to a component would always detach the ref before that component's render is called. Now, we change the `ref` later, when applying the changes to the DOM.
* It is not safe to re-render into a container that was modified by something other than React. This worked previously in some cases but was never supported. We now emit a warning in this case. Instead you should clean up your component trees using `ReactDOM.unmountComponentAtNode`. [See this example.](https://github.com/facebook/react/issues/10294#issuecomment-318820987)
* `componentDidUpdate` lifecycle no longer receives `prevContext` param. ([@bvaughn](https://github.com/bvaughn) in [#8631](https://github.com/facebook/react/pull/8631))
* Non-unique keys may now cause children to be duplicated and/or omitted. Using non-unique keys is not (and has never been) supported, but previously it was a hard error.
* Shallow renderer no longer calls `componentDidUpdate()` because DOM refs are not available. This also makes it consistent with `componentDidMount()` (which does not get called in previous versions either).
* Shallow renderer does not implement `unstable_batchedUpdates()` anymore.
* `ReactDOM.unstable_batchedUpdates` now only takes one extra argument after the callback.
- The names and paths to the single-file browser builds have changed to emphasize the difference between development and production builds. For example:
- `react/dist/react.js``react/umd/react.development.js`
- `react/dist/react.min.js``react/umd/react.production.min.js`
- `react-dom/dist/react-dom.js``react-dom/umd/react-dom.development.js`
- `react-dom/dist/react-dom.min.js``react-dom/umd/react-dom.production.min.js`
* The server renderer has been completely rewritten, with some improvements:
* Server rendering does not use markup validation anymore, and instead tries its best to attach to existing DOM, warning about inconsistencies. It also doesn't use comments for empty components and data-reactid attributes on each node anymore.
* Hydrating a server rendered container now has an explicit API. Use `ReactDOM.hydrate` instead of `ReactDOM.render` if you're reviving server rendered HTML. Keep using `ReactDOM.render` if you're just doing client-side rendering.
* When "unknown" props are passed to DOM components, for valid values, React will now render them in the DOM. [See this post for more details.](https://reactjs.org/blog/2017/09/08/dom-attributes-in-react-16.html) ([@nhunzaker](https://github.com/nhunzaker) in [#10385](https://github.com/facebook/react/pull/10385), [10564](https://github.com/facebook/react/pull/10564), [#10495](https://github.com/facebook/react/pull/10495) and others)
* Errors in the render and lifecycle methods now unmount the component tree by default. To prevent this, add [error boundaries](https://reactjs.org/blog/2017/07/26/error-handling-in-react-16.html) to the appropriate places in the UI.
### Removed Deprecations
- There is no `react-with-addons.js` build anymore. All compatible addons are published separately on npm, and have single-file browser versions if you need them.
- The deprecations introduced in 15.x have been removed from the core package. `React.createClass` is now available as create-react-class, `React.PropTypes` as prop-types, `React.DOM` as react-dom-factories, react-addons-test-utils as react-dom/test-utils, and shallow renderer as react-test-renderer/shallow. See [15.5.0](https://reactjs.org/blog/2017/04/07/react-v15.5.0.html) and [15.6.0](https://reactjs.org/blog/2017/06/13/react-v15.6.0.html) blog posts for instructions on migrating code and automated codemods.
## 15.6.2 (September 25, 2017)
### All Packages
* Switch from BSD + Patents to MIT license
### React DOM
* Fix a bug where modifying `document.documentMode` would trigger IE detection in other browsers, breaking change events. ([@aweary](https://github.com/aweary) in [#10032](https://github.com/facebook/react/pull/10032))
* CSS Columns are treated as unitless numbers. ([@aweary](https://github.com/aweary) in [#10115](https://github.com/facebook/react/pull/10115))
* Fix bug in QtWebKit when wrapping synthetic events in proxies. ([@walrusfruitcake](https://github.com/walrusfruitcake) in [#10115](https://github.com/facebook/react/pull/10011))
* Prevent event handlers from receiving extra argument in development. ([@aweary](https://github.com/aweary) in [#10115](https://github.com/facebook/react/pull/8363))
* Fix cases where `onChange` would not fire with `defaultChecked` on radio inputs. ([@jquense](https://github.com/jquense) in [#10156](https://github.com/facebook/react/pull/10156))
* Add support for `controlList` attribute to DOM property whitelist ([@nhunzaker](https://github.com/nhunzaker) in [#9940](https://github.com/facebook/react/pull/9940))
* Fix a bug where creating an element with a ref in a constructor did not throw an error in development. ([@iansu](https://github.com/iansu) in [#10025](https://github.com/facebook/react/pull/10025))
## 15.6.1 (June 14, 2017)
### React DOM
* Fix a crash on iOS Safari. ([@jquense](https://github.com/jquense) in [#9960](https://github.com/facebook/react/pull/9960))
* Don't add `px` to custom CSS property values. ([@TrySound](https://github.com/TrySound) in [#9966](https://github.com/facebook/react/pull/9966))
## 15.6.0 (June 13, 2017)
### React
* Downgrade deprecation warnings to use `console.warn` instead of `console.error`. ([@flarnie](https://github.com/flarnie) in [#9753](https://github.com/facebook/react/pull/9753))
* Add a deprecation warning for `React.createClass`. Points users to `create-react-class` instead. ([@flarnie](https://github.com/flarnie) in [#9771](https://github.com/facebook/react/pull/9771))
* Add deprecation warnings and separate module for `React.DOM` factory helpers. ([@nhunzaker](https://github.com/nhunzaker) in [#8356](https://github.com/facebook/react/pull/8356))
* Warn for deprecation of `React.createMixin` helper, which was never used. ([@aweary](https://github.com/aweary) in [#8853](https://github.com/facebook/react/pull/8853))
### React DOM
* Add support for CSS variables in `style` attribute. ([@aweary](https://github.com/aweary) in [#9302](https://github.com/facebook/react/pull/9302))
* Add support for CSS Grid style properties. ([@ericsakmar](https://github.com/ericsakmar) in [#9185](https://github.com/facebook/react/pull/9185))
* Fix bug where inputs mutated value on type conversion. ([@nhunzaker](https://github.com/mhunzaker) in [#9806](https://github.com/facebook/react/pull/9806))
* Fix issues with `onChange` not firing properly for some inputs. ([@jquense](https://github.com/jquense) in [#8575](https://github.com/facebook/react/pull/8575))
* Fix bug where controlled number input mistakenly allowed period. ([@nhunzaker](https://github.com/nhunzaker) in [#9584](https://github.com/facebook/react/pull/9584))
* Fix bug where performance entries were being cleared. ([@chrisui](https://github.com/chrisui) in [#9451](https://github.com/facebook/react/pull/9451))
### React Addons
* Fix AMD support for addons depending on `react`. ([@flarnie](https://github.com/flarnie) in [#9919](https://github.com/facebook/react/issues/9919))
* Fix `isMounted()` to return `true` in `componentWillUnmount`. ([@mridgway](https://github.com/mridgway) in [#9638](https://github.com/facebook/react/issues/9638))
* Fix `react-addons-update` to not depend on native `Object.assign`. ([@gaearon](https://github.com/gaearon) in [#9937](https://github.com/facebook/react/pull/9937))
* Remove broken Google Closure Compiler annotation from `create-react-class`. ([@gaearon](https://github.com/gaearon) in [#9933](https://github.com/facebook/react/pull/9933))
* Remove unnecessary dependency from `react-linked-input`. ([@gaearon](https://github.com/gaearon) in [#9766](https://github.com/facebook/react/pull/9766))
* Point `react-addons-(css-)transition-group` to the new package. ([@gaearon](https://github.com/gaearon) in [#9937](https://github.com/facebook/react/pull/9937))
## 15.5.4 (April 11, 2017)
### React Addons
* **Critical Bugfix:** Update the version of `prop-types` to fix critical bug. ([@gaearon](https://github.com/gaearon) in [545c87f](https://github.com/facebook/react/commit/545c87fdc348f82eb0c3830bef715ed180785390))
* Fix `react-addons-create-fragment` package to include `loose-envify` transform for Browserify users. ([@mridgway](https://github.com/mridgway) in [#9642](https://github.com/facebook/react/pull/9642))
### React Test Renderer
* Fix compatibility with Enzyme by exposing `batchedUpdates` on shallow renderer. ([@gaearon](https://github.com/gaearon) in [9382](https://github.com/facebook/react/commit/69933e25c37cf5453a9ef132177241203ee8d2fd))
## 15.5.3 (April 7, 2017)
**Note: this release has a critical issue and was deprecated. Please update to 15.5.4 or higher.**
### React Addons
* Fix `react-addons-create-fragment` package to export correct thing. ([@gaearon](https://github.com/gaearon) in [#9385](https://github.com/facebook/react/pull/9383))
* Fix `create-react-class` package to include `loose-envify` transform for Browserify users. ([@mridgway](https://github.com/mridgway) in [#9642](https://github.com/facebook/react/pull/9642))
## 15.5.2 (April 7, 2017)
**Note: this release has a critical issue and was deprecated. Please update to 15.5.4 or higher.**
### React Addons
* Fix the production single-file builds to not include the development code. ([@gaearon](https://github.com/gaearon) in [#9385](https://github.com/facebook/react/pull/9383))
* Apply better minification to production single-file builds. ([@gaearon](https://github.com/gaearon) in [#9385](https://github.com/facebook/react/pull/9383))
* Add missing and remove unnecessary dependencies to packages. ([@gaearon](https://github.com/gaearon) in [#9385](https://github.com/facebook/react/pull/9383))
## 15.5.1 (April 7, 2017)
**Note: this release has a critical issue and was deprecated. Please update to 15.5.4 or higher.**
### React
* Fix erroneous PropTypes access warning. ([@acdlite](https://github.com/acdlite) in ([ec97ebb](https://github.com/facebook/react/commit/ec97ebbe7f15b58ae2f1323df39d06f119873344))
## 15.5.0 (April 7, 2017)
**Note: this release has a critical issue and was deprecated. Please update to 15.5.4 or higher.**
### React
* <s>Added a deprecation warning for `React.createClass`. Points users to create-react-class instead. ([@acdlite](https://github.com/acdlite) in [#d9a4fa4](https://github.com/facebook/react/commit/d9a4fa4f51c6da895e1655f32255cf72c0fe620e))</s>
* Added a deprecation warning for `React.PropTypes`. Points users to prop-types instead. ([@acdlite](https://github.com/acdlite) in [#043845c](https://github.com/facebook/react/commit/043845ce75ea0812286bbbd9d34994bb7e01eb28))
* Fixed an issue when using `ReactDOM` together with `ReactDOMServer`. ([@wacii](https://github.com/wacii) in [#9005](https://github.com/facebook/react/pull/9005))
* Fixed issue with Closure Compiler. ([@anmonteiro](https://github.com/anmonteiro) in [#8895](https://github.com/facebook/react/pull/8895))
* Another fix for Closure Compiler. ([@Shastel](https://github.com/Shastel) in [#8882](https://github.com/facebook/react/pull/8882))
* Added component stack info to invalid element type warning. ([@n3tr](https://github.com/n3tr) in [#8495](https://github.com/facebook/react/pull/8495))
### React DOM
* Fixed Chrome bug when backspacing in number inputs. ([@nhunzaker](https://github.com/nhunzaker) in [#7359](https://github.com/facebook/react/pull/7359))
* Added `react-dom/test-utils`, which exports the React Test Utils. ([@bvaughn](https://github.com/bvaughn))
### React Test Renderer
* Fixed bug where `componentWillUnmount` was not called for children. ([@gre](https://github.com/gre) in [#8512](https://github.com/facebook/react/pull/8512))
* Added `react-test-renderer/shallow`, which exports the shallow renderer. ([@bvaughn](https://github.com/bvaughn))
### React Addons
* Last release for addons; they will no longer be actively maintained.
* Removed `peerDependencies` so that addons continue to work indefinitely. ([@acdlite](https://github.com/acdlite) and [@bvaughn](https://github.com/bvaughn) in [8a06cd7](https://github.com/facebook/react/commit/8a06cd7a786822fce229197cac8125a551e8abfa) and [67a8db3](https://github.com/facebook/react/commit/67a8db3650d724a51e70be130e9008806402678a))
* Updated to remove references to `React.createClass` and `React.PropTypes` ([@acdlite](https://github.com/acdlite) in [12a96b9](https://github.com/facebook/react/commit/12a96b94823d6b6de6b1ac13bd576864abd50175))
* `react-addons-test-utils` is deprecated. Use `react-dom/test-utils` and `react-test-renderer/shallow` instead. ([@bvaughn](https://github.com/bvaughn))
## 15.4.2 (January 6, 2017)
### React
* Fixed build issues with the Brunch bundler. ([@gaearon](https://github.com/gaearon) in [#8686](https://github.com/facebook/react/pull/8686))
* Improved error messages for invalid element types. ([@sophiebits](https://github.com/sophiebits) in [#8612](https://github.com/facebook/react/pull/8612))
* Removed a warning about `getInitialState` when `this.state` is set. ([@bvaughn](https://github.com/bvaughn) in [#8594](https://github.com/facebook/react/pull/8594))
* Removed some dead code. ([@diegomura](https://github.com/diegomura) in [#8050](https://github.com/facebook/react/pull/8050), [@dfrownfelter](https://github.com/dfrownfelter) in [#8597](https://github.com/facebook/react/pull/8597))
### React DOM
* Fixed a decimal point issue on uncontrolled number inputs. ([@nhunzaker](https://github.com/nhunzaker) in [#7750](https://github.com/facebook/react/pull/7750))
* Fixed rendering of textarea placeholder in IE11. ([@aweary](https://github.com/aweary) in [#8020](https://github.com/facebook/react/pull/8020))
* Worked around a script engine bug in IE9. ([@eoin](https://github.com/eoin) in [#8018](https://github.com/facebook/react/pull/8018))
### React Addons
* Fixed build issues in RequireJS and SystemJS environments. ([@gaearon](https://github.com/gaearon) in [#8686](https://github.com/facebook/react/pull/8686))
* Added missing package dependencies. ([@kweiberth](https://github.com/kweiberth) in [#8467](https://github.com/facebook/react/pull/8467))
## 15.4.1 (November 22, 2016)
### React
* Restructure variable assignment to work around a Rollup bug ([@gaearon](https://github.com/gaearon) in [#8384](https://github.com/facebook/react/pull/8384))
### React DOM
* Fixed event handling on disabled button elements ([@sophiebits](https://github.com/sophiebits) in [#8387](https://github.com/facebook/react/pull/8387))
* Fixed compatibility of browser build with AMD environments ([@zpao](https://github.com/zpao) in [#8374](https://github.com/facebook/react/pull/8374))
## 15.4.0 (November 16, 2016)
### React
* React package and browser build no longer "secretly" includes React DOM. ([@sebmarkbage](https://github.com/sebmarkbage) in [#7164](https://github.com/facebook/react/pull/7164) and [#7168](https://github.com/facebook/react/pull/7168))
* Required PropTypes now fail with specific messages for null and undefined. ([@chenglou](https://github.com/chenglou) in [#7291](https://github.com/facebook/react/pull/7291))
* Improved development performance by freezing children instead of copying. ([@keyanzhang](https://github.com/keyanzhang) in [#7455](https://github.com/facebook/react/pull/7455))
### React DOM
* Fixed occasional test failures when React DOM is used together with shallow renderer. ([@goatslacker](https://github.com/goatslacker) in [#8097](https://github.com/facebook/react/pull/8097))
* Added a warning for invalid `aria-` attributes. ([@jessebeach](https://github.com/jessebeach) in [#7744](https://github.com/facebook/react/pull/7744))
* Added a warning for using `autofocus` rather than `autoFocus`. ([@hkal](https://github.com/hkal) in [#7694](https://github.com/facebook/react/pull/7694))
* Removed an unnecessary warning about polyfilling `String.prototype.split`. ([@nhunzaker](https://github.com/nhunzaker) in [#7629](https://github.com/facebook/react/pull/7629))
* Clarified the warning about not calling PropTypes manually. ([@jedwards1211](https://github.com/jedwards1211) in [#7777](https://github.com/facebook/react/pull/7777))
* The unstable `batchedUpdates` API now passes the wrapped function's return value through. ([@bgnorlov](https://github.com/bgnorlov) in [#7444](https://github.com/facebook/react/pull/7444))
* Fixed a bug with updating text in IE 8. ([@mnpenner](https://github.com/mnpenner) in [#7832](https://github.com/facebook/react/pull/7832))
### React Perf
* When ReactPerf is started, you can now view the relative time spent in components as a chart in Chrome Timeline. ([@gaearon](https://github.com/gaearon) in [#7549](https://github.com/facebook/react/pull/7549))
### React Test Utils
* If you call `Simulate.click()` on a `<input disabled onClick={foo} />` then `foo` will get called whereas it didn't before. ([@nhunzaker](https://github.com/nhunzaker) in [#7642](https://github.com/facebook/react/pull/7642))
### React Test Renderer
* Due to packaging changes, it no longer crashes when imported together with React DOM in the same file. ([@sebmarkbage](https://github.com/sebmarkbage) in [#7164](https://github.com/facebook/react/pull/7164) and [#7168](https://github.com/facebook/react/pull/7168))
* `ReactTestRenderer.create()` now accepts `{createNodeMock: element => mock}` as an optional argument so you can mock refs with snapshot testing. ([@Aweary](https://github.com/Aweary) in [#7649](https://github.com/facebook/react/pull/7649), [#8261](https://github.com/facebook/react/pull/8261))
## 15.3.2 (September 19, 2016)
### React
- Remove plain object warning from React.createElement & React.cloneElement. ([@spudly](https://github.com/spudly) in [#7724](https://github.com/facebook/react/pull/7724))
### React DOM
- Add `playsInline` to supported HTML attributes. ([@reaperhulk](https://github.com/reaperhulk) in [#7519](https://github.com/facebook/react/pull/7519))
- Add `as` to supported HTML attributes. ([@kevinslin](https://github.com/kevinslin) in [#7582](https://github.com/facebook/react/pull/7582))
- Improve DOM nesting validation warning about whitespace. ([@sophiebits](https://github.com/sophiebits) in [#7515](https://github.com/facebook/react/pull/7515))
- Avoid "Member not found" exception in IE10 when calling `preventDefault()` in Synthetic Events. ([@g-palmer](https://github.com/g-palmer) in [#7411](https://github.com/facebook/react/pull/7411))
- Fix memory leak in `onSelect` implementation. ([@AgtLucas](https://github.com/AgtLucas) in [#7533](https://github.com/facebook/react/pull/7533))
- Improve robustness of `document.documentMode` checks to handle Google Tag Manager. ([@SchleyB](https://github.com/SchleyB) in [#7594](https://github.com/facebook/react/pull/7594))
- Add more cases to controlled inputs warning. ([@marcin-mazurek](https://github.com/marcin-mazurek) in [#7544](https://github.com/facebook/react/pull/7544))
- Handle case of popup blockers overriding `document.createEvent`. ([@Andarist](https://github.com/Andarist) in [#7621](https://github.com/facebook/react/pull/7621))
- Fix issue with `dangerouslySetInnerHTML` and SVG in Internet Explorer. ([@zpao](https://github.com/zpao) in [#7618](https://github.com/facebook/react/pull/7618))
- Improve handling of Japanese IME on Internet Explorer. ([@msmania](https://github.com/msmania) in [#7107](https://github.com/facebook/react/pull/7107))
### React Test Renderer
- Support error boundaries. ([@millermedeiros](https://github.com/millermedeiros) in [#7558](https://github.com/facebook/react/pull/7558), [#7569](https://github.com/facebook/react/pull/7569), [#7619](https://github.com/facebook/react/pull/7619))
- Skip null ref warning. ([@Aweary](https://github.com/Aweary) in [#7658](https://github.com/facebook/react/pull/7658))
### React Perf Add-on
- Ensure lifecycle timers are stopped on errors. ([@gaearon](https://github.com/gaearon) in [#7548](https://github.com/facebook/react/pull/7548))
## 15.3.1 (August 19, 2016)
### React
- Improve performance of development builds in various ways. ([@gaearon](https://github.com/gaearon) in [#7461](https://github.com/facebook/react/pull/7461), [#7463](https://github.com/facebook/react/pull/7463), [#7483](https://github.com/facebook/react/pull/7483), [#7488](https://github.com/facebook/react/pull/7488), [#7491](https://github.com/facebook/react/pull/7491), [#7510](https://github.com/facebook/react/pull/7510))
- Cleanup internal hooks to improve performance of development builds. ([@gaearon](https://github.com/gaearon) in [#7464](https://github.com/facebook/react/pull/7464), [#7472](https://github.com/facebook/react/pull/7472), [#7481](https://github.com/facebook/react/pull/7481), [#7496](https://github.com/facebook/react/pull/7496))
- Upgrade fbjs to pick up another performance improvement from [@gaearon](https://github.com/gaearon) for development builds. ([@zpao](https://github.com/zpao) in [#7532](https://github.com/facebook/react/pull/7532))
- Improve startup time of React in Node. ([@zertosh](https://github.com/zertosh) in [#7493](https://github.com/facebook/react/pull/7493))
- Improve error message of `React.Children.only`. ([@sophiebits](https://github.com/sophiebits) in [#7514](https://github.com/facebook/react/pull/7514))
### React DOM
- Avoid `<input>` validation warning from browsers when changing `type`. ([@nhunzaker](https://github.com/nhunzaker) in [#7333](https://github.com/facebook/react/pull/7333))
- Avoid "Member not found" exception in IE10 when calling `stopPropagation()` in Synthetic Events. ([@nhunzaker](https://github.com/nhunzaker) in [#7343](https://github.com/facebook/react/pull/7343))
- Fix issue resulting in inability to update some `<input>` elements in mobile browsers. ([@keyanzhang](https://github.com/keyanzhang) in [#7397](https://github.com/facebook/react/pull/7397))
- Fix memory leak in server rendering. ([@keyanzhang](https://github.com/keyanzhang) in [#7410](https://github.com/facebook/react/pull/7410))
- Fix issue resulting in `<input type="range">` values not updating when changing `min` or `max`. ([@troydemonbreun](https://github.com/troydemonbreun) in [#7486](https://github.com/facebook/react/pull/7486))
- Add new warning for rare case of attempting to unmount a container owned by a different copy of React. ([@ventuno](https://github.com/ventuno) in [#7456](https://github.com/facebook/react/pull/7456))
### React Test Renderer
- Fix ReactTestInstance::toJSON() with empty top-level components. ([@Morhaus](https://github.com/Morhaus) in [#7523](https://github.com/facebook/react/pull/7523))
### React Native Renderer
- Change `trackedTouchCount` invariant into a console.error for better reliability. ([@yungsters](https://github.com/yungsters) in [#7400](https://github.com/facebook/react/pull/7400))
## 15.3.0 (July 29, 2016)
### React
- Add `React.PureComponent` - a new base class to extend, replacing `react-addons-pure-render-mixin` now that mixins don't work with ES2015 classes. ([@spicyj](https://github.com/spicyj) in [#7195](https://github.com/facebook/react/pull/7195))
- Add `React.PureComponent` - a new base class to extend, replacing `react-addons-pure-render-mixin` now that mixins don't work with ES2015 classes. ([@sophiebits](https://github.com/sophiebits) in [#7195](https://github.com/facebook/react/pull/7195))
- Add new warning when modifying `this.props.children`. ([@jimfb](https://github.com/jimfb) in [#7001](https://github.com/facebook/react/pull/7001))
- Fixed issue with ref resolution order. ([@gaearon](https://github.com/gaearon) in [#7101](https://github.com/facebook/react/pull/7101))
- Warn when mixin is undefined. ([@swaroopsm](https://github.com/swaroopsm) in [#6158](https://github.com/facebook/react/pull/6158))
- Downgrade "unexpected batch number" invariant to a warning. ([@spicyj](https://github.com/spicyj) in [#7133](https://github.com/facebook/react/pull/7133))
- Downgrade "unexpected batch number" invariant to a warning. ([@sophiebits](https://github.com/sophiebits) in [#7133](https://github.com/facebook/react/pull/7133))
- Validate arguments to `oneOf` and `oneOfType` PropTypes sooner. ([@troydemonbreun](https://github.com/troydemonbreun) in [#6316](https://github.com/facebook/react/pull/6316))
- Warn when calling PropTypes directly. ([@Aweary](https://github.com/Aweary) in [#7132](https://github.com/facebook/react/pull/7132), [#7194](https://github.com/facebook/react/pull/7194))
- Improve warning when using Maps as children. ([@keyanzhang](https://github.com/keyanzhang) in [#7260](https://github.com/facebook/react/pull/7260))
@@ -19,7 +747,7 @@
- Fix issue resulting in `<input type="range">` initial value being rounded. ([@troydemonbreun](https://github.com/troydemonbreun) in [#7251](https://github.com/facebook/react/pull/7251))
### React Test Renderer
- Initial public release of package allowing more focused testing. Install with `npm install react-test-renderer`. ([@spicyj](https://github.com/spicyj) in [#6944](https://github.com/facebook/react/pull/6944), [#7258](https://github.com/facebook/react/pull/7258), [@iamdustan](https://github.com/iamdustan) in [#7362](https://github.com/facebook/react/pull/7362))
- Initial public release of package allowing more focused testing. Install with `npm install react-test-renderer`. ([@sophiebits](https://github.com/sophiebits) in [#6944](https://github.com/facebook/react/pull/6944), [#7258](https://github.com/facebook/react/pull/7258), [@iamdustan](https://github.com/iamdustan) in [#7362](https://github.com/facebook/react/pull/7362))
### React Perf Add-on
- Fix issue resulting in excessive warnings when encountering an internal measurement error. ([@sassanh](https://github.com/sassanh) in [#7299](https://github.com/facebook/react/pull/7299))
@@ -59,7 +787,7 @@
### React
- Add error codes to production invariants, with links to the view the full error text. ([@keyanzhang](https://github.com/keyanzhang) in [#6948](https://github.com/facebook/react/pull/6948))
- Include component stack information in PropType validation warnings. ([@troydemonbreun](https://github.com/troydemonbreun) in [#6398](https://github.com/facebook/react/pull/6398), [@spicyj](https://github.com/spicyj) in [#6771](https://github.com/facebook/react/pull/6771))
- Include component stack information in PropType validation warnings. ([@troydemonbreun](https://github.com/troydemonbreun) in [#6398](https://github.com/facebook/react/pull/6398), [@sophiebits](https://github.com/sophiebits) in [#6771](https://github.com/facebook/react/pull/6771))
- Include component stack information in key warnings. ([@keyanzhang](https://github.com/keyanzhang) in [#6799](https://github.com/facebook/react/pull/6799))
- Stop validating props at mount time, only validate at element creation. ([@keyanzhang](https://github.com/keyanzhang) in [#6824](https://github.com/facebook/react/pull/6824))
- New invariant providing actionable error in missing instance case. ([@yungsters](https://github.com/yungsters) in [#6990](https://github.com/facebook/react/pull/6990))
@@ -88,7 +816,7 @@
- Add `isRunning()` API. ([@nfcampos](https://github.com/nfcampos) in [#6763](https://github.com/facebook/react/pull/6763))
- Improve accuracy of lifecycle hook timing. ([@gaearon](https://github.com/gaearon) in [#6858](https://github.com/facebook/react/pull/6858))
- Fix internal errors when using ReactPerf with portal components. ([@gaearon](https://github.com/gaearon) in [#6860](https://github.com/facebook/react/pull/6860))
- Fix performance regression. ([@spicyj](https://github.com/spicyj) in [#6770](https://github.com/facebook/react/pull/6770))
- Fix performance regression. ([@sophiebits](https://github.com/sophiebits) in [#6770](https://github.com/facebook/react/pull/6770))
- Add warning that ReactPerf is not enabled in production. ([@sashashakun](https://github.com/sashashakun) in [#6884](https://github.com/facebook/react/pull/6884))
### React CSSTransitionGroup Add-on
@@ -103,7 +831,7 @@
### React
- Ensure we're using the latest `object-assign`, which has protection against a non-spec-compliant native `Object.assign`. ([@zpao](https://github.com/zpao) in [#6681](https://github.com/facebook/react/pull/6681))
- Add a new warning to communicate that `props` objects passed to `createElement` must be plain objects. ([@richardscarrott](https://github.com/richardscarrott) in [#6134](https://github.com/facebook/react/pull/6134))
- Fix a batching bug resulting in some lifecycle methods incorrectly being called multiple times. ([@spicyj](https://github.com/spicyj) in [#6650](https://github.com/facebook/react/pull/6650))
- Fix a batching bug resulting in some lifecycle methods incorrectly being called multiple times. ([@sophiebits](https://github.com/sophiebits) in [#6650](https://github.com/facebook/react/pull/6650))
### React DOM
- Fix regression in custom elements support. ([@jscissr](https://github.com/jscissr) in [#6570](https://github.com/facebook/react/pull/6570))
@@ -152,17 +880,17 @@
- Restore `React.__spread` API to unbreak code compiled with some tools making use of this undocumented API. It is now officially deprecated. ([@zpao](https://github.com/zpao) in [#6444](https://github.com/facebook/react/pull/6444))
### ReactDOM
- Fixed issue resulting in loss of cursor position in controlled inputs. ([@spicyj](https://github.com/spicyj) in [#6449](https://github.com/facebook/react/pull/6449))
- Fixed issue resulting in loss of cursor position in controlled inputs. ([@sophiebits](https://github.com/sophiebits) in [#6449](https://github.com/facebook/react/pull/6449))
## 15.0.0 (April 7, 2016)
### Major changes
- **Initial render now uses `document.createElement` instead of generating HTML.** Previously we would generate a large string of HTML and then set `node.innerHTML`. At the time, this was decided to be faster than using `document.createElement` for the majority of cases and browsers that we supported. Browsers have continued to improve and so overwhelmingly this is no longer true. By using `createElement` we can make other parts of React faster. ([@spicyj](https://github.com/spicyj) in [#5205](https://github.com/facebook/react/pull/5205))
- **`data-reactid` is no longer on every node.** As a result of using `document.createElement`, we can prime the node cache as we create DOM nodes, allowing us to skip a potential lookup (which used the `data-reactid` attribute). Root nodes will have a `data-reactroot` attribute and server generated markup will still contain `data-reactid`. ([@spicyj](https://github.com/spicyj) in [#5205](https://github.com/facebook/react/pull/5205))
- **Initial render now uses `document.createElement` instead of generating HTML.** Previously we would generate a large string of HTML and then set `node.innerHTML`. At the time, this was decided to be faster than using `document.createElement` for the majority of cases and browsers that we supported. Browsers have continued to improve and so overwhelmingly this is no longer true. By using `createElement` we can make other parts of React faster. ([@sophiebits](https://github.com/sophiebits) in [#5205](https://github.com/facebook/react/pull/5205))
- **`data-reactid` is no longer on every node.** As a result of using `document.createElement`, we can prime the node cache as we create DOM nodes, allowing us to skip a potential lookup (which used the `data-reactid` attribute). Root nodes will have a `data-reactroot` attribute and server generated markup will still contain `data-reactid`. ([@sophiebits](https://github.com/sophiebits) in [#5205](https://github.com/facebook/react/pull/5205))
- **No more extra `<span>`s.** ReactDOM will now render plain text nodes interspersed with comment nodes that are used for demarcation. This gives us the same ability to update individual pieces of text, without creating extra nested nodes. If you were targeting these `<span>`s in your CSS, you will need to adjust accordingly. You can always render them explicitly in your components. ([@mwiencek](https://github.com/mwiencek) in [#5753](https://github.com/facebook/react/pull/5753))
- **Rendering `null` now uses comment nodes.** Previously `null` would render to `<noscript>` elements. We now use comment nodes. This may cause issues if making use of `:nth-child` CSS selectors. While we consider this rendering behavior an implementation detail of React, it's worth noting the potential problem. ()[@spicyj](https://github.com/spicyj) in [#5451](https://github.com/facebook/react/pull/5451))
- **Rendering `null` now uses comment nodes.** Previously `null` would render to `<noscript>` elements. We now use comment nodes. This may cause issues if making use of `:nth-child` CSS selectors. While we consider this rendering behavior an implementation detail of React, it's worth noting the potential problem. ([@sophiebits](https://github.com/sophiebits) in [#5451](https://github.com/facebook/react/pull/5451))
- **Functional components can now return `null`.** We added support for [defining stateless components as functions](/react/blog/2015/09/10/react-v0.14-rc1.html#stateless-function-components) in React 0.14. However, React 0.14 still allowed you to define a class component without extending `React.Component` or using `React.createClass()`, so [we couldnt reliably tell if your component is a function or a class](https://github.com/facebook/react/issues/5355), and did not allow returning `null` from it. This issue is solved in React 15, and you can now return `null` from any component, whether it is a class or a function. ([@jimfb](https://github.com/jimfb) in [#5884](https://github.com/facebook/react/pull/5884))
- **Improved SVG support.** All SVG tags are now fully supported. (Uncommon SVG tags are not present on the `React.DOM` element helper, but JSX and `React.createElement` work on all tag names.) All SVG attributes that are implemented by the browsers should be supported too. If you find any attributes that we have missed, please [let us know in this issue](https://github.com/facebook/react/issues/1657). ([@zpao](https://github.com/zpao) in [#6243](https://github.com/facebook/react/pull/6243))
@@ -193,8 +921,8 @@ Each of these changes will continue to work as before with a new warning until t
### New helpful warnings
- If you use a minified copy of the _development_ build, React DOM kindly encourages you to use the faster production build instead. ([@spicyj](https://github.com/spicyj) in [#5083](https://github.com/facebook/react/pull/5083))
- React DOM: When specifying a unit-less CSS value as a string, a future version will not add `px` automatically. This version now warns in this case (ex: writing `style={{'{{'}}width: '300'}}`. Unitless *number* values like `width: 300` are unchanged. ([@pluma](https://github.com/pluma) in [#5140](https://github.com/facebook/react/pull/5140))
- If you use a minified copy of the _development_ build, React DOM kindly encourages you to use the faster production build instead. ([@sophiebits](https://github.com/sophiebits) in [#5083](https://github.com/facebook/react/pull/5083))
- React DOM: When specifying a unit-less CSS value as a string, a future version will not add `px` automatically. This version now warns in this case (ex: writing `style={{width: '300'}}`. Unitless *number* values like `width: 300` are unchanged. ([@pluma](https://github.com/pluma) in [#5140](https://github.com/facebook/react/pull/5140))
- Synthetic Events will now warn when setting and accessing properties (which will not get cleared appropriately), as well as warn on access after an event has been returned to the pool. ([@kentcdodds](https://github.com/kentcdodds) in [#5940](https://github.com/facebook/react/pull/5940) and [@koba04](https://github.com/koba04) in [#5947](https://github.com/facebook/react/pull/5947))
- Elements will now warn when attempting to read `ref` and `key` from the props. ([@prometheansacrifice](https://github.com/prometheansacrifice) in [#5744](https://github.com/facebook/react/pull/5744))
- React will now warn if you pass a different `props` object to `super()` in the constructor. ([@prometheansacrifice](https://github.com/prometheansacrifice) in [#5346](https://github.com/facebook/react/pull/5346))
@@ -210,7 +938,7 @@ Each of these changes will continue to work as before with a new warning until t
### Notable bug fixes
- Fixed multiple small memory leaks. ([@spicyj](https://github.com/spicyj) in [#4983](https://github.com/facebook/react/pull/4983) and [@victor-homyakov](https://github.com/victor-homyakov) in [#6309](https://github.com/facebook/react/pull/6309))
- Fixed multiple small memory leaks. ([@sophiebits](https://github.com/sophiebits) in [#4983](https://github.com/facebook/react/pull/4983) and [@victor-homyakov](https://github.com/victor-homyakov) in [#6309](https://github.com/facebook/react/pull/6309))
- Input events are handled more reliably in IE 10 and IE 11; spurious events no longer fire when using a placeholder. ([@jquense](https://github.com/jquense) in [#4051](https://github.com/facebook/react/pull/4051))
- The `componentWillReceiveProps()` lifecycle method is now consistently called when `context` changes. ([@milesj](https://github.com/milesj) in [#5787](https://github.com/facebook/react/pull/5787))
- `React.cloneElement()` doesnt append slash to an existing `key` when used inside `React.Children.map()`. ([@ianobermiller](https://github.com/ianobermiller) in [#5892](https://github.com/facebook/react/pull/5892))
@@ -219,7 +947,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))
@@ -228,7 +956,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))
@@ -236,7 +964,7 @@ Each of these changes will continue to work as before with a new warning until t
- React no longer depends on ES5 *shams* for `Object.create` and `Object.freeze` in older environments. It still, however, requires ES5 *shims* in those environments. ([@dgreensp](https://github.com/dgreensp) in [#4959](https://github.com/facebook/react/pull/4959))
- React DOM now allows `data-` attributes with names that start with numbers. ([@nLight](https://github.com/nLight) in [#5216](https://github.com/facebook/react/pull/5216))
- React DOM adds a new `suppressContentEditableWarning` prop for components like [Draft.js](https://facebook.github.io/draft-js/) that intentionally manage `contentEditable` children with React. ([@mxstbr](https://github.com/mxstbr) in [#6112](https://github.com/facebook/react/pull/6112))
- React improves the performance for `createClass()` on complex specs. ([@spicyj](https://github.com/spicyj) in [#5550](https://github.com/facebook/react/pull/5550))
- React improves the performance for `createClass()` on complex specs. ([@sophiebits](https://github.com/sophiebits) in [#5550](https://github.com/facebook/react/pull/5550))
## 0.14.8 (March 29, 2016)
@@ -330,7 +1058,7 @@ Each of these changes will continue to work as before with a new warning until t
- Split the main `react` package into two: `react` and `react-dom`. This paves the way to writing components that can be shared between the web version of React and React Native. This means you will need to include both files and some functions have been moved from `React` to `ReactDOM`.
- Addons have been moved to separate packages (`react-addons-clone-with-props`, `react-addons-create-fragment`, `react-addons-css-transition-group`, `react-addons-linked-state-mixin`, `react-addons-perf`, `react-addons-pure-render-mixin`, `react-addons-shallow-compare`, `react-addons-test-utils`, `react-addons-transition-group`, `react-addons-update`, `ReactDOM.unstable_batchedUpdates`).
- Stateless functional components - React components were previously created using React.createClass or using ES6 classes. This release adds a [new syntax](https://facebook.github.io/react/docs/reusable-components.html#stateless-functions) where a user defines a single [stateless render function](https://facebook.github.io/react/docs/reusable-components.html#stateless-functions) (with one parameter: `props`) which returns a JSX element, and this function may be used as a component.
- Stateless functional components - React components were previously created using React.createClass or using ES6 classes. This release adds a [new syntax](https://reactjs.org/docs/reusable-components.html#stateless-functions) where a user defines a single [stateless render function](https://reactjs.org/docs/reusable-components.html#stateless-functions) (with one parameter: `props`) which returns a JSX element, and this function may be used as a component.
- Refs to DOM components as the DOM node itself. Previously the only useful thing you can do with a DOM component is call `getDOMNode()` to get the underlying DOM node. Starting with this release, a ref to a DOM component _is_ the actual DOM node. **Note that refs to custom (user-defined) components work exactly as before; only the built-in DOM components are affected by this change.**
@@ -338,8 +1066,8 @@ Each of these changes will continue to work as before with a new warning until t
- `React.initializeTouchEvents` is no longer necessary and has been removed completely. Touch events now work automatically.
- Add-Ons: Due to the DOM node refs change mentioned above, `TestUtils.findAllInRenderedTree` and related helpers are no longer able to take a DOM component, only a custom component.
- The `props` object is now frozen, so mutating props after creating a component element is no longer supported. In most cases, [`React.cloneElement`](https://facebook.github.io/react/docs/top-level-api.html#react.cloneelement) should be used instead. This change makes your components easier to reason about and enables the compiler optimizations mentioned above.
- Plain objects are no longer supported as React children; arrays should be used instead. You can use the [`createFragment`](https://facebook.github.io/react/docs/create-fragment.html) helper to migrate, which now returns an array.
- The `props` object is now frozen, so mutating props after creating a component element is no longer supported. In most cases, [`React.cloneElement`](https://reactjs.org/docs/react-api.html#cloneelement) should be used instead. This change makes your components easier to reason about and enables the compiler optimizations mentioned above.
- Plain objects are no longer supported as React children; arrays should be used instead. You can use the [`createFragment`](https://reactjs.org/docs/create-fragment.html) helper to migrate, which now returns an array.
- Add-Ons: `classSet` has been removed. Use [classnames](https://github.com/JedWatson/classnames) instead.
- Web components (custom elements) now use native property names. Eg: `class` instead of `className`.
@@ -347,16 +1075,16 @@ Each of these changes will continue to work as before with a new warning until t
- `this.getDOMNode()` is now deprecated and `ReactDOM.findDOMNode(this)` can be used instead. Note that in the common case, `findDOMNode` is now unnecessary since a ref to the DOM component is now the actual DOM node.
- `setProps` and `replaceProps` are now deprecated. Instead, call ReactDOM.render again at the top level with the new props.
- ES6 component classes must now extend `React.Component` in order to enable stateless function components. The [ES3 module pattern](https://facebook.github.io/react/blog/2015/01/27/react-v0.13.0-beta-1.html#other-languages) will continue to work.
- ES6 component classes must now extend `React.Component` in order to enable stateless function components. The [ES3 module pattern](https://reactjs.org/blog/2015/01/27/react-v0.13.0-beta-1.html#other-languages) will continue to work.
- Reusing and mutating a `style` object between renders has been deprecated. This mirrors our change to freeze the `props` object.
- Add-Ons: `cloneWithProps` is now deprecated. Use [`React.cloneElement`](https://facebook.github.io/react/docs/top-level-api.html#react.cloneelement) instead (unlike `cloneWithProps`, `cloneElement` does not merge `className` or `style` automatically; you can merge them manually if needed).
- Add-Ons: `cloneWithProps` is now deprecated. Use [`React.cloneElement`](https://reactjs.org/docs/react-api.html#cloneelement) instead (unlike `cloneWithProps`, `cloneElement` does not merge `className` or `style` automatically; you can merge them manually if needed).
- Add-Ons: To improve reliability, `CSSTransitionGroup` will no longer listen to transition events. Instead, you should specify transition durations manually using props such as `transitionEnterTimeout={500}`.
### Notable enhancements
- 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`.
@@ -390,7 +1118,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://facebook.github.io/react/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
@@ -443,7 +1171,7 @@ Each of these changes will continue to work as before with a new warning until t
#### Bug Fixes
* Immutabilty Helpers: Ensure it supports `hasOwnProperty` as an object key
* Immutability Helpers: Ensure it supports `hasOwnProperty` as an object key
### React Tools
@@ -490,9 +1218,9 @@ Each of these changes will continue to work as before with a new warning until t
#### New Features
* Support for using ES6 classes to build React components; see the [v0.13.0 beta 1 notes](https://facebook.github.io/react/blog/2015/01/27/react-v0.13.0-beta-1.html) for details.
* Support for using ES6 classes to build React components; see the [v0.13.0 beta 1 notes](https://reactjs.org/blog/2015/01/27/react-v0.13.0-beta-1.html) for details.
* Added new top-level API `React.findDOMNode(component)`, which should be used in place of `component.getDOMNode()`. The base class for ES6-based components will not have `getDOMNode`. This change will enable some more patterns moving forward.
* Added a new top-level API `React.cloneElement(el, props)` for making copies of React elements see the [v0.13 RC2 notes](https://facebook.github.io/react/blog/2015/03/03/react-v0.13-rc2.html#react.cloneelement) for more details.
* Added a new top-level API `React.cloneElement(el, props)` for making copies of React elements see the [v0.13 RC2 notes](https://reactjs.org/blog/2015/03/03/react-v0.13-rc2.html#react.cloneelement) for more details.
* New `ref` style, allowing a callback to be used in place of a name: `<Photo ref={(c) => this._photo = c} />` allows you to reference the component with `this._photo` (as opposed to `ref="photo"` which gives `this.refs.photo`).
* `this.setState()` can now take a function as the first argument for transactional state updates, such as `this.setState((state, props) => ({count: state.count + 1}));` this means that you no longer need to use `this._pendingState`, which is now gone.
* Support for iterators and immutable-js sequences as children.
@@ -506,7 +1234,7 @@ Each of these changes will continue to work as before with a new warning until t
#### New Features
* [`React.addons.createFragment` was added](https://facebook.github.io/react/docs/create-fragment.html) for adding keys to entire sets of children.
* [`React.addons.createFragment` was added](https://reactjs.org/docs/create-fragment.html) for adding keys to entire sets of children.
#### Deprecations
@@ -732,7 +1460,7 @@ Each of these changes will continue to work as before with a new warning until t
#### New Features
* Added warnings to help migrate towards descriptors
* Made it possible to server render without React-related markup (`data-reactid`, `data-react-checksum`). This DOM will not be mountable by React. [Read the docs for `React.renderComponentToStaticMarkup`](https://facebook.github.io/react/docs/top-level-api.html#react.rendercomponenttostaticmarkup)
* Made it possible to server render without React-related markup (`data-reactid`, `data-react-checksum`). This DOM will not be mountable by React. [Read the docs for `React.renderComponentToStaticMarkup`](https://reactjs.org/docs/top-level-api.html#react.rendercomponenttostaticmarkup)
* Added support for more attributes:
* `srcSet` for `<img>` to specify images at different pixel ratios
* `textAnchor` for SVG
@@ -744,7 +1472,7 @@ Each of these changes will continue to work as before with a new warning until t
### Addons
* `update` function to deal with immutable data. [Read the docs](https://facebook.github.io/react/docs/update.html)
* `update` function to deal with immutable data. [Read the docs](https://reactjs.org/docs/update.html)
### react-tools
* Added an option argument to `transform` function. The only option supported is `harmony`, which behaves the same as `jsx --harmony` on the command line. This uses the ES6 transforms from [jstransform](https://github.com/facebook/jstransform).
@@ -906,7 +1634,7 @@ Each of these changes will continue to work as before with a new warning until t
### React with Addons (New!)
* Introduced a separate build with several "addons" which we think can help improve the React experience. We plan to deprecate this in the long-term, instead shipping each as standalone pieces. [Read more in the docs](https://facebook.github.io/react/docs/addons.html).
* Introduced a separate build with several "addons" which we think can help improve the React experience. We plan to deprecate this in the long-term, instead shipping each as standalone pieces. [Read more in the docs](https://reactjs.org/docs/addons.html).
### JSX
@@ -939,10 +1667,10 @@ Each of these changes will continue to work as before with a new warning until t
* Switch from using `id` attribute to `data-reactid` to track DOM nodes. This allows you to integrate with other JS and CSS libraries more easily.
* Support for more DOM elements and attributes (e.g., `<canvas>`)
* Improved server-side rendering APIs. `React.renderComponentToString(<component>, callback)` allows you to use React on the server and generate markup which can be sent down to the browser.
* `prop` improvements: validation and default values. [Read our blog post for details...](https://facebook.github.io/react/blog/2013/07/11/react-v0-4-prop-validation-and-default-values.html)
* Support for the `key` prop, which allows for finer control over reconciliation. [Read the docs for details...](https://facebook.github.io/react/docs/multiple-components.html)
* Removed `React.autoBind`. [Read our blog post for details...](https://facebook.github.io/react/blog/2013/07/02/react-v0-4-autobind-by-default.html)
* Improvements to forms. We've written wrappers around `<input>`, `<textarea>`, `<option>`, and `<select>` in order to standardize many inconsistencies in browser implementations. This includes support for `defaultValue`, and improved implementation of the `onChange` event, and circuit completion. [Read the docs for details...](https://facebook.github.io/react/docs/forms.html)
* `prop` improvements: validation and default values. [Read our blog post for details...](https://reactjs.org/blog/2013/07/11/react-v0-4-prop-validation-and-default-values.html)
* Support for the `key` prop, which allows for finer control over reconciliation. [Read the docs for details...](https://reactjs.org/docs/multiple-components.html)
* Removed `React.autoBind`. [Read our blog post for details...](https://reactjs.org/blog/2013/07/02/react-v0-4-autobind-by-default.html)
* Improvements to forms. We've written wrappers around `<input>`, `<textarea>`, `<option>`, and `<select>` in order to standardize many inconsistencies in browser implementations. This includes support for `defaultValue`, and improved implementation of the `onChange` event, and circuit completion. [Read the docs for details...](https://reactjs.org/docs/forms.html)
* We've implemented an improved synthetic event system that conforms to the W3C spec.
* Updates to your component are batched now, which may result in a significantly faster re-render of components. `this.setState` now takes an optional callback as it's second parameter. If you were using `onClick={this.setState.bind(this, state)}` previously, you'll want to make sure you add a third parameter so that the event is not treated as the callback.

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,102 +1,5 @@
# Contributing to React
React is one of Facebook's first open source projects that is both under very active development and is also being used to ship code to everybody on [facebook.com](https://www.facebook.com). We're still working out the kinks to make contributing to this project as easy and transparent as possible, but we're not quite there yet. Hopefully this document makes the process for contributing clear and answers some questions that you may have.
Want to contribute to React? There are a few things you need to know.
## [Code of Conduct](https://code.facebook.com/codeofconduct)
Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please read [the full text](https://code.facebook.com/codeofconduct) so that you can understand what actions will and will not be tolerated.
## Our Development Process
Some of the core team will be working directly on GitHub. These changes will be public from the beginning. Other changesets will come via a bridge with Facebook's internal source control. This is a necessity as it allows engineers at Facebook outside of the core team to move fast and contribute from an environment they are comfortable in.
### `master` is unsafe
We will do our best to keep `master` in good shape, with tests passing at all times. But in order to move fast, we will make API changes that your application might not be compatible with. We will do our best to communicate these changes and always version appropriately so you can lock into a specific version if need be.
### Test Suite
Use `grunt test` to run the full test suite with PhantomJS.
This command is just a facade to [Jest](https://facebook.github.io/jest/). You may optionally run `npm install -g jest-cli` and use Jest commands directly to have more control over how tests are executed.
For example, `jest --watch` lets you automatically run the test suite on every file change.
You can also run a subset of tests by passing a prefix to `jest`. For instance, `jest ReactDOMSVG` will only run tests in the files that start with `ReactDOMSVG`, such as `ReactDOMSVG-test.js`.
When you know which tests you want to run, you can achieve a fast feedback loop by using these two features together. For example, `jest ReactDOMSVG --watch` will re-run only the matching tests on every change.
Just make sure to run the whole test suite before submitting a pull request!
### Pull Requests
**Working on your first Pull Request?** You can learn how from this *free* series [How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github)
You may also be interested in watching [this short video](https://www.youtube.com/watch?v=wUpPsEcGsg8) (26 mins) which gives an introduction on how to contribute to the React JS project.
The core team will be monitoring for pull requests. When we get one, we'll run some Facebook-specific integration tests on it first. From here, we'll need to get another person to sign off on the changes and then merge the pull request. For API changes we may need to fix internal uses, which could cause some delay. We'll do our best to provide updates and feedback throughout the process.
*Before* submitting a pull request, please make sure the following is done…
1. Fork the repo and create your branch from `master`.
2. If you've added code that should be tested, add tests!
3. If you've changed APIs, update the documentation.
4. Ensure the test suite passes (`grunt test`).
5. Make sure your code lints (`grunt lint`) - we've done our best to make sure these rules match our internal linting guidelines.
6. If you haven't already, complete the CLA.
### Contributor License Agreement (CLA)
In order to accept your pull request, we need you to submit a CLA. You only need to do this once, so if you've done this for another Facebook open source project, you're good to go. If you are submitting a pull request for the first time, just let us know that you have completed the CLA and we can cross-check with your GitHub username.
[Complete your CLA here.](https://code.facebook.com/cla)
## Bugs
### Where to Find Known Issues
We will be using GitHub Issues for our public bugs. We will keep a close eye on this and try to make it clear when we have an internal fix in progress. Before filing a new task, try to make sure your problem doesn't already exist.
### Reporting New Issues
The best way to get your bug fixed is to provide a reduced test case. jsFiddle, jsBin, and other sites provide a way to give live examples. Those are especially helpful though may not work for `JSX`-based code.
### Security Bugs
Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe disclosure of security bugs. With that in mind, please do not file public issues; go through the process outlined on that page.
## How to Get in Touch
* IRC - [#reactjs on freenode](https://webchat.freenode.net/?channels=reactjs)
* Discussion forum - [discuss.reactjs.org](https://discuss.reactjs.org/)
## Meeting Notes
React team meets once a week to discuss the development of React, future plans, and priorities.
You can find the meeting notes in a [dedicated repository](https://github.com/reactjs/core-notes/).
## Style Guide
Our linter will catch most styling issues that may exist in your code.
You can check the status of your code styling by simply running: `grunt lint`
However, there are still some styles that the linter cannot pick up. If you are unsure about something, looking at [Airbnb's Style Guide](https://github.com/airbnb/javascript) will guide you in the right direction.
### Code Conventions
* Use semicolons `;`
* Commas last `,`
* 2 spaces for indentation (no tabs)
* Prefer `'` over `"`
* `'use strict';`
* 80 character line length
* Write "attractive" code
* Do not use the optional parameters of `setTimeout` and `setInterval`
### Documentation
* Do not wrap lines at 80 characters
## License
By contributing to React, you agree that your contributions will be licensed under its BSD license.
We wrote a **[contribution guide](https://reactjs.org/contributing/how-to-contribute.html)** to help you get started.

View File

@@ -1,183 +0,0 @@
'use strict';
var path = require('path');
var GULP_EXE = 'gulp';
if (process.platform === 'win32') {
GULP_EXE += '.cmd';
}
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
browserify: require('./grunt/config/browserify'),
npm: require('./grunt/config/npm'),
clean: [
'./build',
'./*.gem',
'./docs/_site',
'./examples/shared/*.js',
'.module-cache',
],
'compare_size': require('./grunt/config/compare_size'),
});
grunt.config.set('compress', require('./grunt/config/compress'));
function spawnGulp(args, opts, done) {
grunt.util.spawn({
// This could be more flexible (require.resolve & lookup bin in package)
// but if it breaks we'll fix it then.
cmd: path.join('node_modules', '.bin', GULP_EXE),
args: args,
opts: Object.assign({stdio: 'inherit'}, opts),
}, function(err, result, code) {
if (err) {
grunt.fail.fatal('Something went wrong running gulp: ', result);
}
done(code === 0);
});
}
Object.keys(grunt.file.readJSON('package.json').devDependencies)
.filter(function(npmTaskName) {
return npmTaskName.indexOf('grunt-') === 0;
})
.filter(function(npmTaskName) {
return npmTaskName !== 'grunt-cli';
})
.forEach(function(npmTaskName) {
grunt.loadNpmTasks(npmTaskName);
});
grunt.registerTask('eslint', function() {
// Use gulp here.
spawnGulp(['eslint'], null, this.async());
});
grunt.registerTask('lint', ['eslint']);
grunt.registerTask('flow', function() {
// Use gulp here.
spawnGulp(['flow'], null, this.async());
});
grunt.registerTask('delete-build-modules', function() {
// Use gulp here.
spawnGulp(['react:clean'], null, this.async());
});
// Our own browserify-based tasks to build a single JS file build.
grunt.registerMultiTask('browserify', require('./grunt/tasks/browserify'));
grunt.registerMultiTask('npm', require('./grunt/tasks/npm'));
var npmReactTasks = require('./grunt/tasks/npm-react');
grunt.registerTask('npm-react:release', npmReactTasks.buildRelease);
grunt.registerTask('npm-react:pack', npmReactTasks.packRelease);
var npmReactDOMTasks = require('./grunt/tasks/npm-react-dom');
grunt.registerTask('npm-react-dom:release', npmReactDOMTasks.buildRelease);
grunt.registerTask('npm-react-dom:pack', npmReactDOMTasks.packRelease);
var npmReactNativeTasks = require('./grunt/tasks/npm-react-native');
grunt.registerTask('npm-react-native:release', npmReactNativeTasks.buildRelease);
grunt.registerTask('npm-react-native:pack', npmReactNativeTasks.packRelease);
var npmReactAddonsTasks = require('./grunt/tasks/npm-react-addons');
grunt.registerTask('npm-react-addons:release', npmReactAddonsTasks.buildReleases);
grunt.registerTask('npm-react-addons:pack', npmReactAddonsTasks.packReleases);
var npmReactTestRendererTasks = require('./grunt/tasks/npm-react-test');
grunt.registerTask('npm-react-test:release', npmReactTestRendererTasks.buildRelease);
grunt.registerTask('npm-react-test:pack', npmReactTestRendererTasks.packRelease);
grunt.registerTask('version-check', function() {
// Use gulp here.
spawnGulp(['version-check'], null, this.async());
});
grunt.registerTask('build:basic', [
'build-modules',
'version-check',
'browserify:basic',
]);
grunt.registerTask('build:addons', [
'build-modules',
'browserify:addons',
]);
grunt.registerTask('build:min', [
'build-modules',
'version-check',
'browserify:min',
]);
grunt.registerTask('build:addons-min', [
'build-modules',
'browserify:addonsMin',
]);
grunt.registerTask('build:npm-react', [
'version-check',
'build-modules',
'npm-react:release',
]);
grunt.registerTask('build:react-dom', require('./grunt/tasks/react-dom'));
var jestTasks = require('./grunt/tasks/jest');
grunt.registerTask('jest:normal', jestTasks.normal);
grunt.registerTask('jest:coverage', jestTasks.coverage);
grunt.registerTask('test', ['jest:normal']);
grunt.registerTask('npm:test', ['build', 'npm:pack']);
// Optimized build task that does all of our builds. The subtasks will be run
// in order so we can take advantage of that and only run build-modules once.
grunt.registerTask('build', [
'delete-build-modules',
'build-modules',
'version-check',
'browserify:basic',
'browserify:addons',
'browserify:min',
'browserify:addonsMin',
'build:react-dom',
'npm-react:release',
'npm-react:pack',
'npm-react-dom:release',
'npm-react-dom:pack',
'npm-react-native:release',
'npm-react-native:pack',
'npm-react-addons:release',
'npm-react-addons:pack',
'npm-react-test:release',
'npm-react-test:pack',
'compare_size',
]);
// Automate the release!
var releaseTasks = require('./grunt/tasks/release');
grunt.registerTask('release:setup', releaseTasks.setup);
grunt.registerTask('release:bower', releaseTasks.bower);
grunt.registerTask('release:docs', releaseTasks.docs);
grunt.registerTask('release:msg', releaseTasks.msg);
grunt.registerTask('release:starter', releaseTasks.starter);
grunt.registerTask('release', [
'release:setup',
'clean',
'build',
'release:bower',
'release:starter',
'compress',
'release:docs',
'release:msg',
]);
grunt.registerTask('build-modules', function() {
spawnGulp(['react:modules'], null, this.async());
});
// The default task - build - to keep setup easy.
grunt.registerTask('default', ['build']);
};

44
LICENSE
View File

@@ -1,31 +1,21 @@
BSD License
MIT License
For React software
Copyright (c) Facebook, Inc. and its affiliates.
Copyright (c) 2013-present, Facebook, Inc.
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name Facebook nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -1,393 +0,0 @@
Attribution 4.0 International
=======================================================================
Creative Commons Corporation ("Creative Commons") is not a law firm and
does not provide legal services or legal advice. Distribution of
Creative Commons public licenses does not create a lawyer-client or
other relationship. Creative Commons makes its licenses and related
information available on an "as-is" basis. Creative Commons gives no
warranties regarding its licenses, any material licensed under their
terms and conditions, or any related information. Creative Commons
disclaims all liability for damages resulting from their use to the
fullest extent possible.
Using Creative Commons Public Licenses
Creative Commons public licenses provide a standard set of terms and
conditions that creators and other rights holders may use to share
original works of authorship and other material subject to copyright
and certain other rights specified in the public license below. The
following considerations are for informational purposes only, are not
exhaustive, and do not form part of our licenses.
Considerations for licensors: Our public licenses are
intended for use by those authorized to give the public
permission to use material in ways otherwise restricted by
copyright and certain other rights. Our licenses are
irrevocable. Licensors should read and understand the terms
and conditions of the license they choose before applying it.
Licensors should also secure all rights necessary before
applying our licenses so that the public can reuse the
material as expected. Licensors should clearly mark any
material not subject to the license. This includes other CC-
licensed material, or material used under an exception or
limitation to copyright. More considerations for licensors:
wiki.creativecommons.org/Considerations_for_licensors
Considerations for the public: By using one of our public
licenses, a licensor grants the public permission to use the
licensed material under specified terms and conditions. If
the licensor's permission is not necessary for any reason--for
example, because of any applicable exception or limitation to
copyright--then that use is not regulated by the license. Our
licenses grant only permissions under copyright and certain
other rights that a licensor has authority to grant. Use of
the licensed material may still be restricted for other
reasons, including because others have copyright or other
rights in the material. A licensor may make special requests,
such as asking that all changes be marked or described.
Although not required by our licenses, you are encouraged to
respect those requests where reasonable. More_considerations
for the public:
wiki.creativecommons.org/Considerations_for_licensees
=======================================================================
Creative Commons Attribution 4.0 International Public License
By exercising the Licensed Rights (defined below), You accept and agree
to be bound by the terms and conditions of this Creative Commons
Attribution 4.0 International Public License ("Public License"). To the
extent this Public License may be interpreted as a contract, You are
granted the Licensed Rights in consideration of Your acceptance of
these terms and conditions, and the Licensor grants You such rights in
consideration of benefits the Licensor receives from making the
Licensed Material available under these terms and conditions.
Section 1 -- Definitions.
a. Adapted Material means material subject to Copyright and Similar
Rights that is derived from or based upon the Licensed Material
and in which the Licensed Material is translated, altered,
arranged, transformed, or otherwise modified in a manner requiring
permission under the Copyright and Similar Rights held by the
Licensor. For purposes of this Public License, where the Licensed
Material is a musical work, performance, or sound recording,
Adapted Material is always produced where the Licensed Material is
synched in timed relation with a moving image.
b. Adapter's License means the license You apply to Your Copyright
and Similar Rights in Your contributions to Adapted Material in
accordance with the terms and conditions of this Public License.
c. Copyright and Similar Rights means copyright and/or similar rights
closely related to copyright including, without limitation,
performance, broadcast, sound recording, and Sui Generis Database
Rights, without regard to how the rights are labeled or
categorized. For purposes of this Public License, the rights
specified in Section 2(b)(1)-(2) are not Copyright and Similar
Rights.
d. Effective Technological Measures means those measures that, in the
absence of proper authority, may not be circumvented under laws
fulfilling obligations under Article 11 of the WIPO Copyright
Treaty adopted on December 20, 1996, and/or similar international
agreements.
e. Exceptions and Limitations means fair use, fair dealing, and/or
any other exception or limitation to Copyright and Similar Rights
that applies to Your use of the Licensed Material.
f. Licensed Material means the artistic or literary work, database,
or other material to which the Licensor applied this Public
License.
g. Licensed Rights means the rights granted to You subject to the
terms and conditions of this Public License, which are limited to
all Copyright and Similar Rights that apply to Your use of the
Licensed Material and that the Licensor has authority to license.
h. Licensor means the individual(s) or entity(ies) granting rights
under this Public License.
i. Share means to provide material to the public by any means or
process that requires permission under the Licensed Rights, such
as reproduction, public display, public performance, distribution,
dissemination, communication, or importation, and to make material
available to the public including in ways that members of the
public may access the material from a place and at a time
individually chosen by them.
j. Sui Generis Database Rights means rights other than copyright
resulting from Directive 96/9/EC of the European Parliament and of
the Council of 11 March 1996 on the legal protection of databases,
as amended and/or succeeded, as well as other essentially
equivalent rights anywhere in the world.
k. You means the individual or entity exercising the Licensed Rights
under this Public License. Your has a corresponding meaning.
Section 2 -- Scope.
a. License grant.
1. Subject to the terms and conditions of this Public License,
the Licensor hereby grants You a worldwide, royalty-free,
non-sublicensable, non-exclusive, irrevocable license to
exercise the Licensed Rights in the Licensed Material to:
a. reproduce and Share the Licensed Material, in whole or
in part; and
b. produce, reproduce, and Share Adapted Material.
2. Exceptions and Limitations. For the avoidance of doubt, where
Exceptions and Limitations apply to Your use, this Public
License does not apply, and You do not need to comply with
its terms and conditions.
3. Term. The term of this Public License is specified in Section
6(a).
4. Media and formats; technical modifications allowed. The
Licensor authorizes You to exercise the Licensed Rights in
all media and formats whether now known or hereafter created,
and to make technical modifications necessary to do so. The
Licensor waives and/or agrees not to assert any right or
authority to forbid You from making technical modifications
necessary to exercise the Licensed Rights, including
technical modifications necessary to circumvent Effective
Technological Measures. For purposes of this Public License,
simply making modifications authorized by this Section 2(a)
(4) never produces Adapted Material.
5. Downstream recipients.
a. Offer from the Licensor -- Licensed Material. Every
recipient of the Licensed Material automatically
receives an offer from the Licensor to exercise the
Licensed Rights under the terms and conditions of this
Public License.
b. No downstream restrictions. You may not offer or impose
any additional or different terms or conditions on, or
apply any Effective Technological Measures to, the
Licensed Material if doing so restricts exercise of the
Licensed Rights by any recipient of the Licensed
Material.
6. No endorsement. Nothing in this Public License constitutes or
may be construed as permission to assert or imply that You
are, or that Your use of the Licensed Material is, connected
with, or sponsored, endorsed, or granted official status by,
the Licensor or others designated to receive attribution as
provided in Section 3(a)(1)(A)(i).
b. Other rights.
1. Moral rights, such as the right of integrity, are not
licensed under this Public License, nor are publicity,
privacy, and/or other similar personality rights; however, to
the extent possible, the Licensor waives and/or agrees not to
assert any such rights held by the Licensor to the limited
extent necessary to allow You to exercise the Licensed
Rights, but not otherwise.
2. Patent and trademark rights are not licensed under this
Public License.
3. To the extent possible, the Licensor waives any right to
collect royalties from You for the exercise of the Licensed
Rights, whether directly or through a collecting society
under any voluntary or waivable statutory or compulsory
licensing scheme. In all other cases the Licensor expressly
reserves any right to collect such royalties.
Section 3 -- License Conditions.
Your exercise of the Licensed Rights is expressly made subject to the
following conditions.
a. Attribution.
1. If You Share the Licensed Material (including in modified
form), You must:
a. retain the following if it is supplied by the Licensor
with the Licensed Material:
i. identification of the creator(s) of the Licensed
Material and any others designated to receive
attribution, in any reasonable manner requested by
the Licensor (including by pseudonym if
designated);
ii. a copyright notice;
iii. a notice that refers to this Public License;
iv. a notice that refers to the disclaimer of
warranties;
v. a URI or hyperlink to the Licensed Material to the
extent reasonably practicable;
b. indicate if You modified the Licensed Material and
retain an indication of any previous modifications; and
c. indicate the Licensed Material is licensed under this
Public License, and include the text of, or the URI or
hyperlink to, this Public License.
2. You may satisfy the conditions in Section 3(a)(1) in any
reasonable manner based on the medium, means, and context in
which You Share the Licensed Material. For example, it may be
reasonable to satisfy the conditions by providing a URI or
hyperlink to a resource that includes the required
information.
3. If requested by the Licensor, You must remove any of the
information required by Section 3(a)(1)(A) to the extent
reasonably practicable.
4. If You Share Adapted Material You produce, the Adapter's
License You apply must not prevent recipients of the Adapted
Material from complying with this Public License.
Section 4 -- Sui Generis Database Rights.
Where the Licensed Rights include Sui Generis Database Rights that
apply to Your use of the Licensed Material:
a. for the avoidance of doubt, Section 2(a)(1) grants You the right
to extract, reuse, reproduce, and Share all or a substantial
portion of the contents of the database;
b. if You include all or a substantial portion of the database
contents in a database in which You have Sui Generis Database
Rights, then the database in which You have Sui Generis Database
Rights (but not its individual contents) is Adapted Material; and
c. You must comply with the conditions in Section 3(a) if You Share
all or a substantial portion of the contents of the database.
For the avoidance of doubt, this Section 4 supplements and does not
replace Your obligations under this Public License where the Licensed
Rights include other Copyright and Similar Rights.
Section 5 -- Disclaimer of Warranties and Limitation of Liability.
a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
c. The disclaimer of warranties and limitation of liability provided
above shall be interpreted in a manner that, to the extent
possible, most closely approximates an absolute disclaimer and
waiver of all liability.
Section 6 -- Term and Termination.
a. This Public License applies for the term of the Copyright and
Similar Rights licensed here. However, if You fail to comply with
this Public License, then Your rights under this Public License
terminate automatically.
b. Where Your right to use the Licensed Material has terminated under
Section 6(a), it reinstates:
1. automatically as of the date the violation is cured, provided
it is cured within 30 days of Your discovery of the
violation; or
2. upon express reinstatement by the Licensor.
For the avoidance of doubt, this Section 6(b) does not affect any
right the Licensor may have to seek remedies for Your violations
of this Public License.
c. For the avoidance of doubt, the Licensor may also offer the
Licensed Material under separate terms or conditions or stop
distributing the Licensed Material at any time; however, doing so
will not terminate this Public License.
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
License.
Section 7 -- Other Terms and Conditions.
a. The Licensor shall not be bound by any additional or different
terms or conditions communicated by You unless expressly agreed.
b. Any arrangements, understandings, or agreements regarding the
Licensed Material not stated herein are separate from and
independent of the terms and conditions of this Public License.
Section 8 -- Interpretation.
a. For the avoidance of doubt, this Public License does not, and
shall not be interpreted to, reduce, limit, restrict, or impose
conditions on any use of the Licensed Material that could lawfully
be made without permission under this Public License.
b. To the extent possible, if any provision of this Public License is
deemed unenforceable, it shall be automatically reformed to the
minimum extent necessary to make it enforceable. If the provision
cannot be reformed, it shall be severed from this Public License
without affecting the enforceability of the remaining terms and
conditions.
c. No term or condition of this Public License will be waived and no
failure to comply consented to unless expressly agreed to by the
Licensor.
d. Nothing in this Public License constitutes or may be interpreted
as a limitation upon, or waiver of, any privileges and immunities
that apply to the Licensor or You, including from the legal
processes of any jurisdiction or authority.
=======================================================================
Creative Commons is not a party to its public licenses.
Notwithstanding, Creative Commons may elect to apply one of its public
licenses to material it publishes and in those instances will be
considered the "Licensor." Except for the limited purpose of indicating
that material is shared under a Creative Commons public license or as
otherwise permitted by the Creative Commons policies published at
creativecommons.org/policies, Creative Commons does not authorize the
use of the trademark "Creative Commons" or any other trademark or logo
of Creative Commons without its prior written consent including,
without limitation, in connection with any unauthorized modifications
to any of its public licenses or any other arrangements,
understandings, or agreements concerning use of licensed material. For
the avoidance of doubt, this paragraph does not form part of the public
licenses.
Creative Commons may be contacted at creativecommons.org.

View File

@@ -1,9 +0,0 @@
The examples provided by Facebook are for non-commercial testing and evaluation
purposes only. Facebook reserves all rights not expressly granted.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

33
PATENTS
View File

@@ -1,33 +0,0 @@
Additional Grant of Patent Rights Version 2
"Software" means the React software distributed by Facebook, Inc.
Facebook, Inc. ("Facebook") hereby grants to each recipient of the Software
("you") a perpetual, worldwide, royalty-free, non-exclusive, irrevocable
(subject to the termination provision below) license under any Necessary
Claims, to make, have made, use, sell, offer to sell, import, and otherwise
transfer the Software. For avoidance of doubt, no license is granted under
Facebook's rights in any patent claims that are infringed by (i) modifications
to the Software made by you or any third party or (ii) the Software in
combination with any software or other technology.
The license granted hereunder will terminate, automatically and without notice,
if you (or any of your subsidiaries, corporate affiliates or agents) initiate
directly or indirectly, or take a direct financial interest in, any Patent
Assertion: (i) against Facebook or any of its subsidiaries or corporate
affiliates, (ii) against any party if such Patent Assertion arises in whole or
in part from any software, technology, product or service of Facebook or any of
its subsidiaries or corporate affiliates, or (iii) against any party relating
to the Software. Notwithstanding the foregoing, if Facebook or any of its
subsidiaries or corporate affiliates files a lawsuit alleging patent
infringement against you in the first instance, and you respond by filing a
patent infringement counterclaim in that lawsuit against that party that is
unrelated to the Software, the license granted hereunder will not terminate
under section (i) of this paragraph due to such counterclaim.
A "Necessary Claim" is a claim of a patent owned by Facebook that is
necessarily infringed by the Software standing alone.
A "Patent Assertion" is any lawsuit or other action alleging direct, indirect,
or contributory infringement or inducement to infringe any patent, including a
cross-claim or counterclaim.

130
README.md
View File

@@ -1,4 +1,4 @@
# [React](https://facebook.github.io/react/) [![Build Status](https://img.shields.io/travis/facebook/react/master.svg?style=flat)](https://travis-ci.org/facebook/react) [![Coverage Status](https://img.shields.io/coveralls/facebook/react/master.svg?style=flat)](https://coveralls.io/github/facebook/react?branch=master) [![npm version](https://img.shields.io/npm/v/react.svg?style=flat)](https://www.npmjs.com/package/react) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](CONTRIBUTING.md#pull-requests)
# [React](https://reactjs.org/) &middot; [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/facebook/react/blob/master/LICENSE) [![npm version](https://img.shields.io/npm/v/react.svg?style=flat)](https://www.npmjs.com/package/react) [![Coverage Status](https://img.shields.io/coveralls/facebook/react/master.svg?style=flat)](https://coveralls.io/github/facebook/react?branch=master) [![CircleCI Status](https://circleci.com/gh/facebook/react.svg?style=shield&circle-token=:circle-token)](https://circleci.com/gh/facebook/react) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://reactjs.org/docs/how-to-contribute.html#your-first-pull-request)
React is a JavaScript library for building user interfaces.
@@ -6,110 +6,72 @@ React is a JavaScript library for building user interfaces.
* **Component-Based:** Build encapsulated components that manage their own state, then compose them to make complex UIs. Since component logic is written in JavaScript instead of templates, you can easily pass rich data through your app and keep state out of the DOM.
* **Learn Once, Write Anywhere:** We don't make assumptions about the rest of your technology stack, so you can develop new features in React without rewriting existing code. React can also render on the server using Node and power mobile apps using [React Native](https://facebook.github.io/react-native/).
[Learn how to use React in your own project](https://facebook.github.io/react/docs/getting-started.html).
[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).
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)
* [Where to Get Support](https://reactjs.org/community/support.html)
* [Contributing Guide](https://reactjs.org/docs/how-to-contribute.html)
You can improve it by sending pull requests to [this repository](https://github.com/reactjs/reactjs.org).
## Examples
We have several examples [on the website](https://facebook.github.io/react/). Here is the first one to get you started:
We have several examples [on the website](https://reactjs.org/). Here is the first one to get you started:
```js
var HelloMessage = React.createClass({
render: function() {
```jsx
class HelloMessage extends React.Component {
render() {
return <div>Hello {this.props.name}</div>;
}
});
}
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://facebook.github.io/react/docs/jsx-in-depth.html). JSX is not required to use React, but it makes code more readable, and writing it feels like writing HTML. A simple transform is included with React that allows converting JSX into native JavaScript for browsers to digest.
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.
## Installation
## Contributing
The fastest way to get started is to serve JavaScript from the CDN (also available on [cdnjs](https://cdnjs.com/libraries/react) and [jsdelivr](https://www.jsdelivr.com/projects/react)):
The main purpose of this repository is to continue to evolve React core, making it faster and easier to use. Development of React happens in the open on GitHub, and we are grateful to the community for contributing bugfixes and improvements. Read below to learn how you can take part in improving React.
```html
<!-- The core React library -->
<script src="https://fb.me/react-15.3.0.js"></script>
<!-- The ReactDOM Library -->
<script src="https://fb.me/react-dom-15.3.0.js"></script>
```
### [Code of Conduct](https://code.facebook.com/codeofconduct)
We've also built a [starter kit](https://facebook.github.io/react/downloads/react-15.3.0.zip) which might be useful if this is your first time using React. It includes a webpage with an example of using React with live code.
Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please read [the full text](https://code.facebook.com/codeofconduct) so that you can understand what actions will and will not be tolerated.
If you'd like to use [bower](http://bower.io), it's as easy as:
### [Contributing Guide](https://reactjs.org/contributing/how-to-contribute.html)
```sh
bower install --save react
```
Read our [contributing guide](https://reactjs.org/contributing/how-to-contribute.html) to learn about our development process, how to propose bugfixes and improvements, and how to build and test your changes to React.
And it's just as easy with [npm](http://npmjs.com):
```sh
npm i --save react
```
## Contribute
The main purpose of this repository is to continue to evolve React core, making it faster and easier to use. If you're interested in helping with that, then keep reading. If you're not interested in helping right now that's ok too. :) Any feedback you have about using React would be greatly appreciated.
### Building Your Copy of React
The process to build `react.js` is built entirely on top of node.js, using many libraries you may already be familiar with.
#### Prerequisites
* You have `node` installed at v4.0.0+ and `npm` at v2.0.0+.
* You have `gcc` installed or are comfortable installing a compiler if needed. Some of our `npm` dependencies may require a compliation step. On OS X, the Xcode Command Line Tools will cover this. On Ubuntu, `apt-get install build-essential` will install the required packages. Similar commands should work on other Linux distros. Windows will require some additional steps, see the [`node-gyp` installation instructions](https://github.com/nodejs/node-gyp#installation) for details.
* You are familiar with `npm` and know whether or not you need to use `sudo` when installing packages globally.
* You are familiar with `git`.
#### Build
Once you have the repository cloned, building a copy of `react.js` is really easy.
```sh
# grunt-cli is needed by grunt; you might have this installed already
npm install -g grunt-cli
npm install
grunt build
```
At this point, you should now have a `build/` directory populated with everything you need to use React. The examples should all work.
### Grunt
We use grunt to automate many tasks. Run `grunt -h` to see a mostly complete listing. The important ones to know:
```sh
# Build and run tests with PhantomJS
grunt test
# Lint the code with ESLint
grunt lint
# Wipe out build directory
grunt clean
```
### Good First Bug
To help you get your feet wet and get you familiar with our contribution process, we have a list of [good first bugs](https://github.com/facebook/react/labels/good%20first%20bug) that contain bugs which are fairly easy to fix. This is a great place to get started.
### Good First Issues
To help you get your feet wet and get you familiar with our contribution process, we have a list of [good first issues](https://github.com/facebook/react/labels/good%20first%20issue) that contain bugs which have a relatively limited scope. This is a great place to get started.
### License
React is [BSD licensed](./LICENSE). We also provide an additional [patent grant](./PATENTS).
React documentation is [Creative Commons licensed](./LICENSE-docs).
Examples provided in this repository and in the documentation are [separately licensed](./LICENSE-examples).
### More…
There's only so much we can cram in here. To read more about the community and guidelines for submitting pull requests, please read the [Contributing document](CONTRIBUTING.md).
## Troubleshooting
See the [Troubleshooting Guide](https://github.com/facebook/react/wiki/Troubleshooting)
React is [MIT licensed](./LICENSE).

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"

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,9 +0,0 @@
---
layout: single
title: Page Not Found
permalink: 404.html
---
We couldn't find what you were looking for.
Please contact the owner of the site that linked you to the original URL and let them know their link is broken.

View File

@@ -1,29 +0,0 @@
source 'https://rubygems.org'
gem 'rake'
# jekyll, which builds it all
# 3.0 includes sass processing
gem 'jekyll', '~>3.1'
# Jekyll extensions
gem 'jekyll-redirect-from'
gem 'jekyll-paginate'
# JSON
gem 'json'
# For `rake watch`
gem 'rb-fsevent'
# For markdown header cleanup
gem 'sanitize', '~>2.0'
# Markdown
gem 'redcarpet'
# Syntax highlighting
gem 'pygments.rb'
# Avoid having to poll for changes on Windows
gem 'wdm', '>= 0.1.0' if Gem.win_platform?

View File

@@ -1,70 +0,0 @@
GEM
remote: https://rubygems.org/
specs:
colorator (0.1)
ffi (1.9.14)
ffi (1.9.14-x64-mingw32)
jekyll (3.1.6)
colorator (~> 0.1)
jekyll-sass-converter (~> 1.0)
jekyll-watch (~> 1.1)
kramdown (~> 1.3)
liquid (~> 3.0)
mercenary (~> 0.3.3)
rouge (~> 1.7)
safe_yaml (~> 1.0)
jekyll-paginate (1.1.0)
jekyll-redirect-from (0.11.0)
jekyll (>= 2.0)
jekyll-sass-converter (1.4.0)
sass (~> 3.4)
jekyll-watch (1.4.0)
listen (~> 3.0, < 3.1)
json (2.0.1)
kramdown (1.11.1)
liquid (3.0.6)
listen (3.0.8)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
mercenary (0.3.6)
mini_portile2 (2.1.0)
nokogiri (1.6.8)
mini_portile2 (~> 2.1.0)
pkg-config (~> 1.1.7)
nokogiri (1.6.8-x64-mingw32)
mini_portile2 (~> 2.1.0)
pkg-config (~> 1.1.7)
pkg-config (1.1.7)
posix-spawn (0.3.11)
pygments.rb (0.6.3)
posix-spawn (~> 0.3.6)
yajl-ruby (~> 1.2.0)
rake (11.2.2)
rb-fsevent (0.9.7)
rb-inotify (0.9.7)
ffi (>= 0.5.0)
redcarpet (3.3.4)
rouge (1.11.1)
safe_yaml (1.0.4)
sanitize (2.1.0)
nokogiri (>= 1.4.4)
sass (3.4.22)
yajl-ruby (1.2.1)
PLATFORMS
ruby
x64-mingw32
DEPENDENCIES
jekyll (~> 3.1)
jekyll-paginate
jekyll-redirect-from
json
pygments.rb
rake
rb-fsevent
redcarpet
sanitize (~> 2.0)
BUNDLED WITH
1.11.2

View File

@@ -1,67 +0,0 @@
# React Documentation & Website
We use [Jekyll](http://jekyllrb.com/) to build the site using ([mostly](http://zpao.com/posts/adding-line-highlights-to-markdown-code-fences/)) Markdown, and we host it by pushing HTML to [GitHub Pages](http://pages.github.com/).
## Installation
If you are working on the site, you will want to install and run a local copy of it.
### Dependencies
In order to use Jekyll, you will need to have Ruby installed.
- [Ruby](http://www.ruby-lang.org/) (version >= 1.8.7)
- [RubyGems](http://rubygems.org/) (version >= 1.3.7)
- [Bundler](http://gembundler.com/)
Mac OS X comes pre-installed with Ruby, but you may need to update RubyGems (via `gem update --system`).
Otherwise, [RVM](https://rvm.io/) and [rbenv](https://github.com/sstephenson/rbenv) are popular ways to install Ruby.
Once you have RubyGems and installed Bundler (via `gem install bundler`), use it to install the dependencies:
```sh
$ cd react/docs
$ bundle install # Might need sudo.
$ npm install
```
### Instructions
The site requires React, so first make sure you've built the project (via `grunt`).
Use Jekyll to serve the website locally (by default, at `http://localhost:4000`):
```sh
$ cd react/docs
$ bundle exec rake
$ bundle exec jekyll serve -w
$ open http://localhost:4000/react/
```
We use [SASS](http://sass-lang.com/) (with [Bourbon](http://bourbon.io/)) for our CSS, and we use JSX to transform some of our JS.
If you only want to modify the HTML or Markdown, you do not have to do anything because we package pre-compiled copies of the CSS and JS.
If you want to modify the CSS or JS, use [Rake](http://rake.rubyforge.org/) to compile them:
```sh
$ cd react/docs
$ bundle exec rake watch # Automatically compiles as needed.
# bundle exec rake Manually compile CSS and JS.
# bundle exec rake js Manually compile JS, only.
```
## Afterthoughts
### Updating `facebook.github.io/react`
The easiest way to do this is to have a separate clone of this repository, checked out to the `gh-pages` branch. We have a build step that expects this to be in a directory named `react-gh-pages` at the same depth as `react`. Then it's just a matter of running `grunt docs`, which will compile the site and copy it out to this repository. From there, you can check it in.
**Note:** This should only be done for new releases. You should create a tag corresponding to the release tag in the main repository.
We also have a rake task that does the same thing (without creating commits). It expects the directory structure mentioned above.
```sh
$ bundle exec rake release
```
### Removing the Jekyll / Ruby Dependency
In an ideal world, we would not be adding a Ruby dependency on part of our project. We would like to move towards a point where we are using React to render the website.

View File

@@ -1,76 +0,0 @@
require('rubygems')
require('json')
require('yaml')
require('open-uri')
desc "download babel-browser"
task :fetch_remotes do
IO.copy_stream(
open('https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.34/browser.min.js'),
'js/babel-browser.min.js'
)
end
desc "generate js from jsx"
task :js do
system "../node_modules/.bin/babel _js --out-dir=js"
end
desc "watch js"
task :watch do
Process.spawn "../node_modules/.bin/babel _js --out-dir=js --watch"
Process.waitall
end
desc "update version to match ../package.json"
task :update_version do
react_version = JSON.parse(File.read('../package.json'))['version']
site_config = YAML.load_file('_config.yml')
if site_config['react_version'] != react_version
site_config['react_version'] = react_version
File.open('_config.yml', 'w+') { |f| f.write(site_config.to_yaml) }
end
end
desc "update SRI hashes"
task :update_hashes do
map = {
'react.js' => 'dev',
'react.min.js' => 'prod',
'react-with-addons.js' => 'addons_dev',
'react-with-addons.min.js' => 'addons_prod',
'react-dom.js' => 'dom_dev',
'react-dom.min.js' => 'dom_prod',
'react-dom-server.js' => 'dom_server_dev',
'react-dom-server.min.js' => 'dom_server_prod'
}
site_config = YAML.load_file('_config.yml')
map.each do |file, key|
site_config['react_hashes'][key] = `openssl dgst -sha384 -binary ../../react-bower/#{file} | openssl base64 -A`
end
File.open('_config.yml', 'w+') { |f| f.write(site_config.to_yaml) }
end
desc "update acknowledgements list"
task :update_acknowledgements do
authors = File.readlines('../AUTHORS').map {|author| author.gsub(/ <.*\n/,'')}
# split into cols here because nobody knows how to use liquid
# need to to_f because ruby will keep slice_size as int and round on its own
slice_size = (authors.size / 3.to_f).ceil
cols = authors.each_slice(slice_size).to_a
File.open('_data/acknowledgements.yml', 'w+') { |f| f.write(cols.to_yaml) }
end
desc "copy error codes to docs"
task :copy_error_codes do
codes_json = File.read('../scripts/error-codes/codes.json')
codes_js = "var errorMap = #{codes_json.chomp};\n"
File.write('js/errorMap.js', codes_js)
end
desc "build into ../../react-gh-pages"
task :release => [:update_version, :js, :fetch_remotes, :copy_error_codes] do
system "jekyll build -d ../../react-gh-pages"
end
task :default => [:js]

View File

@@ -1,65 +0,0 @@
---
name: React
description: A JavaScript library for building user interfaces
url: https://facebook.github.io
baseurl: "/react"
permalink: "/blog/:year/:month/:day/:title.html"
paginate_path: "/blog/page:num/"
paginate: 5
timezone: America/Los_Angeles
highlighter: pygments
defaults:
- scope:
path: ''
type: posts
values:
layout: post
sectionid: blog
- scope:
path: blog
type: pages
values:
sectionid: blog
- scope:
path: docs
type: pages
values:
layout: docs
sectionid: docs
- scope:
path: tips
type: pages
values:
sectionid: docs
- scope:
path: contributing
type: pages
values:
sectionid: docs
exclude:
- Gemfile
- Gemfile.lock
- README.md
- Rakefile
- vendor/bundle
markdown: redcarpet
redcarpet:
extensions:
- fenced_code_blocks
- footnotes
sass:
style: :compressed
sass_dir: _css
gems:
- jekyll-redirect-from
- jekyll-paginate
react_version: 15.2.1
react_hashes:
dev: g2900ZIpFKhyIsz+bnx4YDEfAISugYRU58ljeAgI8TZ0A0AkRLGUCN7OmjF16Cj+
prod: ICzDcvbNpMy31akJ8WzksHoK9tl1iRIUPRCaBRN+sn/k40TNGjs9IvgPN0SekkDT
addons_dev: js+Yc2Nd259A4+UPokRNVOXJdipY9oIrkkDdFJAZzZxgryRJLkWYDrJVgM97aweF
addons_prod: DaNE8gIDQr8RWDoa4y9HX/70fzdOBzpV/e+7RJtMN1MnXEiCMpiIFtutJml6mvPC
dom_dev: LD1cH7LXOdrrq5dOOiE2N/HdgCyrw3nmUMq6oPFCJKUfWO3i7AozvBKz7G3maMHt
dom_prod: 1dLXeik7kFcDPXbz3rX9dibLTGh/D8dpAOL5X2Ml09pH8wpQlpL+JOgOnzAMCO4T
dom_server_dev: WJt1y2JljJEQ1OgpupP2ly0GgIwi7Aodp+n+/fv2bakpgWpXMnLklj5rSouRJt59
dom_server_prod: Y6UDASOvQhWWBwXy/Ccp4vSAt0YAp+ymuRXBX4hffy+pMlOgjXzryIjbiceIB6GF

View File

@@ -1,171 +0,0 @@
html * {
color-profile: sRGB;
rendering-intent: auto;
}
.cm-s-solarized-light {
background-color: #f8f5ec;
color: #637c84;
}
.cm-s-solarized-light .emphasis {
font-weight: bold;
}
.cm-s-solarized-light .dotted {
border-bottom: 1px dotted #cb4b16;
}
.cm-s-solarized-light .CodeMirror-gutter {
background-color: #eee8d5;
border-right: 3px solid #eee8d5;
}
.cm-s-solarized-light .CodeMirror-gutter .CodeMirror-gutter-text {
color: #93a1a1;
}
.cm-s-solarized-light .CodeMirror-cursor {
border-left-color: #002b36 !important;
}
.cm-s-solarized-light .CodeMirror-matchingbracket {
color: #002b36;
background-color: #eee8d5;
box-shadow: 0 0 10px #eee8d5;
font-weight: bold;
}
.cm-s-solarized-light .CodeMirror-nonmatchingbracket {
color: #002b36;
background-color: #eee8d5;
box-shadow: 0 0 10px #eee8d5;
font-weight: bold;
color: #dc322f;
border-bottom: 1px dotted #cb4b16;
}
.cm-s-solarized-light span.cm-keyword {
color: #859900;
}
.cm-s-solarized-light span.cm-atom {
color: #2aa198;
}
.cm-s-solarized-light span.cm-number {
color: #586e75;
}
.cm-s-solarized-light span.cm-def {
color: #637c84;
}
.cm-s-solarized-light span.cm-variable {
color: #637c84;
}
.cm-s-solarized-light span.cm-variable-2 {
color: #b58900;
}
.cm-s-solarized-light span.cm-variable-3 {
color: #cb4b16;
}
.cm-s-solarized-light span.cm-comment {
color: #93a1a1;
}
.cm-s-solarized-light span.cm-property {
color: #657b83;
}
.cm-s-solarized-light span.cm-operator {
color: #657b83;
}
.cm-s-solarized-light span.cm-string {
color: #36958e;
}
.cm-s-solarized-light span.cm-error {
font-weight: bold;
border-bottom: 1px dotted #cb4b16;
}
.cm-s-solarized-light span.cm-bracket {
color: #268bd2;
}
.cm-s-solarized-light span.cm-tag {
color: #268bd2;
}
.cm-s-solarized-light span.cm-attribute {
color: #586e75;
}
.cm-s-solarized-light span.cm-meta {
color: #268bd2;
}
.cm-s-solarized-dark {
background-color: #002b36;
color: #839496;
}
.cm-s-solarized-dark .emphasis {
font-weight: bold;
}
.cm-s-solarized-dark .dotted {
border-bottom: 1px dotted #cb4b16;
}
.cm-s-solarized-dark .CodeMirror-gutter {
background-color: #073642;
border-right: 3px solid #073642;
}
.cm-s-solarized-dark .CodeMirror-gutter .CodeMirror-gutter-text {
color: #586e75;
}
.cm-s-solarized-dark .CodeMirror-cursor {
border-left-color: #fdf6e3 !important;
}
.cm-s-solarized-dark .CodeMirror-matchingbracket {
color: #fdf6e3;
background-color: #073642;
box-shadow: 0 0 10px #073642;
font-weight: bold;
}
.cm-s-solarized-dark .CodeMirror-nonmatchingbracket {
color: #fdf6e3;
background-color: #073642;
box-shadow: 0 0 10px #073642;
font-weight: bold;
color: #dc322f;
border-bottom: 1px dotted #cb4b16;
}
.cm-s-solarized-dark span.cm-keyword {
color: #839496;
font-weight: bold;
}
.cm-s-solarized-dark span.cm-atom {
color: #2aa198;
}
.cm-s-solarized-dark span.cm-number {
color: #93a1a1;
}
.cm-s-solarized-dark span.cm-def {
color: #268bd2;
}
.cm-s-solarized-dark span.cm-variable {
color: #cb4b16;
}
.cm-s-solarized-dark span.cm-variable-2 {
color: #cb4b16;
}
.cm-s-solarized-dark span.cm-variable-3 {
color: #cb4b16;
}
.cm-s-solarized-dark span.cm-comment {
color: #586e75;
}
.cm-s-solarized-dark span.cm-property {
color: #b58900;
}
.cm-s-solarized-dark span.cm-operator {
color: #839496;
}
.cm-s-solarized-dark span.cm-string {
color: #6c71c4;
}
.cm-s-solarized-dark span.cm-error {
font-weight: bold;
border-bottom: 1px dotted #cb4b16;
}
.cm-s-solarized-dark span.cm-bracket {
color: #cb4b16;
}
.cm-s-solarized-dark span.cm-tag {
color: #839496;
}
.cm-s-solarized-dark span.cm-attribute {
color: #93a1a1;
}
.cm-s-solarized-dark span.cm-meta {
color: #268bd2;
}

View File

@@ -1,133 +0,0 @@
@import 'variables.scss';
$textColor: $mediumColor;
$textColorLight: lighten($textColor, 20%);
html {
font-family: $helvetica;
font-family: proxima-nova, $helvetica;
color: $textColor;
line-height: 1.28;
}
p {
margin: 0 0 10px;
}
.subHeader {
font-size: 21px;
font-weight: 200;
line-height: 30px;
margin-bottom: 10px;
}
em {
font-style: italic;
}
h1,
h2,
h3,
h4,
h5,
h6 {
margin: 10px 0;
font-family: inherit;
font-weight: bold;
line-height: 20px;
color: inherit;
text-rendering: optimizelegibility;
}
h1 small,
h2 small,
h3 small,
h4 small,
h5 small,
h6 small {
font-weight: normal;
color: $textColorLight
}
h1,
h2,
h3 {
line-height: 40px;
}
h1 {
font-size: 39px;
}
h2 {
font-size: 31px;
}
h3 {
font-size: 23px;
}
h4 {
font-size: 16px;
}
h5 {
font-size: 14px;
}
h6 {
font-size: 11px;
}
h1 small {
font-size: 24px;
}
h2 small {
font-size: 18px;
}
h3 small {
font-size: 16px;
}
h4 small {
font-size: 14px;
}
ul,
ol {
margin: 0 0 10px 25px;
padding: 0;
}
ul ul,
ul ol,
ol ol,
ol ul {
margin-bottom: 0;
}
li {
line-height: 20px;
}
a {
color: $linkColor;
text-decoration: none;
&:hover,
&:focus {
color: $linkInteract;
text-decoration: underline;
}
&:focus {
outline: thin dotted #333;
outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px;
}
}
.center {
text-align: center;
}

View File

@@ -1,22 +0,0 @@
$primary: #cc7a6f;
$linkColor: darken($primary, 9%);
$linkInteract: darken($linkColor, 9%);
$pageBg: #f9f9f9;
$lightColor: #e9e9e9;
$mediumestColor: #666;
$mediumColor: #484848;
$darkColor: #2d2d2d;
$darkestColor: #222222;
$blueColor: #61dafb;
$orangeColor: complement($blueColor);
$lightTextColor: #fafafa;
$mediumTextColor: #aaa;
$darkTextColor: $mediumColor;
$buttonBlueTop: #77a3d2;
$buttonBlueBottom: #4783c2;
$buttonGreyTop: #9a9a9a;
$buttonGreyBottom: #646464;

View File

@@ -1,8 +0,0 @@
//************************************************************************//
// These mixins/functions are deprecated
// They will be removed in the next MAJOR version release
//************************************************************************//
@mixin inline-block {
display: inline-block;
@warn "inline-block mixin is deprecated and will be removed in the next major version release";
}

View File

@@ -1,79 +0,0 @@
// Settings
@import "settings/prefixer";
@import "settings/px-to-em";
@import "settings/asset-pipeline";
// Custom Helpers
@import "helpers/convert-units";
@import "helpers/gradient-positions-parser";
@import "helpers/is-num";
@import "helpers/linear-angle-parser";
@import "helpers/linear-gradient-parser";
@import "helpers/linear-positions-parser";
@import "helpers/linear-side-corner-parser";
@import "helpers/radial-arg-parser";
@import "helpers/radial-positions-parser";
@import "helpers/radial-gradient-parser";
@import "helpers/render-gradients";
@import "helpers/shape-size-stripper";
@import "helpers/str-to-num";
// Custom Functions
@import "functions/assign";
@import "functions/color-lightness";
@import "functions/flex-grid";
@import "functions/golden-ratio";
@import "functions/grid-width";
@import "functions/modular-scale";
@import "functions/px-to-em";
@import "functions/px-to-rem";
@import "functions/strip-units";
@import "functions/tint-shade";
@import "functions/transition-property-name";
@import "functions/unpack";
// CSS3 Mixins
@import "css3/animation";
@import "css3/appearance";
@import "css3/backface-visibility";
@import "css3/background";
@import "css3/background-image";
@import "css3/border-image";
@import "css3/border-radius";
@import "css3/box-sizing";
@import "css3/calc";
@import "css3/columns";
@import "css3/filter";
@import "css3/flex-box";
@import "css3/font-face";
@import "css3/font-feature-settings";
@import "css3/hyphens";
@import "css3/hidpi-media-query";
@import "css3/image-rendering";
@import "css3/keyframes";
@import "css3/linear-gradient";
@import "css3/perspective";
@import "css3/radial-gradient";
@import "css3/transform";
@import "css3/transition";
@import "css3/user-select";
@import "css3/placeholder";
// Addons & other mixins
@import "addons/button";
@import "addons/clearfix";
@import "addons/directional-values";
@import "addons/ellipsis";
@import "addons/font-family";
@import "addons/hide-text";
@import "addons/html5-input-types";
@import "addons/position";
@import "addons/prefixer";
@import "addons/retina-image";
@import "addons/size";
@import "addons/timing-functions";
@import "addons/triangle";
@import "addons/word-wrap";
// Soon to be deprecated Mixins
@import "bourbon-deprecated-upcoming";

View File

@@ -1,374 +0,0 @@
@mixin button ($style: simple, $base-color: #4294f0, $text-size: inherit, $padding: 7px 18px) {
@if type-of($style) == string and type-of($base-color) == color {
@include buttonstyle($style, $base-color, $text-size, $padding);
}
@if type-of($style) == string and type-of($base-color) == number {
$padding: $text-size;
$text-size: $base-color;
$base-color: #4294f0;
@if $padding == inherit {
$padding: 7px 18px;
}
@include buttonstyle($style, $base-color, $text-size, $padding);
}
@if type-of($style) == color and type-of($base-color) == color {
$base-color: $style;
$style: simple;
@include buttonstyle($style, $base-color, $text-size, $padding);
}
@if type-of($style) == color and type-of($base-color) == number {
$padding: $text-size;
$text-size: $base-color;
$base-color: $style;
$style: simple;
@if $padding == inherit {
$padding: 7px 18px;
}
@include buttonstyle($style, $base-color, $text-size, $padding);
}
@if type-of($style) == number {
$padding: $base-color;
$text-size: $style;
$base-color: #4294f0;
$style: simple;
@if $padding == #4294f0 {
$padding: 7px 18px;
}
@include buttonstyle($style, $base-color, $text-size, $padding);
}
&:disabled {
opacity: 0.5;
cursor: not-allowed;
}
}
// Selector Style Button
//************************************************************************//
@mixin buttonstyle($type, $b-color, $t-size, $pad) {
// Grayscale button
@if $type == simple and $b-color == grayscale($b-color) {
@include simple($b-color, true, $t-size, $pad);
}
@if $type == shiny and $b-color == grayscale($b-color) {
@include shiny($b-color, true, $t-size, $pad);
}
@if $type == pill and $b-color == grayscale($b-color) {
@include pill($b-color, true, $t-size, $pad);
}
@if $type == flat and $b-color == grayscale($b-color) {
@include flat($b-color, true, $t-size, $pad);
}
// Colored button
@if $type == simple {
@include simple($b-color, false, $t-size, $pad);
}
@else if $type == shiny {
@include shiny($b-color, false, $t-size, $pad);
}
@else if $type == pill {
@include pill($b-color, false, $t-size, $pad);
}
@else if $type == flat {
@include flat($b-color, false, $t-size, $pad);
}
}
// Simple Button
//************************************************************************//
@mixin simple($base-color, $grayscale: false, $textsize: inherit, $padding: 7px 18px) {
$color: hsl(0, 0, 100%);
$border: adjust-color($base-color, $saturation: 9%, $lightness: -14%);
$inset-shadow: adjust-color($base-color, $saturation: -8%, $lightness: 15%);
$stop-gradient: adjust-color($base-color, $saturation: 9%, $lightness: -11%);
$text-shadow: adjust-color($base-color, $saturation: 15%, $lightness: -18%);
@if is-light($base-color) {
$color: hsl(0, 0, 20%);
$text-shadow: adjust-color($base-color, $saturation: 10%, $lightness: 4%);
}
@if $grayscale == true {
$border: grayscale($border);
$inset-shadow: grayscale($inset-shadow);
$stop-gradient: grayscale($stop-gradient);
$text-shadow: grayscale($text-shadow);
}
border: 1px solid $border;
border-radius: 3px;
box-shadow: inset 0 1px 0 0 $inset-shadow;
color: $color;
display: inline-block;
font-size: $textsize;
font-weight: bold;
@include linear-gradient ($base-color, $stop-gradient);
padding: $padding;
text-decoration: none;
text-shadow: 0 1px 0 $text-shadow;
background-clip: padding-box;
&:hover:not(:disabled) {
$base-color-hover: adjust-color($base-color, $saturation: -4%, $lightness: -5%);
$inset-shadow-hover: adjust-color($base-color, $saturation: -7%, $lightness: 5%);
$stop-gradient-hover: adjust-color($base-color, $saturation: 8%, $lightness: -14%);
@if $grayscale == true {
$base-color-hover: grayscale($base-color-hover);
$inset-shadow-hover: grayscale($inset-shadow-hover);
$stop-gradient-hover: grayscale($stop-gradient-hover);
}
box-shadow: inset 0 1px 0 0 $inset-shadow-hover;
cursor: pointer;
@include linear-gradient ($base-color-hover, $stop-gradient-hover);
}
&:active:not(:disabled),
&:focus:not(:disabled) {
$border-active: adjust-color($base-color, $saturation: 9%, $lightness: -14%);
$inset-shadow-active: adjust-color($base-color, $saturation: 7%, $lightness: -17%);
@if $grayscale == true {
$border-active: grayscale($border-active);
$inset-shadow-active: grayscale($inset-shadow-active);
}
border: 1px solid $border-active;
box-shadow: inset 0 0 8px 4px $inset-shadow-active, inset 0 0 8px 4px $inset-shadow-active;
}
}
// Shiny Button
//************************************************************************//
@mixin shiny($base-color, $grayscale: false, $textsize: inherit, $padding: 7px 18px) {
$color: hsl(0, 0, 100%);
$border: adjust-color($base-color, $red: -117, $green: -111, $blue: -81);
$border-bottom: adjust-color($base-color, $red: -126, $green: -127, $blue: -122);
$fourth-stop: adjust-color($base-color, $red: -79, $green: -70, $blue: -46);
$inset-shadow: adjust-color($base-color, $red: 37, $green: 29, $blue: 12);
$second-stop: adjust-color($base-color, $red: -56, $green: -50, $blue: -33);
$text-shadow: adjust-color($base-color, $red: -140, $green: -141, $blue: -114);
$third-stop: adjust-color($base-color, $red: -86, $green: -75, $blue: -48);
@if is-light($base-color) {
$color: hsl(0, 0, 20%);
$text-shadow: adjust-color($base-color, $saturation: 10%, $lightness: 4%);
}
@if $grayscale == true {
$border: grayscale($border);
$border-bottom: grayscale($border-bottom);
$fourth-stop: grayscale($fourth-stop);
$inset-shadow: grayscale($inset-shadow);
$second-stop: grayscale($second-stop);
$text-shadow: grayscale($text-shadow);
$third-stop: grayscale($third-stop);
}
border: 1px solid $border;
border-bottom: 1px solid $border-bottom;
border-radius: 5px;
box-shadow: inset 0 1px 0 0 $inset-shadow;
color: $color;
display: inline-block;
font-size: $textsize;
font-weight: bold;
@include linear-gradient(top, $base-color 0%, $second-stop 50%, $third-stop 50%, $fourth-stop 100%);
padding: $padding;
text-align: center;
text-decoration: none;
text-shadow: 0 -1px 1px $text-shadow;
&:hover:not(:disabled) {
$first-stop-hover: adjust-color($base-color, $red: -13, $green: -15, $blue: -18);
$second-stop-hover: adjust-color($base-color, $red: -66, $green: -62, $blue: -51);
$third-stop-hover: adjust-color($base-color, $red: -93, $green: -85, $blue: -66);
$fourth-stop-hover: adjust-color($base-color, $red: -86, $green: -80, $blue: -63);
@if $grayscale == true {
$first-stop-hover: grayscale($first-stop-hover);
$second-stop-hover: grayscale($second-stop-hover);
$third-stop-hover: grayscale($third-stop-hover);
$fourth-stop-hover: grayscale($fourth-stop-hover);
}
cursor: pointer;
@include linear-gradient(top, $first-stop-hover 0%,
$second-stop-hover 50%,
$third-stop-hover 50%,
$fourth-stop-hover 100%);
}
&:active:not(:disabled),
&:focus:not(:disabled) {
$inset-shadow-active: adjust-color($base-color, $red: -111, $green: -116, $blue: -122);
@if $grayscale == true {
$inset-shadow-active: grayscale($inset-shadow-active);
}
box-shadow: inset 0 0 20px 0 $inset-shadow-active;
}
}
// Pill Button
//************************************************************************//
@mixin pill($base-color, $grayscale: false, $textsize: inherit, $padding: 7px 18px) {
$color: hsl(0, 0, 100%);
$border-bottom: adjust-color($base-color, $hue: 8, $saturation: -11%, $lightness: -26%);
$border-sides: adjust-color($base-color, $hue: 4, $saturation: -21%, $lightness: -21%);
$border-top: adjust-color($base-color, $hue: -1, $saturation: -30%, $lightness: -15%);
$inset-shadow: adjust-color($base-color, $hue: -1, $saturation: -1%, $lightness: 7%);
$stop-gradient: adjust-color($base-color, $hue: 8, $saturation: 14%, $lightness: -10%);
$text-shadow: adjust-color($base-color, $hue: 5, $saturation: -19%, $lightness: -15%);
@if is-light($base-color) {
$color: hsl(0, 0, 20%);
$text-shadow: adjust-color($base-color, $saturation: 10%, $lightness: 4%);
}
@if $grayscale == true {
$border-bottom: grayscale($border-bottom);
$border-sides: grayscale($border-sides);
$border-top: grayscale($border-top);
$inset-shadow: grayscale($inset-shadow);
$stop-gradient: grayscale($stop-gradient);
$text-shadow: grayscale($text-shadow);
}
border: 1px solid $border-top;
border-color: $border-top $border-sides $border-bottom;
border-radius: 16px;
box-shadow: inset 0 1px 0 0 $inset-shadow;
color: $color;
display: inline-block;
font-size: $textsize;
font-weight: normal;
line-height: 1;
@include linear-gradient ($base-color, $stop-gradient);
padding: $padding;
text-align: center;
text-decoration: none;
text-shadow: 0 -1px 1px $text-shadow;
background-clip: padding-box;
&:hover:not(:disabled) {
$base-color-hover: adjust-color($base-color, $lightness: -4.5%);
$border-bottom: adjust-color($base-color, $hue: 8, $saturation: 13.5%, $lightness: -32%);
$border-sides: adjust-color($base-color, $hue: 4, $saturation: -2%, $lightness: -27%);
$border-top: adjust-color($base-color, $hue: -1, $saturation: -17%, $lightness: -21%);
$inset-shadow-hover: adjust-color($base-color, $saturation: -1%, $lightness: 3%);
$stop-gradient-hover: adjust-color($base-color, $hue: 8, $saturation: -4%, $lightness: -15.5%);
$text-shadow-hover: adjust-color($base-color, $hue: 5, $saturation: -5%, $lightness: -22%);
@if $grayscale == true {
$base-color-hover: grayscale($base-color-hover);
$border-bottom: grayscale($border-bottom);
$border-sides: grayscale($border-sides);
$border-top: grayscale($border-top);
$inset-shadow-hover: grayscale($inset-shadow-hover);
$stop-gradient-hover: grayscale($stop-gradient-hover);
$text-shadow-hover: grayscale($text-shadow-hover);
}
border: 1px solid $border-top;
border-color: $border-top $border-sides $border-bottom;
box-shadow: inset 0 1px 0 0 $inset-shadow-hover;
cursor: pointer;
@include linear-gradient ($base-color-hover, $stop-gradient-hover);
text-shadow: 0 -1px 1px $text-shadow-hover;
background-clip: padding-box;
}
&:active:not(:disabled),
&:focus:not(:disabled) {
$active-color: adjust-color($base-color, $hue: 4, $saturation: -12%, $lightness: -10%);
$border-active: adjust-color($base-color, $hue: 6, $saturation: -2.5%, $lightness: -30%);
$border-bottom-active: adjust-color($base-color, $hue: 11, $saturation: 6%, $lightness: -31%);
$inset-shadow-active: adjust-color($base-color, $hue: 9, $saturation: 2%, $lightness: -21.5%);
$text-shadow-active: adjust-color($base-color, $hue: 5, $saturation: -12%, $lightness: -21.5%);
@if $grayscale == true {
$active-color: grayscale($active-color);
$border-active: grayscale($border-active);
$border-bottom-active: grayscale($border-bottom-active);
$inset-shadow-active: grayscale($inset-shadow-active);
$text-shadow-active: grayscale($text-shadow-active);
}
background: $active-color;
border: 1px solid $border-active;
border-bottom: 1px solid $border-bottom-active;
box-shadow: inset 0 0 6px 3px $inset-shadow-active;
text-shadow: 0 -1px 1px $text-shadow-active;
}
}
// Flat Button
//************************************************************************//
@mixin flat($base-color, $grayscale: false, $textsize: inherit, $padding: 7px 18px) {
$color: hsl(0, 0, 100%);
@if is-light($base-color) {
$color: hsl(0, 0, 20%);
}
background-color: $base-color;
border-radius: 3px;
border: none;
color: $color;
display: inline-block;
font-size: inherit;
font-weight: bold;
padding: 7px 18px;
text-decoration: none;
background-clip: padding-box;
&:hover:not(:disabled){
$base-color-hover: adjust-color($base-color, $saturation: 4%, $lightness: 5%);
@if $grayscale == true {
$base-color-hover: grayscale($base-color-hover);
}
background-color: $base-color-hover;
cursor: pointer;
}
&:active:not(:disabled),
&:focus:not(:disabled) {
$base-color-active: adjust-color($base-color, $saturation: -4%, $lightness: -5%);
@if $grayscale == true {
$base-color-active: grayscale($base-color-active);
}
background-color: $base-color-active;
cursor: pointer;
}
}

View File

@@ -1,23 +0,0 @@
// Modern micro clearfix provides an easy way to contain floats without adding additional markup.
//
// Example usage:
//
// // Contain all floats within .wrapper
// .wrapper {
// @include clearfix;
// .content,
// .sidebar {
// float : left;
// }
// }
@mixin clearfix {
&:after {
content:"";
display:table;
clear:both;
}
}
// Acknowledgements
// Beat *that* clearfix: [Thierry Koblentz](http://www.css-101.org/articles/clearfix/latest-new-clearfix-so-far.php)

View File

@@ -1,111 +0,0 @@
// directional-property mixins are shorthands
// for writing properties like the following
//
// @include margin(null 0 10px);
// ------
// margin-right: 0;
// margin-bottom: 10px;
// margin-left: 0;
//
// - or -
//
// @include border-style(dotted null);
// ------
// border-top-style: dotted;
// border-bottom-style: dotted;
//
// ------
//
// Note: You can also use false instead of null
@function collapse-directionals($vals) {
$output: null;
$A: nth( $vals, 1 );
$B: if( length($vals) < 2, $A, nth($vals, 2));
$C: if( length($vals) < 3, $A, nth($vals, 3));
$D: if( length($vals) < 2, $A, nth($vals, if( length($vals) < 4, 2, 4) ));
@if $A == 0 { $A: 0 }
@if $B == 0 { $B: 0 }
@if $C == 0 { $C: 0 }
@if $D == 0 { $D: 0 }
@if $A == $B and $A == $C and $A == $D { $output: $A }
@else if $A == $C and $B == $D { $output: $A $B }
@else if $B == $D { $output: $A $B $C }
@else { $output: $A $B $C $D }
@return $output;
}
@function contains-falsy($list) {
@each $item in $list {
@if not $item {
@return true;
}
}
@return false;
}
@mixin directional-property($pre, $suf, $vals) {
// Property Names
$top: $pre + "-top" + if($suf, "-#{$suf}", "");
$bottom: $pre + "-bottom" + if($suf, "-#{$suf}", "");
$left: $pre + "-left" + if($suf, "-#{$suf}", "");
$right: $pre + "-right" + if($suf, "-#{$suf}", "");
$all: $pre + if($suf, "-#{$suf}", "");
$vals: collapse-directionals($vals);
@if contains-falsy($vals) {
@if nth($vals, 1) { #{$top}: nth($vals, 1); }
@if length($vals) == 1 {
@if nth($vals, 1) { #{$right}: nth($vals, 1); }
} @else {
@if nth($vals, 2) { #{$right}: nth($vals, 2); }
}
// prop: top/bottom right/left
@if length($vals) == 2 {
@if nth($vals, 1) { #{$bottom}: nth($vals, 1); }
@if nth($vals, 2) { #{$left}: nth($vals, 2); }
// prop: top right/left bottom
} @else if length($vals) == 3 {
@if nth($vals, 3) { #{$bottom}: nth($vals, 3); }
@if nth($vals, 2) { #{$left}: nth($vals, 2); }
// prop: top right bottom left
} @else if length($vals) == 4 {
@if nth($vals, 3) { #{$bottom}: nth($vals, 3); }
@if nth($vals, 4) { #{$left}: nth($vals, 4); }
}
// prop: top/right/bottom/left
} @else {
#{$all}: $vals;
}
}
@mixin margin($vals...) {
@include directional-property(margin, false, $vals...);
}
@mixin padding($vals...) {
@include directional-property(padding, false, $vals...);
}
@mixin border-style($vals...) {
@include directional-property(border, style, $vals...);
}
@mixin border-color($vals...) {
@include directional-property(border, color, $vals...);
}
@mixin border-width($vals...) {
@include directional-property(border, width, $vals...);
}

View File

@@ -1,7 +0,0 @@
@mixin ellipsis($width: 100%) {
display: inline-block;
max-width: $width;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}

View File

@@ -1,5 +0,0 @@
$georgia: Georgia, Cambria, "Times New Roman", Times, serif;
$helvetica: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif;
$lucida-grande: "Lucida Grande", Tahoma, Verdana, Arial, sans-serif;
$monospace: "Bitstream Vera Sans Mono", Consolas, Courier, monospace;
$verdana: Verdana, Geneva, sans-serif;

View File

@@ -1,10 +0,0 @@
@mixin hide-text {
overflow: hidden;
&:before {
content: "";
display: block;
width: 0;
height: 100%;
}
}

View File

@@ -1,86 +0,0 @@
//************************************************************************//
// Generate a variable ($all-text-inputs) with a list of all html5
// input types that have a text-based input, excluding textarea.
// http://diveintohtml5.org/forms.html
//************************************************************************//
$inputs-list: 'input[type="email"]',
'input[type="number"]',
'input[type="password"]',
'input[type="search"]',
'input[type="tel"]',
'input[type="text"]',
'input[type="url"]',
// Webkit & Gecko may change the display of these in the future
'input[type="color"]',
'input[type="date"]',
'input[type="datetime"]',
'input[type="datetime-local"]',
'input[type="month"]',
'input[type="time"]',
'input[type="week"]';
// Bare inputs
//************************************************************************//
$all-text-inputs: assign-inputs($inputs-list);
// Hover Pseudo-class
//************************************************************************//
$all-text-inputs-hover: assign-inputs($inputs-list, hover);
// Focus Pseudo-class
//************************************************************************//
$all-text-inputs-focus: assign-inputs($inputs-list, focus);
// You must use interpolation on the variable:
// #{$all-text-inputs}
// #{$all-text-inputs-hover}
// #{$all-text-inputs-focus}
// Example
//************************************************************************//
// #{$all-text-inputs}, textarea {
// border: 1px solid red;
// }
//************************************************************************//
// Generate a variable ($all-button-inputs) with a list of all html5
// input types that have a button-based input, excluding button.
//************************************************************************//
$inputs-button-list: 'input[type="button"]',
'input[type="reset"]',
'input[type="submit"]';
// Bare inputs
//************************************************************************//
$all-button-inputs: assign-inputs($inputs-button-list);
// Hover Pseudo-class
//************************************************************************//
$all-button-inputs-hover: assign-inputs($inputs-button-list, hover);
// Focus Pseudo-class
//************************************************************************//
$all-button-inputs-focus: assign-inputs($inputs-button-list, focus);
// Active Pseudo-class
//************************************************************************//
$all-button-inputs-active: assign-inputs($inputs-button-list, active);
// You must use interpolation on the variable:
// #{$all-button-inputs}
// #{$all-button-inputs-hover}
// #{$all-button-inputs-focus}
// #{$all-button-inputs-active}
// Example
//************************************************************************//
// #{$all-button-inputs}, button {
// border: 1px solid red;
// }

View File

@@ -1,32 +0,0 @@
@mixin position ($position: relative, $coordinates: null null null null) {
@if type-of($position) == list {
$coordinates: $position;
$position: relative;
}
$coordinates: unpack($coordinates);
$top: nth($coordinates, 1);
$right: nth($coordinates, 2);
$bottom: nth($coordinates, 3);
$left: nth($coordinates, 4);
position: $position;
@if ($top and $top == auto) or (type-of($top) == number) {
top: $top;
}
@if ($right and $right == auto) or (type-of($right) == number) {
right: $right;
}
@if ($bottom and $bottom == auto) or (type-of($bottom) == number) {
bottom: $bottom;
}
@if ($left and $left == auto) or (type-of($left) == number) {
left: $left;
}
}

View File

@@ -1,45 +0,0 @@
//************************************************************************//
// Example: @include prefixer(border-radius, $radii, webkit ms spec);
//************************************************************************//
// Variables located in /settings/_prefixer.scss
@mixin prefixer ($property, $value, $prefixes) {
@each $prefix in $prefixes {
@if $prefix == webkit {
@if $prefix-for-webkit {
-webkit-#{$property}: $value;
}
}
@else if $prefix == moz {
@if $prefix-for-mozilla {
-moz-#{$property}: $value;
}
}
@else if $prefix == ms {
@if $prefix-for-microsoft {
-ms-#{$property}: $value;
}
}
@else if $prefix == o {
@if $prefix-for-opera {
-o-#{$property}: $value;
}
}
@else if $prefix == spec {
@if $prefix-for-spec {
#{$property}: $value;
}
}
@else {
@warn "Unrecognized prefix: #{$prefix}";
}
}
}
@mixin disable-prefix-for-all() {
$prefix-for-webkit: false !global;
$prefix-for-mozilla: false !global;
$prefix-for-microsoft: false !global;
$prefix-for-opera: false !global;
$prefix-for-spec: false !global;
}

View File

@@ -1,31 +0,0 @@
@mixin retina-image($filename, $background-size, $extension: png, $retina-filename: null, $retina-suffix: _2x, $asset-pipeline: $asset-pipeline) {
@if $asset-pipeline {
background-image: image-url("#{$filename}.#{$extension}");
}
@else {
background-image: url("#{$filename}.#{$extension}");
}
@include hidpi {
@if $asset-pipeline {
@if $retina-filename {
background-image: image-url("#{$retina-filename}.#{$extension}");
}
@else {
background-image: image-url("#{$filename}#{$retina-suffix}.#{$extension}");
}
}
@else {
@if $retina-filename {
background-image: url("#{$retina-filename}.#{$extension}");
}
@else {
background-image: url("#{$filename}#{$retina-suffix}.#{$extension}");
}
}
background-size: $background-size;
}
}

View File

@@ -1,16 +0,0 @@
@mixin size($size) {
$height: nth($size, 1);
$width: $height;
@if length($size) > 1 {
$height: nth($size, 2);
}
@if $height == auto or (type-of($height) == number and not unitless($height)) {
height: $height;
}
@if $width == auto or (type-of($width) == number and not unitless($width)) {
width: $width;
}
}

View File

@@ -1,32 +0,0 @@
// CSS cubic-bezier timing functions. Timing functions courtesy of jquery.easie (github.com/jaukia/easie)
// Timing functions are the same as demo'ed here: http://jqueryui.com/resources/demos/effect/easing.html
// EASE IN
$ease-in-quad: cubic-bezier(0.550, 0.085, 0.680, 0.530);
$ease-in-cubic: cubic-bezier(0.550, 0.055, 0.675, 0.190);
$ease-in-quart: cubic-bezier(0.895, 0.030, 0.685, 0.220);
$ease-in-quint: cubic-bezier(0.755, 0.050, 0.855, 0.060);
$ease-in-sine: cubic-bezier(0.470, 0.000, 0.745, 0.715);
$ease-in-expo: cubic-bezier(0.950, 0.050, 0.795, 0.035);
$ease-in-circ: cubic-bezier(0.600, 0.040, 0.980, 0.335);
$ease-in-back: cubic-bezier(0.600, -0.280, 0.735, 0.045);
// EASE OUT
$ease-out-quad: cubic-bezier(0.250, 0.460, 0.450, 0.940);
$ease-out-cubic: cubic-bezier(0.215, 0.610, 0.355, 1.000);
$ease-out-quart: cubic-bezier(0.165, 0.840, 0.440, 1.000);
$ease-out-quint: cubic-bezier(0.230, 1.000, 0.320, 1.000);
$ease-out-sine: cubic-bezier(0.390, 0.575, 0.565, 1.000);
$ease-out-expo: cubic-bezier(0.190, 1.000, 0.220, 1.000);
$ease-out-circ: cubic-bezier(0.075, 0.820, 0.165, 1.000);
$ease-out-back: cubic-bezier(0.175, 0.885, 0.320, 1.275);
// EASE IN OUT
$ease-in-out-quad: cubic-bezier(0.455, 0.030, 0.515, 0.955);
$ease-in-out-cubic: cubic-bezier(0.645, 0.045, 0.355, 1.000);
$ease-in-out-quart: cubic-bezier(0.770, 0.000, 0.175, 1.000);
$ease-in-out-quint: cubic-bezier(0.860, 0.000, 0.070, 1.000);
$ease-in-out-sine: cubic-bezier(0.445, 0.050, 0.550, 0.950);
$ease-in-out-expo: cubic-bezier(1.000, 0.000, 0.000, 1.000);
$ease-in-out-circ: cubic-bezier(0.785, 0.135, 0.150, 0.860);
$ease-in-out-back: cubic-bezier(0.680, -0.550, 0.265, 1.550);

View File

@@ -1,83 +0,0 @@
@mixin triangle ($size, $color, $direction) {
height: 0;
width: 0;
$width: nth($size, 1);
$height: nth($size, length($size));
$foreground-color: nth($color, 1);
$background-color: if(length($color) == 2, nth($color, 2), transparent);
@if ($direction == up) or ($direction == down) or ($direction == right) or ($direction == left) {
$width: $width / 2;
$height: if(length($size) > 1, $height, $height/2);
@if $direction == up {
border-left: $width solid $background-color;
border-right: $width solid $background-color;
border-bottom: $height solid $foreground-color;
} @else if $direction == right {
border-top: $width solid $background-color;
border-bottom: $width solid $background-color;
border-left: $height solid $foreground-color;
} @else if $direction == down {
border-left: $width solid $background-color;
border-right: $width solid $background-color;
border-top: $height solid $foreground-color;
} @else if $direction == left {
border-top: $width solid $background-color;
border-bottom: $width solid $background-color;
border-right: $height solid $foreground-color;
}
}
@else if ($direction == up-right) or ($direction == up-left) {
border-top: $height solid $foreground-color;
@if $direction == up-right {
border-left: $width solid $background-color;
} @else if $direction == up-left {
border-right: $width solid $background-color;
}
}
@else if ($direction == down-right) or ($direction == down-left) {
border-bottom: $height solid $foreground-color;
@if $direction == down-right {
border-left: $width solid $background-color;
} @else if $direction == down-left {
border-right: $width solid $background-color;
}
}
@else if ($direction == inset-up) {
border-width: $height $width;
border-style: solid;
border-color: $background-color $background-color $foreground-color;
}
@else if ($direction == inset-down) {
border-width: $height $width;
border-style: solid;
border-color: $foreground-color $background-color $background-color;
}
@else if ($direction == inset-right) {
border-width: $width $height;
border-style: solid;
border-color: $background-color $background-color $background-color $foreground-color;
}
@else if ($direction == inset-left) {
border-width: $width $height;
border-style: solid;
border-color: $background-color $foreground-color $background-color $background-color;
}
}

View File

@@ -1,8 +0,0 @@
@mixin word-wrap($wrap: break-word) {
word-wrap: $wrap;
@if $wrap == break-word {
overflow-wrap: break-word;
word-break: break-all;
}
}

View File

@@ -1,52 +0,0 @@
// http://www.w3.org/TR/css3-animations/#the-animation-name-property-
// Each of these mixins support comma separated lists of values, which allows different transitions for individual properties to be described in a single style rule. Each value in the list corresponds to the value at that same position in the other properties.
// Official animation shorthand property.
@mixin animation ($animations...) {
@include prefixer(animation, $animations, webkit moz spec);
}
// Individual Animation Properties
@mixin animation-name ($names...) {
@include prefixer(animation-name, $names, webkit moz spec);
}
@mixin animation-duration ($times...) {
@include prefixer(animation-duration, $times, webkit moz spec);
}
@mixin animation-timing-function ($motions...) {
// ease | linear | ease-in | ease-out | ease-in-out
@include prefixer(animation-timing-function, $motions, webkit moz spec);
}
@mixin animation-iteration-count ($values...) {
// infinite | <number>
@include prefixer(animation-iteration-count, $values, webkit moz spec);
}
@mixin animation-direction ($directions...) {
// normal | alternate
@include prefixer(animation-direction, $directions, webkit moz spec);
}
@mixin animation-play-state ($states...) {
// running | paused
@include prefixer(animation-play-state, $states, webkit moz spec);
}
@mixin animation-delay ($times...) {
@include prefixer(animation-delay, $times, webkit moz spec);
}
@mixin animation-fill-mode ($modes...) {
// none | forwards | backwards | both
@include prefixer(animation-fill-mode, $modes, webkit moz spec);
}

View File

@@ -1,3 +0,0 @@
@mixin appearance ($value) {
@include prefixer(appearance, $value, webkit moz ms o spec);
}

View File

@@ -1,6 +0,0 @@
//************************************************************************//
// Backface-visibility mixin
//************************************************************************//
@mixin backface-visibility($visibility) {
@include prefixer(backface-visibility, $visibility, webkit spec);
}

View File

@@ -1,42 +0,0 @@
//************************************************************************//
// Background-image property for adding multiple background images with
// gradients, or for stringing multiple gradients together.
//************************************************************************//
@mixin background-image($images...) {
$webkit-images: ();
$spec-images: ();
@each $image in $images {
$webkit-image: ();
$spec-image: ();
@if (type-of($image) == string) {
$url-str: str-slice($image, 0, 3);
$gradient-type: str-slice($image, 0, 6);
@if $url-str == "url" {
$webkit-image: $image;
$spec-image: $image;
}
@else if $gradient-type == "linear" {
$gradients: _linear-gradient-parser($image);
$webkit-image: map-get($gradients, webkit-image);
$spec-image: map-get($gradients, spec-image);
}
@else if $gradient-type == "radial" {
$gradients: _radial-gradient-parser($image);
$webkit-image: map-get($gradients, webkit-image);
$spec-image: map-get($gradients, spec-image);
}
}
$webkit-images: append($webkit-images, $webkit-image, comma);
$spec-images: append($spec-images, $spec-image, comma);
}
background-image: $webkit-images;
background-image: $spec-images;
}

View File

@@ -1,55 +0,0 @@
//************************************************************************//
// Background property for adding multiple backgrounds using shorthand
// notation.
//************************************************************************//
@mixin background($backgrounds...) {
$webkit-backgrounds: ();
$spec-backgrounds: ();
@each $background in $backgrounds {
$webkit-background: ();
$spec-background: ();
$background-type: type-of($background);
@if $background-type == string or list {
$background-str: if($background-type == list, nth($background, 1), $background);
$url-str: str-slice($background-str, 0, 3);
$gradient-type: str-slice($background-str, 0, 6);
@if $url-str == "url" {
$webkit-background: $background;
$spec-background: $background;
}
@else if $gradient-type == "linear" {
$gradients: _linear-gradient-parser("#{$background}");
$webkit-background: map-get($gradients, webkit-image);
$spec-background: map-get($gradients, spec-image);
}
@else if $gradient-type == "radial" {
$gradients: _radial-gradient-parser("#{$background}");
$webkit-background: map-get($gradients, webkit-image);
$spec-background: map-get($gradients, spec-image);
}
@else {
$webkit-background: $background;
$spec-background: $background;
}
}
@else {
$webkit-background: $background;
$spec-background: $background;
}
$webkit-backgrounds: append($webkit-backgrounds, $webkit-background, comma);
$spec-backgrounds: append($spec-backgrounds, $spec-background, comma);
}
background: $webkit-backgrounds;
background: $spec-backgrounds;
}

View File

@@ -1,59 +0,0 @@
@mixin border-image($borders...) {
$webkit-borders: ();
$spec-borders: ();
@each $border in $borders {
$webkit-border: ();
$spec-border: ();
$border-type: type-of($border);
@if $border-type == string or list {
$border-str: if($border-type == list, nth($border, 1), $border);
$url-str: str-slice($border-str, 0, 3);
$gradient-type: str-slice($border-str, 0, 6);
@if $url-str == "url" {
$webkit-border: $border;
$spec-border: $border;
}
@else if $gradient-type == "linear" {
$gradients: _linear-gradient-parser("#{$border}");
$webkit-border: map-get($gradients, webkit-image);
$spec-border: map-get($gradients, spec-image);
}
@else if $gradient-type == "radial" {
$gradients: _radial-gradient-parser("#{$border}");
$webkit-border: map-get($gradients, webkit-image);
$spec-border: map-get($gradients, spec-image);
}
@else {
$webkit-border: $border;
$spec-border: $border;
}
}
@else {
$webkit-border: $border;
$spec-border: $border;
}
$webkit-borders: append($webkit-borders, $webkit-border, comma);
$spec-borders: append($spec-borders, $spec-border, comma);
}
-webkit-border-image: $webkit-borders;
border-image: $spec-borders;
border-style: solid;
}
//Examples:
// @include border-image(url("image.png"));
// @include border-image(url("image.png") 20 stretch);
// @include border-image(linear-gradient(45deg, orange, yellow));
// @include border-image(linear-gradient(45deg, orange, yellow) stretch);
// @include border-image(linear-gradient(45deg, orange, yellow) 20 30 40 50 stretch round);
// @include border-image(radial-gradient(top, cover, orange, yellow, orange));

View File

@@ -1,22 +0,0 @@
//************************************************************************//
// Shorthand Border-radius mixins
//************************************************************************//
@mixin border-top-radius($radii) {
@include prefixer(border-top-left-radius, $radii, spec);
@include prefixer(border-top-right-radius, $radii, spec);
}
@mixin border-bottom-radius($radii) {
@include prefixer(border-bottom-left-radius, $radii, spec);
@include prefixer(border-bottom-right-radius, $radii, spec);
}
@mixin border-left-radius($radii) {
@include prefixer(border-top-left-radius, $radii, spec);
@include prefixer(border-bottom-left-radius, $radii, spec);
}
@mixin border-right-radius($radii) {
@include prefixer(border-top-right-radius, $radii, spec);
@include prefixer(border-bottom-right-radius, $radii, spec);
}

View File

@@ -1,4 +0,0 @@
@mixin box-sizing ($box) {
// content-box | border-box | inherit
@include prefixer(box-sizing, $box, webkit moz spec);
}

View File

@@ -1,4 +0,0 @@
@mixin calc($property, $value) {
#{$property}: -webkit-calc(#{$value});
#{$property}: calc(#{$value});
}

View File

@@ -1,47 +0,0 @@
@mixin columns($arg: auto) {
// <column-count> || <column-width>
@include prefixer(columns, $arg, webkit moz spec);
}
@mixin column-count($int: auto) {
// auto || integer
@include prefixer(column-count, $int, webkit moz spec);
}
@mixin column-gap($length: normal) {
// normal || length
@include prefixer(column-gap, $length, webkit moz spec);
}
@mixin column-fill($arg: auto) {
// auto || length
@include prefixer(column-fill, $arg, webkit moz spec);
}
@mixin column-rule($arg) {
// <border-width> || <border-style> || <color>
@include prefixer(column-rule, $arg, webkit moz spec);
}
@mixin column-rule-color($color) {
@include prefixer(column-rule-color, $color, webkit moz spec);
}
@mixin column-rule-style($style: none) {
// none | hidden | dashed | dotted | double | groove | inset | inset | outset | ridge | solid
@include prefixer(column-rule-style, $style, webkit moz spec);
}
@mixin column-rule-width ($width: none) {
@include prefixer(column-rule-width, $width, webkit moz spec);
}
@mixin column-span($arg: none) {
// none || all
@include prefixer(column-span, $arg, webkit moz spec);
}
@mixin column-width($length: auto) {
// auto || length
@include prefixer(column-width, $length, webkit moz spec);
}

View File

@@ -1,5 +0,0 @@
@mixin filter($function: none) {
// <filter-function> [<filter-function]* | none
@include prefixer(filter, $function, webkit spec);
}

View File

@@ -1,321 +0,0 @@
// CSS3 Flexible Box Model and property defaults
// Custom shorthand notation for flexbox
@mixin box($orient: inline-axis, $pack: start, $align: stretch) {
@include display-box;
@include box-orient($orient);
@include box-pack($pack);
@include box-align($align);
}
@mixin display-box {
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox; // IE 10
display: box;
}
@mixin box-orient($orient: inline-axis) {
// horizontal|vertical|inline-axis|block-axis|inherit
@include prefixer(box-orient, $orient, webkit moz spec);
}
@mixin box-pack($pack: start) {
// start|end|center|justify
@include prefixer(box-pack, $pack, webkit moz spec);
-ms-flex-pack: $pack; // IE 10
}
@mixin box-align($align: stretch) {
// start|end|center|baseline|stretch
@include prefixer(box-align, $align, webkit moz spec);
-ms-flex-align: $align; // IE 10
}
@mixin box-direction($direction: normal) {
// normal|reverse|inherit
@include prefixer(box-direction, $direction, webkit moz spec);
-ms-flex-direction: $direction; // IE 10
}
@mixin box-lines($lines: single) {
// single|multiple
@include prefixer(box-lines, $lines, webkit moz spec);
}
@mixin box-ordinal-group($int: 1) {
@include prefixer(box-ordinal-group, $int, webkit moz spec);
-ms-flex-order: $int; // IE 10
}
@mixin box-flex($value: 0.0) {
@include prefixer(box-flex, $value, webkit moz spec);
-ms-flex: $value; // IE 10
}
@mixin box-flex-group($int: 1) {
@include prefixer(box-flex-group, $int, webkit moz spec);
}
// CSS3 Flexible Box Model and property defaults
// Unified attributes for 2009, 2011, and 2012 flavours.
// 2009 - display (box | inline-box)
// 2011 - display (flexbox | inline-flexbox)
// 2012 - display (flex | inline-flex)
@mixin display($value) {
// flex | inline-flex
@if $value == "flex" {
// 2009
display: -webkit-box;
display: -moz-box;
display: box;
// 2012
display: -webkit-flex;
display: -moz-flex;
display: -ms-flexbox; // 2011 (IE 10)
display: flex;
}
@elseif $value == "inline-flex" {
display: -webkit-inline-box;
display: -moz-inline-box;
display: inline-box;
display: -webkit-inline-flex;
display: -moz-inline-flex;
display: -ms-inline-flexbox;
display: inline-flex;
}
@else {
display: $value;
}
}
// 2009 - box-flex (integer)
// 2011 - flex (decimal | width decimal)
// 2012 - flex (integer integer width)
@mixin flex($value) {
// Grab flex-grow for older browsers.
$flex-grow: nth($value, 1);
// 2009
@include prefixer(box-flex, $flex-grow, webkit moz spec);
// 2011 (IE 10), 2012
@include prefixer(flex, $value, webkit moz ms spec);
}
// 2009 - box-orient ( horizontal | vertical | inline-axis | block-axis)
// - box-direction (normal | reverse)
// 2011 - flex-direction (row | row-reverse | column | column-reverse)
// 2012 - flex-direction (row | row-reverse | column | column-reverse)
@mixin flex-direction($value: row) {
// Alt values.
$value-2009: $value;
$value-2011: $value;
$direction: "normal";
@if $value == row {
$value-2009: horizontal;
}
@elseif $value == "row-reverse" {
$value-2009: horizontal;
$direction: reverse;
}
@elseif $value == column {
$value-2009: vertical;
}
@elseif $value == "column-reverse" {
$value-2009: vertical;
$direction: reverse;
}
// 2009
@include prefixer(box-orient, $value-2009, webkit moz spec);
@if $direction == "reverse" {
@include prefixer(box-direction, $direction, webkit moz spec);
}
// 2012
@include prefixer(flex-direction, $value, webkit moz spec);
// 2011 (IE 10)
-ms-flex-direction: $value;
}
// 2009 - box-lines (single | multiple)
// 2011 - flex-wrap (nowrap | wrap | wrap-reverse)
// 2012 - flex-wrap (nowrap | wrap | wrap-reverse)
@mixin flex-wrap($value: nowrap) {
// Alt values.
$alt-value: $value;
@if $value == nowrap {
$alt-value: single;
}
@elseif $value == wrap {
$alt-value: multiple;
}
@elseif $value == "wrap-reverse" {
$alt-value: multiple;
}
@include prefixer(box-lines, $alt-value, webkit moz spec);
@include prefixer(flex-wrap, $value, webkit moz ms spec);
}
// 2009 - TODO: parse values into flex-direction/flex-wrap
// 2011 - TODO: parse values into flex-direction/flex-wrap
// 2012 - flex-flow (flex-direction || flex-wrap)
@mixin flex-flow($value) {
@include prefixer(flex-flow, $value, webkit moz spec);
}
// 2009 - box-ordinal-group (integer)
// 2011 - flex-order (integer)
// 2012 - order (integer)
@mixin order($int: 0) {
// 2009
@include prefixer(box-ordinal-group, $int, webkit moz spec);
// 2012
@include prefixer(order, $int, webkit moz spec);
// 2011 (IE 10)
-ms-flex-order: $int;
}
// 2012 - flex-grow (number)
@mixin flex-grow($number: 0) {
@include prefixer(flex-grow, $number, webkit moz spec);
-ms-flex-positive: $number;
}
// 2012 - flex-shrink (number)
@mixin flex-shrink($number: 1) {
@include prefixer(flex-shrink, $number, webkit moz spec);
-ms-flex-negative: $number;
}
// 2012 - flex-basis (number)
@mixin flex-basis($width: auto) {
@include prefixer(flex-basis, $width, webkit moz spec);
-ms-flex-preferred-size: $width;
}
// 2009 - box-pack (start | end | center | justify)
// 2011 - flex-pack (start | end | center | justify)
// 2012 - justify-content (flex-start | flex-end | center | space-between | space-around)
@mixin justify-content ($value: flex-start) {
// Alt values.
$alt-value: $value;
@if $value == "flex-start" {
$alt-value: start;
}
@elseif $value == "flex-end" {
$alt-value: end;
}
@elseif $value == "space-between" {
$alt-value: justify;
}
@elseif $value == "space-around" {
$alt-value: center;
}
// 2009
@include prefixer(box-pack, $alt-value, webkit moz spec);
// 2012
@include prefixer(justify-content, $value, webkit moz ms o spec);
// 2011 (IE 10)
-ms-flex-pack: $alt-value;
}
// 2009 - box-align (start | end | center | baseline | stretch)
// 2011 - flex-align (start | end | center | baseline | stretch)
// 2012 - align-items (flex-start | flex-end | center | baseline | stretch)
@mixin align-items($value: stretch) {
$alt-value: $value;
@if $value == "flex-start" {
$alt-value: start;
}
@elseif $value == "flex-end" {
$alt-value: end;
}
// 2009
@include prefixer(box-align, $alt-value, webkit moz spec);
// 2012
@include prefixer(align-items, $value, webkit moz ms o spec);
// 2011 (IE 10)
-ms-flex-align: $alt-value;
}
// 2011 - flex-item-align (auto | start | end | center | baseline | stretch)
// 2012 - align-self (auto | flex-start | flex-end | center | baseline | stretch)
@mixin align-self($value: auto) {
$value-2011: $value;
@if $value == "flex-start" {
$value-2011: start;
}
@elseif $value == "flex-end" {
$value-2011: end;
}
// 2012
@include prefixer(align-self, $value, webkit moz spec);
// 2011 (IE 10)
-ms-flex-item-align: $value-2011;
}
// 2011 - flex-line-pack (start | end | center | justify | distribute | stretch)
// 2012 - align-content (flex-start | flex-end | center | space-between | space-around | stretch)
@mixin align-content($value: stretch) {
$value-2011: $value;
@if $value == "flex-start" {
$value-2011: start;
}
@elseif $value == "flex-end" {
$value-2011: end;
}
@elseif $value == "space-between" {
$value-2011: justify;
}
@elseif $value == "space-around" {
$value-2011: distribute;
}
// 2012
@include prefixer(align-content, $value, webkit moz spec);
// 2011 (IE 10)
-ms-flex-line-pack: $value-2011;
}

View File

@@ -1,23 +0,0 @@
// Order of the includes matters, and it is: normal, bold, italic, bold+italic.
@mixin font-face($font-family, $file-path, $weight: normal, $style: normal, $asset-pipeline: $asset-pipeline) {
@font-face {
font-family: $font-family;
font-weight: $weight;
font-style: $style;
@if $asset-pipeline == true {
src: font-url('#{$file-path}.eot');
src: font-url('#{$file-path}.eot?#iefix') format('embedded-opentype'),
font-url('#{$file-path}.woff') format('woff'),
font-url('#{$file-path}.ttf') format('truetype'),
font-url('#{$file-path}.svg##{$font-family}') format('svg');
} @else {
src: url('#{$file-path}.eot');
src: url('#{$file-path}.eot?#iefix') format('embedded-opentype'),
url('#{$file-path}.woff') format('woff'),
url('#{$file-path}.ttf') format('truetype'),
url('#{$file-path}.svg##{$font-family}') format('svg');
}
}
}

View File

@@ -1,10 +0,0 @@
// Font feature settings mixin and property default.
// Examples: @include font-feature-settings("liga");
// @include font-feature-settings("lnum" false);
// @include font-feature-settings("pnum" 1, "kern" 0);
// @include font-feature-settings("ss01", "ss02");
@mixin font-feature-settings($settings...) {
@if length($settings) == 0 { $settings: none; }
@include prefixer(font-feature-settings, $settings, webkit moz ms spec);
}

View File

@@ -1,10 +0,0 @@
// HiDPI mixin. Default value set to 1.3 to target Google Nexus 7 (http://bjango.com/articles/min-device-pixel-ratio/)
@mixin hidpi($ratio: 1.3) {
@media only screen and (-webkit-min-device-pixel-ratio: $ratio),
only screen and (min--moz-device-pixel-ratio: $ratio),
only screen and (-o-min-device-pixel-ratio: #{$ratio}/1),
only screen and (min-resolution: #{round($ratio*96)}dpi),
only screen and (min-resolution: #{$ratio}dppx) {
@content;
}
}

View File

@@ -1,4 +0,0 @@
@mixin hyphens($hyphenation: none) {
// none | manual | auto
@include prefixer(hyphens, $hyphenation, webkit moz ms spec);
}

View File

@@ -1,14 +0,0 @@
@mixin image-rendering ($mode:auto) {
@if ($mode == crisp-edges) {
-ms-interpolation-mode: nearest-neighbor; // IE8+
image-rendering: -moz-crisp-edges;
image-rendering: -o-crisp-edges;
image-rendering: -webkit-optimize-contrast;
image-rendering: crisp-edges;
}
@else {
image-rendering: $mode;
}
}

View File

@@ -1,35 +0,0 @@
// Adds keyframes blocks for supported prefixes, removing redundant prefixes in the block's content
@mixin keyframes($name) {
$original-prefix-for-webkit: $prefix-for-webkit;
$original-prefix-for-mozilla: $prefix-for-mozilla;
$original-prefix-for-microsoft: $prefix-for-microsoft;
$original-prefix-for-opera: $prefix-for-opera;
$original-prefix-for-spec: $prefix-for-spec;
@if $original-prefix-for-webkit {
@include disable-prefix-for-all();
$prefix-for-webkit: true !global;
@-webkit-keyframes #{$name} {
@content;
}
}
@if $original-prefix-for-mozilla {
@include disable-prefix-for-all();
$prefix-for-mozilla: true !global;
@-moz-keyframes #{$name} {
@content;
}
}
$prefix-for-webkit: $original-prefix-for-webkit !global;
$prefix-for-mozilla: $original-prefix-for-mozilla !global;
$prefix-for-microsoft: $original-prefix-for-microsoft !global;
$prefix-for-opera: $original-prefix-for-opera !global;
$prefix-for-spec: $original-prefix-for-spec !global;
@if $original-prefix-for-spec {
@keyframes #{$name} {
@content;
}
}
}

View File

@@ -1,38 +0,0 @@
@mixin linear-gradient($pos, $G1, $G2: null,
$G3: null, $G4: null,
$G5: null, $G6: null,
$G7: null, $G8: null,
$G9: null, $G10: null,
$fallback: null) {
// Detect what type of value exists in $pos
$pos-type: type-of(nth($pos, 1));
$pos-spec: null;
$pos-degree: null;
// If $pos is missing from mixin, reassign vars and add default position
@if ($pos-type == color) or (nth($pos, 1) == "transparent") {
$G10: $G9; $G9: $G8; $G8: $G7; $G7: $G6; $G6: $G5;
$G5: $G4; $G4: $G3; $G3: $G2; $G2: $G1; $G1: $pos;
$pos: null;
}
@if $pos {
$positions: _linear-positions-parser($pos);
$pos-degree: nth($positions, 1);
$pos-spec: nth($positions, 2);
}
$full: $G1, $G2, $G3, $G4, $G5, $G6, $G7, $G8, $G9, $G10;
// Set $G1 as the default fallback color
$fallback-color: nth($G1, 1);
// If $fallback is a color use that color as the fallback color
@if (type-of($fallback) == color) or ($fallback == "transparent") {
$fallback-color: $fallback;
}
background-color: $fallback-color;
background-image: -webkit-linear-gradient($pos-degree $full); // Safari 5.1+, Chrome
background-image: unquote("linear-gradient(#{$pos-spec}#{$full})");
}

View File

@@ -1,8 +0,0 @@
@mixin perspective($depth: none) {
// none | <length>
@include prefixer(perspective, $depth, webkit moz spec);
}
@mixin perspective-origin($value: 50% 50%) {
@include prefixer(perspective-origin, $value, webkit moz spec);
}

View File

@@ -1,8 +0,0 @@
@mixin placeholder {
$placeholders: ":-webkit-input" ":-moz" "-moz" "-ms-input";
@each $placeholder in $placeholders {
&:#{$placeholder}-placeholder {
@content;
}
}
}

View File

@@ -1,39 +0,0 @@
// Requires Sass 3.1+
@mixin radial-gradient($G1, $G2,
$G3: null, $G4: null,
$G5: null, $G6: null,
$G7: null, $G8: null,
$G9: null, $G10: null,
$pos: null,
$shape-size: null,
$fallback: null) {
$data: _radial-arg-parser($G1, $G2, $pos, $shape-size);
$G1: nth($data, 1);
$G2: nth($data, 2);
$pos: nth($data, 3);
$shape-size: nth($data, 4);
$full: $G1, $G2, $G3, $G4, $G5, $G6, $G7, $G8, $G9, $G10;
// Strip deprecated cover/contain for spec
$shape-size-spec: _shape-size-stripper($shape-size);
// Set $G1 as the default fallback color
$first-color: nth($full, 1);
$fallback-color: nth($first-color, 1);
@if (type-of($fallback) == color) or ($fallback == "transparent") {
$fallback-color: $fallback;
}
// Add Commas and spaces
$shape-size: if($shape-size, '#{$shape-size}, ', null);
$pos: if($pos, '#{$pos}, ', null);
$pos-spec: if($pos, 'at #{$pos}', null);
$shape-size-spec: if(($shape-size-spec != ' ') and ($pos == null), '#{$shape-size-spec}, ', '#{$shape-size-spec} ');
background-color: $fallback-color;
background-image: -webkit-radial-gradient(unquote(#{$pos}#{$shape-size}#{$full}));
background-image: unquote("radial-gradient(#{$shape-size-spec}#{$pos-spec}#{$full})");
}

View File

@@ -1,15 +0,0 @@
@mixin transform($property: none) {
// none | <transform-function>
@include prefixer(transform, $property, webkit moz ms o spec);
}
@mixin transform-origin($axes: 50%) {
// x-axis - left | center | right | length | %
// y-axis - top | center | bottom | length | %
// z-axis - length
@include prefixer(transform-origin, $axes, webkit moz ms o spec);
}
@mixin transform-style ($style: flat) {
@include prefixer(transform-style, $style, webkit moz ms o spec);
}

View File

@@ -1,77 +0,0 @@
// Shorthand mixin. Supports multiple parentheses-deliminated values for each variable.
// Example: @include transition (all 2s ease-in-out);
// @include transition (opacity 1s ease-in 2s, width 2s ease-out);
// @include transition-property (transform, opacity);
@mixin transition ($properties...) {
// Fix for vendor-prefix transform property
$needs-prefixes: false;
$webkit: ();
$moz: ();
$spec: ();
// Create lists for vendor-prefixed transform
@each $list in $properties {
@if nth($list, 1) == "transform" {
$needs-prefixes: true;
$list1: -webkit-transform;
$list2: -moz-transform;
$list3: ();
@each $var in $list {
$list3: join($list3, $var);
@if $var != "transform" {
$list1: join($list1, $var);
$list2: join($list2, $var);
}
}
$webkit: append($webkit, $list1);
$moz: append($moz, $list2);
$spec: append($spec, $list3);
}
// Create lists for non-prefixed transition properties
@else {
$webkit: append($webkit, $list, comma);
$moz: append($moz, $list, comma);
$spec: append($spec, $list, comma);
}
}
@if $needs-prefixes {
-webkit-transition: $webkit;
-moz-transition: $moz;
transition: $spec;
}
@else {
@if length($properties) >= 1 {
@include prefixer(transition, $properties, webkit moz spec);
}
@else {
$properties: all 0.15s ease-out 0s;
@include prefixer(transition, $properties, webkit moz spec);
}
}
}
@mixin transition-property ($properties...) {
-webkit-transition-property: transition-property-names($properties, 'webkit');
-moz-transition-property: transition-property-names($properties, 'moz');
transition-property: transition-property-names($properties, false);
}
@mixin transition-duration ($times...) {
@include prefixer(transition-duration, $times, webkit moz spec);
}
@mixin transition-timing-function ($motions...) {
// ease | linear | ease-in | ease-out | ease-in-out | cubic-bezier()
@include prefixer(transition-timing-function, $motions, webkit moz spec);
}
@mixin transition-delay ($times...) {
@include prefixer(transition-delay, $times, webkit moz spec);
}

View File

@@ -1,3 +0,0 @@
@mixin user-select($arg: none) {
@include prefixer(user-select, $arg, webkit moz ms spec);
}

View File

@@ -1,11 +0,0 @@
@function assign-inputs($inputs, $pseudo: null) {
$list : ();
@each $input in $inputs {
$input: unquote($input);
$input: if($pseudo, $input + ":" + $pseudo, $input);
$list: append($list, $input, comma);
}
@return $list;
}

View File

@@ -1,13 +0,0 @@
// Programatically determines whether a color is light or dark
// Returns a boolean
// More details here http://robots.thoughtbot.com/closer-look-color-lightness
@function is-light($hex-color) {
$-local-red: red(rgba($hex-color, 1.0));
$-local-green: green(rgba($hex-color, 1.0));
$-local-blue: blue(rgba($hex-color, 1.0));
$-local-lightness: ($-local-red * 0.2126 + $-local-green * 0.7152 + $-local-blue * 0.0722) / 255;
@return $-local-lightness > .6;
}

View File

@@ -1,39 +0,0 @@
// Flexible grid
@function flex-grid($columns, $container-columns: $fg-max-columns) {
$width: $columns * $fg-column + ($columns - 1) * $fg-gutter;
$container-width: $container-columns * $fg-column + ($container-columns - 1) * $fg-gutter;
@return percentage($width / $container-width);
}
// Flexible gutter
@function flex-gutter($container-columns: $fg-max-columns, $gutter: $fg-gutter) {
$container-width: $container-columns * $fg-column + ($container-columns - 1) * $fg-gutter;
@return percentage($gutter / $container-width);
}
// The $fg-column, $fg-gutter and $fg-max-columns variables must be defined in your base stylesheet to properly use the flex-grid function.
// This function takes the fluid grid equation (target / context = result) and uses columns to help define each.
//
// The calculation presumes that your column structure will be missing the last gutter:
//
// -- column -- gutter -- column -- gutter -- column
//
// $fg-column: 60px; // Column Width
// $fg-gutter: 25px; // Gutter Width
// $fg-max-columns: 12; // Total Columns For Main Container
//
// div {
// width: flex-grid(4); // returns (315px / 995px) = 31.65829%;
// margin-left: flex-gutter(); // returns (25px / 995px) = 2.51256%;
//
// p {
// width: flex-grid(2, 4); // returns (145px / 315px) = 46.031746%;
// float: left;
// margin: flex-gutter(4); // returns (25px / 315px) = 7.936508%;
// }
//
// blockquote {
// float: left;
// width: flex-grid(2, 4); // returns (145px / 315px) = 46.031746%;
// }
// }

View File

@@ -1,3 +0,0 @@
@function golden-ratio($value, $increment) {
@return modular-scale($value, $increment, $golden)
}

View File

@@ -1,13 +0,0 @@
@function grid-width($n) {
@return $n * $gw-column + ($n - 1) * $gw-gutter;
}
// The $gw-column and $gw-gutter variables must be defined in your base stylesheet to properly use the grid-width function.
//
// $gw-column: 100px; // Column Width
// $gw-gutter: 40px; // Gutter Width
//
// div {
// width: grid-width(4); // returns 520px;
// margin-left: $gw-gutter; // returns 40px;
// }

View File

@@ -1,66 +0,0 @@
// Scaling Variables
$golden: 1.618;
$minor-second: 1.067;
$major-second: 1.125;
$minor-third: 1.2;
$major-third: 1.25;
$perfect-fourth: 1.333;
$augmented-fourth: 1.414;
$perfect-fifth: 1.5;
$minor-sixth: 1.6;
$major-sixth: 1.667;
$minor-seventh: 1.778;
$major-seventh: 1.875;
$octave: 2;
$major-tenth: 2.5;
$major-eleventh: 2.667;
$major-twelfth: 3;
$double-octave: 4;
@function modular-scale($value, $increment, $ratio) {
$v1: nth($value, 1);
$v2: nth($value, length($value));
$value: $v1;
// scale $v2 to just above $v1
@while $v2 > $v1 {
$v2: ($v2 / $ratio); // will be off-by-1
}
@while $v2 < $v1 {
$v2: ($v2 * $ratio); // will fix off-by-1
}
// check AFTER scaling $v2 to prevent double-counting corner-case
$double-stranded: $v2 > $v1;
@if $increment > 0 {
@for $i from 1 through $increment {
@if $double-stranded and ($v1 * $ratio) > $v2 {
$value: $v2;
$v2: ($v2 * $ratio);
} @else {
$v1: ($v1 * $ratio);
$value: $v1;
}
}
}
@if $increment < 0 {
// adjust $v2 to just below $v1
@if $double-stranded {
$v2: ($v2 / $ratio);
}
@for $i from $increment through -1 {
@if $double-stranded and ($v1 / $ratio) < $v2 {
$value: $v2;
$v2: ($v2 / $ratio);
} @else {
$v1: ($v1 / $ratio);
$value: $v1;
}
}
}
@return $value;
}

View File

@@ -1,13 +0,0 @@
// Convert pixels to ems
// eg. for a relational value of 12px write em(12) when the parent is 16px
// if the parent is another value say 24px write em(12, 24)
@function em($pxval, $base: $em-base) {
@if not unitless($pxval) {
$pxval: strip-units($pxval);
}
@if not unitless($base) {
$base: strip-units($base);
}
@return ($pxval / $base) * 1em;
}

View File

@@ -1,15 +0,0 @@
// Convert pixels to rems
// eg. for a relational value of 12px write rem(12)
// Assumes $em-base is the font-size of <html>
@function rem($pxval) {
@if not unitless($pxval) {
$pxval: strip-units($pxval);
}
$base: $em-base;
@if not unitless($base) {
$base: strip-units($base);
}
@return ($pxval / $base) * 1rem;
}

View File

@@ -1,5 +0,0 @@
// Srtips the units from a value. e.g. 12px -> 12
@function strip-units($val) {
@return ($val / ($val * 0 + 1));
}

View File

@@ -1,9 +0,0 @@
// Add percentage of white to a color
@function tint($color, $percent){
@return mix(white, $color, $percent);
}
// Add percentage of black to a color
@function shade($color, $percent){
@return mix(black, $color, $percent);
}

View File

@@ -1,22 +0,0 @@
// Return vendor-prefixed property names if appropriate
// Example: transition-property-names((transform, color, background), moz) -> -moz-transform, color, background
//************************************************************************//
@function transition-property-names($props, $vendor: false) {
$new-props: ();
@each $prop in $props {
$new-props: append($new-props, transition-property-name($prop, $vendor), comma);
}
@return $new-props;
}
@function transition-property-name($prop, $vendor: false) {
// put other properties that need to be prefixed here aswell
@if $vendor and $prop == transform {
@return unquote('-'+$vendor+'-'+$prop);
}
@else {
@return $prop;
}
}

View File

@@ -1,17 +0,0 @@
// Convert shorthand to the 4-value syntax
@function unpack($shorthand) {
@if length($shorthand) == 1 {
@return nth($shorthand, 1) nth($shorthand, 1) nth($shorthand, 1) nth($shorthand, 1);
}
@else if length($shorthand) == 2 {
@return nth($shorthand, 1) nth($shorthand, 2) nth($shorthand, 1) nth($shorthand, 2);
}
@else if length($shorthand) == 3 {
@return nth($shorthand, 1) nth($shorthand, 2) nth($shorthand, 3) nth($shorthand, 2);
}
@else {
@return $shorthand;
}
}

View File

@@ -1,15 +0,0 @@
//************************************************************************//
// Helper function for str-to-num fn.
// Source: http://sassmeister.com/gist/9647408
//************************************************************************//
@function _convert-units($number, $unit) {
$strings: 'px' 'cm' 'mm' '%' 'ch' 'pica' 'in' 'em' 'rem' 'pt' 'pc' 'ex' 'vw' 'vh' 'vmin' 'vmax', 'deg', 'rad', 'grad', 'turn';
$units: 1px 1cm 1mm 1% 1ch 1pica 1in 1em 1rem 1pt 1pc 1ex 1vw 1vh 1vmin 1vmax, 1deg, 1rad, 1grad, 1turn;
$index: index($strings, $unit);
@if not $index {
@warn "Unknown unit `#{$unit}`.";
@return false;
}
@return $number * nth($units, $index);
}

View File

@@ -1,13 +0,0 @@
@function _gradient-positions-parser($gradient-type, $gradient-positions) {
@if $gradient-positions
and ($gradient-type == linear)
and (type-of($gradient-positions) != color) {
$gradient-positions: _linear-positions-parser($gradient-positions);
}
@else if $gradient-positions
and ($gradient-type == radial)
and (type-of($gradient-positions) != color) {
$gradient-positions: _radial-positions-parser($gradient-positions);
}
@return $gradient-positions;
}

View File

@@ -1,8 +0,0 @@
//************************************************************************//
// Helper for linear-gradient-parser
//************************************************************************//
@function _is-num($char) {
$values: '0' '1' '2' '3' '4' '5' '6' '7' '8' '9' 0 1 2 3 4 5 6 7 8 9;
$index: index($values, $char);
@return if($index, true, false);
}

View File

@@ -1,25 +0,0 @@
// Private function for linear-gradient-parser
@function _linear-angle-parser($image, $first-val, $prefix, $suffix) {
$offset: null;
$unit-short: str-slice($first-val, str-length($first-val) - 2, str-length($first-val));
$unit-long: str-slice($first-val, str-length($first-val) - 3, str-length($first-val));
@if ($unit-long == "grad") or
($unit-long == "turn") {
$offset: if($unit-long == "grad", -100grad * 3, -0.75turn);
}
@else if ($unit-short == "deg") or
($unit-short == "rad") {
$offset: if($unit-short == "deg", -90 * 3, 1.6rad);
}
@if $offset {
$num: _str-to-num($first-val);
@return (
webkit-image: -webkit- + $prefix + ($offset - $num) + $suffix,
spec-image: $image
);
}
}

View File

@@ -1,41 +0,0 @@
@function _linear-gradient-parser($image) {
$image: unquote($image);
$gradients: ();
$start: str-index($image, "(");
$end: str-index($image, ",");
$first-val: str-slice($image, $start + 1, $end - 1);
$prefix: str-slice($image, 0, $start);
$suffix: str-slice($image, $end, str-length($image));
$has-multiple-vals: str-index($first-val, " ");
$has-single-position: unquote(_position-flipper($first-val) + "");
$has-angle: _is-num(str-slice($first-val, 0, 0));
@if $has-multiple-vals {
$gradients: _linear-side-corner-parser($image, $first-val, $prefix, $suffix, $has-multiple-vals);
}
@else if $has-single-position != "" {
$pos: unquote($has-single-position + "");
$gradients: (
webkit-image: -webkit- + $image,
spec-image: $prefix + "to " + $pos + $suffix
);
}
@else if $has-angle {
// Rotate degree for webkit
$gradients: _linear-angle-parser($image, $first-val, $prefix, $suffix);
}
@else {
$gradients: (
webkit-image: -webkit- + $image,
spec-image: $image
);
}
@return $gradients;
}

View File

@@ -1,61 +0,0 @@
@function _linear-positions-parser($pos) {
$type: type-of(nth($pos, 1));
$spec: null;
$degree: null;
$side: null;
$corner: null;
$length: length($pos);
// Parse Side and corner positions
@if ($length > 1) {
@if nth($pos, 1) == "to" { // Newer syntax
$side: nth($pos, 2);
@if $length == 2 { // eg. to top
// Swap for backwards compatability
$degree: _position-flipper(nth($pos, 2));
}
@else if $length == 3 { // eg. to top left
$corner: nth($pos, 3);
}
}
@else if $length == 2 { // Older syntax ("top left")
$side: _position-flipper(nth($pos, 1));
$corner: _position-flipper(nth($pos, 2));
}
@if ("#{$side} #{$corner}" == "left top") or ("#{$side} #{$corner}" == "top left") {
$degree: _position-flipper(#{$side}) _position-flipper(#{$corner});
}
@else if ("#{$side} #{$corner}" == "right top") or ("#{$side} #{$corner}" == "top right") {
$degree: _position-flipper(#{$side}) _position-flipper(#{$corner});
}
@else if ("#{$side} #{$corner}" == "right bottom") or ("#{$side} #{$corner}" == "bottom right") {
$degree: _position-flipper(#{$side}) _position-flipper(#{$corner});
}
@else if ("#{$side} #{$corner}" == "left bottom") or ("#{$side} #{$corner}" == "bottom left") {
$degree: _position-flipper(#{$side}) _position-flipper(#{$corner});
}
$spec: to $side $corner;
}
@else if $length == 1 {
// Swap for backwards compatability
@if $type == string {
$degree: $pos;
$spec: to _position-flipper($pos);
}
@else {
$degree: -270 - $pos; //rotate the gradient opposite from spec
$spec: $pos;
}
}
$degree: unquote($degree + ",");
$spec: unquote($spec + ",");
@return $degree $spec;
}
@function _position-flipper($pos) {
@return if($pos == left, right, null)
if($pos == right, left, null)
if($pos == top, bottom, null)
if($pos == bottom, top, null);
}

View File

@@ -1,31 +0,0 @@
// Private function for linear-gradient-parser
@function _linear-side-corner-parser($image, $first-val, $prefix, $suffix, $has-multiple-vals) {
$val-1: str-slice($first-val, 0, $has-multiple-vals - 1 );
$val-2: str-slice($first-val, $has-multiple-vals + 1, str-length($first-val));
$val-3: null;
$has-val-3: str-index($val-2, " ");
@if $has-val-3 {
$val-3: str-slice($val-2, $has-val-3 + 1, str-length($val-2));
$val-2: str-slice($val-2, 0, $has-val-3 - 1);
}
$pos: _position-flipper($val-1) _position-flipper($val-2) _position-flipper($val-3);
$pos: unquote($pos + "");
// Use old spec for webkit
@if $val-1 == "to" {
@return (
webkit-image: -webkit- + $prefix + $pos + $suffix,
spec-image: $image
);
}
// Bring the code up to spec
@else {
@return (
webkit-image: -webkit- + $image,
spec-image: $prefix + "to " + $pos + $suffix
);
}
}

View File

@@ -1,69 +0,0 @@
@function _radial-arg-parser($G1, $G2, $pos, $shape-size) {
@each $value in $G1, $G2 {
$first-val: nth($value, 1);
$pos-type: type-of($first-val);
$spec-at-index: null;
// Determine if spec was passed to mixin
@if type-of($value) == list {
$spec-at-index: if(index($value, at), index($value, at), false);
}
@if $spec-at-index {
@if $spec-at-index > 1 {
@for $i from 1 through ($spec-at-index - 1) {
$shape-size: $shape-size nth($value, $i);
}
@for $i from ($spec-at-index + 1) through length($value) {
$pos: $pos nth($value, $i);
}
}
@else if $spec-at-index == 1 {
@for $i from ($spec-at-index + 1) through length($value) {
$pos: $pos nth($value, $i);
}
}
$G1: null;
}
// If not spec calculate correct values
@else {
@if ($pos-type != color) or ($first-val != "transparent") {
@if ($pos-type == number)
or ($first-val == "center")
or ($first-val == "top")
or ($first-val == "right")
or ($first-val == "bottom")
or ($first-val == "left") {
$pos: $value;
@if $pos == $G1 {
$G1: null;
}
}
@else if
($first-val == "ellipse")
or ($first-val == "circle")
or ($first-val == "closest-side")
or ($first-val == "closest-corner")
or ($first-val == "farthest-side")
or ($first-val == "farthest-corner")
or ($first-val == "contain")
or ($first-val == "cover") {
$shape-size: $value;
@if $value == $G1 {
$G1: null;
}
@else if $value == $G2 {
$G2: null;
}
}
}
}
}
@return $G1, $G2, $pos, $shape-size;
}

View File

@@ -1,50 +0,0 @@
@function _radial-gradient-parser($image) {
$image: unquote($image);
$gradients: ();
$start: str-index($image, "(");
$end: str-index($image, ",");
$first-val: str-slice($image, $start + 1, $end - 1);
$prefix: str-slice($image, 0, $start);
$suffix: str-slice($image, $end, str-length($image));
$is-spec-syntax: str-index($first-val, "at");
@if $is-spec-syntax and $is-spec-syntax > 1 {
$keyword: str-slice($first-val, 1, $is-spec-syntax - 2);
$pos: str-slice($first-val, $is-spec-syntax + 3, str-length($first-val));
$pos: append($pos, $keyword, comma);
$gradients: (
webkit-image: -webkit- + $prefix + $pos + $suffix,
spec-image: $image
)
}
@else if $is-spec-syntax == 1 {
$pos: str-slice($first-val, $is-spec-syntax + 3, str-length($first-val));
$gradients: (
webkit-image: -webkit- + $prefix + $pos + $suffix,
spec-image: $image
)
}
@else if str-index($image, "cover") or str-index($image, "contain") {
@warn "Radial-gradient needs to be updated to conform to latest spec.";
$gradients: (
webkit-image: null,
spec-image: $image
)
}
@else {
$gradients: (
webkit-image: -webkit- + $image,
spec-image: $image
)
}
@return $gradients;
}

View File

@@ -1,18 +0,0 @@
@function _radial-positions-parser($gradient-pos) {
$shape-size: nth($gradient-pos, 1);
$pos: nth($gradient-pos, 2);
$shape-size-spec: _shape-size-stripper($shape-size);
$pre-spec: unquote(if($pos, "#{$pos}, ", null))
unquote(if($shape-size, "#{$shape-size},", null));
$pos-spec: if($pos, "at #{$pos}", null);
$spec: "#{$shape-size-spec} #{$pos-spec}";
// Add comma
@if ($spec != ' ') {
$spec: "#{$spec},"
}
@return $pre-spec $spec;
}

View File

@@ -1,26 +0,0 @@
// User for linear and radial gradients within background-image or border-image properties
@function _render-gradients($gradient-positions, $gradients, $gradient-type, $vendor: false) {
$pre-spec: null;
$spec: null;
$vendor-gradients: null;
@if $gradient-type == linear {
@if $gradient-positions {
$pre-spec: nth($gradient-positions, 1);
$spec: nth($gradient-positions, 2);
}
}
@else if $gradient-type == radial {
$pre-spec: nth($gradient-positions, 1);
$spec: nth($gradient-positions, 2);
}
@if $vendor {
$vendor-gradients: -#{$vendor}-#{$gradient-type}-gradient(#{$pre-spec} $gradients);
}
@else if $vendor == false {
$vendor-gradients: "#{$gradient-type}-gradient(#{$spec} #{$gradients})";
$vendor-gradients: unquote($vendor-gradients);
}
@return $vendor-gradients;
}

View File

@@ -1,10 +0,0 @@
@function _shape-size-stripper($shape-size) {
$shape-size-spec: null;
@each $value in $shape-size {
@if ($value == "cover") or ($value == "contain") {
$value: null;
}
$shape-size-spec: "#{$shape-size-spec} #{$value}";
}
@return $shape-size-spec;
}

View File

@@ -1,50 +0,0 @@
//************************************************************************//
// Helper function for linear/radial-gradient-parsers.
// Source: http://sassmeister.com/gist/9647408
//************************************************************************//
@function _str-to-num($string) {
// Matrices
$strings: '0' '1' '2' '3' '4' '5' '6' '7' '8' '9';
$numbers: 0 1 2 3 4 5 6 7 8 9;
// Result
$result: 0;
$divider: 0;
$minus: false;
// Looping through all characters
@for $i from 1 through str-length($string) {
$character: str-slice($string, $i, $i);
$index: index($strings, $character);
@if $character == '-' {
$minus: true;
}
@else if $character == '.' {
$divider: 1;
}
@else {
@if not $index {
$result: if($minus, $result * -1, $result);
@return _convert-units($result, str-slice($string, $i));
}
$number: nth($numbers, $index);
@if $divider == 0 {
$result: $result * 10;
}
@else {
// Move the decimal dot to the left
$divider: $divider * 10;
$number: $number / $divider;
}
$result: $result + $number;
}
}
@return if($minus, $result * -1, $result);
}

Some files were not shown because too many files have changed in this diff Show More