Compare commits

...

6883 Commits
v15.2.1 ... leg

Author SHA1 Message Date
Dan Abramov
8e99618afa Rm bad tests 2020-07-01 15:59:26 +01:00
Dan Abramov
d0e6cbc3b0 Run ReactBrowserEventEmitter test on bundles 2020-07-01 15:52:06 +01:00
Dan Abramov
f918b0eb41 Fix development mode hang when iframe is removed (#19220)
* Fix development mode hang when iframe is removed

* Also fix #16734
2020-07-01 15:33:29 +01:00
Dan Abramov
8bff8987e5 Don't bailout after Suspending in Legacy Mode (#19216)
* Add a failing test for legacy Suspense blocking context updates in memo

* Add more test case coverage for variations of #17356

* Don't bailout after Suspending in Legacy Mode

Co-authored-by: Tharuka Devendra <tsdevendra1@gmail.com>
2020-06-30 22:06:46 +01:00
Shailendra Gupta
f4097c1aef Added warning to <Context.Provider> in case no value prop is provided (#19054)
* added warning to context.provider in case no value prop

* update message

* updated message and pass undefined
2020-06-30 19:50:55 +01:00
Dan Abramov
47ff31a77a Revert "Add regression test for #18497 (#18538)" (#19215)
This reverts commit e9c1445ba0.
2020-06-30 13:38:31 +01:00
Vetrivel Chinnasamy
b621dab5d4 make link https (#19147) 2020-06-30 12:43:52 +01:00
jddxf
fa32cf299f Add regression tests where sync render causes later concurrent render to expire soon (#18608)
* Add a failing test for #17911

* Add more test cases where sync render causes later concurrent render to expire soon
2020-06-30 12:42:59 +01:00
Dan Abramov
1887c5d946 eslint-plugin-react-hooks@4.0.5 2020-06-30 12:16:49 +01:00
Fred Vollmer
b0533fe33c fix(eslint-plugin-react-hooks): Support optional chaining when accessing prototype method inside useCallback and useMemo #19061 (#19062)
* fix(eslint-plugin-react-hooks): Support optional chaining when accessing prototype method #19061

* run prettier

* Add fix for #19043
2020-06-30 12:14:00 +01:00
Sophie Alpert
e9c1445ba0 Add regression test for #18497 (#18538) 2020-06-30 12:09:05 +01:00
Brian Vaughn
9d9cf383c9 Fixed test script handling of unknown/additional args (#19209) 2020-06-29 15:36:45 -04:00
Dominic Gannaway
3c1a7ac87c Move TOP_BEFORE_BLUR to bubble phase (#19197) 2020-06-26 20:35:21 +01:00
Ricky
72bbcad160 Add new test cli (#19184)
* Add new test cli

* Remove --variant accidentally added to test-persist

* s/test/tests

* Updates from review

* Update package.json tests

* Missed a release channel in circle.yaml

* Update config.yml to use just run: with test commands

* Update release-channel options and add build dir checks

* Update test args to use the new release-channel options

* Fix error in circle config.yml

* Fix a wrong condition for the --variant check

* Fix a wrong condition for the --persistent check

* Prettier

* Require build check for devtool tests as well
2020-06-25 20:39:50 -04:00
Christoph Nakazawa
7d0e4150aa Fix react-runtime main field (#19193)
The "main" field in this package points to a non-existent file. This fixes it.
2020-06-25 12:17:42 -04:00
finico
ed94600fc6 Remove unnecessary tag end from CommitRanked view (#19195) 2020-06-25 12:10:47 -04:00
Chen Gang
ffe516f3bf use NoTimestamp instead of -1 (#19182) 2020-06-23 16:28:24 -04:00
Brian Vaughn
1425fcbb86 Re-enabled DebugTracing feature for old reconciler fork (#19161)
* Re-enabled DebugTracing feature for old reconciler fork

It was temporarily removed by @sebmarkbage via PR #18697. Newly re-added tracing is simplified, since the lane(s) data type does not require the (lossy) conversion between priority and expiration time values.

@sebmarkbage mentioned that he removed this because it might get in the way of his planned discrete/sync refactor. I'm not sure if that concern still applies, but just in case- I have only re-added it to the old reconciler fork for now.

* Force Code Sandbox CI to re-run
2020-06-23 12:16:23 -04:00
Brian Vaughn
0836f62a5b Updates the DevTools test script to make it easier to test other URLs. (#19179) 2020-06-23 11:48:35 -04:00
Brian Vaughn
1cfd332fd7 Shutdown DevTools Bridge synchronously when unmounting (#19180) 2020-06-23 11:48:04 -04:00
Jack Works
5b98656909 fix: use define property to overwrite console, close #19099 (#19123)
* fix: use define property to overwrite console, close #19099

* fix: lint error
2020-06-23 10:34:53 -04:00
Andrew Clark
6ba25b96df Bugfix: Legacy Mode + DevTools "force fallback" (#19164)
DevTools has a feature to force a Suspense boundary to show a fallback.
This feature causes us to skip the first render pass (where we render
the primary children) and go straight to rendering the fallback.

There's a Legacy Mode-only codepath that failed to take this scenario
into account, instead assuming that whenever a fallback is being
rendered, it was preceded by an attempt to render the primary children.

SuspenseList can also cause us to skip the first pass, but the relevant
branch is Legacy Mode-only, and SuspenseList is not supported in
Legacy Mode.

Fixes a test that I had temporarily disabled when upstreaming the Lanes
implementation in #19108.
2020-06-19 11:06:42 -07:00
Luna Ruan
d1d9054e09 Revert "Re-enabled DebugTracing feature for old reconciler fork (#19142)" (#19159)
This reverts commit cc7c1aece4.
2020-06-18 18:18:56 -07:00
YeonJuan
090c6ed751 [eslint-plugin-react-hooks]: handling sparse array when no-inline callback (#19145) 2020-06-17 12:29:02 -04:00
Brian Vaughn
cc7c1aece4 Re-enabled DebugTracing feature for old reconciler fork (#19142)
It was temporarily removed by @sebmarkbage via PR #18697. Newly re-added tracing is simplified, since the lane(s) data type does not require the (lossy) conversion between priority and expiration time values.

@sebmarkbage mentioned that he removed this because it might get in the way of his planned discrete/sync refactor. I'm not sure if that concern still applies, but just in case- I have only re-added it to the old reconciler fork for now.
2020-06-16 15:16:15 -04:00
阿林
d4fc2c1457 Fix spelling (#19084) 2020-06-15 20:56:56 -04:00
Ricky
30b47103d4 Fix spelling errors and typos (#19138) 2020-06-15 19:59:44 -04:00
Rick Hanlon
655affa302 Clarifications
Co-authored-by: shengxinjing <316783812@qq.com>
2020-06-12 21:09:29 -04:00
Andrew Clark
103ed08c46 Remove shouldDeprioritizeSubtree from host config (#19124)
No longer being used.
2020-06-12 12:57:20 -07:00
Andrew Clark
8f05f2bd6d Land Lanes implementation in old fork (#19108)
* Add autofix to cross-fork lint rule

* replace-fork: Replaces old fork contents with new

For each file in the new fork, copies the contents into the
corresponding file of the old fork, replacing what was already there.

In contrast to merge-fork, which performs a three-way merge.

* Replace old fork contents with new fork

First I ran  `yarn replace-fork`.

Then I ran `yarn lint` with autofix enabled. There's currently no way to
do that from the command line (we should fix that), so I had to edit the
lint script file.

* Manual fix-ups

Removes dead branches, removes prefixes from internal fields.  Stuff
like that.

* Fix DevTools tests

DevTools tests only run against the old fork, which is why I didn't
catch these earlier.

There is one test that is still failing. I'm fairly certain it's related
to the layout of the Suspense fiber: we no longer conditionally wrap the
primary children. They are always wrapped in an extra fiber.

Since this has been running in www for weeks without major issues, I'll
defer fixing the remaining test to a follow up.
2020-06-11 20:05:15 -07:00
Sebastian Markbåge
7f28234f84 Enable component stacks everywhere except RN (#19120)
This would still affect test renderer and isomorphic in RN.
2020-06-11 19:13:13 -07:00
Dominic Gannaway
e3ccdf1544 Remove synamic modern event system flag for FB (#19059)
* Remove synamic modern event system flag for FB
2020-06-11 19:49:45 +01:00
Andrew Clark
4c7036e807 Bugfix: Infinite loop in beforeblur event (#19053)
* Failing test: Infinite loop in beforeblur event

If the focused node is hidden by a Suspense boundary, we fire the
beforeblur event. Our check for whether a tree is being hidden isn't
specific enough. It should only fire when the tree is initially hidden,
but it's being fired for updates, too.

* Only fire beforeblur on visible -> hidden

Should only beforeblur fire if the node was previously visible. Not
during updates to an already hidden tree.

To optimize this, we should use a dedicated effect tag and mark it in
the render phase. I've left this for a follow-up, though. Maybe can
revisit after the planned refactor of the commit phase.

* Move logic to commit phase

isFiberSuspenseAndTimedOut is used elsewhere, so I inlined the commit
logic into the commit phase itself.
2020-06-01 09:01:21 -07:00
Sebastian Markbåge
1d85bb3ce1 Build FB specific Isomorphic Bundles (#19049)
We need this so we can version them separately and use different
feature flags than we use for OSS RN.

I put them in a separate facebook-react-native folder which won't go
into the RN GH repo. I plan on moving the renderers there too but not yet.
2020-05-29 15:32:38 -07:00
Brian Vaughn
2efe63d99c DevTools: Add break-on-warn feature (#19048)
This commit adds a new tab to the Settings modal: Debugging

This new tab has the append component stacks feature and a new one: break on warn

This new feature adds a debugger statement into the console override
2020-05-29 14:34:43 -07:00
Sebastian Markbåge
89edb0eae3 Enable component stack locations in www (#19047) 2020-05-29 13:26:38 -07:00
Sebastian Markbåge
cb14168175 Remove unnecessary throw catch (#19044)
This was originally added so you could use "break on caught exceptions"
but that feature is pretty useless these days since it's used for feature
detection and Suspense.

The better pattern is to use the stack trace, jump to source and set a
break point here.

Since DevTools injects its own console.error, we could inject a "debugger"
statement in there. Conditionally. E.g. React DevTools could have a flag
to toggle "break on warnings".
2020-05-29 11:25:48 -07:00
Sebastian Markbåge
c03b8661a9 Upgrade Closure Compiler (#19041)
The Symbol bug has now been fixed so we can remove the hack that renames
the global variable.
2020-05-29 09:17:14 -07:00
Sebastian Markbåge
6d375f3078 Revert autofix lint (#19040)
I accidentally committed this since I had it on locally so I didn't have
to manually convert things to const.

However, this causes things to always pass lint since CI also runs this.
2020-05-28 20:32:34 -07:00
Sebastian Markbåge
8f511754db Prettier wants me to change this (#19039) 2020-05-28 20:13:56 -07:00
Sebastian Markbåge
2e7cc949ae Remove www builds of fetch (#19038)
I don't think we'll ever use this just because we have such a unique set up
for network delivery so we'll use something custom for this case.

Also, we don't need a profiling build for this since it doesn't have an
entry point.
2020-05-28 16:12:37 -07:00
Sebastian Markbåge
76f157e3dd Add simple Node build (#19022)
The webpack plugin doesn't really need a separate prod and dev build.
It also needs to be ES2015 otherwise we can't extend native classes.
2020-05-28 15:56:34 -07:00
Sebastian Markbåge
60afa3c117 Lint bundles using the bundle config instead of scanning for files (#19025)
* Lint bundles using the bundle config instead of scanning for files

This ensures that we look for all the files that we expect to see there.
If something doesn't get built we wouldn't detect it.

However, this doesn't find files that aren't part of our builds such as
indirection files in the root. This will need to change with ESM anyway
since indirection files doesn't work. Everything should be built anyway.

This ensures that we can use the bundles.js config to determine special
cases instead of relying on file system conventions.

* Run lint with flag
2020-05-28 15:04:25 -07:00
Sebastian Markbåge
518ce9c25f Add Lazy Elements Behind a Flag (#19033)
We really needed this for Flight before as well but we got away with it
because Blocks were lazy but with the removal of Blocks, we'll need this
to ensure that we can lazily stream in part of the content.

Luckily LazyComponent isn't really just a Component. It's just a generic
type that can resolve into anything kind of like a Promise.

So we can use that to resolve elements just like we can components.

This allows keys and props to become lazy as well.

To accomplish this, we suspend during reconciliation. This causes us to
not be able to render siblings because we don't know if the keys will
reconcile. For initial render we could probably special case this and
just render a lazy component fiber.

Throwing in reconciliation didn't work correctly with direct nested
siblings of a Suspense boundary before but it does now so it depends
on new reconciler.
2020-05-28 14:16:35 -07:00
Sebastian Markbåge
4985bb0a80 Rename 17 to 18 in warnings (#19031)
We're not really supposed to refer to future versions by numbers.

These will all slip so these numbers don't make sense anymore.
2020-05-28 10:25:39 -07:00
Brian Vaughn
86b4070ddb Cleaned up passive effects experimental flags (#19021) 2020-05-28 08:32:37 -07:00
Sebastian Markbåge
607148673b Remove ReactComponentTreeHook from internals (#19032)
We don't really support mixing minor versions anymore anyway. But seems
safe to remove in 17.
2020-05-27 20:41:13 -07:00
Sebastian Markbåge
43e59f29d6 Delete Entries without Build Output from package.json and the build directory (#19029)
* Gate test

* Delete entrypoints without Build Outputs from package.json and build output

If an entry point exists in bundles.js but doesn't have any bundleTypes,
I delete that entry point file from the build directory. I also remove it
from the files field in package.json if it exists.

This allows us to remove bundles from being built in the stable release
channel.
2020-05-27 19:43:08 -07:00
Sebastian Markbåge
e668f1b54f Remove unstable-fire from package.json (#19026)
This hasn't existed for a while now.
2020-05-27 17:07:25 -07:00
Sebastian Markbåge
0219925e02 Remove regenerator from noop (#19024)
This isn't used and it wouldn't work anyway.
2020-05-27 16:14:46 -07:00
Sebastian Markbåge
c66ac10f4d Lint classic www build (#19023) 2020-05-27 14:13:54 -07:00
Dan Abramov
b41beb1a35 Revert "Fix mistyped script arbitrary code execution vulnerability (#18660)" (#19018)
This reverts commit e5cc1462b3.
2020-05-27 17:37:27 +01:00
Sebastian Markbåge
55cb0b7eeb Only prepare extra stack frames if needed (#19014)
We currently prepare an extra stack frame before they're needed.
Particularly for propTypes. This causes problems as they can have
side-effects with the new component stacks and it's slow.

This moves it to be lazy.
2020-05-27 08:43:50 -07:00
Aaron Pettengill
9752d31f12 Document additionalHooks option (#19005)
* Document `additionalHooks` option

* Update README.md

Co-authored-by: Aaron Pettengill <aaron.pettengill@echoman.com>
Co-authored-by: Dan Abramov <dan.abramov@gmail.com>
2020-05-27 15:27:43 +01:00
Dan Abramov
b7ff888190 eslint-plugin-react-hooks@4.0.4 2020-05-27 14:38:27 +01:00
Andrew Clark
18de3b6e7c Bug: Spawning hydration in response to Idle update (#19011)
* Bug: Spawning hydration in response to Idle update

Adds a test that fails in the new fork.

* Fix typos related to Idle priority

These are just silly mistakes that weren't caught by any of our tests.

There's a lot of duplication in the Lanes module right now. It's also
not super stable as we continue to refine our heuristics. Hopefully the
final state is simpler and less prone to these types of mistakes.
2020-05-26 18:53:50 -07:00
Andrew Clark
9273e6585f Disable DevTools build job to unblock master (#19012) 2020-05-26 18:52:58 -07:00
Toru Kobayashi
fb735423bb Fix rollup validate script (#18900)
* Revert "Revert "deps: update ESLint version to v7 (#18897)" (#18899)"

This reverts commit 84fd4b853f.

* fix rollup validate script
2020-05-27 01:19:32 +01:00
Julien Deniau
8abc202c7f [eslint-plugin-react-hooks] Prefer recommended eslint configuration (#18951)
* [eslint-plugin-react-hooks] Prefer recommended eslint configuration

* Update README.md

Co-authored-by: Dan Abramov <dan.abramov@gmail.com>
2020-05-27 01:08:41 +01:00
Yann アウネ Eves
4821d609e9 fix(eslint-plugin-react-hooks): Added matching for nullish coalescing and optional chaining of dependencies, relates to #18985 (#19008) 2020-05-27 01:07:10 +01:00
Brian Vaughn
a012858ba9 Move isCustomComponent() function call outside of loop (#19007) 2020-05-26 13:41:27 -07:00
Dan Abramov
67e130fc68 eslint-plugin-react-hooks@4.0.3 2020-05-26 16:11:08 +01:00
Dan Abramov
bb2239dc90 Revert "Feature: Add support to exhaustive-deps rule for any hook ending with Effect (#18580)" (#19004)
This reverts commit 5ac9ca72df.
2020-05-26 16:08:50 +01:00
Andrew Clark
03e6b8ba2f Make LegacyHidden match semantics of old fork (#18998)
Facebook currently relies on being able to hydrate hidden HTML. So
skipping those trees is a regression.

We don't have a proper solution for this in the new API yet. So I'm
reverting it to match the old behavior.

Now the server renderer will treat LegacyHidden the same as a fragment,
with no other special behavior. We can only get away with this because
we assume that every instance of LegacyHidden is accompanied by a host
component wrapper. In the hidden mode, the host component is given a
`hidden` attribute, which ensures that the initial HTML is not visible.
To support the use of LegacyHidden as a true fragment, without an extra
DOM node, we will have to hide the initial HTML in some other way.
2020-05-25 18:16:53 -07:00
Dan Abramov
3ca1904b37 react-refresh@0.8.3 2020-05-23 14:26:26 +01:00
yjimk
0aa4cc544c Resolve an edge case where ref.node can be falsy (#18984)
Co-authored-by: Jimmy Cann <jimmy.cann@ironstar.io>
2020-05-23 14:25:24 +01:00
Brian Vaughn
8f4dc3e5d0 Warn if MutableSource snapshot is a function (#18933)
* Warn if MutableSource snapshot is a function

useMutableSource does not properly support snapshots that are functions. In part this is because of how it is implemented internally (the function gets mistaken for a state updater function). To fix this we could just wrap another function around the returned snapshot, but this pattern seems problematic to begin with- because the function that gets returned might itself close over mutable values, which would defeat the purpose of using the hook in the first place.

This PR proposes adding a new DEV warning if the snapshot returned is a function. It does not change the behavior (meaning that a function could still work in some cases- but at least the current behavior prevents passing around a closure that may later become stale unless you're really intentional about it e.g. () => () => {...}).

* Replaced .warn with .error
2020-05-21 16:14:29 -07:00
Brian Vaughn
142d4f1c00 useMutableSource hydration support (#18771)
* useMutableSource hydration support

* Remove unnecessary ReactMutableSource fork

* Replaced root.registerMutableSourceForHydration() with mutableSources option

* Response to PR feedback:

1. Moved mutableSources root option to hydrationOptions object
2. Only initialize root mutableSourceEagerHydrationData if supportsHydration config is true
3. Lazily initialize mutableSourceEagerHydrationData on root object
2020-05-21 16:00:46 -07:00
Brian Vaughn
aefb97e6bb DevTools: Add root and renderer version to inspected props panel (#18963)
* DevTools: Add root and renderer version to inspected props panel
* Removed redundant .length check
2020-05-21 14:40:49 -07:00
Andrew Clark
74394aa8cb Add unstable_isNewReconciler to dispatcher (#18975)
This is a bit gross but I need to be able to access it without importing
the renderer.

There might be a better way but I need this to unblock internal bugfix.
2020-05-21 11:56:00 -07:00
Brian Vaughn
099f73710e DevTools: Improve error boundary (#18956)
1. Add support for dark mode
2. Add retry option for case where Profiler data is corrupted
2020-05-21 11:21:22 -07:00
Dominic Gannaway
730ae7afa2 Clear fiber.sibling field when clearing nextEffect (#18970)
* Clear fiber.sibling field when clearing nextEffect
2020-05-21 18:53:56 +01:00
Brian Vaughn
c93a6cb4d5 DevTools: Fix highlight updates Canvas side problem (#18973) 2020-05-21 10:04:37 -07:00
Andrew Clark
f9bf828701 Add `unstable_isNewReconciler export to FB builds (#18974)
Should check this at runtime instead of the GK
2020-05-21 10:03:59 -07:00
Dominic Gannaway
4a3f779d67 Remove event pooling in the modern system (#18969) 2020-05-21 13:54:05 +01:00
Brian Vaughn
22f7663f14 Profiler: Don't count timed out (hidden) subtrees in base duration (#18966) 2020-05-20 18:36:57 -07:00
Andrew Clark
64f50c667a Remove disableHiddenPropDeprioritization flag (#18964)
This is rolled out to 100% public, so we can remove it.
2020-05-20 15:29:34 -07:00
Sebastian Markbåge
a30a1c6ef3 Transfer actualDuration only once for SuspenseList (#18959) 2020-05-20 15:12:38 -07:00
Andrew Clark
8b3b5c3524 Bugfix: Missing mode check in resetChildLanes (#18961)
Deferring a hidden tree is only supported in Concurrent Mode.

The missing check leads to an infinite loop when an update is scheduled
inside a hidden tree, because the pending work never gets reset.

This "accidentally" worked in the old reconciler because the heurstic
we used to detect offscreen trees was if `childExpirationTime`
was `Never`.

In the new reconciler, we check the tag instead. Which means we also
need to check the mode, like we do in the begin phase.

We should move this check out of the hot path. It shouldn't have been
in the hot path of the old reconciler, either.

Probably by moving `resetChildLanes` into the switch statement
in ReactFiberCompleteWork.
2020-05-19 23:10:49 -07:00
Andrew Clark
95ea8ed47c LegacyHidden: mode that defers without hiding (#18958)
Need this to unblock www. Not sure yet how we'll support this properly
long term.

While adding this, I noticed that the normal "hidden" mode of
LegacyHidden doesn't work properly because it doesn't toggle the
visibility of newly inserted nodes. This is fine for now since we only
use it via a userspace abstraction that wraps the children in an
additional node. But implementing this correctly is required for us
to start using it like a fragment, without the wrapper node.
2020-05-19 15:58:02 -07:00
Brian Vaughn
5aa967b69b DevTools editable props tweaks (#18954)
1. Made non-editable prop text higher contrast (easier to read)
2. Also makes it stand out as different from dimmer placeholder text for "new prop"
2020-05-19 09:42:00 -07:00
Toru Kobayashi
dbf2bba632 remove an unused ISSUE_TEMPLATE.md (#18953) 2020-05-19 08:44:01 -07:00
Brian Vaughn
23309eb386 DevTools 4.6.0 -> 4.7.0 2020-05-18 14:16:04 -07:00
Nick Reiley
d897c35ecf [DevTools] Add Component Highlighting to Profiler (#18745)
Co-authored-by: Moji Izadmehr <m.eezadmehr@gmail.com>
Co-authored-by: Brian Vaughn <bvaughn@fb.com>
2020-05-18 11:13:16 -07:00
Nick Reiley
081b565cd7 [DevTools] enable Electron interactions on Linux & auto copy script tags (#18772)
Co-authored-by: Brian Vaughn <brian.david.vaughn@gmail.com>
2020-05-18 10:27:40 -07:00
Sebastian Silbermann
c390ab3643 Add test for displayName on React.memo components (#18925)
* Add test for displayName on React.memo components

* Added extra memo displayName test

Co-authored-by: Brian Vaughn <brian.david.vaughn@gmail.com>
2020-05-15 15:56:50 -07:00
Gabriele Prestifilippo
6ed5c2243f Add MIT license to use-subscription package (#18927)
This package is missing the license attribute (or a license file).

Being a sub-package of React, it should get the same license, however, none was specified.
A scan with `license_checker` would recognize this as `UNKNOWN`.
2020-05-15 15:36:48 -07:00
Brian Vaughn
8dba6691d0 Updated DevTools CHANGELOG for upcoming changes 2020-05-15 10:50:39 -07:00
Nick Reiley
dd2e36df33 Profiler: Skip reading element for imported data (#18913)
* skip reading element for imported data

* rename nodes & enable store lookup for components tab

* replace names

* Added some more test coverage; reverted rename

Co-authored-by: Brian Vaughn <bvaughn@fb.com>
2020-05-15 10:38:01 -07:00
Nick Reiley
7c080902ef [DevTools] Improve HOC search UX (#18802)
Co-authored-by: Brian Vaughn <brian.david.vaughn@gmail.com>
2020-05-15 10:37:34 -07:00
Ricky Vetter
121af3143c Update inaccurate mapChildren comment (#18931)
The function you provide will only be passed a child and an index. It will not be passed a key. This is confirmed in the source, the Flow types, and the jsdoc comments.
2020-05-15 18:05:08 +01:00
Sophie Alpert
21dc41c320 Simplify logic for mutable workInProgressSources (#18920)
isPrimaryRenderer is always constant for a given React build, so these two arrays do nothing.
2020-05-14 14:30:44 -07:00
Andrew Clark
0fb747f368 Add LegacyHidden to server renderer (#18919)
* Add LegacyHidden to server renderer

When the tree is hidden, the server renderer renders nothing. The
contents will be completely client rendered.

When the tree is visible it acts like a fragment.

The future streaming server renderer may want to pre-render these trees
and send them down in chunks, as with Suspense boundaries.

* Force client render, even at Offscreen pri
2020-05-14 11:28:11 -07:00
Andrew Clark
b4a1a4980c Disable <div hidden /> API in old fork, too (#18917)
The motivation for doing this is to make it impossible for additional
uses of pre-rendering to sneak into www without going through the
LegacyHidden abstraction. Since this feature was already disabled in
the new fork, this brings the two closer to parity.

The LegacyHidden abstraction itself still needs to opt into
pre-rendering somehow, so rather than totally disabling the feature, I
updated the `hidden` prop check to be obnoxiously specific. Before, you
could set it to any truthy value; now, you must set it to the string
"unstable-do-not-use-legacy-hidden".

The node will still be hidden in the DOM, since any truthy value will
cause the browser to apply a style of `display: none`.

I will have to update the LegacyHidden component in www to use the
obnoxious string prop. This doesn't block merge, though, since the
behavior is gated by a dynamic flag. I will update the component before
I enable the flag.
2020-05-13 20:01:10 -07:00
Brian Vaughn
9e5b2c94e6 Add expando prop to disabledLog function (#18914)
This will enable it to be identified by Facebook infra even if the function name is mangled during DevTools build process.
2020-05-13 17:03:50 -07:00
Andrew Clark
fdb641629e Fix useMutableSource tearing bug (#18912)
* Failing useMutableSource test

If a source is mutated after initial read but before subscription is set
up, it should still entangle all pending mutations even if snapshot of
new subscription happens to match.

Test case illustrates how not doing this can lead to tearing.

* Fix useMutableSource tearing bug

Fix is to move the entanglement call outside of the block that checks
if the snapshot has changed.
2020-05-13 14:28:17 -07:00
Andrew Clark
33589f7423 useMutableSource: "Entangle" instead of expiring (#18889)
* useMutableSource: "Entangle" instead of expiring

A lane is said to be entangled with another when it's not allowed to
render in a batch that does not also include the other lane.

This commit implements entanglement for `useMutableSource`. If a source
is mutated in between when it's read in the render phase, but before
it's subscribed to in the commit phase, we must account for whether the
same source has pending mutations elsewhere. The old subscriptions must
not be allowed to re-render without also including the new subscription
(and vice versa), to prevent tearing.

In the old reconciler, we did this by synchronously flushing all the
pending subscription updates. This works, but isn't ideal. The new
reconciler can entangle the updates without de-opting to sync.

In the future, we plan to use this same mechanism for other features,
like skipping over intermediate useTransition states.

* Use clz instead of ctrz to pick an arbitrary lane

Should be slightly faster since most engines have built-in support.
2020-05-13 11:33:32 -07:00
Dan Abramov
43063fd844 eslint-plugin-react-hooks@4.0.2 2020-05-13 16:46:26 +01:00
Dan Abramov
f6ff4c43dd Update changelog 2020-05-13 16:45:50 +01:00
Boris Sergeev
487c693846 [eslint-plugin-react-hooks] useWithoutEffectSuffix fix (#18902) (#18907)
* [eslint-plugin-react-hooks] reproduce bug with a test and fix it (#18902)

Since we only reserve `-Effect` suffix, react-hooks/exhaustive-deps is
expected to succeed without warning on a custom hook which contains -Effect- in
the middle of it's name (but does NOT contain it as a suffix).

* [eslint-plugin-react-hooks] reproduced bug with a test and fix it

Since we only reserve `-Effect` suffix, react-hooks/exhaustive-deps is expected
to succeed without warning on a render helper which contains -use- in the middle
of it's name (but does NOT contain it as a prefix, since that would violate hook
naming convetion).

Co-authored-by: Boris Sergeyev <boris.sergeyev@quolab.com>
2020-05-13 16:44:05 +01:00
Dominic Gannaway
6514e4a179 React Flare: fix PressLegacy preventDefault issue (#18904) 2020-05-13 13:59:32 +01:00
Nick Reiley
a3fccd2567 Fix Profiler root change error (#18880) 2020-05-12 15:47:23 -07:00
Dominic Gannaway
61f2a560e0 Add experimental ReactDOM.createEventHandle (#18756) 2020-05-12 20:24:25 +01:00
Dan Abramov
84fd4b853f Revert "deps: update ESLint version to v7 (#18897)" (#18899)
This reverts commit 039ad34a05.
2020-05-12 20:06:14 +01:00
Dan Abramov
14e554b310 Add missing changelog item 2020-05-12 19:18:26 +01:00
Dominic Gannaway
80c4dea0d1 Modern Event System: Add scaffolding for createEventHandle (#18898) 2020-05-12 19:01:12 +01:00
Toru Kobayashi
039ad34a05 deps: update ESLint version to v7 (#18897) 2020-05-12 18:41:37 +01:00
Dan Abramov
9f396bdd5d eslint-plugin-react-hooks@4.0.1 2020-05-12 17:22:00 +01:00
Richard Maisano
c512aa0081 [Blocks] Scaffolding react-fetch + first pass at node implementation (#18863)
* First pass at scaffolding out the Node implementation of react-data.

While incomplete, this patch contains some changes to the react-data
package in order to start adding support for Node.

The first part of this change accounts for splitting react-data/fetch
into two discrete entries, adding (and defaulting to) the Node
implementation.

The second part is sketching out a rough approximation of `fetch` for
Node. This implementation is not complete by any means, but provides a
starting point.

* Remove NodeFetch module and put it directly into ReactDataFetchNode.

* Replaced react-data with react-fetch.

This patch shuffles around some of the scaffolding that was in
react-data in favor of react-fetch. It also removes the additional
"fetch" package in favor of something flatter.

* Tweak package organization

* Simplify and add a test

Co-authored-by: Dan Abramov <dan.abramov@me.com>
2020-05-12 17:21:45 +01:00
Dan Abramov
e936034eec Add item to ESLint Hooks plugin changelog 2020-05-12 17:02:37 +01:00
Michaël De Boey
c3ff21e01b feat(eslint-plugin-react-hooks): Support ESLint 7.x (#18878) 2020-05-12 17:01:28 +01:00
Andrew Clark
8b9c4d1688 Expose LegacyHidden type and disable <div hidden /> API in new fork (#18891)
* Expose LegacyHidden type

I will use this internally at Facebook to migrate away from
<div hidden />. The end goal is to migrate to the Offscreen type, but
that has different semantics. This is an incremental step.

* Disable <div hidden /> API in new fork

Migrates to the unstable_LegacyHidden type instead. The old fork does
not support the new component type, so I updated the tests to use an
indirection that picks the correct API. I will remove this once the
LegacyHidden (and/or Offscreen) type has landed in both implementations.

* Add gated warning for `<div hidden />` API

Only exists so we can detect callers in www and migrate them to the new
API. Should not visible to anyone outside React Core team.
2020-05-11 20:02:08 -07:00
Dominic Gannaway
ef0bf8e31c Revert "Hard code enableComponentStacks in www (#18869)" (#18890)
This reverts commit fd696df472.
2020-05-11 23:29:24 +01:00
Dominic Gannaway
e16703e6c7 Modern Event System: revise ancestor logic (#18886) 2020-05-11 22:09:52 +01:00
Karl Horky
2b9d7cf65f Devtools: Show inspectedElement key in right pane (#18737)
* Start MVP for showing inspected element key

* Add key in other places

* Add key from backend

* Remove unnecessary hydrateHelper call

* Hide copy button when no label

* Move above props

* Revert changes to InspectedElementTree.js

* Move key to left of component name

* Updated CSS

Co-authored-by: Brian Vaughn <brian.david.vaughn@gmail.com>
2020-05-11 13:17:13 -07:00
Rohith Srivathsav
ddcc69c83b Added clear message for functional component starting with lowercase (#18881) 2020-05-10 01:52:11 +01:00
Sebastian Markbåge
539527b642 Don't cut off effects at end of list if hydrating (#18872) 2020-05-08 21:26:51 -07:00
Sebastian Markbåge
fd696df472 Hard code enableComponentStacks in www (#18869)
This is now fully rolled out.
2020-05-08 18:14:54 -07:00
Andrew Clark
6edaf6f764 Detect and prevent render starvation, per lane (#18864)
* Detect and prevent render starvation, per lane

If an update is CPU-bound for longer than expected according to its
priority, we assume it's being starved by other work on the main thread.

To detect this, we keep track of the elapsed time using a fixed-size
array where each slot corresponds to a lane. What we actually store is
the event time when the lane first became CPU-bound.

Then, when receiving a new update or yielding to the main thread, we
check how long each lane has been pending. If the time exceeds a
threshold constant corresponding to its priority, we mark it as expired
to force it to synchronously finish.

We don't want to mistake time elapsed while an update is IO-bound
(waiting for data to resolve) for time when it is CPU-bound. So when a
lane suspends, we clear its associated event time from the array. When
it receives a signal to try again, either a ping or an update, we assign
a new event time to restart the clock.

* Store as expiration time, not start time

I originally stored the start time because I thought I could use this
in the future to also measure Suspense timeouts. (Event times are
currently stored on each update object for this purpose.) But that
won't work because in the case of expiration times, we reset the clock
whenever the update becomes IO-bound. So to replace the per-update
field, I'm going to have to track those on the room separately from
expiration times.
2020-05-08 12:47:51 -07:00
Nick Reiley
6207743168 [DevTools] Allow to continue dragging when leaving profiler picker (#18852)
Co-authored-by: Brian Vaughn <brian.david.vaughn@gmail.com>
2020-05-08 11:19:57 -07:00
Luna Ruan
df14b5bcc1 add new IDs for each each server renderer instance and prefixes to distinguish between each server render (#18576)
There is a worry that `useOpaqueIdentifier` might run out of unique IDs if running for long enough. This PR moves the unique ID counter so it's generated per server renderer object instead. For people who render different subtrees, this PR adds a prefix option to `renderToString`, `renderToStaticMarkup`, `renderToNodeStream`, and `renderToStaticNodeStream` so identifiers can be differentiated for each individual subtree.
2020-05-07 20:46:27 -07:00
Brian Vaughn
69e732ac9d Disable Profiler commit filtering (#18862)
* Disable Profiler commit filtering

We used to filter "empty" DevTools commits, but it was error prone (see #18798). A commit may appear to be empty (no actual durations) because of component filters, but filtering these empty commits causes interaction commit indices to be off by N. This not only corrupts the resulting data, but also potentially causes runtime errors.

For that matter, hiding "empty" commits might cause confusion too. A commit *did happen* even if none of the components the Profiler is showing were involved.

* Restart flaky CI
2020-05-07 17:07:20 -07:00
Brian Vaughn
fb3f0acad9 Disable Webpack setImmediate polyfill for DevTools (#18860)
* Upgrade Webpack deps to latet

* Disable Webpack setImmediate polyfill
2020-05-07 13:13:47 -07:00
Sebastian Markbåge
edf6eac8a1 Don't cut off the tail of a SuspenseList if hydrating (#18854) 2020-05-06 23:51:46 -07:00
Sebastian Markbåge
55f5cdee01 Disable setState before mount in legacy mode (#18851)
We kind of "support" this pattern in legacy mode. It's only deprecated in
Concurrent Mode.
2020-05-06 20:30:59 -07:00
Andrew Clark
47ebc90b08 Put render phase update change behind a flag (#18850)
In the new reconciler, I made a change to how render phase updates
work. (By render phase updates, I mean when a component updates
another component during its render phase. Or when a class component
updates itself during the render phase. It does not include when
a hook updates its own component during the render phase. Those have
their own semantics. So really I mean anything triggers the "`setState`
in render" warning.)

The old behavior is to give the update the same "thread" (expiration
time) as whatever is currently rendering. So if you call `setState` on a
component that happens later in the same render, it will flush during
that render. Ideally, we want to remove the special case and treat them
as if they came from an interleaved event.

Regardless, this pattern is not officially supported. This behavior is
only a fallback. The flag only exists until we can roll out the
`setState` warnning, since existing code might accidentally rely on the
current behavior.
2020-05-06 19:19:14 -07:00
Dominic Gannaway
6778c53c16 Modern Event System: fix bug in EnterLeave (#18849) 2020-05-07 00:13:13 +01:00
Brian Vaughn
7eaa1d7e33 Updated DevTools unstable_ API references (#18847) 2020-05-06 11:14:30 -07:00
Andrew Clark
a71aa803a1 [Release] Follow redirect when downloading tarball (#18845)
Adds -L option to `curl` command.

See: https://curl.haxx.se/docs/manpage.html#-L
2020-05-06 10:28:49 -07:00
Sebastian Markbåge
96f3b7d1c3 Warn if calling setState outside of render but before commit (#18838)
* Don't attempt to render the children of a dehydrated Suspense boundary

The DehydratedFragment tag doesn't exist so doing so throws.

This can happen if we schedule childExpirationTime on the boundary and
bail out.

* Warn if scheduling work on a component before it is committed
2020-05-06 09:45:35 -07:00
Dan Abramov
33c3af284c [Blocks Fixture] Remove remaining Blocks (#18840) 2020-05-06 15:53:51 +01:00
Dan Abramov
595d27bd73 [Blocks Fixture] Drop the Blocks (#18837)
* [Blocks Fixture] Add a tiny router

* Add a way to load nested entrypoint

* Only expose URL params to nested routers

* Add keys to route definitions

* [Blocks Fixture] Drop the Blocks
2020-05-06 05:17:44 +01:00
Dominic Gannaway
823dc581fe Modern Event System: fix EnterLeave plugin logic (#18830) 2020-05-05 22:10:07 +01:00
Fernando Lores
40e6029462 wrap SuspenseInstanceRetry callback so scheduler waits for it (#18805) 2020-05-05 12:47:49 -07:00
Brian Vaughn
3cde22a84e Experimental test selector API (#18607)
Adds several new experimental APIs to aid with automated testing.

Each of the methods below accepts an array of "selectors" that identifies a path (or paths) through a React tree. There are four basic selector types:

* Component: Matches Fibers with the specified React component type
* Role: Matches Host Instances matching the (explicit or implicit) accessibility role.
* Test name: Matches Host Instances with a data-testname attribute.
* Text: Matches Host Instances that directly contain the specified text.
* There is also a special lookahead selector type that enables further matching within a path (without actually including the path in the result). This selector type was inspired by the :has() CSS pseudo-class. It enables e.g. matching a <section> that contained a specific header text, then finding a like button within that <section>.

API
* findAllNodes(): Finds all Host Instances (e.g. HTMLElement) within a host subtree that match the specified selector criteria.
* getFindAllNodesFailureDescription(): Returns an error string describing the matched and unmatched portions of the selector query.
* findBoundingRects(): For all React components within a host subtree that match the specified selector criteria, return a set of bounding boxes that covers the bounds of the nearest (shallowed) Host Instances within those trees.
* observeVisibleRects(): For all React components within a host subtree that match the specified selector criteria, observe if it’s bounding rect is visible in the viewport and is not occluded.
* focusWithin(): For all React components within a host subtree that match the specified selector criteria, set focus within the first focusable Host Instance (as if you started before this component in the tree and moved focus forwards one step).
2020-05-05 10:37:46 -07:00
Dan Abramov
c13a59c7d6 Fix Blocks fixture 2020-05-05 18:14:06 +01:00
Kevin Lewis
7992ca10df eslint-plugin-react-hooks: allow OptionalMemberExpression in deps (#18819) (#18820)
* eslint-plugin-react-hooks: allow OptionalMemberExpression in deps (#18819)

* add test case for #18819

* fix test

* run prettier
2020-05-05 13:53:42 +01:00
Dominic Gannaway
e028ce2ab7 Modern Event System: ensure target ancestors are only host nodes (#18827) 2020-05-05 13:10:05 +01:00
Dan Abramov
4d124a4f67 [Blocks Fixture] Misc updates (#18811)
* [Blocks Fixture] Update navigation buttons immediately

* Add more profile links

* Minor refactor

* Add subroutes to Profile
2020-05-05 11:53:02 +01:00
Andrew Clark
fe7163e73d Add unstable prefix to experimental APIs (#18825)
We've been shipping unprefixed experimental APIs (like `createRoot` and
`useTransition`) to the Experimental release channel, with the rationale
that because these APIs do not appear in any stable release, we're free
to change or remove them later without breaking any downstream projects.

What we didn't consider is that downstream projects might be tempted to
use feature detection:

```js
const useTransition = React.useTransition || fallbackUseTransition;
```

This pattern assumes that the version of `useTransition` that exists in
the Experimental channel today has the same API contract as the final
`useTransition` API that we'll eventually ship to stable.

To discourage feature detection, I've added an `unstable_` prefix to
all of our unstable APIs.

The Facebook builds still have the unprefixed APIs, though. We will
continue to support those; if we make any breaking changes, we'll
migrate the internal callers like we usually do. To make testing easier,
I added the `unstable_`-prefixed APIs to the www builds, too. That way
our tests can always use the prefixed ones without gating on the
release channel.
2020-05-04 22:25:41 -07:00
Sebastian Markbåge
cd4a96035f Remove old CM exports (#18710) 2020-05-04 21:39:57 -07:00
Dominic Gannaway
9751935abf Modern Event System: improve dispatching queue (#18799) 2020-05-04 16:55:45 +01:00
Dan Abramov
3e13d70984 [RN] Remove debugging invariant (#18813) 2020-05-04 15:48:35 +01:00
Dan Abramov
f6fcae58e9 [Blocks] Add Shell to Fixture (#18803)
* [Blocks] Add Feed page to fixture

* Add minimal routing

* Always show post with comments
2020-05-04 01:59:55 +01:00
Dan Abramov
d830cd9984 [Blocks] Fix stale data on updates (#18810)
* [Blocks] Failing test for nested load

* Simplify the test

* Add a similar test that fails in PROD

* Copy .type when cloning work in progress
2020-05-04 01:43:51 +01:00
Sebastian Markbåge
64d4b84204 Rename Flight to Transport (#18808)
* Rename Flight to Transport

Flight is still the codename for the implementation details (like Fiber).

However, now the public package is react-transport-... which is only
intended to be used directly by integrators.

* Rename names
2020-05-03 11:33:48 -07:00
Andrew Clark
93e078ddf2 Initial Lanes implementation (#18796)
See PR #18796 for more information.

All of the changes I've made in this commit are behind the
`enableNewReconciler` flag. Merging this to master will not affect the
open source builds or the build that we ship to Facebook.

The only build that is affected is the `ReactDOMForked` build, which is
deployed to Facebook **behind an experimental flag (currently disabled
for all users)**. We will use this flag to gradually roll out the new
reconciler, and quickly roll it back if we find any problems.

Because we have those protections in place, what I'm aiming for with
this initial PR is the **smallest possible atomic change that lands
cleanly and doesn't rely on too many hacks**. The goal has not been to
get every single test or feature passing, and it definitely is not to
implement all the features that we intend to build on top of the new
model. When possible, I have chosen to preserve existing semantics and
defer changes to follow-up steps. (Listed in the section below.)

(I did not end up having to disable any tests, although if I had, that
should not have necessarily been a merge blocker.)

For example, even though one of the primary goals of this project is to
improve our model for parallel Suspense transitions, in this initial
implementation, I have chosen to keep the same core heuristics for
sequencing and flushing that existed in the ExpirationTimes model: low
priority updates cannot finish without also finishing high priority
ones.

Despite all these precautions, **because the scope of this refactor is
inherently large, I do expect we will find regressions.** The flip side
is that I also expect the new model to improve the stability of the
codebase and make it easier to fix bugs when they arise.
2020-05-02 17:09:31 -07:00
Moti Zilberman
3c7d52c3d6 Give unresolved lazy() a name in component stack (#16104)
* Give unresolved lazy() a name in component stack

* Normalize stack in tests

Co-authored-by: Sebastian Markbage <sema@fb.com>
2020-05-01 16:41:39 -07:00
Benedikt Franke
333deb707d Remove hint to post feedback about exhaustive-deps rule (#18712)
The thread is closed and locked.
2020-05-01 19:13:59 +01:00
Dominic Gannaway
aa88589d0b Refine experimental Scopes API (#18778)
* Refine experimental Scopes API
2020-05-01 19:01:43 +01:00
Dan Abramov
d804f99b9e eslint-plugin-react-hooks@4.0.0 2020-05-01 17:13:56 +01:00
Dan Abramov
4e93b9364c Add changelog for eslint-plugin-react-hooks (#18801) 2020-05-01 17:12:32 +01:00
Aaron Pettengill
5ac9ca72df Feature: Add support to exhaustive-deps rule for any hook ending with Effect (#18580)
* Add test cases for support exhaustive deps ending in Effect

* Apply the exhaustive deps lint rule to any hook ending with Effect

* Add another test for supporting linting useXEffect hooks

Co-authored-by: Aaron Pettengill <aaron.pettengill@echoman.com>
2020-05-01 16:57:25 +01:00
Dan Abramov
eab94403d7 Build Flight runtime for WWW (revert part of earlier change) 2020-05-01 16:44:25 +01:00
Sebastian Markbåge
17dcc29cd1 Don't "schedule" discrete work if we're scheduling sync work (#18797) 2020-05-01 08:43:15 -07:00
Dan Abramov
9491f39472 react-refresh@0.8.2 2020-05-01 16:18:13 +01:00
Dan Abramov
43a1c72751 Don't build react-data for WWW 2020-05-01 16:13:11 +01:00
Dan Abramov
01914a7673 Update bundle configs to not build some packages (#18800)
* Stop building old ReactCache for FB

* Update other bundle configs
2020-05-01 16:07:36 +01:00
Sophie Alpert
21670cf4be [react-refresh/babel] Always insert registrations after var (#18794)
Previously, we transformed

```
let Foo = styled.div``;
```

to

```
let Foo = _c1 = styled.div``;
```

and then babel-plugin-styled-components would infer `_c1` as the display name. Widen the existing case that applies to function expressions to apply to any type of variable declaration.
2020-05-01 16:01:11 +01:00
Andrew Clark
914b57be27 Move legacy hidden API to new internal Fiber type (#18782)
* Unhide Suspense trees without entanglement

When a Suspense boundary is in its fallback state, you cannot switch
back to the main content without also finishing any updates inside the
tree that might have been skipped. That would be a form of tearing.

Before we fixed this in #18411, the way this bug manifested was that a
boundary was suspended by an update that originated from a child
component (as opposed to props from a parent). While the fallback was
showing, it received another update, this time at high priority. React
would render the high priority update without also including the
original update. That would cause the fallback to switch back to the
main content, since the update that caused the tree to suspend was no
longer part of the render. But then, React would immediately try to
render the original update, which would again suspend and show the
fallback, leading to a momentary flicker in the UI.

The approach added in #18411 is, when receiving a high priority update
to a Suspense tree that's in its fallback state is to bail out, keep
showing the fallback and finish the update in the rest of the tree.
After that commits, render again at the original priority. Because low
priority expiration times are inclusive of higher priority expiration
times, this ensures that all the updates are committed together.

The new approach in this commit is to turn `renderExpirationTime` into a
context-like value that lives on the stack. Then, when unhiding the
Suspense boundary, we can push a new `renderExpirationTime` that is
inclusive of both the high pri update and the original update that
suspended. Then the boundary can be unblocked in a single render pass.

An advantage of the old approach is that by deferring the work of
unhiding, there's less work to do in the high priority update.

The key advantage of the new approach is that it solves the consistency
problem without having to entangle the entire root.

* Create internal LegacyHidden type

This only exists so we can clean up the internal implementation of
`<div hidden={isHidden} />`, which is not a stable feature. The goal
is to move everything to the new Offscreen type instead. However,
Offscreen has different semantics, so before we can remove the legacy
API, we have to migrate our internal usage at Facebook. So we'll need
to maintain both temporarily.

In this initial commit, I've only added the type. It's not used
anywhere. The next step is to use it to implement `hidden`.

* Use LegacyHidden to implement old hidden API

If a host component receives a `hidden` prop, we wrap its children in
an Offscreen fiber. This is similar to what we do for Suspense children.

The LegacyHidden type happens to share the same implementation as the
new Offscreen type, for now, but using separate types allows us to fork
the behavior later when we implement our planned changes to the
Offscreen API.

There are two subtle semantic changes here. One is that the children of
the host component will have their visibility toggled using the same
mechanism we use for Offscreen and Suspense: find the nearest host node
children and give them a style of `display: none`. We didn't used to do
this in the old API, because the `hidden` DOM attribute on the parent
already hides them. So with this change, we're actually "overhiding" the
children. I considered addressing this, but I figure I'll leave it as-is
in case we want to expose the LegacyHidden component type temporarily
to ease migration of Facebook's internal callers to the Offscreen type.

The other subtle semantic change is that, because of the extra fiber
that wraps around the children, this pattern will cause the children
to lose state:

```js
return isHidden ? <div hidden={true} /> : <div />;
```

The reason is that I didn't want to wrap every single host component
in an extra fiber. So I only wrap them if a `hidden` prop exists. In
the above example, that means the children are conditionally wrapped
in an extra fiber, so they don't line up during reconciliation, so
they get remounted every time `isHidden` changes.

The fix is to rewrite to:

```js
return <div hidden={isHidden} />;
```

I don't anticipate this will be a problem at Facebook, especially since
we're only supposed to use `hidden` via a userspace wrapper component.
(And since the bad pattern isn't very React-y, anyway.)

Again, the eventual goal is to delete this completely and replace it
with Offscreen.
2020-04-30 19:37:27 -07:00
Brian Vaughn
ac533fde3d Prevent stale legacy root from clearing a container (DRAFT) (#18792)
* Don't clear a container because of a stale legacy root

* Added test repro for FB error
2020-04-30 15:56:21 -07:00
Dan Abramov
5b89d353e2 Update react-refresh README 2020-04-30 15:43:21 +01:00
Dan Abramov
3a9c373521 [Blocks] Add preload to fetch (#18785) 2020-04-30 02:23:18 +01:00
Dan Abramov
dd7f0deb94 [Blocks] Use native fetch (#18784)
* [Blocks] Use native fetch

* Use the prototype

* Support arrayBuffer() and blob()

* ctor

* Simplify

* Use an expando

* Keep a map of formats

* Unused

* Remove unnecessary second property read

* Keep it simple

* Store the original thenable
2020-04-30 01:24:04 +01:00
Alex Taylor
e71f5df9c3 Consistent useCallback implementation in ReactDOMServer (#18783) 2020-04-29 16:22:10 -07:00
Dan Abramov
515326753b [Blocks] Initial implementation of cache and data/fetch (#18774)
* Rename ReactCache -> ReactCacheOld

We still use it in some tests so I'm going to leave it for now. I'll start making the new one in parallel in the react package.

* Add react/unstable-cache entry point

* Add react-data entry point

* Initial implementation of cache and data/fetch

* Address review
2020-04-29 19:14:15 +01:00
Dan Abramov
53d68b33ff [Blocks] Add Client Fixture (#18773)
* [Blocks] Add Client Fixture

* Add more TODOs
2020-04-29 02:23:09 +01:00
Dominic Gannaway
88d0be6da5 Refactor ElementListenerMap (#18766) 2020-04-28 21:53:51 +01:00
Brian Vaughn
ea2af878cc Root API should clear non-empty roots before mounting (#18730)
* Root API should clear non-empty roots before mounting

Legacy render-into-subtree API removes children from a container before rendering into it. The root API did not do this previously, but just left the children around in the document.

This commit adds a new FiberRoot flag to clear a container's contents before mounting. This is done during the commit phase, to avoid multiple, observable mutations.
2020-04-28 13:07:42 -07:00
Nick Reiley
d2ef120089 Allow Node 14.x (#18755) 2020-04-28 15:57:45 +01:00
Sebastian Markbåge
53ce0c3452 Allow flushSync to noop in life cycles but with a warning (#18759) 2020-04-27 20:07:39 -07:00
Andrew Clark
f342a2399f SuspenseList: Reschedule at same priority (#18738)
SuspenseList progressively renders items even if the list is CPU bound,
i.e. it isn't waiting for missing data. It does this by showing a
fallback for the remaining items, committing the items in that have
already finished, then starting a new render to continue working on
the rest.

When it schedules that subsequent render, it uses a slightly lower
priority than the current render: `renderExpirationTime - 1`.

This commit changes it to reschedule at `renderExpirationTime` instead.

I don't know what the original motivation was for bumping the expiration
time slightly lower. The comment says that the priorities of the two
renders are the same (which makes sense to me) so I imagine it was
motivated by some implementation detail. I don't think it's necessary
anymore, though perhaps it was when it was originally written. If it is
still necessary, we should write a test case that illustrates why.
2020-04-25 20:27:35 -07:00
Andrew Clark
cb70753993 Move hide/unhide logic to Offscreen component
The Offscreen component is not a public type, yet, but once it is, it
will share the same hide/unhide logic as Suspense children.
2020-04-25 00:10:09 -07:00
Andrew Clark
cb48f974c9 Wrap primary tree in Offscreen fiber type
Still just acts like a fragment. Next step is to move the hide/unhide
logic to the Offscreen implementation.
2020-04-25 00:10:09 -07:00
Luna Ruan
ed01fdacce Add Offscreen component type
Doesn't do anything special in this initial commit. Just acts like a
fragment.
2020-04-25 00:10:09 -07:00
Andrew Clark
1df756ba2c Always wrap Suspense children in fragment (#18711)
Changes the internal fiber structure of the Suspense component. When a
Suspense boundary can't finish rendering and switches to a fallback, we
wrap the "primary" tree in a Fragment fiber and hide all its DOM nodes.
Then we mount the fallback tree into a separate Fragment fiber. Both
trees will render into the same parent DOM node (since React fragments
aren't part of the host tree), but the wrappers ensure that the children
in each tree are reconciled separately.

The old implementation would try to be clever and only add the fragment
wrapper when the fallback was in place, to save memory. This "worked"
but was prone to regressions, since this is the only such place in the
codebase where we wrap existing nodes in a new node. (In other words,
it's a form of reparenting, which we don't implement elsewhere).

Since the original implementation, we've also added lots of additional
requirements to the Suspense component that have led to an explosion in
complexity, like limited support in Legacy Mode (with very different
semantics) and progressive hydration.

We're planning to add even more features to the Suspense boundary, so
we're going to sacrifice a bit more memory for a simpler implementation
that is less prone to regressions.

This ended up removing a lot of weird hacks and edge cases, but there
are still plenty left over. Most of the remaining complexity is related
to Legacy mode. That's the next thing we should aim to drop support for.

Because this is a risky change, I've only changed this in the new
reconciler. It blocks some other features, but as of now we're not
planning to implement those in the old reconciler. If that changes, this
should cherry-pick to the other implementation without much effort.
2020-04-25 00:09:19 -07:00
Andrew Clark
db6513914f Make ExpirationTime an opaque type (#18732)
* Add LanePriority type

React's internal scheduler has more priority levels than the external
Scheduler package. Let's use React as the source of truth for tracking
the priority of updates so we have more control. We'll still fall back
to Scheduler in the default case. In the future, we should consider
removing `runWithPriority` from Scheduler and replacing the valid use
cases with React-specific APIs.

This commit adds a new type, called a LanePriority to disambiguate from
the Scheduler one.

("Lane" refers to another type that I'm planning. It roughly translates
to "thread." Each lane will have a priority associated with it.)

I'm not actually using the lane anywhere, yet. Only setting stuff up.

* Remove expiration times train model

In the old reconciler, expiration times are computed by applying an
offset to the current system time. This has the effect of increasing
the priority of updates as time progresses. Because we also use
expiration times as a kind of "thread" identifier, it turns out this
is quite limiting because we can only flush work sequentially along
the timeline.

The new model will use a bitmask to represent parallel threads that
can be worked on in any combination and in any order.

In this commit, expiration times and the linear timeline are still in
place, but they are no longer based on a timestamp. Effectively, they
are constants based on their priority level.

* Stop using ExpirationTime to represent timestamps

Follow up to the previous commit. This converts the remaining places
where we were using the ExpirationTime type to represent a timestamp,
like Suspense timeouts.

* Fork Dependencies and PendingInteractionMap types

These contain expiration times

* Make ExpirationTime an opaque type

ExpirationTime is currently just an alias for the `number` type, for a
few reasons. One is that it predates Flow's opaque type feature. Another
is that making it opaque means we have to move all our comparisons and
number math to the ExpirationTime module, and use utility functions
everywhere else.

However, this is actually what we want in the new system, because the
Lanes type that will replace ExpirationTime is a bitmask with a
particular layout, and performing operations on it will involve more
than just number comparisions and artihmetic. I don't want this logic to
spread ad hoc around the whole codebase.

The utility functions get inlined by Closure so it doesn't matter
performance-wise.

I automated most of the changes with JSCodeshift, with only a few manual
tweaks to stuff like imports. My goal was to port the logic exactly to
prevent subtle mistakes, without trying to simplify anything in the
process. I'll likely need to audit many of these sites again when I
replace them with the new type, though, especially the ones
in ReactFiberRoot.

I added the codemods I used to the `scripts` directory. I won't merge
these to master. I'll remove them in a subsequent commit. I'm only
committing them here so they show up in the PR for future reference.

I had a lot of trouble getting Flow to pass. Somehow it was not
inferring the correct type of the constants exported from the
ExpirationTime module, despite being annotated correctly.

I tried converting them them to constructor functions — `NoWork`
becomes `NoWork()` — and that made it work. I used that to unblock me,
and fixed all the other type errors. Once there were no more type
errors, I tried converting the constructors back to constants. Started
getting errors again.

Then I added a type constraint everywhere a constant was referenced.
That fixed it. I also figured out that you only have to add a constraint
when the constant is passed to another function, even if the function is
annotated. So this indicates to me that it's probably a Flow bug. I'll
file an issue with Flow.

* Delete temporary codemods used in previous commit

I only added these to the previous commit so that I can easily run it
again when rebasing. When the stack is squashed, it will be as if they
never existed.
2020-04-24 23:26:04 -07:00
Chang Yan
4b02b66111 [ESLint] Extend isHook to recognize those under PascalCase's namespace (#18722)
* Extend Namespace to PascalCase

* Add valid case for jest.useFakeTimer

* format

* format :(

* fix nits
2020-04-24 02:50:52 +01:00
Dominic Gannaway
30cee2f4c7 Modern Event System: register onMouseEnter for portals (#18720) 2020-04-23 20:57:52 +01:00
Dominic Gannaway
4e3545fd6f ReactDOMEventListener: clean up module (#18713) 2020-04-23 20:19:28 +01:00
Sebastian Markbåge
b58dec979a Remove unnecessary stack (#18707) 2020-04-23 09:44:37 -07:00
Sebastian Markbåge
a2fb84bebd Disable prepareStackTrace while we're generating stacks (#18708)
This could be used to do custom formatting of the stack trace in a way
that isn't compatible with how we use it. So we disable it while we use
it.

In theory we could call this ourselves with the result of our stack.
It would be a lot of extra production code though. My personal opinion
is that this should always be done server side instead of on the client.

We could expose a custom parser that converts it and passes it through
prepareStackTrace as structured data. That way it's external and doesn't
have to be built-in to React.
2020-04-23 09:16:58 -07:00
Brian Vaughn
b9fc3d8d59 DevTools temporarily disable prepareStackTrace before creating custom component stacks (#18717) 2020-04-23 09:02:42 -07:00
Sebastian Markbåge
b0cb137bcb Don't dedupe using the stack (#18693)
We currently use the stack to dedupe warnings in a couple of places.
This is a very heavy weight way of computing that a warning doesn't need
to be fired.

This uses parent component name as a heuristic for deduping. It's not
perfect but as soon as you fix one you'll uncover the next. It might be a
little annoying but having many logs is also annoying.

We now have no special cases for stacks. The only thing that uses stacks in
dev is the console.error and dev tools. This means that we could
externalize this completely to an console.error patching module and drop
it from being built-in to react.

The only prod/dev behavior is the one we pass to error boundaries or the
error we throw if you don't have an error boundary.
2020-04-22 19:02:11 -07:00
Sebastian Markbåge
571f5ad2d6 Temporarily Remove DebugTracing from the New Reconciler (#18697)
* Remove priority field from tracing

* Remove DebugTracing mode from new reconciler (temporarily)

* Run DebugTracing tests in the *other* variant so it's no on for new reconciler
2020-04-21 20:14:40 -07:00
Sebastian Markbåge
2325375f4f Nit: add suffix _TIMEOUT consistently in scheduler (#18696) 2020-04-21 19:44:42 -07:00
Nick Reiley
e5cc1462b3 Fix mistyped script arbitrary code execution vulnerability (#18660)
* add test to trustedTypes-test.internal.js

* fix mistyped script arbitrary code execution

* Removed redundant .toLowerCase() call

Co-authored-by: Brian Vaughn <brian.david.vaughn@gmail.com>
2020-04-21 12:10:25 -07:00
Brian Vaughn
9025949d84 Pin RNW to canary (#18692)
This unbreaks DevTools shell with the latest ReactDOM in master.
2020-04-21 11:46:29 -07:00
Brian Vaughn
36cab2720a DevTools: Improved "native" component stacks (#18656)
* DevTools console override handles new component stack format

DevTools does not attempt to mimic the default browser console format for its component stacks but it does properly detect the new format for Chrome, Firefox, and Safari.
2020-04-21 11:46:11 -07:00
Sebastian Markbåge
940f48b999 Avoid passing custom stacks to console.error (#18685)
* Detect double stacks in the new format in tests

* Remove unnecessary uses of getStackByFiberInDevAndProd

These all execute in the right execution context already.

* Set the debug fiber around the cases that don't have an execution context

* Remove stack detection in our console log overrides

We never pass custom stacks as part of the args anymore.

* Bonus: Don't append getStackAddendum to invariants

We print component stacks for every error anyway so this is just duplicate
information.
2020-04-21 09:22:46 -07:00
Dominic Gannaway
ff431b7fc4 Remove ReactDOM.useEvent and associated types+tests (#18689) 2020-04-21 16:40:44 +01:00
Dominic Gannaway
7b3934b34f Revert "Pressable click fix (#18625)" (#18688)
This reverts commit 5f7b175b35.
2020-04-21 11:08:30 +01:00
Dominic Gannaway
80d39d8b57 Remove null sibling (#18687) 2020-04-21 10:43:50 +01:00
Sebastian Markbåge
0960b7ba58 Upgrade fbjs-scripts (#18684)
* Upgrade fbjs-scripts

This script takes into account the NODE_ENV as part of jest cache keys.
This avoids flaky tests since we depend on different transforms in prod
and dev.

* Upgrade Fresh test to Babel 7 transform
2020-04-20 18:20:03 -07:00
Naman Goel
5f7b175b35 Pressable click fix (#18625)
* Update press-legacy to use native click events

* update tests for pressable change

* fix formatting issue

* Address comments. Bring back some tests, remove others. Cleanup

* Fix flow and lint errors

* formatting fix missed by yarn lint
2020-04-20 23:13:17 +01:00
Dominic Gannaway
4f59a149b8 Modern event system: fix selectionchange bug (#18680) 2020-04-20 19:54:12 +01:00
Dominic Gannaway
a152827ef6 Refine the heuristics around beforeblur/afterblur (#18668)
* Refine the heuristics around beforeblur/afterblur
2020-04-20 19:32:22 +01:00
Sebastian Silbermann
707478e68a chore: Build react-dom/server in codesandbox CI (#18679) 2020-04-20 18:48:07 +01:00
Sebastian Silbermann
ffb6c6c07b fix: skip dangerouslySetInnerHtml hydration warning if it's undefined (#18676)
* test: Add failing case for dangerouslySetInnerHtml=undefined

* fix: skip dangerouslySetInnerHtml warning if it's undefined

* test: add similar test that should trigger the warning

* chore: Remove redundant nullish check

* Poke yarn_test_www_variant which timed out

* test: Add smaller test for innerHTML=string to innerHTML=undefined
2020-04-20 18:46:55 +01:00
Dominic Gannaway
1078029af6 Revert "Revert focus event PRs (#18655)" (#18671)
This reverts commit 58c895e59c.
2020-04-20 16:00:33 +01:00
Nicolas Gallagher
96203240d3 ReactDOM: remove unstable-native-dependencies bundle (#18483)
This is only used by react-native-web and will be replaced by a user-space
implementation. See: https://github.com/necolas/react-native-web/issues/1568
2020-04-18 15:40:13 -07:00
Brian Vaughn
263bc5d54b Fix incorrect unmounted state update warning (#18617)
* Fix incorrect unmounted state update warning

We detach fibers (which nulls the  field) when we commit a deletion, so any state updates scheduled between that point and when we eventually flush passive effect destroys won't have a way to check if there is a pending passive unmount effect scheduled for its alternate unless we also explicitly track this for both the current and the alternate.

This commit adds a new DEV-only effect type, `PendingPassiveUnmountDev`, to handle this case.
2020-04-18 12:18:19 -07:00
Andrew Clark
52a0d6b5ab Make Flow work with your editor (#18664)
We typecheck the reconciler against each one of our host configs.
`yarn flow dom` checks it against the DOM renderer, `yarn flow native`
checks it against the native renderer, and so on.

To do this, we generate separate flowconfig files.

Currently, there is no root-level host config, so running Flow
directly via `flow` CLI doesn't work. You have to use the `yarn flow`
command and pick a specific renderer.

A drawback of this design, though, is that our Flow setup doesn't work
with other tooling. Namely, editor integrations.

I think the intent of this was maybe so you don't run Flow against a
renderer than you intended, see it pass, and wrongly think you fixed
all the errors. However, since they all run in CI, I don't think this
is a big deal. In practice, I nearly always run Flow against the same
renderer (DOM), and I'm guessing that's the most common workflow for
others, too.

So what I've done in this commit is modify the `yarn flow` command to
copy the generated `.flowconfig` file into the root directory. The
editor integration will pick this up and show Flow information for
whatever was the last renderer you checked.

Everything else about the setup is the same, and all the renderers will
continue to be checked by CI.
2020-04-18 10:24:46 -07:00
Andrew Clark
cfefc81ab2 Fix for #18657 (#18663)
* Failing test for #18657

* Remove incorrect priority check

I think this was just poor factoring on my part in #18411. Honestly it
doesn't make much sense to me, but my best guess is that I must have
thought that when `baseTime > currentChildExpirationTime`, the function
would fall through to the
`currentChildExpirationTime < renderExpirationTime` branch below.

Really I think just made an oopsie.

Regardless, this logic is galaxy brainéd. A goal of the Lanes refactor
I'm working on is to make these types of checks -- is there remaining
work in this tree? -- a lot easier to think about. Hopefully.
2020-04-17 16:32:55 -07:00
Dominic Gannaway
e7163a9c2f Revise isFiberInsideHiddenOrRemovedTree (#18662) 2020-04-17 23:58:40 +01:00
Andrew Clark
a4b1e65afc Remove redundant expiration time comparisons (#18620)
I'm going through all the expiration times comparisons as part of my
refactor and I noticed this one has a redundancy.
2020-04-17 11:48:05 -07:00
Dominic Gannaway
58c895e59c Revert focus event PRs (#18655)
* Revert "Further cleanup to before/after blur (#18649)"

This reverts commit e2ccbf0358.

* Revert "Unify Flare FocusWithin responder with useFocusWithin (#18636)"

This reverts commit f24a9e7098.
2020-04-17 16:27:19 +01:00
Dominic Gannaway
e2ccbf0358 Further cleanup to before/after blur (#18649) 2020-04-17 11:52:29 +01:00
Brian Vaughn
c5c25d35a3 Fixed DevTools extension build:dev command (#18648) 2020-04-16 17:39:16 -07:00
dependabot[bot]
f8b084276d Bump https-proxy-agent from 2.2.1 to 2.2.4 in /scripts/release (#18642)
Bumps [https-proxy-agent](https://github.com/TooTallNate/node-https-proxy-agent) from 2.2.1 to 2.2.4.
- [Release notes](https://github.com/TooTallNate/node-https-proxy-agent/releases)
- [Commits](https://github.com/TooTallNate/node-https-proxy-agent/compare/2.2.1...2.2.4)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-04-16 16:06:13 -07:00
dependabot[bot]
0f9b30f7b5 Bump https-proxy-agent from 2.2.2 to 2.2.4 (#18643)
Bumps [https-proxy-agent](https://github.com/TooTallNate/node-https-proxy-agent) from 2.2.2 to 2.2.4.
- [Release notes](https://github.com/TooTallNate/node-https-proxy-agent/releases)
- [Commits](https://github.com/TooTallNate/node-https-proxy-agent/compare/2.2.2...2.2.4)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-04-16 16:06:06 -07:00
Dominic Gannaway
32bb44c80a Clean up modern plugins to remove dead code (#18639) 2020-04-16 20:10:23 +01:00
Dan Abramov
0301f3e24f Statically disable factory components for WWW (#18641) 2020-04-16 19:42:30 +01:00
Dominic Gannaway
f24a9e7098 Unify Flare FocusWithin responder with useFocusWithin (#18636) 2020-04-16 19:35:41 +01:00
Dominic Gannaway
b1a083183c Revert legacy plugin modules (#18638) 2020-04-16 18:46:24 +01:00
Dominic Gannaway
31977d1bb3 Create copy of Legacy event plugins for Modern system (#18637) 2020-04-16 16:09:05 +01:00
Andrew Clark
c12c2c4c8c Run error replay test again new reconciler (#18628)
This is one of our few tests of an internal function. Need to import
the module that corresponds to the reconciler that's being tested.
2020-04-16 08:08:22 -07:00
Boris Serdiuk
7b4403cecd Fix requiring timers module with non standard require (#18632)
fixes #18589
2020-04-16 12:36:09 +01:00
Thomas Brown
5f6b75dd26 ADD: disableRemotePlayback attribute for HTML5 videos (#18619)
* Add support for disableremoteplayback

* Order attributes alphabetically

Co-authored-by: Tom Brown <Thomas.Brown-CIC-UK@ibm.com>
2020-04-16 10:23:48 +01:00
Brian Vaughn
71964c0346 Fix CI (#18626) 2020-04-15 22:27:24 -07:00
Andrew Clark
50b9f154c1 Fix wrong command in config.yml (#18624) 2020-04-15 21:44:38 -07:00
Brian Vaughn
22dc2e42bd Add experimental DebugTracing logger for internal use (#18531) 2020-04-15 19:10:15 -07:00
Andrew Clark
dbd2626855 Update nvmrc to the same one used in CI (#18623) 2020-04-15 16:03:02 -07:00
Andrew Clark
b680174841 Delete mutableSourceFirstPendingUpdateTime (#18613) 2020-04-15 07:47:37 -07:00
Andrew Clark
cbafbf4f32 Fix typo in TestFlags
Copypasta when setting up `old` and `new` aliases. `old` should mean
that `enableNewReconciler` is off.
2020-04-14 23:32:53 -07:00
Dominic Gannaway
d53988a9d1 ReactDOM.useEvent: add useEvent interaction hook (#18604) 2020-04-14 22:06:46 +01:00
Dominic Gannaway
bf55ea7434 Move beforeblur phase to prepareForCommit (#18609) 2020-04-14 21:30:54 +01:00
Andrew Clark
843b50cbe1 Remove .internal from more test suites (#18597) 2020-04-14 07:43:00 -07:00
BetaSu
1d7bd52688 remove unnecessary variable comparation (#18598)
Since it will continue when the props are equal in line 767, there is no need to compare whether they are not equal.
2020-04-14 14:53:47 +01:00
Andrew Clark
b928fc030a Delete flushSuspenseFallbacksInTests flag (#18596)
* Move renderer `act` to work loop

* Delete `flushSuspenseFallbacksInTests`

This was meant to be a temporary hack to unblock the `act` work, but it
quickly spread throughout our tests.

What it's meant to do is force fallbacks to flush inside `act` even in
Concurrent Mode. It does this by wrapping the `setTimeout` call in a
check to see if it's in an `act` context. If so, it skips the delay and
immediately commits the fallback.

Really this is only meant for our internal React tests that need to
incrementally render. Nobody outside our team (and Relay) needs to do
that, yet. Even if/when we do support that, it may or may not be with
the same `flushAndYield` pattern we use internally.

However, even for our internal purposes, the behavior isn't right
because a really common reason we flush work incrementally is to make
assertions on the "suspended" state, before the fallback has committed.
There's no way to do that from inside `act` with the behavior of this
flag, because it causes the fallback to immediately commit. This has led
us to *not* use `act` in a lot of our tests, or to write code that
doesn't match what would actually happen in a real environment.

What we really want is for the fallbacks to be flushed at the *end` of
the `act` scope. Not within it.

This only affects the noop and test renderer versions of `act`, which
are implemented inside the reconciler. Whereas `ReactTestUtils.act` is
implemented in "userspace" for backwards compatibility. This is fine
because we didn't have any DOM Suspense tests that relied on this flag;
they all use test renderer or noop.

In the future, we'll probably want to move always use the reconciler
implementation of `act`. It will not affect the prod bundle, because we
currently only plan to support `act` in dev. Though we still haven't
completely figured that out. However, regardless of whether we support a
production `act` for users, we'll still need to write internal React
tests in production mode. For that use case, we'll likely add our own
internal version of `act` that assumes a mock Scheduler and might rely
on hacks that don't 100% align up with the public one.
2020-04-13 20:02:18 -07:00
Andrew Clark
f3f3d77c20 Fix www tests not running in prod (#18593)
I made a mistake when setting these up a while ago. Setting the NODE_ENV
in the CircleCI config doesn't work because it's also set in the node
script command.

The number of test commands is getting out of control. Might need to fix
it at some point. Not today for me.
2020-04-13 15:53:13 -07:00
Andrew Clark
bec7599067 Migrate conditional tests to gate pragma (#18585)
* Migrate conditional tests to gate pragma

I searched through the codebase for this pattern:

```js
describe('test suite', () => {
  if (!__EXPERIMENTAL__) { // or some other condition
    test("empty test so Jest doesn't complain", () => {});
    return;
  }

  // Unless we're in experimental mode, none of the tests in this block
  // will run.
})
```

and converted them to the `@gate` pragma instead.

The reason this pattern isn't preferred is because you end up disabling
more tests than you need to.

* Add flag for www release channels

Using a heuristic where I check a flag that is known to only be enabled
in www. I left a TODO to instead set the release channel explicitly in
each test config.
2020-04-13 14:45:52 -07:00
Chris Dobson
6c43a62c0f DevTools: Switch between "Rendered At" renders using keyboard arrow keys (#18586)
* Add keyboard navigation to fibre info sidebar

Co-authored-by: Brian Vaughn <brian.david.vaughn@gmail.com>
2020-04-13 13:00:13 -07:00
Andrew Clark
0c3c27a718 Fix "missing flag" error for non-boolean types (#18592)
Not all test flags are booleans, e.g. the build type
2020-04-13 12:57:31 -07:00
Andrew Clark
65237a237e Codemod it.experimental to gate pragma (#18582)
* Codemod it.experimental to gate pragma

Find-and-replace followed by Prettier

* Delete it.experimental

Removes the API from our test setup script
2020-04-13 10:28:59 -07:00
Andrew Clark
42d7c2e8f7 Add pragma for feature testing: @gate (#18581)
* Add pragma for feature testing: @gate

The `@gate` pragma declares under which conditions a test is expected to
pass.

If the gate condition passes, then the test runs normally (same as if
there were no pragma).

If the conditional fails, then the test runs and is *expected to fail*.

An alternative to `it.experimental` and similar proposals.

Examples
--------

Basic:

```js
// @gate enableBlocksAPI
test('passes only if Blocks API is available', () => {/*...*/})
```

Negation:

```js
// @gate !disableLegacyContext
test('depends on a deprecated feature', () => {/*...*/})
```

Multiple flags:

```js
// @gate enableNewReconciler
// @gate experimental
test('needs both useEvent and Blocks', () => {/*...*/})
```

Logical operators (yes, I'm sorry):

```js
// @gate experimental && (enableNewReconciler || disableSchedulerTimeoutBasedOnReactExpirationTime)
test('concurrent mode, doesn\'t work in old fork unless Scheduler timeout flag is disabled', () => {/*...*/})
```

Strings, and comparion operators

No use case yet but I figure eventually we'd use this to gate on
different release channels:

```js
// @gate channel ===  "experimental" || channel === "modern"
test('works in OSS experimental or www modern', () => {/*...*/})
```

How does it work?

I'm guessing those last two examples might be controversial. Supporting
those cases did require implementing a mini-parser.

The output of the transform is very straightforward, though.

Input:
```js
// @gate a && (b || c)
test('some test', () => {/*...*/})
```

Output:

```js
_test_gate(ctx => ctx.a && (ctx.b || ctx.c, 'some test'), () => {/*...*/});
```

It also works  with `it`, `it.only`, and `fit`. It leaves `it.skip` and
`xit` alone because those tests are disabled anyway.

`_test_gate` is a global method that I set up in our Jest config. It
works about the same as the existing `it.experimental` helper.

The context (`ctx`) argument is whatever we want it to be. I set it up
so that it throws if you try to access a flag that doesn't exist. I also
added some shortcuts for common gating conditions, like `old`
and `new`:

```js
// @gate experimental
test('experimental feature', () => {/*...*/})

// @gate new
test('only passes in new reconciler', () => {/*...*/})
```

Why implement this as a pragma instead of a runtime API?

- Doesn't require monkey patching built-in Jest methods. Instead it
  compiles to a runtime function that composes Jest's API.
- Will be easy to upgrade if Jest ever overhauls their API or we switch
  to a different testing framework (unlikely but who knows).
- It feels lightweight so hopefully people won't feel gross using it.
  For example, adding or removing a gate pragma will never affect the
  indentation of the test, unlike if you wrapped the test in a
  conditional block.

* Compatibility with console error/warning tracking

We patch console.error and console.warning to track unexpected calls
in our tests. If there's an unexpected call, we usually throw inside
an `afterEach` hook. However, that's too late for tests that we
expect to fail, because our `_test_gate` runtime can't capture the
error. So I also check for unexpected calls inside `_test_gate`.

* Move test flags to dedicated file

Added some instructions for how the flags are set up and how to
use them.

* Add dynamic version of gate API

Receives same flags as the pragma.

If we ever decide to revert the pragma, we can codemod them to use
this instead.
2020-04-13 10:14:34 -07:00
Sebastian Markbåge
72d00ab623 Fix Component Stacks for IE and Native Classes in Safari (#18575)
* Add more edge cases to fixture

Also adjust some expectations. I think the column should ideally be 1 but varies.
The Example row is one line off because it throws on the hook but should ideally be the component.
Similarly class components with constructors may have the line in the constructor.

* Account for the construct call taking a stack frame

We do this by first searching for the first different frame, then find
the same frames and then find the first different frame again.

* Throw controls

Otherwise they don't get a stack frame associated with them in IE.

* Protect against generating stacks failing

Errors while generating stacks will bubble to the root. Since this technique
is a bit sketchy, we should probably protect against it.

* Don't construct the thing that throws

Instead, we pass the prototype as the "this". It's new every time anyway.
2020-04-10 19:39:02 -07:00
Sebastian Markbåge
98d410f500 Build Component Stacks from Native Stack Frames (#18561)
* Implement component stack extraction hack

* Normalize errors in tests

This drops the requirement to include owner to pass the test.

* Special case tests

* Add destructuring to force toObject which throws before the side-effects

This ensures that we don't double call yieldValue or advanceTime in tests.

Ideally we could use empty destructuring but ES lint doesn't like it.

* Cache the result in DEV

In DEV it's somewhat likely that we'll see many logs that add component
stacks. This could be slow so we cache the results of previous components.

* Fixture

* Add Reflect to lint

* Log if out of range.

* Fix special case when the function call throws in V8

In V8 we need to ignore the first line. Normally we would never get there
because the stacks would differ before that, but the stacks are the same if
we end up throwing at the same place as the control.
2020-04-10 13:32:12 -07:00
Brian Vaughn
8e13f099ab Overhauled release scripts and docs (#18569)
* Overhauled release scripts and docs
2020-04-10 12:28:40 -07:00
Andrew Clark
af1b039bdd ESLint rule to forbid cross fork imports (#18568)
Modules that belong to one fork should not import modules that belong to
the other fork.

Helps make sure you correctly update imports when syncing changes across
implementations.

Also could help protect against code size regressions that might happen
if one of the forks accidentally depends on two copies of the same
module.
2020-04-09 18:11:34 -07:00
Sebastian Markbåge
50bdd75a60 Bubble errors if processing the error itself errors (#18567)
If we've tried completing an incomplete boundary once and failed, we don't
need to try again.
2020-04-09 17:40:11 -07:00
Sebastian Markbåge
348ed0e93f Don't return from perform/completeUnitOfWork (#18566)
* Remove unnecessary workInProgress line

* Mutate workInProgress instead of returning

We were ambivalent about this before.

* Make handleError a void method too
2020-04-09 17:12:04 -07:00
Andrew Clark
b04c7fa28c Decouple expiration times and transition timeouts (#17920)
We currently use the expiration time to represent the timeout of a
transition. Since we intend to stop treating work priority as a
timeline, we can no longer use this trick.

In this commit, I've changed it to store the event time on the update
object instead. Long term, we will store event time on the root as a map
of transition -> event time. I'm only storing it on the update object
as a temporary workaround to unblock the rest of the changes.
2020-04-09 15:09:36 -07:00
Andrew Clark
dc630d3374 Fork ReactFiberExpirationTime
I had thought I wouldn't fork this one because the new "lanes" module
will be pretty different, but I need it to make some
incremental changes.
2020-04-09 15:09:34 -07:00
Dan Abramov
e5d06e34b6 Revert "Clear more Fiber fields in detachFiber (#18556)" (#18562)
This reverts commit d48dbb8249.
2020-04-09 20:45:02 +01:00
Sebastian Markbåge
cbab25bb51 Exclude forwardRef and memo from stack frames (#18559)
We can't patch the row. We could give these their own "built-in" stack
frame since they're conceptually HoCs. However, from a debugging
perspective this is not very useful meta data and quite noisy. So I'm
just going to exclude them.
2020-04-09 11:42:22 -07:00
Andrew Clark
26fc16484e Script for syncing changes between forks (#18550)
Adds command `yarn merge-fork`.

```sh
yarn merge-fork --base-dir=packages/react-reconciler/src ReactFiberWorkLoop
```

This will take all the changes in `ReactFiberWorkLoop.new.js` and apply
them to `ReactFiberWorkLoop.old.js`.

You can merge multiple modules at a time:

```sh
yarn merge-fork \
  --base-dir=packages/react-reconciler/src \
  ReactFiberWorkLoop \
  ReactFiberBeginWork \
  ReactFiberCompleteWork \
  ReactFiberCommitWork
```

You can provide explicit "old" and "new" file names. This only works
for one module at a time:

```sh
yarn merge-fork \
  --base-dir=packages/react-reconciler/src \
  --old=ReactFiberExpirationTime.js \
  --new=ReactFiberLane.js
```

The default is to merge changes from the new module to the old one. To
merge changes in the opposite direction, use `--reverse`.

```sh
yarn merge-fork \
  --reverse \
  --base-dir=packages/react-reconciler/src \
  ReactFiberWorkLoop
```

By default, the changes are compared to HEAD. You can use `--base-ref`
to compare to any rev. For example, while working on a PR, you might
make multiple commits to the new fork before you're ready to backport
them to the old one. In that case, you want to compare to the merge
base of your PR branch:

```sh
yarn merge-fork \
  --base-ref=$(git merge-base HEAD origin/master)
  --base-dir=packages/react-reconciler/src \
  ReactFiberWorkLoop
```
2020-04-09 11:37:13 -07:00
Sebastian Markbåge
11ac10b44e Port error boundaries test to yieldValue (#18558) 2020-04-09 11:13:01 -07:00
Dominic Gannaway
d48dbb8249 Clear more Fiber fields in detachFiber (#18556) 2020-04-09 18:31:34 +01:00
Dominic Gannaway
0566b706ee Fix fiber memory leak with runAllPassiveEffectDestroysBeforeCreates (#18554) 2020-04-09 15:35:07 +01:00
Dominic Gannaway
ca1a703d21 Make enableLegacyFBSupport flag dynamic for www (#18551) 2020-04-09 15:31:36 +01:00
Dominic Gannaway
8cbce05be1 Move plugins into their own directory (#18553) 2020-04-09 14:18:33 +01:00
Dan Abramov
c74f0b0646 Update stale.yml 2020-04-09 13:36:11 +01:00
Andrew Clark
4c6470cb3b Point ReactDOMForked to the new implementation
Updates Rollup, Jest, and Flow configuration to point to the new
entry points.
2020-04-09 00:03:35 -07:00
Andrew Clark
17f582e045 Add forked copies of reconciler modules
All changes in this commit were generated by the following commands.

Copy each module that ends with `.old` to a new file that ends
with `.new`:

```sh
for f in packages/react-reconciler/src/*.old.js; do cp "$f" "$(echo "$f" | sed s/\.old/\.new/)"; done
```

Then transform the internal imports:

```sh
grep -rl --include="*.new.js" '.old' packages/react-reconciler/src/| xargs sed -i '' "s/\.old\'/\.new\'/g"
```
2020-04-09 00:03:35 -07:00
Andrew Clark
376d5c1b5a Split cross-package types from implementation
Some of our internal reconciler types have leaked into other packages.
Usually, these types are treated as opaque; we don't read and write
to its fields. This is good.

However, the type is often passed back to a reconciler method. For
example, React DOM creates a FiberRoot with `createContainer`, then
passes that root to `updateContainer`. It doesn't do anything with the
root except pass it through, but because `updateContainer` expects a
full FiberRoot, React DOM is still coupled to all its fields.

I don't know if there's an idiomatic way to handle this in Flow. Opaque
types are simlar, but those only work within a single file. AFAIK,
there's no way to use a package as the boundary for opaqueness.

The immediate problem this presents is that the reconciler refactor will
involve changes to our internal data structures. I don't want to have to
fork every single package that happens to pass through a Fiber or
FiberRoot, or access any one of its fields. So my current plan is to
share the same Flow type across both forks. The shared type will be a
superset of each implementation's type, e.g. Fiber will have both an
`expirationTime` field and a `lanes` field. The implementations will
diverge, but not the types.

To do this, I lifted the type definitions into a separate module.
2020-04-08 23:49:23 -07:00
Andrew Clark
d686f3f16a Add .old prefix to reconciler modules 2020-04-08 23:49:19 -07:00
Sebastian Markbåge
147bdef11b Port more tests to the Scheduler.unstable_yieldValue pattern and drop internal.js (#18549)
* Drop the .internal.js suffix on some files that don't need it anymore

* Port some ops patterns to scheduler yield

* Fix triangle test to avoid side-effects in constructor

* Move replaying of setState updaters until after the effect

Otherwise any warnings get silenced if they're deduped.

* Drop .internal.js in more files

* Don't check propTypes on a simple memo component unless it's lazy

Comparing the elementType doesn't work for this because it will never be
the same for a simple element.

This caused us to double validate these. This was covered up because in
internal tests this was deduped since they shared the prop types cache
but since we now inline it, it doesn't get deduped.
2020-04-08 20:54:54 -07:00
Sebastian Markbåge
b014e2d5e3 Don't use closures in DevTools injection (#18278)
* Don't use closures in DevTools injection

Nested closures are tricky. They're not super efficient and when they share
scope between multiple closures they're hard for a compiler to optimize.
It's also unclear how many versions will be created.

By hoisting things out an just make it simple calls the compiler can do
a much better job.

* Store injected hook to work around fast refresh
2020-04-08 17:57:17 -07:00
Sebastian Markbåge
5474a83e25 Disable console.logs in the second render pass of DEV mode double render (#18547)
* Disable console log during the second rerender

* Use the disabled log to avoid double yielding values in scheduler mock

* Reenable debugRenderPhaseSideEffectsForStrictMode in tests that can
2020-04-08 16:43:51 -07:00
Dan Abramov
b225d4f261 Revert "Revert "Refactor commitPlacement to recursively insert nodes (#17996)" (#18517)" (#18540)
This reverts commit e69ca310ea.
2020-04-08 11:22:02 +01:00
jddxf
241103a6fb Fix bailout broken in lazy components due to default props resolving (#18539)
* Add failing tests for lazy components

* Fix bailout broken in lazy components due to default props resolving

We should never compare unresolved props with resolved props. Since comparing
resolved props by reference doesn't make sense, we use unresolved props in that
case. Otherwise, resolved props are used.

* Avoid reassigning props warning when we bailout
2020-04-08 10:58:57 +01:00
Andrew Clark
2dddd1e00c Bugfix: Render phase update causes remaining updates in same component to be dropped (#18537)
* Bugfix: Render phase update leads to dropped work

Render phase updates should not affect the `fiber.expirationTime` field.
We don't have to set anything on the fiber because we're going to
process the render phase update immediately.

We also shouldn't reset the `expirationTime` field in between render
passes because it represents the remaining work left in the update
queues. During the re-render, the updates that were skipped in the
original pass are not processed again.

I think my original motivation for using this field for render phase
updates was so I didn't have to add another module level variable.

* Add repro case for #18486

Co-authored-by: Dan Abramov <dan.abramov@me.com>
2020-04-07 19:17:01 -07:00
Andrew Clark
2def7b3caf More robust fix for #18515 (#18535)
* Add another test for #18515 using pings

Adds a regression test for the same underlying bug as #18515 but using
pings.

Test already passes, but I confirmed it fails if you revert the fix
in #18515.

* Set nextPendingLevel after commit, too
2020-04-07 18:52:31 -07:00
Dominic Gannaway
948fad357b Improve detachFiber (#18536) 2020-04-08 01:45:23 +01:00
Carl Vitullo
03de849af0 Make uncontrolled -> controlled warning clearer (#17070)
* Make uncontrolled -> controlled warning clearer

* Update phrasing, mirror for opposite direction

* Remove unused substitution

* Update warning tests

* Literally got these backwards, womp womp

* Rerere-fix tests
2020-04-07 23:19:56 +01:00
jddxf
ddc4b65cfe Clear finished discrete updates during commit phase (#18515)
* Reproduce a bug where `flushDiscreteUpdates` causes fallback never to be committed

* Ping suspended level when canceling its timer

Make sure the suspended level is marked as pinged so that we return back
to it later, in case the render we're about to start gets aborted.
Generally we only reach this path via a ping, but we shouldn't assume
that will always be the case.

* Clear finished discrete updates during commit phase

If a root is finished at a priority lower than that of the latest pending discrete
updates on it, these updates must have been finished so we can clear them now.
Otherwise, a later call of `flushDiscreteUpdates` would start a new empty render
pass which may cause a scheduled timeout to be cancelled.

* Add TODO

Happened to find this while writing a test. A JSX element comparison
failed because one of them elements had a functional component as an
owner, which should ever happen.

I'll add a regression test later.

Co-authored-by: Andrew Clark <git@andrewclark.io>
2020-04-07 13:34:41 -07:00
Dominic Gannaway
d53a4dbbc2 Export unstable_useEvent for www FB ReactDOM builds (#18532) 2020-04-07 21:32:38 +01:00
Brian Vaughn
8edcd03b64 DevTools Profiler: Fix "cannot read property 'memoizedState' of null" (#18522) 2020-04-07 10:30:25 -07:00
Brian Vaughn
e8ac48f90b Fix whitespace problem wiht DevTools Components search (#18527) 2020-04-07 10:28:21 -07:00
Brian Vaughn
dc49ea108c Filter certain DOM attributes (e.g. src) if value is empty string (#18513)
* Filter certain DOM attributes (e.g. src, href) if their values are empty strings

This prevents e.g. <img src=""> from making an unnecessar HTTP request for certain browsers.

* Expanded warning recommendation

* Improved error message

* Further refined error message
2020-04-07 09:52:36 -07:00
Dan Abramov
bce982b799 Change stalebot messages (#18524) 2020-04-07 17:30:45 +01:00
Brian Vaughn
32621a354f Improved Profiler tooltip confusing/misleading wording (#18523) 2020-04-07 09:26:50 -07:00
Dan Abramov
e69ca310ea Revert "Refactor commitPlacement to recursively insert nodes (#17996)" (#18517)
This reverts commit df5faddcc2.
2020-04-07 13:41:51 +01:00
Luna Ruan
3278d24218 Add useOpaqueIdentifier Hook (#17322)
* Add useOpaqueIdentifier Hook

We currently use unique IDs in a lot of places. Examples are:
  * `<label for="ID">`
  * `aria-labelledby`

This can cause some issues:
  1. If we server side render and then hydrate, this could cause an
     hydration ID mismatch
  2. If we server side render one part of the page and client side
     render another part of the page, the ID for one part could be
     different than the ID for another part even though they are
     supposed to be the same
  3. If we conditionally render something with an ID ,  this might also
     cause an ID mismatch because the ID will be different on other
     parts of the page

This PR creates a new hook `useUniqueId` that generates a different
unique ID based on whether the hook was called on the server or client.
If the hook is called during hydration, it generates an opaque object
that will rerender the hook so that the IDs match.

Co-authored-by: Andrew Clark <git@andrewclark.io>
2020-04-06 17:17:27 -07:00
Sebastian Markbåge
4169420198 Refactor Component Stack Traces (#18495)
* Add feature flag

* Split stack from current fiber

You can get stack from any fiber, not just current.

* Refactor description of component frames

These should use fiber tags for switching. This also puts the relevant code
behind DEV flags.

* We no longer expose StrictMode in component stacks

They're not super useful and will go away later anyway.

* Update tests

Context is no longer part of SSR stacks. This was already the case on the
client.

forwardRef no longer is wrapped on the stack. It's still in getComponentName
but it's probably just noise in stacks. Eventually we'll remove the wrapper
so it'll go away anyway. If we use native stack frames they won't have this
extra wrapper.

It also doesn't pick up displayName from the outer wrapper. We could maybe
transfer it but this will also be fixed by removing the wrapper.

* Forward displayName onto the inner function for forwardRef and memo in DEV

This allows them to show up in stack traces.

I'm not doing this for lazy because lazy is supposed to be called on the
consuming side so you shouldn't assign it a name on that end. Especially
not one that mutates the inner.

* Use multiple instances of the fake component

We mutate the inner component for its name so we need multiple copies.
2020-04-06 15:43:39 -07:00
Dominic Gannaway
a3875663f6 React Event System: cleanup plugins + break out update batching logic (#18503) 2020-04-06 22:01:20 +01:00
dependabot[bot]
717a33abb9 Bump minimist from 1.2.0 to 1.2.3 in /scripts/bench (#18500)
Bumps [minimist](https://github.com/substack/minimist) from 1.2.0 to 1.2.3.
- [Release notes](https://github.com/substack/minimist/releases)
- [Commits](https://github.com/substack/minimist/compare/1.2.0...1.2.3)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-04-06 19:29:11 +01:00
dependabot[bot]
8c974a70c9 Bump minimist from 1.2.0 to 1.2.3 (#18501)
Bumps [minimist](https://github.com/substack/minimist) from 1.2.0 to 1.2.3.
- [Release notes](https://github.com/substack/minimist/releases)
- [Commits](https://github.com/substack/minimist/compare/1.2.0...1.2.3)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-04-06 19:28:56 +01:00
Brian Vaughn
3498f13669 Profiler tooltip shows self duration (#18510) 2020-04-06 09:47:15 -07:00
Faelivrinx
c781156163 Fix performance issue in react-devtools when highlight enabled (#18498)
* Fix performance issue in react-devtools when highlight enabled

* getting minimum expiration time (fix)
2020-04-06 16:17:45 +01:00
Sophie Alpert
fe2cb52554 [eslint] Consider useRef() as ... as constant (#18496)
Sometimes you need to use casts, eg: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/28884#issuecomment-471341041. This change ignores them and allows you to still omit the ref object from the deps list.

Test Plan: unit tests
2020-04-05 14:13:34 -07:00
Sebastian Markbåge
1fd45437d7 Don't use checkPropTypes for internals (#18488)
We use console.error for internal warnings.
2020-04-04 15:10:46 -07:00
Zen
2ff27ec112 [eslint] strip tailing property in assignments (#16784)
* [eslint] strip tailing property in assignments

* inline `stripTailingPropInAssignment`
2020-04-04 14:26:39 +01:00
Nick Reiley
f625fce857 Add KeyboardEvent.code to synthetic event (#18287)
* Add KeyboardEvent.code to synthetic event

* remove null to 0 transformation

* make onKeyPress work
2020-04-04 14:24:46 +01:00
Sebastian Markbåge
5022fdfd5f Refactor Error Dialog Logging (#18487)
* Remove unnecessary CapturedError fields.

componentName is not necessary and is misleading when the error is caused
elsewhere in the stack. The stack is sufficient.

The many error boundary fields are unnecessary because they can be inferred
by the boundary itself.

* Don't attempt to build a stack twice

If it was possible, it would've been done in createCapturedValue.

* Push the work needed by the works into the forks

This avoids needing this in the npm published case.
2020-04-03 19:01:40 -07:00
Sebastian Markbåge
e2dd30898e [Flight] Lazily parse models and allow any value to suspend (#18476)
* Lazily initialize models as they're read intead of eagerly when received

This ensures that we don't spend CPU cycles processing models that we're
not going to end up rendering.

This model will also allow us to suspend during this initialization if
data is not yet available to satisfy the model.

* Refactoring carefully to ensure bundles still compile to something optimal

* Remove generic from Response

The root model needs to be cast at one point or another same as othe
chunks. So we can parameterize the read instead of the whole Response.

* Read roots from the 0 key of the map

The special case to read the root isn't worth the field and code.

* Store response on each Chunk

Instead of storing it on the data tuple which is kind of dynamic, we store
it on each Chunk. This uses more memory. Especially compared to just making
initializeBlock a closure, but overall is simpler.

* Rename private fields to underscores

Response objects are exposed.

* Encode server components as delayed references

This allows us to stream in server components one after another over the
wire. It also allows parallelizing their fetches and resuming only the
server component instead of the whole parent block.

This doesn't yet allow us to suspend deeper while waiting on this content
because we don't have "lazy elements".
2020-04-03 14:58:02 -07:00
Sebastian Markbåge
59fd09cb67 [Flight] Add webpack plugin build (#18485)
* Eject CRA from Flight

We need to eject because we're going to add a custom Webpack Plugin.

We can undo this once the plugin has upstreamed into CRA.

* Add Webpack plugin build

I call this entry point "webpack-plugin" instead of "plugin" even though
this is a webpack specific package. That's because there will also be a
Node.js plugin to do the server transform.

* Add Flight Webpack plugin to fixture

* Rm UMD builds

* Transform classes

* Rename webpack-plugin to plugin

This avoids the double webpack name. We're going to reuse this for both
server and client.
2020-04-03 14:04:56 -07:00
Luna Ruan
a876808f0a remove jsx plugin from react (#18484)
Now that the React JSX Babel Plugin is in Babel, remove this code from react
2020-04-03 13:00:50 -07:00
Hristo Kanchev
7785a5263e [DevTools] - Highlight rendered by elements on hover. (#18479)
* [DevTools] - Highlight rendered by elements on hover.

* Fixed formatting issue.

* DevTools - Extracted highlight logic to custom hook. Added highlight support for rendered by elements.

* Removed unnecessary padding style

* Removed unnecessary wrapper function.

Co-authored-by: Brian Vaughn <brian.david.vaughn@gmail.com>
2020-04-03 10:49:49 -07:00
Brian Vaughn
f312a3fc36 useMutableSource: bugfix for new getSnapshot with mutation (#18297) 2020-04-03 10:20:17 -07:00
Dan Abramov
a8f2165e83 Update to Jest 25 (#18480)
* Revert "Revert "Upgrade to jest 25 (#17896)" (#18376)"

This reverts commit fc7835c657.

* Other fixes

* Fix a broken test
2020-04-03 16:37:36 +01:00
Nick Reiley
c083a643b1 Add <progress> to DOM fixtures (#18293)
* Add <progress> to DOM fixtures

* Remove uncontrolled
2020-04-03 14:39:59 +01:00
Sebastian Markbåge
3c16baf848 Remove /dist/ UMD builds (#18473)
* Remove /dist/ UMD builds

We publish UMDs to npm (and we're considering stopping even that).

This means we'll stop publishing to http://react.zpao.com/builds/master/latest/

* Update fixture paths
2020-04-02 17:52:32 -07:00
Dominic Gannaway
91c9d69f9a Modern Event System: Remove TestUtils.SimulateNative support (#18471) 2020-04-03 00:12:47 +01:00
Dan Abramov
e55855e7ae Deprecate TestUtils.SimulateNative (#13407) 2020-04-02 23:48:03 +01:00
Brian Vaughn
4123d729e5 Revert "Revert: Enable new passive effect behavior for FB builds (#18467)" (#18468)
This reverts commit 3966081cf2.
2020-04-02 15:24:36 -07:00
Dominic Gannaway
8815e4cc72 Cleanup getListener and EventSystemFlags (#18469) 2020-04-02 23:17:10 +01:00
Dominic Gannaway
5e464546af ReactDOM.useEvent: fix scope propagation issue (#18464) 2020-04-02 18:26:56 +01:00
Dominic Gannaway
d5e4b3ae1d Modern Event System: refine flags and handling of enableLegacyFBSupport (#18466) 2020-04-02 18:26:34 +01:00
Dominic Gannaway
3966081cf2 Revert: Enable new passive effect behavior for FB builds (#18467) 2020-04-02 16:25:35 +01:00
Dan Abramov
7dfdff42af Run more flags in VARIANT tests (#18461)
* Run more flags in VARIANT tests

* Revert enabling modern system

* Fix
2020-04-02 16:19:09 +01:00
Dan Abramov
31734540dc Remove a flag for style collision warning (#18462) 2020-04-02 11:55:17 +01:00
Dominic Gannaway
663c13d71d Refactor Enter/Leave listener accumulation (#18405)
* Refactor Enter/Leave listener accumulation
2020-04-02 11:07:20 +01:00
Dan Abramov
c80cd8ee27 Revert "Fix email cursor jump (#18379)" (#18459)
* Revert "Fix email cursor jump (#18379)"

This reverts commit 9b88b78b3d.

* Leave fixtures be
2020-04-01 22:44:59 +01:00
Andrew Clark
58afba0663 Fix: Don't read primaryChild.childExpirationTime (#18457)
This is a variant of the fix in 5a0f1d. We can't rely on the primary
fiber's `childExpirationTime` field to be correct.

In this case, we can read from the Suspense boundary fiber instead.
This will include updates that exist in the fallback fiber, but that's
not a big deal; the important thing is that we don't drop updates.
2020-04-01 14:36:42 -07:00
Brian Vaughn
2ea7c60794 Fixed race condition in release script (#18456) 2020-04-01 14:17:55 -07:00
Dan Abramov
99d779f629 Don't close "Needs Investigation" issues (#18458) 2020-04-01 22:08:09 +01:00
Gabriel McAdams
3f46844899 [eslint-plugin-react-hooks] Added meta property (including docs) (#16607)
* [eslint-plugin-react-hooks] Added meta property (including docs)

* [eslint-plugin-react-hooks] Fixed typo (`RuleOfHooks` -> `RulesOfHooks`)

Co-authored-by: Dan Abramov <dan.abramov@gmail.com>
2020-04-01 21:13:10 +01:00
Dan Abramov
2bf60d9f9c Fix ESLint rule crash (#18455) 2020-04-01 20:54:42 +01:00
Sebastian Markbåge
3e94bce765 Enable prefer-const lint rules (#18451)
* Enable prefer-const rule

Stylistically I don't like this but Closure Compiler takes advantage of
this information.

* Auto-fix lints

* Manually fix the remaining callsites
2020-04-01 12:35:52 -07:00
Sebastian Markbåge
e6ea3d3873 Use Closure Compiler to compile to ES5 instead of Babel (#18449)
* Upgrade Closure

There are newer versions but they don't yet have corresponding releases
of google-closure-compiler-osx.

* Configure build

* Refactor ReactSymbols a bit

Provides a little better output.
2020-04-01 12:08:37 -07:00
Utkarsh Kukreti
5200547100 Do not warn when a controlled input has onInput handler. (#18189)
`onInput` behaves the same as `onChange` for controlled inputs as far as I
know, so React should not print the following warning when `onInput` is
present.

> Failed prop type: You provided a `value` prop to a form field without an `onChange` handler. This will render a read-only field. If the field should be mutable use `defaultValue`. Otherwise, set either `onChange` or `readOnly`.
2020-04-01 19:58:07 +01:00
Sebastian Silbermann
7516bdfce3 feat(createContext): Include displayName in warning (#18386) 2020-04-01 19:42:38 +01:00
Nick Reiley
9b88b78b3d Fix email cursor jump (#18379)
* add email input fixture to show cursor jump

* fix cursor jump in email input

Co-authored-by: Peter Potapov <dr.potapoff-peter@yandex.ru>

* add regression tests to ensure attributes are working

Co-authored-by: Peter Potapov <dr.potapoff-peter@yandex.ru>
2020-04-01 19:30:26 +01:00
Brian Vaughn
5ee0efe832 Remove state update warning for passive effect cleanup functions (#18453) 2020-04-01 10:49:24 -07:00
Dan Abramov
d8d2b6e89c Disable module components dynamically for WWW (#18446)
* Make disableModulePatternComponents dynamic for WWW

* Run both flags and tests and respect the flag in SSR
2020-04-01 18:31:59 +01:00
Sebastian Markbåge
e2c6702fca Remove ConcurrentMode and AsyncMode symbols (#18450)
This API was never released.
2020-04-01 10:18:52 -07:00
Dominic Gannaway
d6d5f5aabe Move accumulateEventTargetListeners to its own module/function (#18407) 2020-04-01 14:19:21 +01:00
Dominic Gannaway
dc3c6c9565 ReactDOM.useEvent: revert and add guard for null stateNode (#18441) 2020-04-01 12:45:26 +01:00
Sebastian Markbåge
0f334553c9 Reset stateNode in resetWorkInProgress (#18448)
* test(SuspenseList): Add failing test for class component

* Reset stateNode when resetWorkInProgress

This is supposed to put the Fiber into the same state as if it was just
created by child fiber reconciliation. For newly created fibers, that means
that stateNode is null.

Co-authored-by: Sebastian Silbermann <silbermann.sebastian@gmail.com>
2020-03-31 21:14:59 -07:00
Brian Vaughn
153b5c305d Cleanup previous shims directories before re-copying (#18447) 2020-03-31 12:22:02 -07:00
Brian Vaughn
4de3a60325 Remove disableMapsAsChildren flag (#18445)
Change warning to say the case is unsupported (not "will be deprecated")
2020-03-31 11:00:51 -07:00
Brian Vaughn
f4cc970276 Enable new passive effect behavior for FB builds (#18444)
* Enable new passive effect behavior for FB builds

Previously this behavior was controlled by GKs. This PR updates the flags to be enabled statically. It also enables the flags in the test builds.
2020-03-31 10:05:15 -07:00
Dan Abramov
9065e02d66 Fix a warning typo (#18443) 2020-03-31 15:55:30 +01:00
Dan Abramov
1960131f11 Add opt-in support for dangerous autofix (#18437) 2020-03-31 11:43:01 +01:00
Andrew Clark
90e90ac8e0 Revert useEvent PRs (#18438)
* Revert "ReactDOM.useEvent: enable on internal www and add inspection test (#18395)"

This reverts commit e0ab1a429d.

* Revert "ReactDOM.useEvent: Add support for experimental scopes API (#18375)"

This reverts commit a16b349745.

* ReactDOM.useEvent: Add support for experimental scopes API
2020-03-30 19:16:28 -07:00
Dan Abramov
da54641a10 [ESLint] Check deps when callback body is outside the Hook call, too (#18435)
* Refactor: visit CallExpression

Instead of visiting the functions and looking up to see if they're in a Hook call, visit Hook calls and look down to see if there's a callback inside. I will need this refactor so I can visit functions declared outside the call.

* Check deps when callback body is outside the Hook call

* Handle the unknown case
2020-03-31 02:09:32 +01:00
Dan Abramov
bf30e370a5 Remove User Timings (#18417) 2020-03-31 00:29:53 +01:00
Ricky
dd7e5e4f5a Add getInspectorDataForViewAtPoint (take two) (#18388)
* Add getInspectorDataForViewAtPoint (take two)

* Updates from review

* Add DEV to dev-only variable

* Missed this rename
2020-03-30 15:42:41 -04:00
Andrew Clark
d7382b6c43 Bugfix: Do not unhide a suspended tree without finishing the suspended update (#18411)
* Bugfix: Suspended update must finish to unhide

When we commit a fallback, we cannot unhide the content without including
the level that originally suspended. That's because the work at level
outside the boundary (i.e. everything that wasn't hidden during that
render) already committed.

* Test unblocking with a high-pri update
2020-03-30 11:25:04 -07:00
Dan Abramov
1f8c40451a Make interaction tracing on by default in all WWW builds (#18419) 2020-03-30 16:07:58 +01:00
Sebastian Silbermann
ba31ad40a9 feat(StrictMode): Double-invoke render for every component (#18430)
* feat(StrictMode): Double-invoke render for every component

* fix: Mark ReactTestRendererAsync as internal
2020-03-29 23:13:46 +01:00
Sebastian Markbåge
689d27586e Reset lastEffect when resuming SuspenseList (#18412)
We store an effect pointer so we can backtrack in the effect list in some
cases. This is a stateful variable. If we interrupt a render we need to
reset it.

This field was added after the optimization was added and I didn't remember
to reset it here.

Otherwise we end up not resetting the firstEffect so it points to a stale
list. As a result children don't end up inserted like we think they were.
Then we try to remove them it errors.

It would be nicer to just get rid of the effect list and use the tree for
effects instead. Maybe we still need something for deletions tho.
2020-03-29 10:13:17 -07:00
Rodrigo Graça
1af2a10891 https link to editorconfig.org (#18421) 2020-03-29 15:18:52 +01:00
zefeng
d7918f4a9b chore: npm link more directly (#18428) 2020-03-29 15:18:15 +01:00
Brian Vaughn
be4c8b19c1 Don't show destroy function state update warning when updating ancestors (#18409)
React can't directly detect a memory leak, but there are some clues that warn about one. One of these clues is when an unmounted React component tries to update its state. For example, if a component forgets to remove an event listener when unmounting, that listener may be called later and try to update state, at which point React would warn about the potential leak.

Warning signals like this are more useful if they're strong. For this reason, it's good to always avoid updating state from inside of an effect's cleanup function. Even when you know there is no potential leak, React has no way to know and so it will warn anyway.

In most cases we suggest moving state updates to the useEffect() body instead (to avoid triggering the warning). This works so long as the component is updating its own state (or the state of a descendant). However this will not work when a component updates its parent state in a cleanup function. If such a component is unmounted but its parent remains mounted, the state will be incorrect. For this reason, we now avoid showing the warning if a component is updating an ancestor.
2020-03-28 10:18:14 -07:00
Andrew Clark
35a2f74974 Delete leftover assignment from #18384
This assignment should have been deleted in #18384. It was deleted in
the other branches, but I missed this one. About to open a PR that
includes a test that covers this branch.
2020-03-27 15:17:30 -07:00
Andrew Clark
9d67847f7b [Bugfix] Dropped updates inside a suspended tree (#18384)
* Minor test refactor: `resolveText`

Adds a `resolveText` method as an alternative to using timers. Also
removes dependency on react-cache (for just this one test file; can do
the others later).

Timer option is still there if you provide a `ms` prop.

* Bugfix: Dropped updates in suspended tree

When there are multiple updates at different priority levels inside
a suspended subtree, all but the highest priority one is dropped after
the highest one suspends.

We do have tests that cover this for updates that originate outside of
the Suspense boundary, but not for updates that originate inside.

I'm surprised it's taken us this long to find this issue, but it makes
sense in that transition updates usually originate outside the boundary
or "seam" of the part of the UI that is transitioning.

* Bugfix: Suspense fragment skipped by setState

Fixes a bug where updates inside a suspended tree are dropped because
the fragment fiber we insert to wrap the hidden children is not part of
the return path, so it doesn't get marked during setState.

As a workaround, I recompute `childExpirationTime` right before deciding
to bail out by bubbling it up from the next level of children.

This is something we should consider addressing when we refactor the
Fiber data structure.

* Add back `lastPendingTime` field

This reverts commit 9a541139dfe36e8b9b02b1c6585889e2abf97389.

I want to use this so we can check if there might be any lower priority
updates in a suspended tree.

We can remove it again during the expiration times refactor.

* Use `lastPendingTime` instead of Idle

We don't currently have an mechanism to check if there are lower
priority updates in a subtree, but we can check if there are any in the
whole root. This still isn't perfect but it's better than using Idle,
which frequently leads to redundant re-renders.

When we refactor `expirationTime` to be a bitmask, this will no longer
be necessary because we'll know exactly which "task bits" remain.

* Add a test for updating the fallback
2020-03-26 11:31:40 -07:00
Dan Abramov
5bd1bc29b3 eslint-plugin-react-hooks@3.0.0 2020-03-26 17:59:25 +00:00
Dominic Gannaway
e0ab1a429d ReactDOM.useEvent: enable on internal www and add inspection test (#18395) 2020-03-26 17:13:05 +00:00
Brian Vaughn
6cceaeb67a DevTools v4.5.0 -> 4.6.0 2020-03-26 10:00:37 -07:00
Brian Vaughn
d92631eab1 Remove "es6-symbol" package from DevTools (#18397) 2020-03-26 09:31:36 -07:00
Dominic Gannaway
a16b349745 ReactDOM.useEvent: Add support for experimental scopes API (#18375)
* ReactDOM.useEvent: Add support for experimental scopes API
2020-03-26 13:29:54 +00:00
Sebastian Markbåge
dbb060d561 Pass BundlerConfig through to Relay Integration (#18393)
I wasn't sure we needed this but looks like it'll come in handy.
2020-03-25 20:25:54 -07:00
Sebastian Markbåge
ce6fe50b01 Add server-runtime to create Server Blocks (#18392)
This is equivalent to the jsx-runtime in that this is what the compiled
output on the server is supposed to target.

It's really just the same code for all the different Flights, but they
have different types in their arguments so each one gets their own entry
point. We might use this to add runtime warnings per entry point.

Unlike the client-side React.block call this doesn't provide the factory
function that curries the load function. The compiler is expected to wrap
this call in the currying factory.
2020-03-25 19:03:31 -07:00
Sebastian Markbåge
64ed221c3d Formalize the Wakeable and Thenable types (#18391)
* Formalize the Wakeable and Thenable types

We use two subsets of Promises throughout React APIs. This introduces
the smallest subset - Wakeable. It's the thing that you can throw to
suspend. It's something that can ping.

I also use a shared type for Thenable in the cases where we expect a value
so we can be a bit more rigid with our us of them.

* Make Chunks into Wakeables instead of using native Promises

This value is just going from here to React so we can keep it a lighter
abstraction throughout.

* Renamed thenable to wakeable in variable names
2020-03-25 16:49:37 -07:00
Sebastian Markbåge
a6924d77b1 Change .model getter to .readRoot method (#18382)
Originally the idea was to hide all suspending behind getters or proxies.
However, this has some issues with perf on hot code like React elements.

It also makes it too easy to accidentally access it the first time in an
effect or callback where things aren't allowed to suspend. Making it
an explicit method call avoids this issue.

All other suspending has moved to explicit lazy blocks (and soon elements).
The only thing remaining is the root. We could require the root to be an
element or block but that creates an unfortunate indirection unnecessarily.

Instead, I expose a readRoot method on the response. Typically we try to
avoid virtual dispatch but in this case, it's meant that you build
abstractions on top of a Flight response so passing it a round is useful.
2020-03-25 11:47:55 -07:00
Brian Vaughn
bd5781962a Inlined DevTools event emitter impl (#18378)
DevTools previously used the NPM events package for dispatching events. This package has an unfortunate flaw though- if a listener throws during event dispatch, no subsequent listeners are called. I've replaced that event dispatcher with my own implementation that ensures all listeners are called before it re-throws an error.

This commit replaces that event emitter with a custom implementation that calls all listeners before re-throwing an error.
2020-03-25 10:26:40 -07:00
Dan Abramov
6498f62edc Fix a mistake in ReactChildren refactor (#18380)
* Regression test for map() returning an array

* Add forgotten argument

This fixes the bug.

* Remove unused arg and retval

These aren't directly observable. The arg wasn't used, it's accidental and I forgot to remove. The retval was triggering a codepath that was unnecessary (pushing to array) so I removed that too.

* Flowify ReactChildren

* Tighten up types

* Rename getComponentKey to getElementKey
2020-03-25 09:20:46 +00:00
Dan Abramov
2ba43edc26 Rename internal fields (#18377) 2020-03-24 18:19:20 +00:00
Sebastian Markbåge
a317bd033f Flip the arguments of Blocks and make the query optional (#18374)
* Flip the arguments of Blocks and make the query optional

* Rename Query to Load
2020-03-24 10:58:23 -07:00
Andrew Clark
fc7835c657 Revert "Upgrade to jest 25 (#17896)" (#18376)
This reverts commit cf0081263c.

The changes to the test code relate to changes in JSDOM that come with Jest 25:

* Several JSDOM workarounds are no longer needed.
* Several tests made assertions to match incorrect JSDOM behavior (e.g. setAttribute calls) that JSDOM has now patched to match browsers.
  * https://codesandbox.io/s/resets-value-of-datetime-input-to-fix-bugs-in-ios-safari-1ppwh
* JSDOM no longer triggers default actions when dispatching click events.
  * https://codesandbox.io/s/beautiful-cdn-ugn8f
* JSDOM fixed (jsdom/jsdom#2700) a bug so that calling focus() on an already focused element does not dispatch a FocusEvent.
* JSDOM now supports passive events.
* JSDOM has improved support for custom CSS properties.
  * But requires jsdom/cssstyle#112 to land to support webkit prefixed properties.
2020-03-24 10:51:48 -07:00
Dominic Gannaway
0140118e8e ReactDOM.useEvent: add support for beforeblur/afterblur (#18370)
* ReactDOM.useEvent: add support for beforeblur/afterblur
2020-03-24 16:14:55 +00:00
Sebastian Markbåge
a56309fb88 [Flight] Integrate Blocks into Flight (#18371)
* Resolve Server-side Blocks instead of Components

React elements should no longer be used to extract arbitrary data but only
for prerendering trees.

Blocks are used to create asynchronous behavior.

* Resolve Blocks in the Client

* Tests

* Bug fix relay JSON traversal

It's supposed to pass the original object and not the new one.

* Lint

* Move Noop Module Test Helpers to top level entry points

This module has shared state. It needs to be external from builds.

This lets us test the built versions of the Noop renderer.
2020-03-23 17:53:45 -07:00
Dan Abramov
fc96a52be3 Refactor React.Children to reduce indirection (#18332)
* Don't pool traversal context

* Remove traverseAllChildrenImpl indirection

All usages are internal so we can simply use the inner function directly.

* Implement forEach through map

* Remove second usage of traverseAllChildren

This isn't useful by itself but makes the layering easier to follow. traverseAllChildren is only used at the lowest layer now.

* Reimplement count() and toArray() in terms of map()

* Inline the only use of mapSingleChildIntoContext

* Move forEach down in the file

* Use the language

Get rid of the traversal context. Use closures.

* Make mapIntoArray take an already escaped prefix

* Move count state out of mapIntoArray

* Inline traverseAllChildren into mapIntoArray

* Inline handleChild into mapIntoArray
2020-03-23 22:56:00 +00:00
Sebastian Markbåge
fd61f7ea53 Refactor Lazy Components to use teh Suspense (and wrap Blocks in Lazy) (#18362)
* Refactor Lazy Components

* Switch Blocks to using a Lazy component wrapper

Then resolve to a true Block inside.

* Test component names of lazy Blocks
2020-03-22 21:53:05 -07:00
Mohammad Aziz
31a9e391f7 Remove unnecessary lines for hasBadMapPolyfill issue for rollup (#16231) 2020-03-22 14:52:59 +00:00
Sebastian Markbåge
c0cd1be908 [Flight] Move bundler configs to use Suspense instead of returning thenable (#18367)
* Move bundler configs to use suspense instead of returning thenable

* Fix some Flow types
2020-03-21 22:28:36 -07:00
Sebastian Markbåge
4b7f8496a8 Rename CI jobs after the command line equivalent (#18364)
This makes it easier to know what to write on your command line to replicate
a failure locally.
2020-03-21 16:02:01 -07:00
Sebastian Markbåge
b779dd51e8 Stop syncing ReactTypes to RN (#18366)
This is a really old one and all callers have since been codemodded away
anyway because of problems.

This file is not really as rigorously maintained as the official Flow types
but has a few more specifics. However, the inconsistency causes problems
when you try to pass files typed using the built-in Flow typing for React
and mix it with these.

We just happen to get away with it because we compile out the types. If we
didn't we would hit those problems by even using these in our renderers.
2020-03-21 15:22:40 -07:00
Sebastian Markbåge
c5d2fc7127 Move some files out of /shared and rename to upper case (#18363)
* Rename lower case isomorphic default exports modules to upper case named exports

We're somewhat inconsistent here between e.g. ReactLazy and memo.

Let's pick one.

This also moves the responder, fundamental, scope creators from shared
since they're isomorphic and same as the other creators.

* Move some files that are specific to the react-reconciler from shared

Individual renderers are allowed to deep require into the reconciler.

* Move files specific to react-dom from shared

react-interactions is right now dom specific (it wasn't before) so we can
type check it together with other dom stuff. Avoids the need for
a shared ReactDOMTypes to be checked by RN for example.

* Move ReactWorkTags to the reconciler

* Move createPortal to export from reconciler

Otherwise Noop can't access it since it's not allowed deep requires.
2020-03-21 15:22:01 -07:00
Dominic Gannaway
a600408b28 ReactDOM.useEvent: add EventTarget support (#18355)
* ReactDOM.useEvent: add support for all EventTarget types
2020-03-20 18:31:47 +00:00
Dominic Gannaway
dbd85a08d9 ReactDOM.useEvent: support custom types (#18351)
* ReactDOM.useEvent: support custom types
2020-03-20 14:45:33 +00:00
Luna Ruan
7c1478680f fix string ref cannot be auto converted warning for React.jsxDEV (#18354)
The string ref cannot be auto converted warning was using the wrong _self. This diff fixes this so it is now using the correct __self
2020-03-19 23:47:53 -07:00
Andrew Clark
f198872716 Empty commit to fix master.
I accidentally did that thing again where I updated a PR branch to
be the same as the tip of master, which confused GitHub and caused it
to run PR checks against master.
2020-03-19 17:53:09 -07:00
Sebastian Markbåge
fc91508c1f Follow ups to bundler configs (#18352)
Follow ups from https://github.com/facebook/react/pull/18334

I also introduced the concept of a module reference on the client too.
We don't need this for webpack so that gets compiled out but we need it
for www. Similarly I also need a difference between preload and load.
2020-03-19 17:49:40 -07:00
Andrew Clark
31e6756b8c Remove error code step from publish script (#18350)
Error codes don't need to be pulled from CI anymore because the ones
in source are already expected to match the build output.

I noticed this when running the 16.13.1 release. Patch releases are cut
with the commit used to build the previous release as a base. So the
publish script accidentally reverted the changes that had landed to
the error codes file since then.
2020-03-19 14:45:07 -07:00
Dominic Gannaway
9e7f334c71 ModernEventSystem: fix event replaying (#18346)
* ModernEventSystem: fix event replaying
2020-03-19 20:44:38 +00:00
Dominic Gannaway
ffefb4e77f ModernEventSystem: refine Flow types (#18349) 2020-03-19 20:25:52 +00:00
Andrew Clark
6818a2aa01 Revert accidental changes to package.json (#18348)
The publish script was written before we switched to running patch
releases out-of-band, so when updating the local package.json version
numbers, it accidentally reverted other changes that have landed to
master since 16.13 was released.
2020-03-19 13:16:37 -07:00
Andrew Clark
ad445b127e Update package.jsons for 16.13.1 patch relase 2020-03-19 12:58:31 -07:00
Andrew Clark
8b48d52fb4 Changelog for 16.13.1 2020-03-19 12:36:34 -07:00
Dominic Gannaway
8311cb5d24 Modern Event System: refactor legacy FB support logic (#18336) 2020-03-19 13:22:36 +00:00
Dan Abramov
1cf4a170ac Stop exposing ReactDOMComponentTree from FB builds (#18338) 2020-03-18 20:35:58 +00:00
Ian Obermiller
d3368beeec [eslint-plugin-react-hooks] Disallow hooks in class components (#18341)
Per discussion at Facebook, we think hooks have reached a tipping point where it is more valuable to lint against potential hooks in classes than to worry about false positives.

Test plan:
```
# run from repo root
yarn test --watch RuleOfHooks
```
2020-03-18 19:55:13 +00:00
Sebastian Markbåge
8206b4b864 Wire up bundler configs (#18334)
This allows different flight server and clients to have different configs
depending on bundler to serialize and resolve modules.
2020-03-18 12:18:34 -07:00
Kerollos Magdy
6b7281ec14 [DevTools] Add shortcut keys for tab switching (#18248)
* [DevTools] Add shortcut keys for tab switching
* Use LocalStorage to remember most recently selected tab

Resolves #18227 and #18226

Co-authored-by: Brian Vaughn <brian.david.vaughn@gmail.com>
2020-03-18 11:05:41 -07:00
ItsByteMe
5152c4a9fd Fixed inconcistency with surrounding punctuation (#18339)
There was an inconsistency present on line 99 regarding the punctuation of the comment, all other comments found end in a period and this line had it's period omitted.
2020-03-18 17:10:32 +00:00
Sebastian Markbåge
94505b9613 Don't use EventListener Fork in Modern WWW Builds (#18333)
* Move unsubscribe fork to EventListener

That way we can statically compile out more of these indirections.

* Don't use the EventListener fork for Modern WWW builds
2020-03-18 13:13:50 +00:00
Luna Ruan
aae83a4b9a Fix UMD Builds (ReactSharedInternals)
ReactCurrentBatchConfig.suspense does not exist in ReactSharedInternals.umd. This PR adds it.
2020-03-17 17:56:14 -07:00
Dominic Gannaway
7d466bcc25 React Event System: Refactor ElementListenerMap for upgrading (#18308) 2020-03-18 00:15:50 +00:00
Dan Abramov
fe1f79b95b Don't fire the render phase update warning for class lifecycles (#18330)
* Change the warning to not say "function body"

This warning is more generic and may happen with class components too.

* Dedupe by the rendering component

* Don't warn outside of render
2020-03-18 00:07:14 +00:00
Sebastian Silbermann
22cab1cbd6 test(getComponentName): Increase test coverage (#18149)
Co-authored-by: Brian Vaughn <brian.david.vaughn@gmail.com>
2020-03-17 14:47:24 -07:00
Sebastian Silbermann
756e1ea5d4 fix(react-devtools-shared): useDebugValue with complex types (#18070)
Co-authored-by: Brian Vaughn <brian.david.vaughn@gmail.com>
2020-03-17 13:57:01 -07:00
Luna Ruan
90f8fe6f55 add jsx-runtime and jsx-dev-runtime (#18299)
This PR adds the jsx-runtime and jsx-dev-runtime modules for the JSX Babel Plugin. WWW still relies on jsx/jsxs/jsxDEV from the "react" module, so once we refactor the code to point to the runtime modules we will remove jsx/jsxs/jsxDEV from the "react" module.
2020-03-17 13:22:19 -07:00
Dan Abramov
26666427d6 Don't support older isomorphic React with newer renderers (#18329)
* Don't support older isomorphic React with newer renderers

* Remove the lazy hack
2020-03-17 19:30:10 +00:00
Dominic Gannaway
3a0076e0e8 useEvent: Small tweaks and changes (#18328) 2020-03-17 15:32:26 +00:00
Minh Nguyen
9240918536 Bump react-shallow-renderer to 16.13.1 (#18187) 2020-03-17 00:35:28 +00:00
Dominic Gannaway
c804f9aebb ReactDOM.useEvent: wire to event system to the hook (#18304) 2020-03-16 21:46:17 +00:00
Brian Vaughn
297f7588c4 Moved passive effects flag to be beside execution context (#18322) 2020-03-16 10:27:42 -07:00
Jovi De Croock
95df39b6b1 improve error message for cross-functional component updates (#18316)
* improve error message for cross-functional component updates

* correctly use %s by quoting it

* use workInProgress and lint

* add test assertion

* fix test

* Improve the error message

Co-authored-by: Dan Abramov <dan.abramov@me.com>
2020-03-16 17:05:30 +00:00
Brian Vaughn
c0ed0a2468 Replace passive effect context with boolean (#18309) 2020-03-16 09:56:43 -07:00
Brian Vaughn
730389b9d3 Warn against state updates from useEffect destroy functions (#18307)
Don't warn about unmounted state updates from within passive destroy function

* Fixed test conditional. (It broke after recent variant refactor.)
* Changed warning wording for setState from within useEffect destroy callback
2020-03-13 15:33:50 -07:00
Dominic Gannaway
0705b7282f Refine event system types + pass through priority (#18305) 2020-03-13 17:57:17 +00:00
Dominic Gannaway
45d26f6edb Remove un-used function arg (#18303) 2020-03-13 14:16:12 +00:00
Dan Abramov
73ff8b9094 Run ReactElementJSX-test against bundles (#18301)
* Run ReactElementJSX-test against bundles

* Try the new thing
2020-03-13 12:07:22 +00:00
Andrew Clark
8c015e0e14 Revert "Move MS Windows build to CircleCI (#17984)" (#18302)
This reverts commit 885ed46909.
2020-03-12 20:57:13 -07:00
wittgenst
885ed46909 Move MS Windows build to CircleCI (#17984)
* Move MS Windows build to CircleCI

* Update to latest NodeJS

Co-authored-by: Chris Lüer <lueer@fb.com>
2020-03-12 17:15:30 -07:00
Dominic Gannaway
2a7cd58956 ReactDOM.useEvent: Add DOM host event listener logic (#18292) 2020-03-12 22:41:33 +00:00
Dominic Gannaway
d3ec42020d Address feedback for accumulateTwoPhaseListeners (#18289) 2020-03-12 21:48:29 +00:00
Andrew Clark
cd48a06547 Set up infra for react-reconciler fork (#18285)
* ReactFiberReconciler -> ReactFiberReconciler.old

* Set up infra for react-reconciler fork

We're planning to land some significant refactors of the reconciler.
We want to be able to gradually roll out the new implementation side-by-
side with the existing one. So we'll create a short lived fork of the
react-reconciler package. Once the new implementation has stabilized,
we'll delete the old implementation and promote the new one.

This means, for as long as the fork exists, we'll need to maintain two
separate implementations. This sounds painful, but since the forks will
still be largely the same, most changes will not require two separate
implementations. In practice, you'll implement the change in the old
fork and then copy paste it to the new one.

This commit only sets up the build and testing infrastructure. It does
not actually fork any modules. I'll do that in subsequent PRs.

The forked version of the reconciler will be used to build a special
version of React DOM. I've called this build ReactDOMForked. It's only
built for www; there's no open source version.

The new reconciler is disabled by default. It's enabled in the
`yarn test-www-variant` command. The reconciler fork isn't really
related to the "variant" feature of the www builds, but I'm piggy
backing on that concept to avoid having to add yet another
testing dimension.
2020-03-12 11:38:32 -07:00
Andrew Clark
615df434bb Remove manual feature flag overrides (#18291)
Tests now run against both versions of these flags, using the
test-www-variant command. So we can remove the manual overrides.
2020-03-12 10:17:02 -07:00
Dominic Gannaway
99d271228d ReactDOM.useEvent: more scaffolding changes (#18282) 2020-03-12 09:12:06 +00:00
Brian Vaughn
97a8c72bf8 Wrap Components and Profiler tabs with box-size style too (#18286)
For the browser extension, these views get rendered into portals and so they don't inherit the box-sizing style from the .DevTools wrapper element. This causes views like the Profiler commit selector to subtly break.
2020-03-11 19:12:57 -07:00
Andrew Clark
5374919033 Empty commit to fix CI on master
Weird GitHub bug caused CI jobs to run against master as if it was
a PR. Now it looks like master is failing, even though it isn't.

Bloop.
2020-03-11 18:29:46 -07:00
Dominic Gannaway
8b155d2613 Flow type ReactDOMComponentTree (#18280) 2020-03-11 19:38:23 +00:00
Brian Vaughn
322cdcd3ab useMutableSource hook (#18000)
useMutableSource hook

useMutableSource() enables React components to safely and efficiently read from a mutable external source in Concurrent Mode. The API will detect mutations that occur during a render to avoid tearing and it will automatically schedule updates when the source is mutated.

RFC: reactjs/rfcs#147
2020-03-11 12:34:39 -07:00
Dominic Gannaway
30a998debf ModernEventSystem: refactor accumulateTwoPhaseListeners (#18274) 2020-03-11 18:55:01 +00:00
Andrew Clark
8fe066fdac Bugfix: "Captured" updates on legacy queue (#18265)
* Bugfix: "Captured" updates on legacy queue

This fixes a bug with error boundaries. Error boundaries have a notion
of "captured" updates that represent errors that are thrown in its
subtree during the render phase. These updates are meant to be dropped
if the render is aborted.

The bug happens when there's a concurrent update (an update from an
interleaved event) in between when the error is thrown and when the
error boundary does its second pass. The concurrent update is
transferred from the pending queue onto the base queue. Usually, at this
point the base queue is the same as the current queue. So when we
append the pending updates to the work-in-progress queue, it also
appends to the current queue.

However, in the case of an error boundary's second pass, the base queue
has already forked from the current queue; it includes both the
"captured" updates and any concurrent updates. In that case, what we
need to do is append separately to both queues. Which we weren't doing.

That isn't the full story, though. You would expect that this mistake
would manifest as dropping the interleaved updates. But instead what
was happening is that the "captured" updates, the ones that are meant
to be dropped if the render is aborted, were being added to the
current queue.

The reason is that the `baseQueue` structure is a circular linked list.
The motivation for this was to save memory; instead of separate `first`
and `last` pointers, you only need to point to `last`.

But this approach does not work with structural sharing. So what was
happening is that the captured updates were accidentally being added
to the current queue because of the circular link.

To fix this, I changed the `baseQueue` from a circular linked list to a
singly-linked list so that we can take advantage of structural sharing.

The "pending" queue, however, remains a circular list because it doesn't
need to be persistent.

This bug also affects the root fiber, which uses the same update queue
implementation and also acts like an error boundary.

It does not affect the hook update queue because they do not have any
notion of "captured" updates. So I've left it alone for now. However,
when we implement resuming, we will have to account for the same issue.

* Ensure base queue is a clone

When an error boundary captures an error, we append the error update
to the work-in-progress queue only so that if the render is aborted,
the error update is dropped.

Before appending to the queue, we need to make sure the queue is a
work-in-progress copy. Usually we clone the queue during
`processUpdateQueue`; however, if the base queue has lower priority
than the current render, we may have bailed out on the boundary fiber
without ever entering `processUpdateQueue`. So we need to lazily clone
the queue.

* Add warning to protect against refactor hazard

The hook queue does not have resuming or "captured" updates, but if
we ever add them in the future, we'll need to make sure we check if the
queue is forked before transfering the pending updates to them.
2020-03-11 11:53:45 -07:00
Sebastian Markbåge
b5c6dd2de5 Don't use Spread in DevTools Injection (#18277) 2020-03-11 10:58:25 -07:00
Sebastian Markbage
a463fef31b Revert "[React Native] Add getInspectorDataForViewAtPoint (#18233)"
This reverts commit bf351089a0.
2020-03-11 10:05:26 -07:00
Sebastian Markbåge
dc7eedae3c Encode server rendered host components as array tuples (#18273)
This replaces the HTML renderer with instead resolving host elements into
arrays tagged with the react.element symbol. These turn into proper
React Elements on the client.

The symbol is encoded as the magical value "$". This has security implications
so this special value needs to remain escaped for other strings.

We could just encode the element as {$$typeof: "$", key: key props: props}
but that's a lot more bytes. So instead I encode it as:
["$", key, props] and then convert it back.

It would be nicer if React's reconciler could just accept these tuples.
2020-03-11 09:48:02 -07:00
Ricky
bf351089a0 [React Native] Add getInspectorDataForViewAtPoint (#18233) 2020-03-11 16:12:41 +00:00
Sebastian Markbåge
99d7371863 [Flight] Split Streaming from Relay Implemenation (#18260)
* Add ReactFlightServerConfig intermediate

This just forwards to the stream version of Flight which is itself forked
between Node and W3C streams.

The dom-relay goes directly to the Relay config though which allows it to
avoid the stream part of Flight.

* Separate streaming protocol into the Stream config

* Split streaming parts into the ReactFlightServerConfigStream

This decouples it so that the Relay implementation doesn't have to encode
the JSON to strings. Instead it can be fed the values as JSON objects and
do its own encoding.

* Split FlightClient into a basic part and a stream part

Same split as the server.

* Expose lower level async hooks to Relay

This requires an external helper file that we'll wire up internally.
2020-03-10 14:55:04 -07:00
Dominic Gannaway
160505b0ca ReactDOM.useEvent: Add more scaffolding for useEvent hook (#18271) 2020-03-10 20:31:12 +00:00
Dominic Gannaway
a3bf668812 Flare: Fix listener upgrade bug (#18270) 2020-03-10 17:59:03 +00:00
Brian Vaughn
526c12f49e Enable enableProfilerCommitHooks flag for FB (#18230) 2020-03-10 10:40:45 -07:00
Kerollos Magdy
9e5626cdde Fix yarn warning on running 'yarn build-for-devtools' (#18232)
fixes #18231
2020-03-10 15:37:02 +00:00
Dominic Gannaway
29534252ad ReactDOM.useEvent add flag and entry point (#18267) 2020-03-10 12:18:49 +00:00
Dominic Gannaway
704c8b0118 Fix Flow type for AnyNativeEvent (#18266) 2020-03-10 10:46:12 +00:00
Sebastian Markbåge
bdc5cc4635 Add Relay Flight Build (#18242)
* Rename to clarify that it's client-only

* Rename FizzStreamer to FizzServer for consistency

* Rename react-flight to react-client/flight

For consistency with react-server. Currently this just includes flight
but it could be expanded to include the whole reconciler.

* Add Relay Flight Build

* Rename ReactServerHostConfig to ReactServerStreamConfig

This will be the config specifically for streaming purposes.
There will be other configs for other purposes.
2020-03-07 11:23:30 -08:00
Sebastian Markbåge
7a1691cdff Refactor Host Config Infra (getting rid of .inline*.js) (#18240)
* Require deep for reconcilers

* Delete inline* files

* Delete react-reconciler/persistent

This no longer makes any sense because it react-reconciler takes
supportsMutation or supportsPersistence as options. It's no longer based
on feature flags.

* Fix jest mocking

* Fix Flow strategy

We now explicitly list which paths we want to be checked by a renderer.
For every other renderer config we ignore those paths.

Nothing is "any" typed. So if some transitive dependency isn't reachable
it won't be accidentally "any" that leaks.
2020-03-06 16:20:42 -08:00
Sebastian Markbåge
238b57f0f7 [Blocks] Make it possible to have lazy initialized and lazy loaded Blocks (#18220)
* Lazify Blocks

Blocks now initialize lazily.

* Initialize Blocks eagerly in ChildFiber

This is for the case when it's a new Block that hasn't yet initialized.
We need to first initialize it to see what "render function" it resolves
to so that we can use that in our comparison.

* Remove extra import type line
2020-03-06 15:14:46 -08:00
Andrew Clark
235a6c4af6 Bugfix: Dropped effects in Legacy Mode Suspense (#18238)
* Failing: Dropped effects in Legacy Mode Suspense

* Transfer mounted effects on suspend in legacy mode

In legacy mode, a component that suspends bails out and commit in
its previous state. If the component previously had mounted effects,
we must transfer those to the work-in-progress so they don't
get dropped.
2020-03-06 11:10:01 -08:00
Andrew Clark
5fbb165602 Hard-code disableModulePatternComponents (#18239)
Hard-coding this until tests are fixed, to unblock master.
2020-03-06 11:09:36 -08:00
Brian Vaughn
cccba39f5b Fixed broken anchor tag for patch release 2020-03-06 11:05:01 -08:00
Dan Abramov
562cf013db Add a flag to disable module pattern components (#18133) 2020-03-06 18:46:32 +00:00
Andrew Clark
115cd12d9b Add test run that uses www feature flags (#18234)
In CI, we run our test suite against multiple build configurations. For
example, we run our tests in both dev and prod, and in both the
experimental and stable release channels. This is to prevent accidental
deviations in behavior between the different builds. If there's an
intentional deviation in behavior, the test author must account
for them.

However, we currently don't run tests against the www builds. That's
a problem, because it's common for features to land in www before they
land anywhere else, including the experimental release channel.
Typically we do this so we can gradually roll out the feature behind
a flag before deciding to enable it.

The way we test those features today is by mutating the
`shared/ReactFeatureFlags` module. There are a few downsides to this
approach, though. The flag is only overridden for the specific tests or
test suites where you apply the override. But usually what you want is
to run *all* tests with the flag enabled, to protect against unexpected
regressions.

Also, mutating the feature flags module only works when running the
tests against source, not against the final build artifacts, because the
ReactFeatureFlags module is inlined by the build script.

Instead, we should run the test suite against the www configuration,
just like we do for prod, experimental, and so on. I've added a new
command, `yarn test-www`. It automatically runs in CI.

Some of the www feature flags are dynamic; that is, they depend on
a runtime condition (i.e. a GK). These flags are imported from an
external module that lives in www. Those flags will be enabled for some
clients and disabled for others, so we should run the tests against
*both* modes.

So I've added a new global `__VARIANT__`, and a new test command `yarn
test-www-variant`. `__VARIANT__` is set to false by default; when
running `test-www-variant`, it's set to true.

If we were going for *really* comprehensive coverage, we would run the
tests against every possible configuration of feature flags: 2 ^
numberOfFlags total combinations. That's not practical, though, so
instead we only run against two combinations: once with `__VARIANT__`
set to `true`, and once with it set to `false`. We generally assume that
flags can be toggled independently, so in practice this should
be enough.

You can also refer to `__VARIANT__` in tests to detect which mode you're
running in. Or, you can import `shared/ReactFeatureFlags` and read the
specific flag you can about. However, we should stop mutating that
module going forward. Treat it as read-only.

In this commit, I have only setup the www tests to run against source.
I'll leave running against build for a follow up.

Many of our tests currently assume they run only in the default
configuration, and break when certain flags are toggled. Rather than fix
these all up front, I've hard-coded the relevant flags to the default
values. We can incrementally migrate those tests later.
2020-03-06 09:29:05 -08:00
Christoph Nakazawa
4027f2a3b8 Break up require/import statements in strings (#18222) 2020-03-05 22:27:55 +00:00
Brian Vaughn
024a764310 Implemented Profiler onCommit() and onPostCommit() hooks (#17910)
* Implemented Profiler onCommit() and onPostCommit() hooks
* Added enableProfilerCommitHooks feature flag for commit hooks
* Moved onCommit and onPassiveCommit behind separate feature flag
2020-03-05 11:02:00 -08:00
Brian Vaughn
d35f8a5818 feat: honor displayName of context types (#18224)
* Revert "Revert "feat: honor displayName of context types (#18035)" (#18223)"

This reverts commit 3ee812e6b6.

* Add warning of displayName is set on the consumer

* dedupe warning
2020-03-05 10:13:52 -08:00
Dominic Gannaway
3ee812e6b6 Revert "feat: honor displayName of context types (#18035)" (#18223)
This reverts commit 45c172d948.
2020-03-05 15:58:04 +00:00
Dominic Gannaway
6a0efddd89 Modern Event System: export internal FB flag for testing (#18221) 2020-03-05 14:05:00 +00:00
Sunil Pai
21b713b9fd Updated React Native home URL (#18218) 2020-03-05 13:15:46 +00:00
Dominic Gannaway
60b11f6c1b Modern Event System: Support nested portal/root boundaries (#18201) 2020-03-05 09:00:13 +00:00
Sebastian Markbåge
fa03206ee4 Remove _ctor field from Lazy components (#18217)
* This type is all wrong and nothing cares because it's all any

* Refine Flow types of Lazy Components

We can type each condition.

* Remove _ctor field from Lazy components

This field is not needed because it's only used before we've initialized,
and we don't have anything else to store before we've initialized.

* Check for _ctor in case it's an older isomorphic that created it

We try not to break across minors but it's no guarantee.

* Move types and constants from shared to isomorphic

The "react" package owns the data structure of the Lazy component. It
creates it and decides how any downstream renderer may use it.

* Move constants to shared

Apparently we can't depend on react/src/ because the whole package is
considered "external" as far as rollup is concerned.
2020-03-04 20:52:48 -08:00
Dominic Gannaway
2fe0fbb05e Use accumulateTwoPhaseDispatchesSingle directly (#18203) 2020-03-05 00:04:27 +00:00
Dominic Gannaway
503fd82b42 Modern Event System: Add support for internal FB Primer (#18210) 2020-03-04 23:41:59 +00:00
Brian Vaughn
45c172d948 feat: honor displayName of context types (#18035)
* test: Add test for current behavior of displayName
* feat: consider displayName of context types
2020-03-04 14:54:16 -08:00
Dominic Gannaway
83c3ed290c Fix instanceContainsElem bug from typo (#18213) 2020-03-04 19:53:16 +00:00
Vishal Jagtap
7e94d89f3e Updated React Native Website URL (#18207) 2020-03-04 12:10:48 +00:00
Brian Vaughn
355970aa4b DevTools 4.4.0 -> 4.5.0 2020-03-03 15:04:07 -08:00
Andrew Clark
ec652f4daf Bugfix: Expired partial tree infinite loops (#17949)
* Bugfix: Expiring a partially completed tree (#17926)

* Failing test: Expiring a partially completed tree

We should not throw out a partially completed tree if it expires in the
middle of rendering. We should finish the rest of the tree without
yielding, then finish any remaining expired levels in a single batch.

* Check if there's a partial tree before restarting

If a partial render expires, we should stay in the concurrent path
(performConcurrentWorkOnRoot); we'll stop yielding, but the rest of the
behavior remains the same.

We will only revert to the sync path (performSyncWorkOnRoot) when
starting on a new level.

This approach prevents partially completed concurrent work from
being discarded.

* New test: retry after error during expired render

* Regression: Expired partial tree infinite loops

Adds regression tests that reproduce a scenario where a partially
completed tree expired then fell into an infinite loop.

The code change that exposed this bug made the assumption that if you
call Scheduler's `shouldYield` from inside an expired task, Scheduler
will always return `false`. But in fact, Scheduler sometimes returns
`true` in that scenario, which is a bug.

The reason it worked before is that once a task timed out, React would
always switch to a synchronous work loop without checking `shouldYield`.

My rationale for relying on `shouldYield` was to unify the code paths
between a partially concurrent render (i.e. expires midway through) and
a fully concurrent render, as opposed to a render that was synchronous
the whole time. However, this bug indicates that we need a stronger
guarantee within React for when tasks expire, given that the failure
case is so catastrophic. Instead of relying on the result of a dynamic
method call, we should use control flow to guarantee that the work is
synchronously executed.

(We should also fix the Scheduler bug so that `shouldYield` always
returns false inside an expired task, but I'll address that separately.)

* Always switch to sync work loop when task expires

Refactors the `didTimeout` check so that it always switches to the
synchronous work loop, like it did before the regression.

This breaks the error handling behavior that I added in 5f7361f (an
error during a partially concurrent render should retry once,
synchronously). I'll fix this next. I need to change that behavior,
anyway, to support retries that occur as a result of `flushSync`.

* Retry once after error even for sync renders

Except in legacy mode.

This is to support the `useOpaqueReference` hook, which uses an error
to trigger a retry at lower priority.

* Move partial tree check to performSyncWorkOnRoot

* Factor out render phase

Splits the work loop and its surrounding enter/exit code into their own
functions. Now we can do perform multiple render phase passes within a
single call to performConcurrentWorkOnRoot or performSyncWorkOnRoot.
This lets us get rid of the `didError` field.
2020-03-03 13:42:18 -08:00
Brian Vaughn
d2158d6ccb Fix flow types (#18204)
* Added missing @flow pragma to React.js

* Fixed useContext() return type definition

* Fixed previously masked Flow errors in DevTools and react-interactions packages

* Added displayName to internal Context Flow type

* Removed Flow generic annotations for createResponder

This seems to cause a parsing error. (Not sure why.) The API is deprecated anyway so I'm being lazy for now and just adding a .
2020-03-03 12:46:24 -08:00
Dominic Gannaway
8e6a08ea4f Modern Event System: add plugin handling and forked paths (#18195) 2020-03-03 14:37:06 +00:00
Luna Ruan
7e83af17ce Put React.jsx and React.jsxDEV behind experimental build (#18023)
This PR puts the React.jsx and React.jsxDEV (enableJSXTransformAPI feature flag) in the experimental build so that we can use it to test React Native.
2020-03-02 18:08:40 -08:00
Dominic Gannaway
8cb2fb21eb Refine isFiberSuspenseAndTimedOut (#18184) 2020-03-02 14:15:42 +00:00
Dominic Gannaway
dbc7b9f50c Fix bug with PressLegacy blur (#18194) 2020-03-02 13:42:46 +00:00
Dominic Gannaway
62861bbcc7 More event system cleanup and scaffolding (#18179) 2020-03-02 10:59:07 +00:00
Sebastian Markbåge
8ccfce460f Only use Rollup's CommonJS plugin for "react-art" (#18186)
* Only use Rollup's CommonJS plugin for "react-art"

We still need it for the "art" UMD builds but nothing else should have
CommonJS dependencies anymore.

* react-debug-tools and jest-react should leave object-assign as an external dep

This avoids it being compiled into the output.
2020-02-28 16:46:16 -08:00
Minh Nguyen
c26506a7d2 Update react-shallow-renderer from 16.12.0 to 16.13.0 (#18185) 2020-02-28 16:35:52 -08:00
Eli White
26aa1987ce [Native] Enable and remove targetAsInstance feature flag. (#18182) 2020-02-28 13:45:42 -08:00
Sebastian Markbåge
4469700bb6 Change ReactVersion from CJS to ES module (#18181) 2020-02-28 13:09:02 -08:00
Sebastian Markbåge
58eedbb024 Check in a forked version of object-assign only for UMD builds (#18180)
* Check in a forked version of object-assign

This one uses ES modules so that we can inline it into UMD builds.

We could wait for object-assign to make an ESM export but we're going to
remove this dependency and assume global polyfills in the next version
anyway. However, we'd have to figure out how to keep the copyright header
and it'll get counted in terms of byte size (even if other tooling removes
it).

A lot of headache when we have our own implementation anyway. So I'll just
use that.

Ours is not resilient to checking certain browser bugs but those browsers
are mostly unused anyway. (Even FB breaks on them presumably.)

We also don't need to be resilient to Symbols since the way React uses it
we shouldn't need to copy symbols

* Don't transpile Object.assign to object-assign in object-assign

The polyfill needs to be able to feature detect Object.assign.
2020-02-28 11:14:09 -08:00
Henry Q. Dineen
053347e6bc react-test-renderer: improve findByType() error message (#17439)
* improve findByType error message

* fix flow typing

* Adding a test for the "Unknown" branch when `getComponentName()` returns a falsy value. The error message in this case not the most descriptive but seems consistent with the `getComponentName(type) || 'Unknown'` pattern seen in multiple places in this code base.
2020-02-28 17:55:33 +00:00
Dan Abramov
4ee592e95a Add an early invariant to debug a mystery crash (#18159) 2020-02-28 11:56:36 +00:00
Sophie Alpert
7ea4e4111f Fix typo in warning text (#18103)
Mentioned in #18090.
2020-02-28 11:53:20 +00:00
Simen Bekkhus
79a25125b1 feat: add recommended config eslint rule (#14762)
* feat: add recommended config eslint rule

* add exhaustive-deps to recommended as well
2020-02-28 02:01:17 +00:00
Joshua Gross
ae60caacfd [Fabric] Fix targetAsInstance dispatchEvent "cannot read property of null" (#18156)
* Fix Fabric targetAsInstance dispatchEvent: targetFiber stateNode is null in some cases

Co-authored-by: Dan Abramov <dan.abramov@gmail.com>
2020-02-27 17:23:25 -08:00
Dan Abramov
d72700ff5a Remove runtime dependency on prop-types (#18127)
* Remove runtime dep on prop-types

* Fix test
2020-02-28 01:21:54 +00:00
Sebastian Markbåge
549e418830 Move remaining things to named exports (#18165)
* Move remaining things to named exports

The interesting case here is the noop renderers. The wrappers around the
reconciler now changed to use a local export that gets mutated.

ReactNoop and ReactNoopPersistent now have to destructure the object to
list out the names it's going to export. We should probably refactor
ReactNoop away from createReactNoop. Especially since it's also not Flow
typed.

* Switch interactions to star exports

This will have esModule compatibility flag on them. They should ideally
export default instead.
2020-02-27 17:18:55 -08:00
Sebastian Markbåge
739f20beda Remove Node shallow builds (#18157)
This is just a forwarding module. We can hardcode it.
2020-02-27 14:11:40 -08:00
Sebastian Markbåge
3e809bf5d4 Convert React Native builds to named exports (#18136)
These don't need any forks because we always export the same things atm.
2020-02-27 11:33:44 -08:00
Dan Abramov
869dbda722 Don't build shallow renderer for FB (#18153) 2020-02-27 18:17:58 +00:00
Minh Nguyen
293878e079 Replace ReactShallowRenderer with a dependency (#18144)
Closes #17321.
2020-02-27 18:10:25 +00:00
Dan Abramov
abcca45951 Run test-prod job for experimental builds (#18152) 2020-02-27 16:21:36 +00:00
Dan Abramov
1ad2179002 Bust Circle caches 2020-02-27 15:33:10 +00:00
Dan Abramov
b4e3148918 Remove unused flag (#18132) 2020-02-27 12:58:15 +00:00
Dan Abramov
849e8328b5 Remove unnecessary warnings (#18135) 2020-02-27 02:14:30 +00:00
Sebastian Markbåge
f9c0a45441 Convert the rest of react-dom and react-test-renderer to Named Exports (#18145)
Nothing interesting here except that ReactShallowRenderer currently exports
a class with a static method instead of an object.

I think the public API is probably just meant to be createRenderer but
currently the whole class is exposed. So this means that we have to keep
it as default export. We could potentially also expose a named export for
createRenderer but that's going to cause compatibility issues.

So I'm just going to make that export default.

Unfortunately Rollup and Babel (which powers Jest) disagree on how to
import this. So to make it work I had to move the jest tests to imports.

This doesn't work with module resetting. Some tests weren't doing that
anyway and the rest is just testing ReactShallowRenderer so meh.
2020-02-26 18:04:32 -08:00
Brian Vaughn
2738b6d022 Updated CHANGELOG to remove passive effects change from 16.13 release. (It wasn't part of that release.) 2020-02-26 13:06:02 -08:00
Dan Abramov
69c769ae04 Fix changelog link 2020-02-26 21:04:36 +00:00
Dan
efaffc4797 Prettier 2020-02-26 21:02:20 +00:00
Sunil Pai
c1c5499cc3 update version numbers for 16.13 (#18143)
also includes a bugfix when downloading error codes from circleci.
2020-02-26 20:33:29 +00:00
Sunil Pai
169b1f79be Changelog for 16.13.0 (#18124)
* Changelog for 16.13.0

* Update CHANGELOG.md
2020-02-26 20:15:01 +00:00
Brian Vaughn
71418fda3b Rearranged some DevTools Components code 2020-02-26 11:33:52 -08:00
Hristo Kanchev
d166319e86 [DevTools] Added resize support for Components panel. (#18046)
* feat: DevTools - Added Resize Support.

* feat: Prettier.

* feat: DevTools - Added debug comments.

* feat: DevTools - Removed Use Memo.

* feat: DevTools - Added types.

* feat: DevTools - Extracted values to constants.

* feat: DevTools - Removed useCallback.

* feat: DevTools - Finished refactoring.

* feat: DevTools - Merging fixup.

* feat: DevTools - Prettier fix.

* feat: DevTools - Extracted code from Components fil.

* feat: DevTools - Fixed orientation change issue.

* feat: DevTools - Added flow types for reducer and refs.

* feat: DevTools - Fixed orientation change on initial load.

* Update packages/react-devtools-shared/src/devtools/views/Components/ComponentsResizer.js

* Removed unused `orientationRef`

* Fix Flow ref issue

Co-authored-by: Brian Vaughn <brian.david.vaughn@gmail.com>
2020-02-26 11:30:42 -08:00
Brian Vaughn
e1c7e651fe Update ReactDebugHooks to handle composite hooks (#18130)
The useState hook has always composed the useReducer hook. 1:1 composition like this is fine.

But some more recent hooks (e.g. useTransition, useDeferredValue) compose multiple hooks internally. This breaks react-debug-tools because it causes off-by-N errors when the debug tools re-renders the function.

For example, if a component were to use the useTransition and useMemo hooks, the normal hooks dispatcher would create a list of first state, then callback, then memo hooks, but the debug tools package would expect a list of transition then memo. This can break user code and cause runtime errors in both the react-debug-tools package and in product code.

This PR fixes the currently broken hooks by updating debug tools to be aware of the composite hooks (how many times it should call nextHook essentially) and adds tests to make sure they don't get out of sync again. We'll need to add similar tests for future composite hooks (like useMutableSource #18000).
2020-02-26 09:28:35 -08:00
Sunil Pai
d28bd2994b remove OSS testing builds (#18138)
The testing build versions of react-dom are included in the builds right now, but we're not ready to share them yet. This PR removes them for now (back soon for the next release)
2020-02-26 13:12:55 +00:00
Sebastian Markbåge
8e13e770e3 Remove /testing entry point from 'react' package (#18137)
We're not actually building this entry point. I can't think of a reason
we'd need to fork the isomorphic one. We don't really fork it for
anything since it's so generic to work with all renderers.

Since /profiling doesn't have this, it might confuse the story if we made
people alias two things for testing but not profiling.
2020-02-26 10:48:34 +00:00
Steve Harrison
f3ecd56bea Fixed a spelling mistake in a comment. (#18119) 2020-02-25 21:01:08 -08:00
Sebastian Markbåge
60016c448b Export React as Named Exports instead of CommonJS (#18106)
* Add options for forked entry points

We currently fork .fb.js entry points. This adds a few more options.

.modern.fb.js - experimental FB builds
.classic.fb.js - stable FB builds
.fb.js - if no other FB build, use this for FB builds
.experimental.js - experimental builds
.stable.js - stable builds
.js - used if no other override exists

This will be used to have different ES exports for different builds.

* Switch React to named exports

* Export named exports from the export point itself

We need to re-export the Flow exported types so we can use them in our code.

We don't want to use the Flow types from upstream since it doesn't have the non-public APIs that we have.

This should be able to use export * but I don't know why it doesn't work.

This actually enables Flow typing of React which was just "any" before.
This exposed some Flow errors that needs fixing.

* Create forks for the react entrypoint

None of our builds expose all exports and they all differ in at least one
way, so we need four forks.

* Set esModule flag to false

We don't want to emit the esModule compatibility flag on our CommonJS
output. For now we treat our named exports as if they're CommonJS.

This is a potentially breaking change for scheduler (but all those apis
are unstable), react-is and use-subscription. However, it seems unlikely
that anyone would rely on this since these only have named exports.

* Remove unused Feature Flags

* Let jest observe the stable fork for stable tests

This lets it do the negative test by ensuring that the right tests fail.

However, this in turn will make other tests that are not behind
__EXPERIMENTAL__ fail. So I need to do that next.

* Put all tests that depend on exports behind __EXPERIMENTAL__

Since there's no way to override the exports using feature flags
in .intern.js anymore we can't use these APIs in stable.

The tradeoff here is that we can either enable the negative tests on
"stable" that means experimental are expected to fail, or we can disable
tests on stable. This is unfortunate since some of these APIs now run on
a "stable" config at FB instead of the experimental.

* Switch ReactDOM to named exports

Same strategy as React.

I moved the ReactDOMFB runtime injection to classic.fb.js

Since we only fork the entrypoint, the `/testing` entrypoint needs to
be forked too to re-export the same things plus `act`. This is a bit
unfortunate. If it becomes a pattern we can consider forking in the
module resolution deeply.

fix flow

* Fix ReactDOM Flow Types

Now that ReactDOM is Flow type checked we need to fix up its types.

* Configure jest to use stable entry for ReactDOM in non-experimental

* Remove additional FeatureFlags that are no longer needed

These are only flagging the exports and no implementation details so we
can control them fully through the export overrides.
2020-02-25 13:54:27 -08:00
Dominic Gannaway
8d7535e540 Add @nolint to FB bundle headers (#18126) 2020-02-25 14:45:31 +00:00
Dominic Gannaway
a29a273c17 [react-interactions] Ensure blur to window disengages press (#18125) 2020-02-25 14:14:19 +00:00
Moji Izadmehr
bf13d3e3c6 [eslint-plugin-react-hooks] Fix cyclic caching for loops containing a… (#16853)
* [eslint-plugin-react-hooks] Fix cyclic caching for loops containing a condition

* [eslint-plugin-react-hooks] prettier write

* [eslint-plugin-react-hooks] Fix set for tests

* Update packages/eslint-plugin-react-hooks/src/RulesOfHooks.js

Co-Authored-By: Luke Kang <kidkkr@icloud.com>

Co-authored-by: Luke Kang <kidkkr@icloud.com>
2020-02-25 11:38:23 +00:00
Haseeb Furkhan Mohammed
0e49074f7a Cross platform support to run yarn test:edge for Microsoft Edge dev tools extension (#18108)
* Test automation for edge dev tools extension

* Linter changes

* Load extension automatically.

* Fixed path in `test` command

Co-authored-by: Brian Vaughn <brian.david.vaughn@gmail.com>
2020-02-24 18:17:01 -08:00
Sebastian Markbåge
ccab494738 Move type DOMContainer to HostConfig (#18112)
Exports from ReactDOM represents React's public API. This include types
exported by React. At some point we'll start building Flow types from
these files.

The duplicate name between DOMContainer and Container seems confusing too
since it was used in the same files even though they're the same.
2020-02-24 08:57:48 -08:00
adasq
501a78881e runAllPassiveEffectDestroysBeforeCreates's feature flag description typo fixed (#18115) 2020-02-24 14:49:13 +00:00
Sebastian Markbåge
be76966f6b Code mod import * as React from 'react' in react-window (#18105) 2020-02-21 23:20:17 -08:00
Sebastian Markbåge
09348798a9 Codemod to import * as React from "react"; (#18102)
* import * as React from "react";

This is the correct way to import React from an ES module since the ES
module will not have a default export. Only named exports.

* import * as ReactDOM from "react-dom"
2020-02-21 19:45:20 -08:00
Brian Vaughn
78e816032c Don't warn about unmounted updates if pending passive unmount (#18096)
I recently landed a change to the timing of passive effect cleanup functions during unmount (see #17925). This change defers flushing of passive effects for unmounted components until later (whenever we next flush pending passive effects).

Since this change increases the likelihood of a (not actionable) state update warning for unmounted components, I've suppressed that warning for Fibers that have scheduled passive effect unmounts pending.
2020-02-21 13:11:53 -08:00
Sebastian Markbåge
2c4221ce8b Change string refs in function component message (#18031)
This should refer to string refs specifically. The forwardRef part doesn't
make any sense in this case. I think this was just an oversight.
2020-02-21 10:12:34 -08:00
Sebastian Markbåge
65bbda7f16 Rename Chunks API to Blocks (#18086)
Sounds like this is the name we're going with. This also helps us
distinguish it from other "chunking" implementation details.
2020-02-20 23:56:40 -08:00
Dan Abramov
8b596e00a4 Remove unused arguments in the reconciler (#18092) 2020-02-21 02:26:19 +00:00
Andrew Clark
5de5b61507 Bugfix: memo drops lower pri updates on bail out (#18091)
Fixes a bug where lower priority updates on a components wrapped with
`memo` are sometimes left dangling in the queue without ever being
processed, if they are preceded by a higher priority bailout.

Cause
-----

The pending update priority field is cleared at the beginning of
`beginWork`. If there is remaining work at a lower priority level, it's
expected that it will be accumulated on the work-in-progress fiber
during the begin phase.

There's an exception where this assumption doesn't hold:
SimpleMemoComponent contains a bailout that occurs *before* the
component is evaluated and the update queues are processed, which means
we don't accumulate the next priority level. When we complete the fiber,
the work loop is left to believe that there's no remaining work.

Mitigation
----------

Since this only happens in a single case, a late bailout in
SimpleMemoComponent, I've mitigated the bug in that code path by
restoring the original update priority from the current fiber.

This same case does not apply to MemoComponent, because MemoComponent
fibers do not contain hooks or update queues; rather, they wrap around
an inner fiber that may contain those. However, I've added a test case
for MemoComponent to protect against a possible future regression.

Possible next steps
-------------------

We should consider moving the update priority assignment in `beginWork`
out of the common path and into each branch, to avoid similar bugs in
the future.
2020-02-20 16:21:31 -08:00
Kunuk Nykjær
abfbae02a4 Update Rollup version to 1.19.4 and fix breaking changes (#15037)
* update rollup versioni

* ignore Rollup warnings for known warning codes

* add lecacy support from elas7

* rollup 1.5

* upd to ver 1.6.0

* don't throw error

* use return instead of throw error

* upd code in comment

* fix getters test

* rollup 1.7

* rollup 1.7.3

* remove comments

* use rollup 1.7.4

* update yarn.lock for new rollup version

* rollup version 1.9.0

* rollback to version 1.7.4

* add globalThis to eslintrc.umd

* rollup 1.9.0

* upd rollup plugin versions to satisfied latest versions

* add result.json update

* rollup 1.9.3

* rollup 1.10.0

* ver 1.10.1

* rollup 1.11.3

* rollup ver 1.12.3

* rollup 1.13.1

* rollup 1.14.6

* rollup 1.15.6

* rollup 1.16.2

* upd tests

* prettier

* Rollup 1.16.3

* upd

* should throw when finding getters with a different syntax from the ones generated by Rollup

* add more one test

* rollup-plugin-prettier updated changed stuff, revert them

* don't upd all the Rollup plugins

* rollup-plugin-babel 3.0.7

* upd rollup plugin versions

* upd rollup-plugin-commonjs

* bracket spacing

* rollup 1.16.6

* rollup 1.16.7

* rename test description

* rollup 1.18.0

* use externalLiveBindings: false

* rollup 1.19.3

* remove remove-getters

* simplify CIRCULAR_DEPENDENCY warning

* simplify if logic in sizes-plugin

* rollup 1.19.4

* update output for small optimizations

* remove globalThis

* remove results.json file

* re-add globalThis
2020-02-20 22:09:30 +00:00
Sunil Pai
b789060dca Feature Flag for React.jsx` "spreading a key to jsx" warning (#18074)
Adds a feature flag for when React.jsx warns you about spreading a key into jsx. It's false for all builds, except as a dynamic flag for fb/www.

I also included the component name in the warning.
2020-02-20 11:30:04 +00:00
Dominic Gannaway
3f85d53ca6 Further pre-requisite changes to plugin event system (#18083) 2020-02-20 00:46:03 +00:00
Andrew Clark
ea6ed3dbbd Warn for update on different component in render (#17099)
This warning already exists for class components, but not for functions.

It does not apply to render phase updates to the same component, which
have special semantics that we do support.
2020-02-19 12:43:14 -08:00
Eli White
085d02133e [Native] Migrate focus/blur to call TextInputState with the host component (#18068) 2020-02-19 11:33:40 -08:00
Brian Vaughn
7e770dae93 Profiler tooltip tweaks (#18082)
* Moved Profiler views into Profiler folder

* Tweaked Profiler tooltip CSS styles

* Tweaked Tooltip positioning code
2020-02-19 10:58:45 -08:00
Dominic Gannaway
b6c94d636c Add guard around FocusWithin responder root events (#18080) 2020-02-19 18:32:18 +00:00
Dominic Gannaway
1000f6135e Add container to event listener signature (#18075) 2020-02-19 18:00:57 +00:00
Dan Abramov
a12dd52a4a Don't build some packages for WWW (#18078) 2020-02-19 17:59:42 +00:00
Moji Izadmehr
44e5f5e645 Add fiber summary tooltip to devtools profiling (#18048)
* Add tooltip component

* Separate logic of ProfilerWhatChanged to a component

* Add hovered Fiber info tooltip component

* Add flame graph chart tooltip

* Add commit ranked list tooltip

* Fix flow issues

* Minor improvement in filter

* Fix flickering issue

* Resolved issues on useCallbacks and mouse event listeners

* Fix lints

* Remove unnecessary useCallback
2020-02-19 09:44:31 -08:00
Dominic Gannaway
2512c309e3 Remove Flare bundles from build (#18077) 2020-02-19 17:25:41 +00:00
Sunil Pai
a8643e905e add no-restricted-globals to eslint config (#18076)
Our current lint config assumes a browser environment, which means it won't warn you if you use a variable like `name` without declaring it earlier. This imports the same list as the one used by create-react-app, and enables it against our codebase.
2020-02-19 17:14:53 +00:00
Dominic Gannaway
4912ba31e3 Add modern event system flag + rename legacy plugin module (#18073) 2020-02-19 14:36:39 +00:00
Andrew Clark
4d9f850065 Re-throw errors thrown by the renderer at the root in the complete phase (#18029)
* Re-throw errors thrown by the renderer at the root

React treats errors thrown at the root as a fatal because there's no
parent component that can capture it. (This is distinct from an
"uncaught error" that isn't wrapped in an error boundary, because in
that case we can fall back to deleting the whole tree -- not great, but
at least the error is contained to a single root, and React is left in a
consistent state.)

It turns out we didn't have a test case for this path. The only way it
can happen is if the renderer's host config throws. We had similar test
cases for host components, but none for the host root.

This adds a new test case and fixes a bug where React would keep
retrying the root because the `workInProgress` pointer was not advanced
to the next fiber. (Which in this case is `null`, since it's the root.)

We could consider in the future trying to gracefully exit from certain
types of root errors without leaving React in an inconsistent state. For
example, we should be able to gracefully exit from errors thrown in the
begin phase. For now, I'm treating it like an internal invariant and
immediately exiting.

* Add comment
2020-02-18 15:55:38 -08:00
Brian Vaughn
14afeb1033 Added missing feature flag 2020-02-18 14:49:57 -08:00
Brian Vaughn
691096c95d Split recent passive effects changes into 2 flags (#18030)
* Split recent passive effects changes into 2 flags

Separate flags can now be used to opt passive effects into:
1) Deferring destroy functions on unmount to subsequent passive effects flush
2) Running all destroy functions (for all fibers) before create functions

This allows us to test the less risky feature (2) separately from the more risky one.

* deferPassiveEffectCleanupDuringUnmount is ignored unless runAllPassiveEffectDestroysBeforeCreates is true
2020-02-18 14:19:43 -08:00
Andrew Clark
56d8a73aff [www] Disable Scheduler timeout w/ dynamic flag (#18069)
Before attempting to land an expiration times refactor, I want to see
if this particular change will impact performance (either positively
or negatively). I will test this with a GK.
2020-02-18 13:43:16 -08:00
Dominic Gannaway
1a6d8179b6 [react-interactions] Ensure onBeforeBlur fires for hideInstance (#18064) 2020-02-18 18:50:38 +00:00
Ryota Murakami
48c4867d74 Update issue templates to directly link to relevant sources (#18039)
GitHub supports linking to off-site sources for certain types of issue.
2020-02-18 10:30:00 -08:00
Brian Vaughn
90be006da8 Updated Yarn lockfile 2020-02-18 09:40:59 -08:00
Haseeb Furkhan Mohammed
d5ddc16a33 React developer tools extension for Microsoft Edge (#18041)
* Port Chrome extension to Microsoft Edge
2020-02-18 09:40:30 -08:00
Dominic Gannaway
f48a5e64e8 Further cleanup of plugin event system (#18056) 2020-02-18 13:31:59 +00:00
Dan Abramov
d533229fba Fix Prettier 2020-02-17 20:36:16 +00:00
Dan Abramov
56a8c35321 eslint-plugin-react-hooks@2.4.0 2020-02-17 20:26:56 +00:00
Will Douglas
93a229bab5 Update eslint rule exhaustive deps to use new suggestions feature (#17385)
This closes #16313
2020-02-17 20:24:27 +00:00
Dominic Gannaway
9def56ec0e Refactor DOM plugin system to single module (#18025) 2020-02-14 08:10:42 +00:00
Eli White
2d6be757df [Native] Delete NativeComponent and NativeMethodsMixin (#18036)
* [Native] Delete NativeComponent and NativeMethodsMixin

* Remove more files
2020-02-13 15:09:25 -08:00
Luna Ruan
d4f2b0379c Add Auto Import to Babel Plugin (#16626)
This babel transform is a fork of the @babel/plugin-transform-react-jsx transform and is for experimentation purposes only. We don't plan to own this code in the future, and we will upstream this to Babel at some point once we've proven out the concept.

As per the RFC to simplify element creation, we want to add the ability to auto import "react' directly from the babel plugin. This commit updates the babel plugin with two options:

1.) importSource: The React module to import from. Defaults to react.
2.) autoImport: The type of import. Defaults to none.
- none: Does not import React. JSX compiles to React.jsx etc.
- namespace: import * as _react from "react";. JSX compiles to _react.jsx etc.
- default: import _default from "react"; JSX compiles to _default.jsx etc.
- namedExports: import {jsx as _jsx} from "react"; JSX compiles to _jsx etc.
- require: var _react = _interopRequireWildcard(require("react"));. jSX compiles to _react.jsx etc.

namespace, default, and namedExports can only be used when sourceType: module and require can only be used when sourceType: script.

It also adds two pragmas (jsxAutoImport and jsxImportSource) that allow users to specify autoImport and importSource in the docblock.
2020-02-13 12:36:19 -08:00
Dan Abramov
8777b44e98 Add Modern WWW build (#18028)
* Build both stable and experimental WWW builds

* Flip already experimental WWW flags to true

* Remove FB-specific internals from modern FB builds

We think we're not going to need these.

* Disable classic features in modern WWW builds

* Disable legacy ReactDOM API for modern WWW build

* Don’t include user timing in prod

* Fix bad copy paste and add missing flags to test renderer

* Add testing WWW feature flag file

We need it because WWW has a different meaning of experimental now.
2020-02-13 20:33:53 +00:00
Sunil Pai
58b8797b73 remove "Unreleased" section from CHANGELOG (#18027)
This section is empty, and imo isn't really helpful in React's changelog. I'm honestly not sure why this is even here? Figured I'd start a discussion with a PR, or we can remove it right now.
2020-02-12 17:17:49 +00:00
Dan Abramov
a607ea4c42 Remove getIsHydrating (#18019) 2020-02-12 01:01:29 +00:00
Dominic Gannaway
988f4b14ee Do not export passiveBrowserEventsSupported from Focus responder (#18022)
Remove code
2020-02-11 15:57:37 -08:00
Brian Vaughn
f7278034de Flush all passive destroy fns before calling create fns (#17947)
* Flush all passive destroy fns before calling create fns

Previously we only flushed destroy functions for a single fiber.

The reason this is important is that interleaving destroy/create effects between sibling components might cause components to interfere with each other (e.g. a destroy function in one component may unintentionally override a ref value set by a create function in another component).

This PR builds on top of the recently added deferPassiveEffectCleanupDuringUnmount kill switch to separate passive effects flushing into two separate phases (similar to layout effects).

* Change passive effect flushing to use arrays instead of lists

This change offers a small advantage over the way we did things previous: it continues invoking destroy functions even after a previous one errored.
2020-02-11 09:52:54 -08:00
Dominic Gannaway
529e58ab0a Remove legacy www config from Rollup build (#18016) 2020-02-11 13:42:19 +00:00
Dominic Gannaway
42918f40aa Change build from babylon to babel (#18015) 2020-02-11 11:56:26 +00:00
Dominic Gannaway
df5faddcc2 Refactor commitPlacement to recursively insert nodes (#17996) 2020-02-10 23:38:24 +00:00
Dan Abramov
ab7b83a924 Stop exposing some internals on FB build (#18011) 2020-02-10 19:52:27 +00:00
Dan Abramov
517de74b0c Tweak comment wording (#18007)
* Revert "Update ReactFiberExpirationTime.js (#17825)"

This reverts commit b63cb6f6cf.

* Reword
2020-02-10 16:15:10 +00:00
haseeb
b63cb6f6cf Update ReactFiberExpirationTime.js (#17825)
replaced 'add' with 'subtract'
2020-02-10 12:37:49 +00:00
Jesse Katsumata
89c6042df3 fix: typo in test (#18005) 2020-02-10 12:34:09 +00:00
Sophie Alpert
4f71f25a34 Re-enable shorthand CSS property collision warning (#18002)
Originally added in https://github.com/facebook/react/pull/14181; disabled in https://github.com/facebook/react/pull/14245. Intention was to enable it in React 16.7 but we forgot.
2020-02-10 11:42:11 +00:00
Brian Vaughn
e05dedc415 Added $FlowFixMe to DevTools shell for module we Flow-ignore (#18001) 2020-02-07 14:36:51 -08:00
Dan Abramov
d1bfdfb861 Ignore react-native-web in Flow checks (#17999) 2020-02-07 16:24:25 +00:00
Dominic Gannaway
c55c34e46a Move React Map child check to behind flags or __DEV__ (#17995) 2020-02-07 12:21:50 +00:00
cutjavascript
901d76bc5c dataForRoots.set duplicate removal (#17993)
dataForRoots.set duplicate removal
2020-02-06 11:48:02 -08:00
Dan Abramov
3f814e7582 Fix Flow type for React Native (#17992) 2020-02-06 18:31:13 +00:00
Dominic Gannaway
256d78d11f Add feature flag for removing children Map support (#17990) 2020-02-06 13:19:35 +00:00
Dominic Gannaway
df134d31cb Use babel parser rather than Babylon in extract errors (#17988) 2020-02-06 12:46:32 +00:00
Brian Vaughn
9e158c091b Updated release script documentation and command names (#17929)
* Updated release script documentation and command names

* Update scripts/release/README.md

Co-Authored-By: Sunil Pai <threepointone@oculus.com>

* Updated README

Co-authored-by: Sunil Pai <threepointone@oculus.com>
2020-02-05 08:52:31 -08:00
Sunil Pai
d84c539b31 fix sizebot - point correctly to circleci artifact (#17975)
similar to #17972, this should fix sizebot not reporting stats right now
2020-02-04 14:03:12 -08:00
Brian Vaughn
613cbd3ace Formatting fix (Prettier) to build script 2020-02-04 11:37:38 -08:00
Brian Vaughn
562d2fbc49 Fix release scripts (#17972)
Circle CI seems to have changed the reported artifact path which broke our scripts.
2020-02-04 11:36:49 -08:00
Andrew Clark
9dba218d93 [Mock Scheduler] Mimic browser's advanceTime (#17967)
The mock Scheduler that we use in our tests has its own fake timer
implementation. The `unstable_advanceTime` method advances the timeline.

Currently, a call to `unstable_advanceTime` will also flush any pending
expired work. But that's not how it works in the browser: when a timer
fires, the corresponding task is added to the Scheduler queue. However,
we will still wait until the next message event before flushing it.

This commit changes `unstable_advanceTime` to more closely resemble the
browser behavior, by removing the automatic flushing of expired work.

```js
// Before this commit
Scheduler.unstable_advanceTime(ms);

// Equivalent behavior after this commit
Scheduler.unstable_advanceTime(ms);
Scheduler.unstable_flushExpired();
```

The general principle is to prefer separate APIs for scheduling tasks
and flushing them.

This change does not affect any public APIs. `unstable_advanceTime` is
only used by our own test suite. It is not used by `act`.

However, we may need to update tests in www, like Relay's.
2020-02-04 11:35:21 -08:00
Murat ÇATAL
cddde45806 apply changes on editablevalue on blur feature implemented (#17062)
* apply changes on editablevalue on blur feature implemented

* Removed "Undo" button and unnecessary event.preventDefault()

Co-authored-by: Brian Vaughn <brian.david.vaughn@gmail.com>
2020-02-04 11:05:01 -08:00
Dan Abramov
d6e08fe0a8 Remove Suspense priority warning (#17971)
* Remove Suspense priority warning

* Fix tests
2020-02-04 18:05:15 +00:00
Alfredo Granja
812277dab6 Fix onMouseEnter is fired on disabled buttons (#17675) 2020-02-04 14:56:55 +00:00
Hassan Alam
2078aa9a40 Add dom fixture for autofilled form state (#17951) 2020-02-04 14:53:35 +00:00
Sunil Pai
3e9251d605 make testing builds for React/ReactDOM (#17915)
This PR introduces adds `react/testing` and `react-dom/testing`.
- changes infra to generate these builds
- exports act on ReactDOM in these testing builds
- uses the new test builds in fixtures/dom

In the next PR -

- I'll use the new builds for all our own tests
- I'll replace usages of TestUtils.act with ReactDOM.act.
2020-02-03 23:31:31 +00:00
Sebastian Markbåge
ace9e8134c Simplify Continuous Hydration Targets (#17952)
* Simplify Continuous Hydration Targets

Let's use a constant priority for this. This helps us avoid restarting
a render when switching targets and simplifies the model.

The downside is that now we're not down-prioritizing the previous hover
target. However, we think that's ok because it'll only do one level too
much and then stop.

* Add test meant to show why it's tricky to merge both hydration levels

Having both levels co-exist works. However, if we deprioritize hydration
using a single level, we might deprioritize the wrong thing.

This adds a test that catches it if we ever try a naive deprioritization
in the future.

It also tests that we don't down-prioritize if we're changing the hover
in the middle of doing continuous priority work.
2020-02-03 12:47:14 -08:00
Brian Vaughn
7df32c4c8c Flush useEffect clean up functions in the passive effects phase (#17925)
* Flush useEffect clean up functions in the passive effects phase

This is a change in behavior that may cause broken product code, so it has been added behind a killswitch (deferPassiveEffectCleanupDuringUnmount)

* Avoid scheduling unnecessary callbacks for cleanup effects

Updated enqueuePendingPassiveEffectDestroyFn() to check rootDoesHavePassiveEffects before scheduling a new callback. This way we'll only schedule (at most) one.

* Updated newly added test for added clarity.

* Cleaned up hooks effect tags

We previously used separate Mount* and Unmount* tags to track hooks work for each phase (snapshot, mutation, layout, and passive). This was somewhat complicated to trace through and there were man tag types we never even used (e.g. UnmountLayout, MountMutation, UnmountSnapshot). In addition to this, it left passive and layout hooks looking the same after renders without changed dependencies, which meant we were unable to reliably defer passive effect destroy functions until after the commit phase.

This commit reduces the effect tag types to only include Layout and Passive and differentiates between work and no-work with an HasEffect flag.

* Disabled deferred passive effects flushing in OSS builds for now

* Split up unmount and mount effects list traversal
2020-02-03 12:30:01 -08:00
Evyatar
9944bf27fb Add version property to ReactDOM (#15780) 2020-02-03 11:19:04 -08:00
Dominic Gannaway
434770c3b4 Add beforeRemoveInstance method to ReactNoop (#17959) 2020-02-03 11:31:51 +00:00
Mark Huang
08c1f79e1e Fix Cannot read property 'sub' of undefined when navigating to plain-text pages (#17848)
Update various parts of DevTools to account for the fact that the global "hook" might be undefined if DevTools didn't inject it (due to the page's `contentType`) it (due to the page's `contentType`)
2020-02-02 12:04:48 -08:00
Brian Vaughn
9ad35905fa Add DevTools tests for copying complex values (#17948) 2020-01-31 15:17:57 -08:00
Deniz Susman
00745b053f Typo fix (#17946) 2020-01-31 14:51:43 -08:00
Farhad Yasir
d9a5170594 fix: check bigint in serializeToString and change it to string (#17931) 2020-01-31 14:35:59 -08:00
Nicolas Gallagher
38cd75861f Update google-closure-compiler (#17902) 2020-01-30 17:34:03 -08:00
Brian Vaughn
6ae2c33a75 StrictMode should call sCU twice in DEV (#17942) 2020-01-30 13:03:44 -08:00
Andrew Clark
9dbe1c54df Revert "Bugfix: Expiring a partially completed tree (#17926)" (#17941)
This reverts commit 01974a867c.

* Failing test: Expiring a partially completed tree

We should not throw out a partially completed tree if it expires in the
middle of rendering. We should finish the rest of the tree without
yielding, then finish any remaining expired levels in a single batch.

* Check if there's a partial tree before restarting

If a partial render expires, we should stay in the concurrent path
(performConcurrentWorkOnRoot); we'll stop yielding, but the rest of the
behavior remains the same.

We will only revert to the sync path (performSyncWorkOnRoot) when
starting on a new level.

This approach prevents partially completed concurrent work from
being discarded.

* New test: retry after error during expired render
2020-01-30 11:14:57 -08:00
Brian Vaughn
d2ae77d0e4 Remove root.unmount() callback from DevTools code (#17939) 2020-01-30 09:36:43 -08:00
Sebastian Markbåge
e98797f7b9 Fix Event Replaying in Flare by Eagerly Adding Active Listeners (#17933)
* Add test of Event Replaying using Flare

* Fix Event Replaying in Flare by Eagerly Adding Active Listeners

This effectively reverts part of https://github.com/facebook/react/pull/17513
2020-01-30 09:32:41 -08:00
Dominic Gannaway
1662035852 Ensure createRoot warning parity with ReactDOM.render (#17937) 2020-01-30 17:17:42 +00:00
Dominic Gannaway
b2382a7150 Add ReactDOM.unstable_renderSubtreeIntoContainer warning flag (#17936) 2020-01-30 11:56:04 +00:00
Andrew Clark
01974a867c Bugfix: Expiring a partially completed tree (#17926)
* Failing test: Expiring a partially completed tree

We should not throw out a partially completed tree if it expires in the
middle of rendering. We should finish the rest of the tree without
yielding, then finish any remaining expired levels in a single batch.

* Check if there's a partial tree before restarting

If a partial render expires, we should stay in the concurrent path
(performConcurrentWorkOnRoot); we'll stop yielding, but the rest of the
behavior remains the same.

We will only revert to the sync path (performSyncWorkOnRoot) when
starting on a new level.

This approach prevents partially completed concurrent work from
being discarded.

* New test: retry after error during expired render
2020-01-29 12:40:18 -08:00
Dan Abramov
241c4467ee Add a note about expiring OTP codes 2020-01-29 16:31:51 +00:00
Dan Abramov
faabe22b4f Use next tag for canary releases in the doc (#17923) 2020-01-29 16:09:05 +00:00
Dan Abramov
57333ca33a Show first component stack in context warning (#17922)
* Update tests

* Show first component stack in context warning

Co-authored-by: Dominic Gannaway <trueadm@users.noreply.github.com>
2020-01-29 14:57:52 +00:00
Dan Abramov
a8fce06d3e Fix Jest diff call (#17921) 2020-01-29 14:38:22 +00:00
Dan Abramov
29a1559619 Add semver dependency explicitly to DevTools (#17919) 2020-01-29 14:20:56 +00:00
Dominic Gannaway
b7f217d40c [Concurrent Mode] Add missing event plugin priorities (#17914) 2020-01-28 13:20:26 +00:00
Brian Vaughn
e26682a9f3 Removed Root API callback params and added warnings (#17916) 2020-01-27 12:35:08 -08:00
Simen Bekkhus
cf0081263c Upgrade to jest 25 (#17896)
The changes to the test code relate to changes in JSDOM that come with Jest 25:

* Several JSDOM workarounds are no longer needed.
* Several tests made assertions to match incorrect JSDOM behavior (e.g. setAttribute calls) that JSDOM has now patched to match browsers.
  * https://codesandbox.io/s/resets-value-of-datetime-input-to-fix-bugs-in-ios-safari-1ppwh
* JSDOM no longer triggers default actions when dispatching click events.
  * https://codesandbox.io/s/beautiful-cdn-ugn8f
* JSDOM fixed (jsdom/jsdom#2700) a bug so that calling focus() on an already focused element does not dispatch a FocusEvent.
* JSDOM now supports passive events.
* JSDOM has improved support for custom CSS properties.
  * But requires jsdom/cssstyle#112 to land to support webkit prefixed properties.
2020-01-25 08:43:02 -08:00
Nicolas Gallagher
6faf6f5eb1 Update to flow 0.97 (#17892) 2020-01-24 10:52:38 -08:00
Nicolas Gallagher
81e30c7ff6 Remove unused modules from legacy event responders (#17907) 2020-01-24 10:50:27 -08:00
Nicolas Gallagher
9d09052d2f Update various monorepo dependencies (#17901) 2020-01-24 10:28:50 -08:00
Simen Bekkhus
3c713d5131 chore: update to latest release of babel (#17897) 2020-01-24 17:49:24 +00:00
Luna Ruan
3b3decf871 add warning when owner and self are different for string refs (#17864)
When owner and self are different for string refs, we can't easily convert them to callback refs. This PR adds a warning for string refs when owner and self are different to tell users to manually update these refs.
2020-01-22 12:32:51 -08:00
Nicolas Gallagher
6c00c5bba4 Update to flow-bin@0.89 (#17842) 2020-01-22 10:02:30 -08:00
Sebastian Markbåge
cf7a0c24d4 Remove dynamic GKs for selective/train (#17888)
There are shipped/shipping.
2020-01-21 19:43:35 -08:00
Dominic Gannaway
c322f5913f Add unstable_renderSubtreeIntoContainer and unstable_createPortal feature flags (#17880) 2020-01-21 21:17:42 +00:00
Dominic Gannaway
f2fd484afd Add React.createFactory() deprecation warning (#17878) 2020-01-21 15:51:39 +00:00
Sebastian Markbåge
0c04acaf89 Remove FB specific build (#17875)
I moved unstable_SuspenseList internally. We don't need the FB build.
I plan on also removing the ReactDOM fb specific entry. We shouldn't add
any more FB specific internals nor APIs. If they're experimental they
should go onto the experimental builds to avoid too many permutations.
2020-01-20 16:06:01 -08:00
Dominic Gannaway
9fd760ce75 Add disable <textarea/> children flag (#17874) 2020-01-20 15:12:30 +00:00
Dominic Gannaway
a209a97ed7 Add feature flag around React.createFactory (#17873) 2020-01-20 15:00:18 +00:00
Andrew Clark
95bd7aad7d Remove renderPhaseUpdates Map (#17625)
* Remove renderPhaseUpdates Map

Follow up to #17484, which was reverted due to a bug found in www.

* Failing test: Dropped updates

When resetting render phase updates after a throw, we should only clear
the pending queue of hooks that were already processed.

* Fix non-render-phase updates being dropped

Detects if a queue has been processed by whether the hook was cloned.
If we change the implementation to an array instead of a list, we'll
need some other mechanism to determine whether the hook was processed.

* Regression test: startTransition in render phase

useTransition uses the state hook as part of its implementation, so we
need to fork it in the dispatcher used for re-renders, too.
2020-01-17 16:00:35 -05:00
Bogdan
29b4d0721c Allow debug-test commands to run on Windows (#17122)
Fix #17121
2020-01-17 10:20:09 -08:00
Dominic Gannaway
b43b36dd91 Remove ReactInstanceMap_DO_NOT_USE shim (#17861) 2020-01-17 12:37:55 +00:00
Dominic Gannaway
9e075d16b2 [react-interactions] Remove deprecated Scope APIs + update Focus components/docs (#17859) 2020-01-17 12:16:39 +00:00
Brian Vaughn
bc1f3e1a69 Fix DevTools Flow error for key-sort function (#17849) 2020-01-15 09:45:16 -08:00
Dominic Gannaway
b6173e643a [react-interactions] Add DO_NOT_USE to Scope methods (#17835) 2020-01-15 09:50:09 +00:00
Brian Vaughn
8aefb1995c Removed 'reactInternal' reference in DevTools overlay highlighter (#17841) 2020-01-14 15:38:09 -08:00
Jason Williams
643dcb5526 Add support for Node v13 for development (#17837) 2020-01-14 23:20:42 +00:00
Brian Vaughn
1e1a989422 Re-enabled DevTools context menu option in Firefox to inspect function prop source (#17838) 2020-01-14 14:00:28 -08:00
Nicolas Gallagher
3bd6adceda Update typescript package and jest preprocessor (#17839) 2020-01-14 13:52:52 -08:00
Nicolas Gallagher
50eafef07e Update babel-eslint and eslint packages (#17829) 2020-01-14 09:26:44 -08:00
André
4f480d0645 Fix typo in TestCase description (#17077) 2020-01-12 11:54:12 -08:00
Dan
f4ca909e0e react-refresh@0.7.2 2020-01-12 17:54:30 +00:00
Dan Abramov
255d9ac5f5 [Fresh] Fix edge case with early function call (#17824) 2020-01-12 17:53:50 +00:00
Nicolas Gallagher
64aae7b06f Fix issue template for questions (#17817) 2020-01-10 10:57:34 -08:00
Emily
d8570ec6ea Create ReactFabric.stopSurface and use that for bridgeless mode binding (#16164) 2020-01-10 10:21:32 -08:00
Nicolas Gallagher
05e487a12f Add GitHub issue templates (#17815) 2020-01-09 16:16:37 -08:00
Ganapati V S
5d6129b5d1 Update ReactSuspenseList-test.internal.js (#17034)
Typo
2020-01-09 14:14:00 -08:00
Dawid Loranc
ff900095b9 Fix message typo in printOperationsArray function (#17039) 2020-01-09 14:13:03 -08:00
Alican Çubukçuoğlu
1b6e269751 Create SECURITY.md (#15784)
Adds SECURITY.md as mentioned in #15722.
2020-01-09 14:07:41 -08:00
Tao
3ac81a57fb Update create-react-app note for eslint-plugin-react-hooks (#16982)
eslint-plugin-react-hooks was added in react-scripts 3.0.0
2020-01-09 13:47:05 -08:00
Brian Vaughn
435259f189 Add better test coverage for hooks in DevTools Profiler's change-detection (#17816) 2020-01-09 13:15:19 -08:00
Nicolas Gallagher
2e4948a34d Add configuration for the "Stale" GitHub App (#17806)
Configuration for the bot that marks and closes stale issues and pull requests.
https://probot.github.io/apps/stale/
2020-01-09 11:13:41 -08:00
Dan Abramov
e706721490 Update Flow to 0.84 (#17805)
* Update Flow to 0.84

* Fix violations

* Use inexact object syntax in files from fbsource

* Fix warning extraction to use a modern parser

* Codemod inexact objects to new syntax

* Tighten types that can be exact

* Revert unintentional formatting changes from codemod
2020-01-09 14:50:44 +00:00
Dan Abramov
b979db4e72 Bump Prettier (#17811)
* Bump Prettier

* Reformat

* Use non-deprecated option
2020-01-09 13:54:11 +00:00
Sebastian Markbåge
18875b2401 Remove special casing of toString values when enableTrustedTypesIntegration (#17774)
* Remove toString of dangerouslySetInnerHTML

As far as I can tell, the toString call was added here:

caae627cd5 (diff-5574f655d491348f422bca600ff6711dR887)

It was never really needed. Subsequently when we added Trusted Types,
this needed to be changed to a special call but we really should just
always let it pass through.

* Remove special casing of toString values when enableTrustedTypesIntegration

As far as I can tell, we only toString in user space because of IE8/9.

We don't really support IE8/9 anymore and by the time this flag is on,
we should be able to deprecate it.

Unless this is also an issue in IE11. I haven't tested yet.
2020-01-08 14:40:07 -08:00
Eli White
19f6fe170c Revert "Revert "Dispatch commands to both UIManagers from both renderers (#17211)" (#17232)" (#17799)
* Revert "Revert "Dispatch commands to both UIManagers from both renderers (#17211)" (#17232)"

This reverts commit d0fc0ba0a6.

* Clean up another __DEV__ warning check
2020-01-07 16:47:19 -08:00
Brian Vaughn
6250462bed Renamed "ReactDOM-fb" imports to "ReactDOM" in www shims (#17797)
* Renamed "ReactDOM-fb" imports to "ReactDOM" in www shims

* Removed ReactDOMComponentTree_DO_NOT_USE.js
2020-01-07 13:05:36 -08:00
Dominic Gannaway
5e21157d86 [react-interactions] Fix Hover issues with portals (#17765) 2020-01-07 19:45:26 +00:00
Brian Vaughn
40568e9773 Updated DevTools CHANGELOG to add pending release details 2020-01-06 10:37:20 -08:00
Brian Vaughn
5586b3022c Merge branch 'GasimGasimzada-scope-devtools-styles' 2020-01-06 10:36:13 -08:00
Brian Vaughn
7580d6717c Fixed padding problem in standalone shell 2020-01-06 10:35:36 -08:00
Brian Vaughn
80e32487b9 Fixed box-sizing problem in test shell 2020-01-06 10:23:55 -08:00
Brian Vaughn
c1b573bf2f Merge branch 'scope-devtools-styles' of https://github.com/GasimGasimzada/react into GasimGasimzada-scope-devtools-styles 2020-01-06 10:13:35 -08:00
Brian Vaughn
fc921a1693 Updated DevTools CHANGELOG to add pending release details 2020-01-06 10:12:26 -08:00
Brian Vaughn
1c63b2e416 Renamed "backend.js" to "react_devtools_backend.js" (#17790) 2020-01-06 09:29:20 -08:00
Brian Vaughn
2bb227ef80 DevTools: Improve function props display for inspected elements (#17789) 2020-01-06 09:19:59 -08:00
Brian Vaughn
24f824250f DevTools Profiler: Improve how empty commits are filtered (#17771)
Previously, DevTools filtered empty commits on the backend, while profiling, through the use of a bailout heuristic that React currently happens to use. This approach was brittle and may have exacerbated the long-standing Profiler bug #16446.

This PR removes that heuristic and adds as a post-processing filtering pass instead. This removes the coupling between DevTools and a React internal implementation detail that may change.

I believe DevTools has two choices of criteria for this filtering:
* Filter commits that have no actual duration metadata.
* Filter commits that have no recorded operations (no mutations to the tree, no changed tree base durations).

I chose the first option, filtering by commits that have no reported metadata. It will miss an edge case, e.g. , but we would have nothing meaningful to show in the Profiler for those cases anyway. (This particular edge case is why one of the snapshots changed with this commit.)

The second option, filtering by recorded operations, could potentially miss a more important edge case: where a component *did* render, but its  didn't change. (In that event, there would be no operations to send.)
2020-01-04 16:50:39 -08:00
Sebastian Markbåge
edeea07207 Remove toString of dangerouslySetInnerHTML (#17773)
As far as I can tell, the toString call was added here:

caae627cd5 (diff-5574f655d491348f422bca600ff6711dR887)

It was never really needed. Subsequently when we added Trusted Types,
this needed to be changed to a special call but we really should just
always let it pass through.
2020-01-04 05:47:23 -08:00
Gasim Gasimzada
9cc094a19a Scope dev tools wildcard styles within DevTools CSS class 2020-01-04 14:04:15 +04:00
Brian Vaughn
f749045a5b DevTools 4.3.0 -> 4.4.0 2020-01-03 10:02:50 -08:00
Sebastian Markbåge
59f21f1b24 HostText needs to copy over from current if it is unchanged in persistent mode (#17538)
stateNode is not one of the fields that gets copied over by createWorkInProgress.

This is bad for persistent mode since it's not the same instance.

In HostComponent we happened to always end up transferring the current stateNode when we bail.
However, we didn't do this for HostText.
2020-01-03 17:35:17 +00:00
Brian Vaughn
7e2ab87a61 DevTools: Replaced unsafe hasOwnProperty() calls (#17768)
DevTools previously called  in several places with user-defined values. This could lead to runtime errors if those values had an overriden  attribute. This commit replaces those callse with  instead.

New test cases have been added.
2020-01-03 09:34:12 -08:00
Brian Vaughn
5d3d71b1dd Partial fix DevTools Profiler ''Could not find node…'' error (#17759)
The Profiler stores:

1. A snapshot of the React tree when profiling started
2. The operations array for each commit
3. Profiling metadata (e.g. durations, what changed, etc) for each commit

It uses this information (snapshot + operations diff) to reconstruct the state of the application for a given commit as it's viewed in the Profiler UI. Because of this, it's very important that the operations and metadata arrays align. If they don't align, the profiler will be unable to correctly reconstruct the tree, and it will likely throw errors (like 'Could not find node…')

#16446 tracks a long-standing bug where these two arrays get misaligned. I am still not entirely sure what causes this bug, but with PR #17253, I exacerbated things by introducing another potential way for it to happen. This PR addresses the regression at least (and adds test coverage for it).

I will follow up this afternoon on the original #16446 issue. I think I may have a lead on what's happening at least, if not exactly an idea of how to reproduce it.
2020-01-03 09:28:31 -08:00
Brian Vaughn
cca994c6a1 DevTools Profiler commit selector wraps around (#17760)
I used to disable the <- and -> buttons when you reached the beginning or end of the profiler data. This can be kind of annoying though when you just want to get to the last commit, and I don't think there's a good reason to enforce it anyway, so I backed that change out. The buttons now wrap around at the beginning or end of the list.
2020-01-02 14:44:07 -08:00
Brian Vaughn
b05cd611ba Fixed CircleCI DevTools build artifact tar internal structure (#17758) 2020-01-02 09:28:20 -08:00
Brian Vaughn
195b3db618 Added missing guard to DevTools for Objects with null proto (#17757)
This prevents a runtime error from occurring when these objects are inspected.
2020-01-02 08:27:29 -08:00
Brian Vaughn
2c1e5d2b22 Build and store DevTools artifacts in Circle CI (#17746) 2020-01-01 07:58:47 -08:00
Brian Vaughn
86883d7aac Updated DevTools pending CHANGELOG 2019-12-30 09:12:49 -08:00
dependabot[bot]
b4e2fac09d Bump handlebars from 4.0.11 to 4.5.3 in /fixtures/expiration (#17729)
Bumps [handlebars](https://github.com/wycats/handlebars.js) from 4.0.11 to 4.5.3.
- [Release notes](https://github.com/wycats/handlebars.js/releases)
- [Changelog](https://github.com/wycats/handlebars.js/blob/master/release-notes.md)
- [Commits](https://github.com/wycats/handlebars.js/compare/v4.0.11...v4.5.3)

Signed-off-by: dependabot[bot] <support@github.com>
2019-12-30 08:57:08 -08:00
dependabot[bot]
e6226e6493 Bump handlebars from 4.0.6 to 4.5.3 in /fixtures/dom (#17730)
Bumps [handlebars](https://github.com/wycats/handlebars.js) from 4.0.6 to 4.5.3.
- [Release notes](https://github.com/wycats/handlebars.js/releases)
- [Changelog](https://github.com/wycats/handlebars.js/blob/master/release-notes.md)
- [Commits](https://github.com/wycats/handlebars.js/compare/v4.0.6...v4.5.3)

Signed-off-by: dependabot[bot] <support@github.com>
2019-12-30 08:56:44 -08:00
dependabot[bot]
3bec713b85 Bump handlebars from 4.0.10 to 4.5.3 in /fixtures/attribute-behavior (#17728)
Bumps [handlebars](https://github.com/wycats/handlebars.js) from 4.0.10 to 4.5.3.
- [Release notes](https://github.com/wycats/handlebars.js/releases)
- [Changelog](https://github.com/wycats/handlebars.js/blob/master/release-notes.md)
- [Commits](https://github.com/wycats/handlebars.js/compare/v4.0.10...v4.5.3)

Signed-off-by: dependabot[bot] <support@github.com>
2019-12-30 08:56:11 -08:00
dependabot[bot]
ee38c00bd5 Bump handlebars from 4.0.6 to 4.5.3 in /fixtures/fiber-debugger (#17727)
Bumps [handlebars](https://github.com/wycats/handlebars.js) from 4.0.6 to 4.5.3.
- [Release notes](https://github.com/wycats/handlebars.js/releases)
- [Changelog](https://github.com/wycats/handlebars.js/blob/master/release-notes.md)
- [Commits](https://github.com/wycats/handlebars.js/compare/v4.0.6...v4.5.3)

Signed-off-by: dependabot[bot] <support@github.com>
2019-12-30 08:56:05 -08:00
dependabot[bot]
4d463fce4e Bump handlebars from 4.1.2 to 4.5.3 (#17732)
Bumps [handlebars](https://github.com/wycats/handlebars.js) from 4.1.2 to 4.5.3.
- [Release notes](https://github.com/wycats/handlebars.js/releases)
- [Changelog](https://github.com/wycats/handlebars.js/blob/master/release-notes.md)
- [Commits](https://github.com/wycats/handlebars.js/compare/v4.1.2...v4.5.3)

Signed-off-by: dependabot[bot] <support@github.com>
2019-12-30 08:46:41 -08:00
Karan Sharma
d259f45813 Fix various typos (#17724) 2019-12-29 13:47:51 -08:00
Chris Watson
9357a483e9 Fix for the standalone devtools not responding to clicks. (#17584) 2019-12-29 13:46:27 -08:00
Brian Vaughn
22ef96ae63 Devtools renable copy attr context menu for firefox (#17740)
* Use exportFunction() to share clipboard copy with JS running in document/page context.

* Remove no-longer-used option to disable copy operation.
2019-12-29 13:27:44 -08:00
Brian Vaughn
2b903da355 Make DevTools check document.contentType before injecting (#17739)
It should only inject the global hook into HTML documents. This will avoid breaking syntax highlighting for e.g. XML documents.
2019-12-29 13:02:50 -08:00
Brian Vaughn
0eac01abcd Added missing Flow type coverage to DevTools context menu (#17733)
The  param should probably be a generic type, but I'm not sure how to satisfy Flow with the current top-level  Map. At least this adds basic coverage (which was missing before, oops).
2019-12-29 08:44:24 -08:00
Brian Vaughn
f887d1aa27 [DevTools] Display RegExp values in props/state (#17690)
Previously, when props/state contained a regexp, it was shown as an
empty object. This commit adds regexps as values in need of special
rehydration (like Symbols or TypedArrays), and display them as a user
might expect.

Co-authored-by: Zirak <zirakertan@gmail.com>
2019-12-22 11:49:28 -08:00
Brian Vaughn
1959671d45 Add tooltip to interaction name in DevTools Profiler sidebar (#17689) 2019-12-22 08:52:53 -08:00
Nick S. Plekhanov
ccc6100d7f Fix comments typos (#17550)
* Fix comments typos

* Fix comments typos

* Fix more typos

Co-authored-by: Brian Vaughn <brian.david.vaughn@gmail.com>
2019-12-22 08:44:34 -08:00
Maxime Bouveron
6215e1c2db Add Shift+Enter to go to previous search result (#17005) 2019-12-22 08:38:14 -08:00
Dominic Gannaway
85d9655d6f [react-dom] Refactor event priority handling to its own module (#17678) 2019-12-20 23:15:36 +00:00
Brian Vaughn
3e09677836 DevTools v4.2.1 -> 4.3.0 2019-12-20 09:11:37 -08:00
Nicolas Gallagher
31350237fa Add unit tests to dom-event-testing-library (#17680)
Unit tests for the simple event mocks
2019-12-20 16:35:02 +00:00
Brian Vaughn
79734771cd Disable "copy to clipboard" and "go to definition" context menu options for Firefox addon (#17668) 2019-12-20 08:31:38 -08:00
Dominic Gannaway
dbc46ac63e [react-interactions] Rename test + fix master (#17679) 2019-12-20 16:00:39 +00:00
Brian Vaughn
1b9328cd9b Null stateNode after unmount (#17666) 2019-12-19 13:32:14 -08:00
Dan Abramov
897976600c [ESLint] Allow partial matches for custom Effect Hooks (#17663) 2019-12-19 17:04:17 +00:00
Nicolas Gallagher
72592310a8 Create packages/dom-event-testing-library (#17660)
Moves the unit testing library for events into the `packages` directory so it can more easily be used in tests for other react packages, and mirrored internally to help with testing of event hooks we prototype in www.
2019-12-19 16:51:25 +00:00
Dominic Gannaway
e7494c86c5 [react-interactions] Remove batchedUpdates from responder lifecycles (#17659) 2019-12-19 13:07:00 +00:00
Nicolas Gallagher
a5e951d4cc [react-interactions] Event testing library improvements (#17614)
Introduces a state machine around pointer events to produce more accurate mock
touch events. This allows multi-touch unit tests to be written entirely in
terms of mock pointer interactions, while producing the expected
'changedTouches', 'targetTouches', and 'touches' fields for mock touch events.
2019-12-18 23:32:48 +00:00
Brian Vaughn
95056b6836 DevTools build script enhancements (#17653)
* Updated DevTools local development instructions to mention experimental build step

* Added a command to download latest experimental release (for DevTools)

* Updated build instructions for clarity

* Added build-for-devtools package alias
2019-12-18 14:34:40 -08:00
Brian Vaughn
fd2a3ae57f Updated DevTools changelog 2019-12-18 12:51:18 -08:00
Brian Vaughn
933f6a07ca DevTools context menu (#17608)
* Added rudimentary context menu hook and menu UI

* Added backend support for copying a value at a specific path for the inspected element

* Added backend support for storing a value (at a specified path) as a global variable

* Added special casing to enable copying undefined/unserializable values to the clipboard

* Added copy and store-as-global context menu options to selected element props panel

* Store global variables separately, with auto-incremented name (like browsers do)

* Added tests for new copy and store-as-global backend functions

* Fixed some ownerDocument/contentWindow edge cases

* Refactored context menu to support dynamic options

Used this mechanism to add a conditional menu option for inspecting the current value (if it's a function)

* Renamed "safeSerialize" to "serializeToString" and added inline comment
2019-12-18 12:12:34 -08:00
Sebastian Markbåge
7dc9745427 [Flight] Chunks API (#17398)
* Add feature flags

* Add Chunk type and constructor

* Wire up Chunk support in the reconciler

* Update reconciler to reconcile Chunks against the render method

This allows the query and args to be updated.

* Drop the ref. Chunks cannot have refs anyway.

* Add Chunk checks in more missing cases

* Rename secondArg

* Add test and fix lazy chunks

Not really a supported use case but for consistency I guess.

* Fix fragment test
2019-12-18 18:25:43 +00:00
Eli White
9354dd2752 Make HostComponent inexact (#17412) 2019-12-18 18:21:42 +00:00
Sebastian Markbåge
4c270375e9 Favor fallthrough switch instead of case statements for work tags (#17648)
* Favor fallthrough switch instead of case statements for work tags

Currently we're inconsistently handling tags that are only relevant
for certain flags. We should throw if the tag is not part of the built
feature flags. This should also mean that the case statements can be
eliminated.

We can achieve this effect by putting the invariant outside of the switch
and always early return in the switch. We already do this in beginWork.
This PR makes this consistent in other places.

* Fail if fundamental/scope tags are discovered without the flag on
2019-12-18 15:53:27 +00:00
Dan Abramov
6fef7c47a9 Add a regression test for switching from Fragment to a component (#17647)
* Add a regression test for switching from Fragment to a component

* Add a few more tests
2019-12-18 15:21:42 +00:00
Dominic Gannaway
9fe1031244 [react-interactions] Rename Flare APIs to deprecated and remove from RN (#17644) 2019-12-18 10:24:46 +00:00
Brian Vaughn
e84327ba0c Added more forwardRef test cases for DevTools (#17642) 2019-12-17 12:45:10 -08:00
Dan Abramov
4b0cdf29a8 Build FB RN targets only in experimental mode (#17641) 2019-12-17 20:22:49 +00:00
zthxxx
24dbe851e8 fix(dev-tools): fix show correct displayName with forwardRef in Dev Tools (#17613)
* fix(dev-tools): fix show correct displayName with forwardRef in Dev Tools

allow set `displayName` after `React.forwardRef()`,
makesure Dev Tools show displayName as same as `getWrappedName` in `shared/getComponentName.js`

* Removed a little unnecessary/redundant code.

* Fixed lint error (removed unused var)
2019-12-17 11:29:16 -08:00
Brian Vaughn
bb75a4fa89 Improved selection and toggling for props/hooks/state (#17588)
1. Enable nested values to be expanded/collapsed by clicking on values as well as keys.
2. Enable keys and values to be selectable (for copy-pasting purposes)
2019-12-17 11:28:37 -08:00
伊撒尔
7309c5f934 Use zero-fill right shift instead of Math.floor (#17616)
For positive numbers, binary displacement is better.
2019-12-17 11:16:04 -08:00
Dan Abramov
9bb3fbe893 Move DevTools CI job to experimental workflow (#17640) 2019-12-17 18:21:38 +00:00
Dan Abramov
3c54df0914 Fix missing stacks in WWW warnings (#17638) 2019-12-17 15:21:18 +00:00
Dan Abramov
b66e86d957 react-refresh@0.7.1 2019-12-17 13:50:57 +00:00
Dan Abramov
c2d1561c60 [Fast Refresh] Support injecting runtime after renderer executes (#17633) 2019-12-17 13:49:39 +00:00
Dan Abramov
0253ee9a2e Additional test infra changes for toErrorDev rename (#17632) 2019-12-17 13:31:47 +00:00
Dan Abramov
36a6e29bb3 Fix test_build_devtools CI job to run test-build-devtools (#17631)
* Skip abandoned project folders in Jest config

This fixes a problem that occurs after renaming a package.

* Fix test_build_devtools to run test-build-devtools

* Exclude console.error plugin for DevTools packages

* Use correct release channel for DevTools tests

This should fix the createRoot error.

* Fix TZ dependent test

* Change DT job dependencies
2019-12-16 16:03:12 -08:00
Dan Abramov
7c21bf72ac Fix release script to ignore empty package folders 2019-12-16 19:16:58 +00:00
Dan Abramov
f42431abe1 Revert "Remove renderPhaseUpdates Map (#17484)" (#17623)
This reverts commit 8a347ed024.
2019-12-16 19:03:00 +00:00
Dan Abramov
0b5a26a489 Rename toWarnDev -> toErrorDev, toLowPriorityWarnDev -> toWarnDev (#17605)
* Rename toWarnDev -> toErrorDev in tests

* Rename toWarnDev matcher implementation to toErrorDev

* Rename toLowPriorityWarnDev -> toWarnDev in tests and implementation
2019-12-16 12:48:16 +00:00
Dan Abramov
0cf22a56a1 Use console directly instead of warning() modules (#17599)
* Replace all warning/lowPriWarning with console calls

* Replace console.warn/error with a custom wrapper at build time

* Fail the build for console.error/warn() where we can't read the stack
2019-12-14 18:09:25 +00:00
Dan Abramov
b6c423daad Use matching test command for equivalence tests (#17604) 2019-12-14 17:52:29 +00:00
Sebastian Markbåge
8a347ed024 Remove renderPhaseUpdates Map (#17484)
* Render phase updates can now be extracted from the pending queue

* Use a custom dispatcher for the second render pass

* Discard render phase updates if component throws

When aborting a render, we also need to throw out render phase updates.
Remove the updates from the queues so they do not persist to the next
render. We already did a single pass through the whole list of hooks, so
we know that any pending updates must have been dispatched during the
render phase. The ones that were dispatched before we started rendering
were already transferred to the current hook's queue.
2019-12-13 16:45:09 -08:00
Dominic Gannaway
be603f5a51 [react-events] Remove lastNativeEvent in favor of SystemFlags (#17585) 2019-12-13 17:03:35 +00:00
Dan Abramov
b15bf36750 Add component stacks to (almost) all warnings (#17586) 2019-12-12 23:47:55 +00:00
Nicolas Gallagher
612a76812f [react-interactions] Mock touchend events should use empty array for 'touches' (#17589)
The 'touches' value should be an empty array rather than 'null'
2019-12-12 22:21:30 +00:00
Brian Vaughn
12c000412d Improved inspected element props with inline previews (#17579)
* Improved inspected element props with inline previews

This mimics the inline preview shown by the brower console and dramatically improves the UX when inspecting deep values. I also updated tests to add more coverage for this new functionality.

* Cleaned up the DataView vs typed array check

* Added early bailouts to DevTools when generating preview strings for iterables/objects/arrays, to avoid doing unnecessary work
2019-12-11 17:52:17 -08:00
Dominic Gannaway
2afeebdcc4 [react-interactions] Remove responder root event types + revert commit phase change (#17577) 2019-12-11 16:48:46 +00:00
Laura buns
9ac42dd074 Remove the condition argument from warning() (#17568)
* prep for codemod

* prep warnings

* rename lint rules

* codemod for ifs

* shim www functions

* Handle more cases in the transform

* Thanks De Morgan

* Run the codemod

* Delete the transform

* Fix up confusing conditions manually

* Fix up www shims to match expected API

* Also check for low-pri warning in the lint rule
2019-12-11 03:28:14 +00:00
Andrew Clark
7bf40e1cfd Initialize update queue object on mount (#17560)
* Refactor Update Queues to Fix Rebasing Bug

Fixes a bug related to rebasing updates. Once an update has committed,
it should never un-commit, even if interrupted by a higher priority
update. The fix includes a refactor of how update queues work.

This commit is a combination of two PRs:

- #17483 by @sebmarkbage refactors the hook update queue
- #17510 by @acdlite refactors the class and root update queue

Landing one without the other would cause state updates to sometimes be
inconsistent across components, so I've combined them into a single
commit in case they need to be reverted.

Co-authored-by: Sebastian Markbåge <sema@fb.com>
Co-authored-by: Andrew Clark <git@andrewclark.io>

* Initialize update queue object on mount

Instead of lazily initializing update queue objects on the first update,
class and host root queues are created on mount. This simplifies the
logic for appending new updates and matches what we do for hooks.
2019-12-10 18:42:42 -06:00
Brian Vaughn
031a5aaffb Show component location for selected element in bottom/right of props panel (#17567)
* Show component location info for selected element in bottom/right of props panel

* Moved RegExp declaration into function basedon PR feedback
2019-12-10 09:24:34 -08:00
Andrew Clark
e039e690b5 Revert Update Queue Refactor
Reverts b617db3d96.

Found some bugs when attempting to land in www. Reverting to fix master.
I'll land again *after* the change successfully land downstream.
2019-12-09 15:16:09 -08:00
Andrew Clark
b617db3d96 Refactor Update Queues to Fix Rebasing Bug
Fixes a bug related to rebasing updates. Once an update has committed,
it should never un-commit, even if interrupted by a higher priority
update. The fix includes a refactor of how update queues work.

This commit is a combination of two PRs:

- #17483 by @sebmarkbage refactors the hook update queue
- #17510 by @acdlite refactors the class and root update queue

Landing one without the other would cause state updates to sometimes be
inconsistent across components, so I've combined them into a single
commit in case they need to be reverted.

Co-authored-by: Sebastian Markbåge <sema@fb.com>
Co-authored-by: Andrew Clark <git@andrewclark.io>
2019-12-09 13:19:26 -08:00
Dominic Gannaway
3c1efa0d77 [react-interactions] Remove Focus/FocusWithin root event types (#17555) 2019-12-09 14:27:45 +00:00
Nicolas Gallagher
9e937e7e86 [react-interactions] fix Press/Tap behavior for virtual middle clicks (#17554)
Tools like BetterTouchTool for macOS trigger middle-clicks with a 'buttons'
value that doesn't correspond to the middle-mouse button. To account for this
we also inspect the value of 'button'.

Close #17367
2019-12-09 13:04:24 +00:00
Laura buns
b43eec7eaa Replace wrap-warning-with-env-check with an eslint plugin (#17540)
* Replace Babel plugin with an ESLint plugin

* Fix ESLint rule violations

* Move shared conditions higher

* Test formatting nits

* Tweak ESLint rule

* Bugfix: inside else branch, 'if' tests are not satisfactory

* Use a stricter check for exactly if (__DEV__)

This makes it easier to see what's going on and matches dominant style in the codebase.

* Fix remaining files after stricter check
2019-12-06 18:25:54 +00:00
Dominic Gannaway
acfe4b21b2 [react-interactions] Upgrade passive event listeners to active listeners (#17513) 2019-12-04 19:30:50 +00:00
Farhad Yasir
5235d193d7 fix: make serializable data in react-devtools (#17233)
* fix: make serializable data for bridge in react-devtools

* fix: add bigint data type in hydration

* refactor: remove console.log

* test: update unit tests for bigint in react-devtools
2019-12-04 15:53:00 +00:00
Sebastian Markbåge
5064c7f6aa Revert Rerender Error Check (#17519)
* Add failing test

* Revert "Move rerender error check to avoid global state"

This reverts commit 3e77742d8c4e64b89f816c0b1ce0bc156f8c5f61.
2019-12-03 23:10:36 -08:00
Dominic Gannaway
6d105ad3f6 [react-interactions] Move Flare event registration to commit phase (#17518) 2019-12-04 02:08:20 +00:00
Sebastian Markbåge
dc18b8b8d2 Don't group Idle/Offscreen work with other work (#17456)
When we suspend we always try a lower level but we shouldn't try offscreen.
2019-12-03 13:38:02 -08:00
Sebastian Markbåge
f523b2e0d3 Use fewer global variables in Hooks (#17480)
* We don't need the global state for this

* Move componentUpdateQueue and sideEffectTag out of global state

* Move firstWorkInProgressHook off global state

* Move remainingExpirationTime off global state

* Reset fiber to its current state if it throws

* Move rerender error check to avoid global state

This means that it's harder to find it since it's not in the dispatch
function's stack but we can add a DEV only one for that if we really
need it. Alternatively, we can check it in against the renderUpdates queue.

* Move next___Hook out of global state

* Assert that currentlyRenderingFiber is always set

When accessed, this should always be set. This could enforced by storing
this on the dispatcher for example.

* Add another test just to be safe
2019-12-03 12:51:36 -08:00
Sebastian Markbåge
d75323f65d Remove case that only exists for createBatch (#17506)
The comment says this is only needed for createBatch().commit() which
doesn't exist anymore.
2019-12-03 10:35:17 -08:00
Sebastian Markbåge
79572e34d1 Adjust SuspenseList CPU bound heuristic (#17455)
* Adjust SuspenseList CPU bound heuristic

In SuspenseList we switch to rendering fallbacks (or stop rendering further
rows in the case of tail="collapsed/hidden") if it takes more than 500ms
to render the list. The limit of 500ms is similar to the train model and
designed to be short enough to be in the not noticeable range.

This works well if each row is small because we time the 500ms range well.
However, if we have a few large rows then we're likely to exceed the limit
by a lot. E.g. two 480ms rows hits almost a second instead of 500ms.

This PR adjusts the heuristic to instead compute whether something has
expired based on the render time of the last row. I.e. if we think rendering
one more row would exceed the timeout, then we don't attempt.

This still works well for small rows and bails earlier for large rows.

The expiration is still based on the start of the list rather than the
start of the render. It should probably be based on the start of the render
but that's a bigger change and needs some thought.

* Comment
2019-12-02 17:53:08 -08:00
Sung M. Kim
b64938e123 Fixed changelog formatting #17481 (#17487) 2019-11-29 13:57:38 +00:00
Dan Abramov
969f4b5bb8 Change DevTools hook warning message (#17478) 2019-11-28 00:47:13 +00:00
Brian Vaughn
3816ae7c38 DevTools version bump 4.2.0 -> 4.2.1 2019-11-27 07:49:49 -08:00
Brian Vaughn
5fc97420b9 Remove dependency on local git checkout from build process (#17475)
* Remove dependency on local git checkout from build process

* Updated Webpack dependencies to account for recent changes to deps for Flight
2019-11-27 07:48:09 -08:00
Dan Abramov
6470e0f169 [Fresh] Make all errors recoverable (#17438)
* [Fresh] Detect root updates more reliably

* [Fresh] Use WeakMap for root elements

* [Fresh] Make initial failures recoverable too

* Fix DevTools check

* Fix wrong flow type
2019-11-25 17:25:34 +00:00
Andrew Clark
54f66731c8 Update release script URL (#17428)
CircleCI API endpoint changed
2019-11-21 13:19:03 -08:00
Dan Abramov
237a966da0 [Fresh] Fix an infinite loop in an edge case (#17414)
* [Fresh] Fix an infinite loop in an edge case

* Make it work in IE11
2019-11-21 14:10:26 +00:00
Dominic Gannaway
007a276b65 [react-interactions] Fix memory leak in event responder system (#17421) 2019-11-21 13:15:37 +00:00
Dominic Gannaway
3fdfa231ad [react-interactions] Refine virtual click detection for FF+JAWS/NVDA (#17422) 2019-11-21 13:09:30 +00:00
Dominic Gannaway
a7d07ff24d [react-interactions] Rename Flare listeners prop to DEPRECATED_flareListeners (#17394) 2019-11-18 13:32:50 +00:00
Sebastian Markbåge
3ad076472c Update Fixtures to use new APIs (#17380)
Also renamed unstable-async to concurrent
2019-11-17 14:42:47 -08:00
Andrew Clark
1f2da0babd Forgot to mark test as experimental (#17391) 2019-11-17 13:59:25 -08:00
David Garner
a807c307c4 [eslint] Check forwardRef callbacks (#17255)
* [eslint] Check forwardRef callbacks (#17220)

* [eslint] Make tests more realistic (#17220)

* [eslint] Check anonymous callback of React.memo for rules-of-hooks (#17220)

* [eslint] Add tests for callbacks not known to be components (#17220)

* [eslint] Correct comments and add another test (#17220)
2019-11-17 13:39:08 +00:00
Andrew Clark
2586303662 [Bugfix] Pending state is always user-blocking (#17382)
Fixes a bug where `isPending` is only set to `true` if `startTransition`
is called from inside an input event. That's usually the case, but
not always.

Now it works regardless of where you call it.
2019-11-15 15:46:09 -08:00
Sebastian Markbåge
8e74a31b2d Add Webpack as devDependency (#17379)
This is now used by the Flight package so it needs to be installed as a
peer.
2019-11-15 14:02:59 -08:00
Sebastian Markbåge
39dbb14da3 [Flight] Move Flight DOM to a Webpack Specific Package (#17372)
* Move Flight DOM to Webpack Specific Packagee

We'll have Webpack specific coupling so we need to ensure that it can be
versioned separately from various Webpack versions. We'll also have builds
for other bundlers in the future.

* Move to peerDep

* Move DOM Flight Tests

* Merge ReactFlightIntegration into ReactFlightDOM

This was an integration test. We can add to it.

* Fix fixture paths
2019-11-15 11:46:07 -08:00
Dominic Gannaway
532810a370 [react-interactions] FocusWithin beforeblur propagation fix (#17375) 2019-11-15 12:05:00 +00:00
Dominic Gannaway
f30ccb9ed9 [react-interactions] Fix unatached fiber bug (#17371) 2019-11-15 00:47:33 +00:00
Luna Ruan
1832f832c5 Changelog for 16.12 2019-11-14 16:06:10 -08:00
Luna Ruan
9a5f28dbed update version numbers for 16.12 2019-11-14 16:02:18 -08:00
Ricky
769dd522a2 [Fast Refresh] Fix for intentional unmounts after an error (#17368) 2019-11-14 18:40:25 +00:00
Dominic Gannaway
df8db4e005 [react-interactions] Enable event system before dispatching blur (#17365) 2019-11-14 13:47:39 +00:00
Dominic Gannaway
fc43644eba [react-interactions] Follow up active element blur logic (#17364) 2019-11-14 11:55:50 +00:00
Dominic Gannaway
a61886b16b [react-interactions] Refine custom active element blur logic (#17354) 2019-11-13 20:46:00 +00:00
Andrew Clark
b53ea6ca05 [Bugfix] Passive effects triggered by synchronous renders in a multi-root app (#17347)
* Regression test: Effects dropped across roots

See #17066

* [Bugfix] Passive effects loop

The bug
-------

In a multi-root app, certain passive effects (`useEffect`) are never
fired. See #17066.

The underlying problem
----------------------

The implicit contract of `flushPassiveEffects` is that, right after
calling it, there should be no pending passive effects. In the normal
case, in concurrent mode, this is true. But the current implementation
fails to account for the case where a passive effect schedules
synchronous work, which in turn schedules additional passive effects.

This led to `rootWithPendingPassiveEffects` being overwritten in the
commit phase, because an assignment that assumed it was replacing null
was actually replacing a reference to another root, which has the
consequence of dropping passive effects on that root.

The fix
-------

The fix I've chosen here is, at the beginning of the commit phase, keep
flushing passive effects in a loop until there are no more.

This doesn't not change the "public" implementation of
`flushPassiveEffects`, though it arguably should work this way, too. I
say "public" because it's only used by implementation layers on top of
React which we control: mainly, the legacy version of `act` that does
not use the mock Scheduler build. So there's probably still a bug
in that `act` implementation.

I will address `act` in a follow-up. The ideal solution is to replace
the legacy `act` with one implemented directly in the renderer, using a
special testing-only build of React DOM. Since that requires a breaking
change, we'll need an interim solution. We could make the "public" `act`
recursively flush effects in a loop, as I've done for the commit phase.
However, I think a better solution is to stop automatically flushing the
synchronous update queue at the end of `flushPassiveEffects`, and
instead require the caller to explicitly call `flushSyncUpdateQueue` (or
the equivalent) if needed. This follows the same pattern we use
internally in the work loop, which is designed to avoid factoring
hazards like the one that resulted in this bug.
2019-11-12 10:41:07 -08:00
Vasilii Cuhar
f4cc45ce96 [Fresh] Add options to configure RefreshSig and RefreshReg identifiers (#17340) 2019-11-12 14:16:23 +00:00
Eli White
ade764157f [Native] If statement cleanup for null targets (#17346) 2019-11-11 12:58:30 -08:00
Eli White
3dcec3a925 [Native] Add FeatureFlag to dispatch events with instance currentTarget (#17345)
* [Native] Add FeatureFlag to dispatch events with instance targets

* Prettier

* [Native] Change currentTarget to be an instance behind a flag 2/2
2019-11-11 12:42:06 -08:00
Eli White
2c6ea0b3ff [Native] Add FeatureFlag to dispatch events with instance targets (#17323)
* [Native] Add FeatureFlag to dispatch events with instance targets

* Prettier
2019-11-11 11:35:29 -08:00
Eli White
01bce8c248 Change legacy-events plugin nativeEventTarget to allow null (#17344) 2019-11-11 11:22:41 -08:00
Dominic Gannaway
6cff70a740 [react-interactions] Expost host instance to Scope Query function (#17341) 2019-11-11 13:51:46 +00:00
Dan Abramov
b8f8258775 Split ReactDOM entry point (#17331)
* Split ReactDOM entry point

* BatchedRoot -> BlockingRoot
2019-11-10 13:43:29 +00:00
Dan Abramov
a7b4d51a20 Warn when doing createRoot twice on the same node (another approach) (#17329)
* Unify fields used for createRoot warning and event system

* Warn when doing createRoot twice on the same node

* Stricter check for modern roots

* Unmark asynchronously

* Fix Flow
2019-11-10 00:54:13 +00:00
Dan Abramov
be3bfa6fab [Flight] Basic Integration Test (#17307)
* [Flight] Basic Integration Test

* Just act()

* Lint

* Remove unnecessary acts

* Use Concurrent Mode

* it.experimental

* Fix prod test by advancing time

* Don't observe initial state
2019-11-09 02:56:03 +00:00
Dan Abramov
182f64f938 [Flight] End-to-End Fixture (#17319) 2019-11-09 02:44:27 +00:00
Dan Abramov
6cb6b1d668 Add yarn build --unsafe-partial (#17316)
* Add yarn build --partial

* unsafe-partial
2019-11-08 19:41:40 +00:00
Moti Zilberman
38dd17ab98 [RN] Hoist static deepDiffer options object (#17303) 2019-11-07 16:03:55 +00:00
Moti Zilberman
61d3dd0e08 Update deepDiffer usage in React Native renderer (#17282)
* Add RN prop diffing test with function values

* Update RN deepDiffer mock

* Explicitly ignore functions in RN prop differ
2019-11-07 04:00:20 -08:00
Dominic Gannaway
e701632ad4 [react-interactions] Change unmount blur logic to a dedicated event (#17291) 2019-11-07 10:27:02 +00:00
Dominic Gannaway
ce4b3e9981 [react-interactions] Add optional searchNodes to Scope.queryAllNodes (#17293) 2019-11-06 22:52:59 +00:00
Sebastian Markbåge
dee03049f5 [Flight] Basic Streaming Suspense Support (#17285)
* Return whether to keep flowing in Host config

* Emit basic chunk based streaming in the Flight server

When something suspends a new chunk is created.

* Add reentrancy check

The WHATWG API is designed to be pulled recursively.

We should refactor to favor that approach.

* Basic streaming Suspense support on the client

* Add basic suspense in example

* Add comment describing the protocol that the server generates
2019-11-06 09:48:34 -08:00
Dan Abramov
f50f39b55f [Flight] Better compat with http.createServer (#17289) 2019-11-06 17:10:26 +00:00
Brian Vaughn
3452706308 DevTools cleanup (#17283)
1. Add a Store test for memo, lazy, and forwardRef components
2. Remove dead code for React.lazy
3. Update DT tests to include HOC badge names in the serialized store
2019-11-05 22:19:10 -08:00
Dominic Gannaway
cd1bdcd067 [react-interactions] Prevent duplicate onPress firing for keyboard Enter (#17266)
* [react-interactions] Prevent duplicate onPress firing for keyboard Enter

* address feedback
2019-11-05 23:28:26 +00:00
Waseem Dahman
4f02c93c7c Fix devtools displaying Anonymous for memo of ref-forwarding components (#17274)
* [react-is] return correct typeOf value of forwardRef

* [react-devtools-shared] use correct displayName of memo(forwardRef(Component))

* [react-devtools-shared] add resolveFiberType and resolve fiber type of memo recursively

Resolving the fiber type of memo recursively before passing it to getDisplayName
will prevent it from displaying "Anonymous" as displayName for components
wrapped with both memo and forwardRef: memo(forwardRef(Component))

* rework resolveFiberType
2019-11-05 14:08:01 -08:00
Brian Vaughn
053cf0fedc Fix react-is memo and lazy type checks (#17278) 2019-11-05 10:37:12 -08:00
Andrew Clark
0f3838a01b Remove debugRenderPhaseSideEffects flag (#17270)
There are two similar flags, `debugRenderPhaseSideEffects` and
`debugRenderPhaseSideEffectsForStrictMode`. The strict mode one is the
only one that is actually used. I think originally the theory is that
we would one day turn it on for all components, even outside strict
mode. But what we'll do instead is migrate everyone to strict mode.

The only place `debugRenderPhaseSideEffects` was being used was in
an internal test file. I rewrote those tests to use public APIs.
2019-11-04 14:07:05 -08:00
Dominic Gannaway
cb09dbe0ab [react-interactions] Add handleSimulateChildBlur upon DOM node removal (#17225)
* [react-interactions] Add handleSimulateChildBlur upon DOM node removal
2019-11-04 20:02:45 +00:00
Eli White
6095993d46 Types: findHostInstance_DEPRECATED returns React.ElementRef<HostComponent<mixed>> (#17265)
* Types: findHostInstance_DEPRECATED returns React.ElementRef<HostComponent<mixed>>

* Prettier
2019-11-04 10:14:01 -08:00
Mateusz Burzyński
62ef25077e Avoid bundling in ponyfill for Object.assign in use-subscription package (#17259) 2019-11-04 07:33:10 -08:00
Sebastian Markbåge
f4148b2561 [Flight] Move around the Server side a bit (#17251)
* Rename ReactFlightStreamer -> ReactFlightServer

* Unify Browser/Node stream tests into one file and use the client reader

* Defer to the actual ReactDOM for HTML rendering for now

This will need to use a variant of Fizz to do inline SSR in Flight.
However, I don't want to build the whole impl right now but also don't
want to exclude the use case yet. So I outsource it to the existing
renderer. Ofc, this doesn't work with Suspense atm.
2019-11-01 17:39:24 -07:00
Sebastian Markbåge
fadc97167f [Flight] Add Client Infrastructure (#17234)
* Change demo to server

* Expose client in package.json

* Reorganize tests

We don't want unit tests but instead test how both server and clients work
together. So this merges server/client test files.

* Fill in the client implementation a bit

* Use new client in fixture

* Add Promise/Uint8Array to lint rule

I'll probably end up deleting these deps later but they're here for now.
2019-11-01 16:05:07 -07:00
Brian Vaughn
36fd29f09f Don't show empty (no work) commits in Profiler (#17253) 2019-11-01 15:51:39 -07:00
Andrew Clark
a2e05b6c14 [Scheduler] Delete old rAF implementation (#17252)
We've been using the message loop version for a while. Time to delete.
2019-11-01 13:32:22 -07:00
Andrew Clark
6dc2734b41 Codemod tests to it.experimental (#17243)
`it.experimental` marks that a test only works in Experimental builds.

It also asserts that a test does *not* work in the stable builds. The
main benefit is that we're less likely to accidentally expose an
experimental API before we intend. It also forces us to un- mark an
experimental test once it become stable.
2019-11-01 10:20:08 -07:00
Ives van Hoorne
a1ff9fd7bb Add CodeSandbox CI Config (#17175)
* Add CodeSandbox CI Config

* Add default sandbox to build

* Make build more efficient and add scheduler

* Force build

* Add scheduler image

* Add scheduler/tracing to the build

* Force another build
2019-10-31 10:44:48 -07:00
Brian Vaughn
273679a78c DevTools standalone shell changes: (#17213)
* DevTools standalone shell changes:

1. Update React Native connection wording
2. Tweak styles slightly

* Tweaked standalone DevTools error warning text
2019-10-31 09:22:08 -07:00
Eli White
d0fc0ba0a6 Revert "Dispatch commands to both UIManagers from both renderers (#17211)" (#17232)
This reverts commit 8eee0eb01c.
2019-10-30 18:03:37 -07:00
Eli White
bdcdb69a24 Rename findHostInstance_deprecated to findHostInstance_DEPRECATED (#17228) 2019-10-30 13:10:16 -07:00
Eli White
515746c217 Add findHostInstance_deprecated to the React Native Renderer (#17224) 2019-10-30 11:42:37 -07:00
Brian Vaughn
9a35adc96d Only call Profiler onRender when a descendant had work (#17223) 2019-10-30 11:08:42 -07:00
Eli White
8eee0eb01c Dispatch commands to both UIManagers from both renderers (#17211)
* Dispatch commands to both UIManagers from both renderers

* Merge test files
2019-10-29 18:16:23 -07:00
Sebastian Markbåge
f4e974d26e Add Experimental Flight Infrastructure (#16398)
* Add Flight Build and Unify HostFormat Config between Flight and Fizz

* Add basic resolution of models

* Add basic Flight fixture

Demonstrates the streaming protocol.

* Rename to flight-server to distinguish from the client parts

* Add Flight Client package and entry point

* Fix fixture
2019-10-29 14:45:47 -07:00
Sebastian Markbåge
6cd365cac6 Don't treat the last row in hidden as deleted if already mounted (#17206)
Already mounted rows that resuspend may be considered as part of a tail
if they're at the end. However, for purposes of the tail="..." option
they don't get deleted. We deal with that in cutOffTailIfNeeded.

However, if they're also the first to suspend in the "hidden" case, we have
a special case that deletes the actual rendered row. This needs to consider
if that row was already mounted or things go wrong.
2019-10-29 13:38:25 -07:00
Dominic Gannaway
048879edad [react-interactions] Ensure props on scope query function is always object (#17212) 2019-10-29 13:26:46 -07:00
Brian Vaughn
3497ccc149 Add guard to handle modified React elements with non-string keys (#17164) 2019-10-29 08:41:48 -07:00
Lea Rosema
0f64703edf Update .mailmap (#17177) 2019-10-28 16:48:54 +00:00
Deniz Susman
3f9c036758 Typo fix in comment (#17111) 2019-10-26 08:33:05 -07:00
Dan Abramov
f6b8d31a76 Rename createSyncRoot to createBlockingRoot (#17165)
* Rename createSyncRoot to createBlockingRoot

* Fix up
2019-10-23 15:04:39 -07:00
Wilco Fiers
9c02d26549 docs: Fixed a typo in readme.md (#17119) 2019-10-23 18:52:14 +01:00
Andrew Clark
57b2fbb741 Changelog for 16.11.0 2019-10-22 14:30:12 -07:00
Andrew Clark
8075c8505b Update local package versions for 16.10 release 2019-10-22 14:30:06 -07:00
Brian Vaughn
5faf377df5 Fixed a style bug in props editor (#17162) 2019-10-21 15:08:55 -07:00
Dominic Gannaway
f7ec65eeba [react-interactions] Make events non-passive to allow preventDefault (#17136) 2019-10-21 22:37:27 +02:00
Andrew Clark
1022ee0ec1 Read current time without marking event start time (#17160)
* Failing test: DevTools hook freezes timeline

The DevTools hook calls `requestCurrentTime` after the commit phase has
ended, which has the accidnental consequence of freezing the start
time for subsequent updates. If enough time goes by, the next update
will instantly expire.

I'll push a fix in the next commit.

* Read current time without marking event start time

`requestCurrentTime` is only meant to be used for updates, because
subsequent calls within the same event will receive the same time.
Messing this up has bad consequences.

I renamed it to `requestCurrentTimeForUpdate` and created a new
function that returns the current time without the batching heuristic,
called `getCurrentTime`.

Swapping `requestCurrentTime` for `getCurrentTime` in the DevTools
hook fixes the regression test added in the previous commit.
2019-10-21 13:15:37 -07:00
Andrew Clark
349cf5acc3 Experimental test helper: it.experimental (#17149)
Special version of Jest's `it` for experimental tests. Tests marked as
experimental will run **both** stable and experimental modes. In
experimental mode, they work the same as the normal Jest methods. In
stable mode, they are **expected to fail**. This means we can detect
when a test previously marked as experimental can be un-marked when the
feature becomes stable. It also reduces the chances that we accidentally
add experimental APIs to the stable builds before we intend.

I added corresponding methods for the focus and skip APIs:

- `fit` -> `fit.experimental`
- `it.only` -> `it.only.experimental` or `it.experimental.only`
- `xit` -> `xit.experimental`
- `it.skip` -> `it.skip.experimental` or `it.experimental.skip`

Since `it` is an alias of `test`, `test.experimental` works, too.
2019-10-19 16:08:08 -07:00
Andrew Clark
edc234c730 Build script should default to experimental (#17144)
`yarn build` defaults to building in experimental mode. To opt-out, set
the `RELEASE_CHANNEL` environment variable to `stable`. This is the same
as what we do when running tests via `yarn test`, to make local
development easier.
2019-10-18 19:35:33 -07:00
Sebastian Markbåge
3cc564547c SuspenseList support in DevTools (#17145)
* SuspenseList support in DevTools

This adds SuspenseList tags to DevTools so that the name properly shows
up.

It also switches to use the tag instead of Symbol type for Suspense
components. We shouldn't rely on the type for any built-ins since that
field will disappear from the fibers. How the Fibers get created is an
implementation detail that can change e.g. with a compiler or if we
use instanceof checks that are faster than symbol comparisons.

* Add SuspenseList test to shell app
2019-10-18 17:18:36 -07:00
Sebastian Markbåge
68fb58029d Remove unstable_ prefix in various internal uses (#17146)
* Rename unstable_createRoot in DevTools

* Rename createSyncRoot in warning
2019-10-18 17:18:10 -07:00
Andrew Clark
3059ab3523 Add experimental instructions to release README (#17143) 2019-10-18 16:26:06 -07:00
Andrew Clark
093de5fb43 Lint experimental build artifacts (#17141)
Adds `lint_build` job to the experimental workflow
2019-10-18 16:03:08 -07:00
Andrew Clark
7082d5a2db Don't build non-experimental www bundles (#17139)
Reduces the likelihood we'll accidentally sync the wrong ones.
2019-10-18 14:36:59 -07:00
Andrew Clark
c47f59331e Move SuspenseList to experimental package (#17130)
Also moves `withSuspenseConfig`
2019-10-18 14:24:13 -07:00
Luna Ruan
685ed561f2 Migrate useDeferredValue and useTransition (#17058)
Migrated useDeferredValue and useTransition from Facebook's www repo into ReactFiberHooks.
2019-10-18 12:48:43 -07:00
Dan Abramov
0b61e26983 Update RN typings for a shim (#17138) 2019-10-18 18:05:09 +01:00
Sebastian Markbåge
4eeee358e1 [SuspenseList] Store lastEffect before rendering (#17131)
* Add a failing test for SuspenseList bug

* Store lastEffect before rendering

We can't reset the effect list to null because we don't rereconcile the
children so we drop deletion effects if we do that.

Instead we store the last effect as it was before we started rendering
so we can go back to where it was when we reset it.

We actually already do something like this when we delete the last row
for the tail="hidden" mode so we had a field available for it already.
2019-10-17 15:57:07 -07:00
Nicolas Gallagher
4fb5bf61dd [react-interactions] Fix focus-visible heuristic (#17124)
Respond to all keys not just `Tab`
2019-10-17 09:24:31 -07:00
Dominic Gannaway
8facc05373 [react-interactions] Allow event.preventDefault on LegacyPress responder (#17113)
[react-interactions] Allow event.preventDefault on LegacyPress responder
2019-10-17 10:21:02 +02:00
Andrew Clark
7cec15155a Remove prefixed concurrent APIs from www build (#17108)
The downstream callers have been updated, so we can remove these.
2019-10-16 18:58:33 -07:00
Sebastian Markbåge
ed5f010ae5 Client render Suspense content if there's no boundary match (#16945)
Without the enableSuspenseServerRenderer flag there will never be a boundary match. Also when it is enabled, there might not be a boundary match if something was conditionally rendered by mistake.

With this PR it will now client render the content of a Suspense boundary in that case and issue a DEV only hydration warning. This is the only sound semantics for this case.

Unfortunately, landing this will once again break #16938. It will be less bad though because at least it'll just work by client rendering the content instead of hydrating and issue a DEV only warning.

However, we must land this before enabling the enableSuspenseServerRenderer flag since it does this anyway.

I did notice that we special case fallback={undefined} due to our unfortunate semantics for that. So technically a workaround that works is actually setting the fallback to undefined on the server and during hydration. Then flip it on only after hydration. That could be a workaround if you want to be able to have a Suspense boundary work only after hydration for some reason.

It's kind of unfortunate but at least those semantics are internally consistent. So I added a test for that.
2019-10-16 16:23:12 -07:00
Dominic Gannaway
916937563b [react-interactions] Add onFocusWithin event to FocusWithin responder (#17115) 2019-10-16 22:57:08 +02:00
Andrew Clark
d7feeb25ac unstable_createRoot -> createRoot in test (#17107)
Fixes test added in #17105, which was based on an earler commit than the
one that removed the `unstable_` prefix from `createRoot`.
2019-10-15 21:37:54 -07:00
Sebastian Markbåge
6ff23f2a5d Change retry priority to "Never" for dehydrated boundaries (#17105)
This changes the "default" retryTime to NoWork which schedules at Normal
pri.

Dehydrated bouundaries normally hydrate at Never priority except when they
retry where we accidentally increased them to Normal because Never was used
as the default value. This changes it so NoWork is the default.

Dehydrated boundaries however get initialized to Never as the default.

Therefore they now hydrate as Never pri unless their priority gets
increased by a forced rerender or selective hydration.

This revealed that erroring at this Never priority can cause an infinite
rerender. So I fixed that too.
2019-10-15 19:53:20 -07:00
Andrew Clark
2c832b4dcf Separate sizebot for experimental builds (#17100)
Configures the sizebot to leave a second comment that tracks the
experimental build artifacts.
2019-10-15 18:43:06 -07:00
Luna Ruan
3ac0eb075d Modify Babel React JSX Duplicate Children Fix (#17101)
If a JSX element has both a children prop and children (ie. <div children={childOne}>{childTwo}</div>), IE throws an Multiple definitions of a property not allowed in strict mode. This modifies the previous fix (which used an Object.assign) by making the duplicate children a sequence expression on the next prop/child instead so that ordering is preserved. For example:

```
<Component children={useA()} foo={useB()} children={useC()}>{useD()}</Component>
```
should compile to
```
React.jsx(Component, {foo: (useA(), useB()), children: (useC(), useD)})
```
2019-10-15 17:13:21 -07:00
Andrew Clark
43562455c9 Temporary patch www fork with prefixed APIs (#17103)
I'm doing this here instead of in the downstream repo so that if the
sync diff gets reverted, it doesn't revert this, too.

Once the sync has landed, and the callers are updated in www, I will
remove this.
2019-10-15 16:44:33 -07:00
Andrew Clark
9123c479f4 Enable concurrent APIs in all experimental forks (#17102)
Forgot to update the flags in the forked modules.
2019-10-15 16:19:45 -07:00
Andrew Clark
30c5daf943 Remove concurrent apis from stable (#17088)
* Tests run in experimental mode by default

For local development, you usually want experiments enabled. Unless
the release channel is set with an environment variable, tests will
run with __EXPERIMENTAL__ set to `true`.

* Remove concurrent APIs from stable builds

Those who want to try concurrent mode should use the experimental
builds instead.

I've left the `unstable_` prefixed APIs in the Facebook build so we
can continue experimenting with them internally without blessing them
for widespread use.

* Turn on SSR flags in experimental build

* Remove prefixed concurrent APIs from www build

Instead we'll use the experimental builds when syncing to www.

* Remove "canary" from internal React version string
2019-10-15 15:09:19 -07:00
Dominic Gannaway
4cb399a433 [react-interactions] Modify Scope query mechanism (#17095) 2019-10-15 15:57:02 +02:00
Dominic Gannaway
e7704e22a1 [babel-plugin-react-jsx] Avoid duplicate "children" key in props object (#17094)
* [babel-plugin-react-jsx] Avoid duplicate "children" key in props object

* Use Object.assign approach
2019-10-15 15:41:09 +02:00
Krzysztof Kotowicz
fdba0e5ce7 Fixed a bug with illegal invocation for Trusted Types (#17083)
* Fixed a bug with illegal invocation.

* Fixed the test.
2019-10-15 11:41:42 +01:00
Andrew Clark
a8c6a1b34e Update release scripts to support experimental releases (#17086)
* Download correct artifacts for release channel

Experimental builds should pull artifacts from the
`process_artifacts_experimental` job.

I think instead of two separate CI workflows, a better approach might
be to build stable artifacts to the `build` directory and the
experimental artifacts to a `build_experimental` directory, and
generate both within the same workflow. This would take some work since
lots of things assume the output directory is `build`, but something
to consider in the future.

* Prevent experimental promotion to stable

Adds a check to the `prepare-stable` script to prevent experimental
builds from being published using stable semver versions.
2019-10-14 14:15:23 -07:00
Andrew Clark
d364d8555f Set up experimental builds (#17071)
* Don't bother including `unstable_` in error

The method names don't get stripped out of the production bundles
because they are passed as arguments to the error decoder.

Let's just always use the unprefixed APIs in the messages.

* Set up experimental builds

The experimental builds are packaged exactly like builds in the stable
release channel: same file structure, entry points, and npm package
names. The goal is to match what will eventually be released in stable
as closely as possible, but with additional features turned on.

Versioning and Releasing
------------------------

The experimental builds will be published to the same registry and
package names as the stable ones. However, they will be versioned using
a separate scheme. Instead of semver versions, experimental releases
will receive arbitrary version strings based on their content hashes.
The motivation is to thwart attempts to use a version range to match
against future experimental releases. The only way to install or depend
on an experimental release is to refer to the specific version number.

Building
--------

I did not use the existing feature flag infra to configure the
experimental builds. The reason is because feature flags are designed
to configure a single package. They're not designed to generate multiple
forks of the same package; for each set of feature flags, you must
create a separate package configuration.

Instead, I've added a new build dimension called the **release
channel**. By default, builds use the **stable** channel. There's
also an **experimental** release channel. We have the option to add more
in the future.

There are now two dimensions per artifact: build type (production,
development, or profiling), and release channel (stable or
experimental). These are separate dimensions because they are
combinatorial: there are stable and experimental production builds,
stable and experimental developmenet builds, and so on.

You can add something to an experimental build by gating on
`__EXPERIMENTAL__`, similar to how we use `__DEV__`. Anything inside
these branches will be excluded from the stable builds.
This gives us a low effort way to add experimental behavior in any
package without setting up feature flags or configuring a new package.
2019-10-14 10:46:42 -07:00
Sebastian Markbåge
d5b54d0c35 [SuspenseList] Fix bugs with dropped Promises (#17082)
* Transfer any pending promises from inner boundary to list

For non-hidden modes, this boundary should commit so this shouldn't be
needed but the nested boundary can make a second pass which forces these
to be recreated without resuspending. In this case, the outer list assumes
that it can collect the inner promises to still rerender if needed.

* Propagate suspense "context" change to nested SuspenseLists

This means that we always rerender any nested SuspenseLists together.

This bug looks similar to the previous one but is not based on the lack of
retry but that the retry only happens on the outer boundary but the inner
doesn't get a retry ping since it didn't know about its own promise after
the second pass.
2019-10-14 09:42:10 -07:00
Andrew Clark
75955bf1d7 Pass prod error messages directly to constructor (#17063)
* Remove "Invariant Violation" from dev errors

When I made the change to compile `invariant` to throw expressions, I
left a small runtime to set the error's `name` property to "Invariant
Violation" to maintain the existing behavior.

I think we can remove it. The argument for keeping it is to preserve
continuity in error logs, but this only affects development errors,
anyway: production error messages are replaced with error codes.

* Pass prod error messages directly to constructor

Updates the `invariant` transform to pass an error message string
directly to the Error constructor, instead of mutating the
message property.

Turns this code:

```js
invariant(condition, 'A %s message that contains %s', adj, noun);
```

into this:

```js
if (!condition) {
  throw Error(
    __DEV__
      ? `A ${adj} message that contains ${noun}`
      : formatProdErrorMessage(ERR_CODE, adj, noun)
  );
}
```
2019-10-11 09:10:40 -07:00
Dominic Gannaway
0ac8e563d0 [react-interactions] Add getInstanceFromNode support to TestHostRenderer (#17065)
Fix bad WeakMap key case

Fix bad WeakMap key case
2019-10-11 16:58:27 +02:00
Brian Vaughn
22b2642a56 DevTools test shell tweaks (#17054)
* Updated DevTools shell ignore warning message to account for recent changes in warning text

* Update DevTools console patching to patch the parent window's console rather than the iframe, to more accurately simulate real usage environment
2019-10-09 12:37:25 -07:00
Eli White
4be45be5ff Stop warning about setNativeProps being deprecated (#17045)
* Stop warning about setNativeProps being deprecated

* Remove ReactNative.setNativeProps

* Remove more Fabric tests
2019-10-08 11:21:20 -07:00
Dominic Gannaway
b71ab61c8f [react-interactions] Adds more experimental Scope API methods (#17042) 2019-10-08 19:32:53 +02:00
Andrew Clark
5a71cbe7a9 Remove unused export
Meant to do this in e4b21be but neglected to `git add` the changes.
2019-10-07 15:32:34 -07:00
Andrew Clark
71d012ecd0 Remove dormant createBatch experiment (#17035)
* Remove dormant createBatch experiment

In a hybrid React app with multiple roots, `createBatch` is used to
coordinate an update to a root with its imperative container.

We've pivoted away from multi-root, hybrid React apps for now to focus
on single root apps.

This PR removes the API from the codebase. It's possible we'll add back
some version of this feature in the future.

* Remove unused export
2019-10-07 14:15:15 -07:00
Andrew Clark
cd1b167ad4 [Scheduler Profiler] Use microsecond precision (#17010)
The `performance.now` returns a timestamp in milliseconds as a float.
The browser has the option to adjust the precision of the float, but
it's usually more precise than a millisecond. However, this precision
is lost when the timestamp is logged by the Scheduler profiler, because
we store the numbers in an Int32Array.

This change multiplies the millisecond float value by 1000, giving us
three more degrees of precision.
2019-10-07 09:16:18 -07:00
Dominic Gannaway
55731fd8ce [react-interactions] Refine a11y component flow types (#17032) 2019-10-07 16:36:16 +02:00
Dominic Gannaway
a011aacafa [react-interactions] Remove FB builds of a11y components (#17030) 2019-10-07 12:45:49 +02:00
Dominic Gannaway
fff5b1ca77 [react-interactions] Add FocusTable colSpan support (#17019) 2019-10-07 12:04:41 +02:00
Luna Ruan
4bc52ef0df Revert "update hideOrUnhideAllChildren to hide portals that aren't wrapped in a host component (#16992)" (#17011)
This reverts commit de2edc268d.
2019-10-03 17:22:22 -07:00
Sebastian Markbåge
3a2b5f148d [Selective Hydration] ReactDOM.unstable_scheduleHydration(domNode) (#17004)
Adds an API to explicitly prioritize hydrating the path to a particular DOM node without relying on events to do it.

The API uses the current scheduler priority to schedule it. For the same priority, the last one wins. This allows a similar effect as continuous events. This is useful for example to hydrate based on scroll position, or prioritize components that will upgrade to client-rendered-only content.

I considered having an API that explicitly overrides the current target(s). However that makes it difficult to coordinate across components in an app.

This just hydrates one target at a time but if it is blocked on I/O we could consider increasing priority of later targets too.
2019-10-03 14:48:28 -07:00
Dominic Gannaway
26ba38ae4b [EnterLeaveEventPlugin] Fix bug when dealing with unhandled DOM nodes (#17006) 2019-10-03 23:35:09 +02:00
Andrew Clark
abedf17597 Changelog for v16.10.2 2019-10-03 14:16:13 -07:00
Andrew Clark
d256f88ac6 Update local version numbers for 16.10.2 release 2019-10-03 14:14:10 -07:00
Brian Vaughn
a8b8ffb894 DevTools v4.1.3 -> v4.2.0 2019-10-03 12:34:35 -07:00
Brian Vaughn
0545f366d4 Added trace updates feature (DOM only) (#16989)
* Added trace updates feature (DOM only)
* Updated DevTools CHANGELOG
2019-10-03 11:07:18 -07:00
Simen Bekkhus
e09097a75d chore: upgrade to jest 24 (#15778)
* chore: upgrade to jest 24

* download react-is from npm manually
2019-10-03 22:44:18 +05:30
Rane Wallin
5943b1da6c Fixing grammatical errors in error message (#16973)
* Fixing grammatical errors in error message

* Fixing grammar error in test file
2019-10-03 18:14:48 +05:30
Dominic Gannaway
4c5698400f [react-interactions] Remove context.setTimeout & context.clearTimeout (#17000) 2019-10-03 13:37:37 +02:00
Dominic Gannaway
b33633d932 [react-interactions] Repurpose React a11y modules (#16997) 2019-10-03 11:19:24 +02:00
Luna Ruan
de2edc268d update hideOrUnhideAllChildren to hide portals that aren't wrapped in a host component (#16992)
Currently, when a node suspends, if its subtree contains a portal, the portal is not hidden. This hides portals in the subtree when it's not wrapped in a host component .
2019-10-02 15:30:55 -07:00
Sebastian Markbåge
bb680a0905 [Selective Hydration] Prioritize the last continuous target (#16937)
* Prioritize the last continuous target

This ensures that the current focus target is always hydrated first.

Slightly higher than the usual Never expiration time used for hydration.
The priority increases with each new queued item so that the last always
wins.

* Don't export the moving target

It's not useful for comparison purposes anyway.
2019-10-02 14:52:23 -07:00
Eli White
10277cc5ba Remove unused canonical check in fiber host component (#16914) 2019-10-02 11:07:20 -07:00
Nicolas Gallagher
ab1a4f249e Move eventSystemFlags to last argument in event plugin extractors (#16978)
Fix for necolas/react-native-web#1443
2019-10-02 10:31:15 -07:00
Nicolas Gallagher
f6efb224b0 [react-interactions] Tap cancels on second pointerdown (#16936)
This patch causes onTapCancel to be called whenever a second pointer interacts
with the responder target.
2019-10-01 15:13:31 -07:00
Dominic Gannaway
34457729a6 [react-interactions] Add allowModifiers flag to FocusList + FocusTable (#16971) 2019-10-01 17:59:52 +02:00
Rango Yuan
b34f042e5b Fix mouseenter handlers fired twice (#16928) 2019-10-01 14:03:14 +02:00
Andrew Clark
05dc814cf0 Remove IIFE wrappers from dev invariant checks (#16963)
The error transform works by replacing calls to `invariant` with
an `if` statement.

Since we're replacing a call expression with a statement, Babel wraps
the new statement in an immediately-invoked function expression (IIFE).
This wrapper is unnecessary in practice because our `invariant` calls
are always part of their own expression statement.

In the production bundle, the function wrappers are removed by Closure.
But they remain in the development bundles.

This commit updates the transform to confirm that an `invariant` call
expression's parent node is an expression statement. (If not, it throws
a transform error.)

Then, it replaces the expression statement instead of the expression
itself, effectively removing the extraneous IIFE wrapper.
2019-09-30 11:14:51 -07:00
Brian Vaughn
2c8832075b React DevTools v4.1.2 -> v.4.1.3 2019-09-30 09:33:23 -07:00
Brian Vaughn
6c73a1e776 Updated DevTools CHANGELOG 2019-09-30 08:31:47 -07:00
David Huang
6a3de7a414 [DevTools] postMessage target origin needs to be '*' for local files (#16953) 2019-09-30 08:29:18 -07:00
Dominic Gannaway
ac8e8b3278 [react-interactions] Add tab handling to FocusList (#16958) 2019-09-30 17:13:35 +02:00
Dominic Gannaway
10c7dfe3b4 [react-interactins] FocusTable tabScope handling+tabIndex control (#16922) 2019-09-30 11:41:20 +02:00
Kirankumar Ambati
d3622d0f97 chore: updated comment message (#16949) 2019-09-29 15:00:49 -07:00
Andrew Clark
2a264a9dbe Update local version numbers for 16.10.1 release 2019-09-28 21:41:42 -07:00
Andrew Clark
22019ef5a2 Changelog for v16.10.1 2019-09-28 11:24:19 -07:00
Sebastian Markbåge
d8a76ad580 Allow Suspense Mismatch on the Client to Silently Proceed (#16943)
* Regression test: Suspense + hydration + legacy

* Allow Suspense Mismatch on the Client to Silently Proceed

This fixes but isn't actually the semantics that we want this case to have.
2019-09-28 10:43:53 -07:00
Sebastian Markbåge
9d637844e9 Remove enableUserBlockingEvents flag (#16882)
Seems like this worked out. We can clean up the flag now.
2019-09-27 19:46:56 -07:00
Sebastian Markbåge
fe31cc710e [Selective Hydration] Increase priority for non-synchronous discrete events and retries (#16935)
* Increase retryTime for increased priority dehydrated boundaries

* Increaese the priority to user blocking for every next discrete boundary
2019-09-27 17:27:17 -07:00
Brian Vaughn
b550679617 Fixed typo in DevTools CHANGELOG 2019-09-27 17:10:27 -07:00
Brian Vaughn
5184346daf DevTools v4.1.1 -> v4.1.2 2019-09-27 17:03:17 -07:00
Brian Vaughn
d4278663c6 Replaced === check with Object.is() to support values like NaN (#16934) 2019-09-27 16:54:53 -07:00
Nicolas Gallagher
d1121c0174 [react-interactions] Fix virtual click heuristic (#16915) 2019-09-27 15:38:47 -07:00
Andrew Clark
f553515d1e Fix heading level in changelog 2019-09-27 13:37:36 -07:00
Andrew Clark
7dc83a6100 Changelog for 16.10 2019-09-27 13:31:47 -07:00
Andrew Clark
93f5f11b79 Update local version numbers for 16.10 release 2019-09-27 13:31:35 -07:00
Luna Ruan
c8dc7a926e expose isHydrating (#16909)
expose isHydrating for FB
2019-09-26 14:47:01 -07:00
Eli White
db8afe4f63 Add HostComponent type to ReactNative (#16898)
* Add HostComponent type to ReactNative

* Use type alias imports instead of wildcard

* Fix forgotten Object in measureLayout type
2019-09-26 14:42:18 -07:00
Andrew Clark
fad5102101 [bugfix] Fix false positive render phase update (#16907)
Need to reset the current "debug phase" inside the catch block.
Otherwise React thinks we're still in the render phase during the
subsequent event.
2019-09-26 12:47:48 -07:00
Brian Vaughn
a9cd9a765b DevTools v4.1.0 -> v4.1.1 2019-09-26 10:22:59 -07:00
Brian Vaughn
b6606ecba8 DevTools shows unsupported renderer version dialog (#16897)
* DevTools shows unsupported renderer version dialog

* Optimistic CHANGELOG udpate
2019-09-26 08:41:46 -07:00
Brian Vaughn
84e83db1ee Updated DevTools CHANGELOG 2019-09-26 08:26:18 -07:00
Dominic Gannaway
b9811ed5bc [react-interactions] Add wrapping support to FocusList/FocusTable (#16903) 2019-09-26 15:15:48 +02:00
David Huang
49b0cb6db8 Moving backend injection to the content script (#16900) 2019-09-26 14:03:07 +01:00
Sebastian Markbåge
3694a3b5e9 Selective Hydration (#16880)
* Add Feature Flag for Selective Hydration

* Enable Synchronous Hydration of Discrete Events

* Resolve cyclic dependency
2019-09-25 15:26:27 -07:00
Dominic Gannaway
4bb0e96b4b [react-interactions] FocusTable key press bound propgataion (#16895) 2019-09-25 21:12:39 +02:00
Brian Vaughn
fa1a326227 Update useEditableValue hook to sync external value changes (#16878)
* Update useEditableValue to mirror value cahnges

Previously, the hook initialized local state (in useState) to mirror the prop/state value. Updates to the value were ignored though. (Once the state was initialized, it was never updated.) The new hook updates the local/editable state to mirror the external value unless there are already pending, local edits being made.

* Optimistic CHANGELOG update

* Added additional useEditableValue() unit test cases
2019-09-25 10:46:27 -07:00
Dominic Gannaway
57bf275fbd [devtools] Add support for React Scope symbol/number (#16893) 2019-09-25 19:03:37 +02:00
Dominic Gannaway
7c3bd08b37 [react-interactions] Add more documentation for a11y components (#16894) 2019-09-25 19:01:15 +02:00
Sebastian Markbåge
a06d181af0 Include tag in begin/complete invariant (#16881) 2019-09-25 08:10:35 -07:00
Sebastian Markbåge
0d8c0cd096 These flags are hard coded in our internal config (#16883)
By hard coding them here they can get properly DCE and don't have to be
sent to users. The internal config should only have dynamic flags.
2019-09-25 08:00:29 -07:00
Dominic Gannaway
d6d83d7060 [react-interactions] Add Portal propagation configuration (#16889) 2019-09-25 16:56:51 +02:00
Dominic Gannaway
d0ebde77f6 [react-interactions] Add initial docs explaining React Scopes (#16892) 2019-09-25 14:57:47 +02:00
Joshua Gross
32e5c97d11 [React Native] Improve errors for invalid ViewConfig getter functions (#16879)
* [React Native] Improve logging for missing view configs and invalid view config getter functions

* [React Native] Improve logging for missing view configs and invalid view config getter functions
2019-09-24 17:46:21 -07:00
Dominic Gannaway
ebc299fc2f [react-interactions] TabFocus -> FocusManager (#16874) 2019-09-24 23:26:20 +02:00
Dominic Gannaway
793f176dad [react-interactions] Make FocusList bundle (#16876) 2019-09-24 18:02:13 +02:00
Dominic Gannaway
68a87eee54 [react-interactions] Add FocusList component (#16875) 2019-09-24 17:14:29 +02:00
Jessica Franco
18d2e0c03e Warning system refactoring (part 1) (#16799)
* Rename lowPriorityWarning to lowPriorityWarningWithoutStack

This maintains parity with the other warning-like functions.

* Duplicate the toWarnDev tests to test toLowPriorityWarnDev

* Make a lowPriorityWarning version of warning.js

* Extract both variants in print-warning

Avoids parsing lowPriorityWarning.js itself as the way it forwards the
call to lowPriorityWarningWithoutStack is not analyzable.
2019-09-24 13:45:38 +01:00
Andrew Clark
8b580a89d6 Idle updates should not be blocked by hidden work (#16871)
* Idle updates should not be blocked by hidden work

Use the special `Idle` expiration time for updates that are triggered at
Scheduler's `IdlePriority`, instead of `Never`.

The key difference between Idle and Never¹ is that Never work can be
committed in an inconsistent state without tearing the UI. The main
example is offscreen content, like a hidden subtree.

¹ "Never" isn't the best name. I originally called it that because it
"never" expires, but neither does Idle. Since it's mostly used for
offscreen subtrees, we could call it "Offscreen." However, it's also
used for dehydrated Suspense boundaries, which are inconsistent in the
sense that they haven't finished yet, but aren't visibly inconsistent
because the server rendered HTML matches what the hydrated tree would
look like.

* Reset as early as possible using local variable

* Updates in a hidden effect should be Idle

I had made them Never to avoid an extra render when a hidden effect
updates the hidden component -- if they are Idle, we have to render once
at Idle, which bails out on the hidden subtree, then again at Never to
actually process the update -- but the problem of needing an extra
render pass to bail out hidden updates already exists and we should fix
that properly instead of adding yet another special case.
2019-09-23 20:52:48 -07:00
Nicolas Gallagher
c5e7190ed4 [react-interactions] Press with useRef instead of useState (#16870)
We only need to read and modify the value for the lifetime of the hook
2019-09-23 16:25:13 -07:00
Brian Vaughn
911104a129 DevTools CHANGELOG update 2019-09-23 12:58:58 -07:00
Brian Vaughn
bce2ac63a9 Revert change to backend injection method from PR #16752 (#16864)
PR #16752 changed how we were injecting the backend script to be done by the content script in order to work around Trusted Type limitations with our previous approach. This may have caused a regression (see #16840) so I'm backing it out to verify.
2019-09-23 12:56:36 -07:00
Brian Vaughn
9b3cde9b62 Fix DevTools v4.1 editable hook regression (#16867)
* Fixed a regression in hooks editor from a recent EditableValue change

* Fixed a reset/state bug in useEditableValue() hook and removed unnecessary useMemo()
2019-09-23 12:56:01 -07:00
Dominic Gannaway
1a6294d3e2 [react-interaction] Refactor a11y components more (#16866) 2019-09-23 21:30:49 +02:00
Dominic Gannaway
1758b3f7ba [react-interactions] Add no-op stopPropagation + preventDefault to Press (#16868)
Fix
2019-09-23 21:18:40 +02:00
Andrew Clark
013b7ad117 [suspense][error handling] Inline renderRoot and fix error handling bug (#16801)
* Outline push/pop logic in `renderRoot`

I want to get rid of the the `isSync` argument to `renderRoot`, and
instead use separate functions for concurrent and synchronous render.

As a first step, this extracts the push/pop logic that happens before
and after the render phase into helper functions.

* Extract `catch` block into helper function

Similar to previous commit. Extract error handling logic into
a separate function so it can be reused.

* Fork `renderRoot` for sync and concurrent

Removes `isSync` argument in favor of separate functions.

* Extra "root completion" logic to separate function

Moving this out to avoid an accidental early return, which would
bypass the call to `ensureRootIsScheduled` and freeze the UI.

* Inline `renderRoot`

Inlines `renderRoot` into `performConcurrentWorkOnRoot` and
`performSyncWorkOnRoot`. This lets me remove the `isSync` argument
and also get rid of a redundant try-catch wrapper.

* [suspense][error handling] Add failing unit test

Covers an edge case where an error is thrown inside the complete phase
of a component that is in the return path of a component that suspends.
The second error should also be handled (i.e. able to be captured by
an error boundary.

The test is currently failing because there's a call to
`completeUnitOfWork` inside the main render phase `catch` block. That
call is not itself wrapped in try-catch, so anything that throws is
treated as a fatal/unhandled error.

I believe this bug is only observable if something in the host config
throws; and, only in legacy mode, because in concurrent/batched mode,
`completeUnitOfWork` on fiber that throws follows the "unwind" path
only, not the "complete" path, and the "unwind" path does not call
any host config methods.

* [scheduler][profiler] Start time of delayed tasks

Fixes a bug in the Scheduler profiler where the start time of a delayed
tasks is always 0.

* Remove ad hoc `throw`

Fatal errors (errors that are not captured by an error boundary) are
currently rethrown from directly inside the render phase's `catch`
block. This is a refactor hazard because the code in this branch has
to mirror the code that happens at the end of the function, when exiting
the render phase in the normal case.

This commit moves the throw to the end, using a new root exit status.

* Handle errors that occur on unwind
2019-09-23 11:23:28 -07:00
Sebastian Markbåge
0a527707cd Event Replaying (#16725)
* Add Event Replaying Infra

* Wire up Roots and Suspense boundaries, to retry events, after they commit

* Replay discrete events in order in a separate scheduler callback

* Add continuous events

These events only replay their last target if the target is not yet
hydrated. That way we don't have to wait for a previously hovered
boundary before invoking the current target.

* Enable tests from before

These tests were written with replaying in mind and now we can properly
enable them.

* Unify replaying and dispatching

* Mark system flags as a replay and pass to legacy events

That way we can check if this is a replay and therefore needs a special
case. One such special case is "mouseover" where we check the
relatedTarget.

* Eagerly listen to all replayable events

To minimize breakages in a minor, I only do this for the new root APIs
since replaying only matters there anyway. Only if hydrating.

For Flare, I have to attach all active listeners since the current
system has one DOM listener for each. In a follow up I plan on optimizing
that by only attaching one if there's at least one active listener
which would allow us to start with only passive and then upgrade.

* Desperate attempt to save bytese

* Add test for mouseover replaying

We need to check if the "relatedTarget" is mounted due to how the old
event system dispatches from the "out" event.

* Fix for nested boundaries and suspense in root container

This is a follow up to #16673 which didn't have a test because it wasn't
observable yet. This shows that it had a bug.

* Rename RESPONDER_EVENT_SYSTEM to PLUGIN_EVENT_SYSTEM
2019-09-23 11:21:10 -07:00
Andrew Clark
a87d245fc2 [work loop] Prevent work loop from being inlined (#16865)
Uses Closure Compiler's `@noinline` directive.

See https://github.com/google/closure-compiler/wiki/Annotating-JavaScript-for-the-Closure-Compiler#noinline
2019-09-23 11:12:47 -07:00
Nicolas Gallagher
312b462d54 [react-interactions] Improve consistency of Tap responder (#16837)
Makes sure that touch events with modifier keys behave the same way as other
pointer types (i.e., does not call `onTapStart` if the gesture begins with a
modifier key held down)
2019-09-23 10:48:11 -07:00
Dominic Gannaway
70754f10d4 [react-interaction] Tweak Focus Table component (#16862) 2019-09-23 16:39:43 +02:00
Dominic Gannaway
d7f6dd5a80 [react-interactions] Fix typo in FocusTable (#16860) 2019-09-23 14:20:43 +02:00
Dan Abramov
cef47cbc01 Rename experimental react-ui => react-interactions (#16842) 2019-09-20 11:51:03 +01:00
Dominic Gannaway
57a5805a9f [react-ui] Add preventDefault+stopPropagation to Keyboard + update Focus components (#16833) 2019-09-20 11:21:38 +02:00
Brian Vaughn
08b51aa384 Added React DevTools v4.1.0 release date to CHANGELOG 2019-09-19 15:22:22 -07:00
Brian Vaughn
b5cebedfbe React DevTools version bump 4.0.6 -> 4.1.0 2019-09-19 15:11:48 -07:00
Sebastian Markbåge
35bf9d27a3 Exclude react-dom when flow checking other builds (#16737)
This is because the HostConfig can't be guaranteed to be consistent with
other code such as code that touches the DOM directly.

Ideally we'd have a more systemic solution to this since it will pop
up for other packages later too.
2019-09-19 12:41:51 -07:00
Nicolas Gallagher
fd870e6b6a [react-ui/events] Tap responder API changes (#16827)
This patch limits the `onTap*` callbacks to the primary pointer button.
Auxiliary button and modified primary button interactions call
`onAuxiliaryTap`, cancel any active tap, and preserve the native behavior.
2019-09-19 09:36:29 -07:00
Dan Abramov
4ddcb8e134 [DevTools] Remove Welcome dialog (#16834) 2019-09-19 08:41:18 -07:00
Dominic Gannaway
924a305780 [react-ui] Remove event object warnings (#16822) 2019-09-19 12:46:17 +02:00
halvves
a5df18a9e5 prevent firefox marking required textareas invalid (#16578)
* prevent firefox marking required textareas invalid

Bug was caused by an IE10/IE11 bugfix dealing with the placeholder attribute and textContent. Solved by avoiding the IE bugfix when textContent was empty.

Closes #16402

* more explicit conditional check for textContent

re: @philipp-spiess code review

* clarify textarea test fixture's expected result

better describe the behavior we are testing for
re: @philipp-spiess code review
2019-09-18 14:38:02 -07:00
Dan Abramov
f818af9b03 [Fresh] Always remount classes (#16823) 2019-09-18 16:32:11 +01:00
Ricky
6ecfa90eb0 [React Native] Fix for view config registrations (#16821) 2019-09-18 15:31:00 +01:00
Dominic Gannaway
18cb59050b [react-core] Do not null fiber.sibling in detachFiber (#16820) 2019-09-18 14:18:32 +02:00
Kuba Juszczyk
d862f0ea56 Optimize objectIs (#16212) 2019-09-17 23:55:43 +02:00
Pavlo Tymchuk
d1c2555861 [react-devtools-shared] Added string type check for object name prop in getDisplayName function (#16798)
* [react-devtools-shared] Added string type check for object name prop in getDisplayName function from utils.js file; tests included;

* Re-added empty string check to getDisplayName()

* Tweaked tests to use real functions

This more closely simulates how the utility is being used in production, and would catch cases like anonymous functions (with empty string names).
2019-09-17 13:17:04 -07:00
Brian Vaughn
70dcdd265d Updated pending CHANGELOG for DevTools 2019-09-17 13:15:53 -07:00
Brian Vaughn
e8c7ddeef2 Release script filters DevTools NPM pakcages (#16810) 2019-09-17 12:46:13 -07:00
Dominic Gannaway
8f1533f4d8 [react-ui] Fix bundle name [hotfix] (#16811) 2019-09-17 21:10:51 +02:00
Dominic Gannaway
7c802de797 [react-a11y] Add react-ui/accessibility to bundle build (#16804) 2019-09-17 20:22:09 +02:00
Andrew Clark
901139c291 [scheduler][profiler] Start time of delayed tasks (#16809)
Fixes a bug in the Scheduler profiler where the start time of a delayed
tasks is always 0.
2019-09-17 10:24:48 -07:00
Dominic Gannaway
f40ceb0010 [react-ui] FocusGrid -> ReactFocusTable + tweaks and fixes (#16806) 2019-09-17 19:22:10 +02:00
Dominic Gannaway
2f1e8c5f78 [react-core] Clear more properties in detachFiber (#16807) 2019-09-17 17:30:22 +02:00
Dan Abramov
8e0c574122 Follow-up to initial Trusted Types support (#16795)
* Follow-up to initial Trusted Types support

* Fast-path both strings and numbers

* Move shared objects out of every test
2019-09-17 16:06:26 +01:00
Nicolas Gallagher
3af05de1aa [react-ui] usePress from useKeyboard and useTap (#16772)
This implements 'usePress' in user-space as a combination of 'useKeyboard' and 'useTap'.  The existing 'usePress' API is preserved for now. The previous 'usePress' implementation is moved to 'PressLegacy'.
2019-09-16 14:36:27 -07:00
Dominic Gannaway
494300b366 [react-ui] Move experimental event+a11y work to react-ui package (#16794) 2019-09-16 20:05:50 +02:00
Nicolas Gallagher
9691eb273a [react-events] Keyboard support for virtual clicks (#16780)
This accounts for all clicks that are natively dispatched following relevant
keyboard interactions (e.g., key is "Enter"), as well as programmatic clicks,
and screen-reader virtual clicks.
2019-09-16 10:40:05 -07:00
Emanuel Tesař
b8d079b413 Add trusted types to react on client side (#16157)
* Add trusted types to react on client side

* Implement changes according to review

* Remove support for trusted URLs, change TrustedTypes to trustedTypes

* Add support for deprecated trusted URLs

* Apply PR suggesstions

* Warn only once, remove forgotten check, put it behind a flag

* Move comment

* Fix PR comments

* Fix html toString concatenation

* Fix forgotten else branch

* Fix PR comments
2019-09-16 13:43:22 +01:00
Heaven
cdbfa5044b fix typo inteval -> interval & continutation -> continuation (#16760)
* fix typo alterate -> alternate

* fix typo interal -> interval & continutation -> continuation
2019-09-14 12:51:20 -07:00
Andrew Clark
45b6443c90 Spelling is fundamental (#16782) 2019-09-13 16:27:18 -07:00
Andrew Clark
45898d0be0 [Scheduler] Prevent event log from growing unbounded (#16781)
If a Scheduler profile runs without stopping, the event log will grow
unbounded. Eventually it will run out of memory and the VM will throw
an error.

To prevent this from happening, let's automatically stop the profiler
once the log exceeds a certain limit. We'll also print a warning with
advice to call `stopLoggingProfilingEvents` explicitly.
2019-09-13 15:50:25 -07:00
Nicolas Gallagher
87eaa90ef8 [react-events] Keyboard calls preventDefault on 'click' events (#16779)
Make sure to call preventDefault for any 'click' events that follow a 'keydown'
event that matches 'preventKeys'
2019-09-13 13:19:18 -07:00
Brian Vaughn
0c0b30b8c7 Remove unnecessary interaction tracing ping wrapper (#16777) 2019-09-13 11:04:36 -07:00
Andrew Clark
137ea783b1 Re-enable risky work loop changes (#16771)
The stack of PRs in #16743 was reverted. This adds them back.
2019-09-13 09:33:46 -07:00
Brian Vaughn
d6f6b951e1 Support disabling interaction tracing for suspense promises (#16776)
* Support disabling interaction tracing for suspense promises

If a thrown Promise has the __reactDoNotTraceInteractions attribute, React will not wrapped its callbacks to continue tracing any current interaction(s).

* Added optional '__reactDoNotTraceInteractions' attribute to Flow Thenable type
2019-09-13 08:59:57 -07:00
Dominic Gannaway
b4b8a349a3 [react-interactions] Add experimental FocusGrid API (#16766) 2019-09-13 12:29:39 +02:00
Andrew Clark
a7dabcb60a Revert "Re-arrange slightly to prevent refactor hazard (#16743)" (#16769)
This reverts commit ab4951fc03.

* Track "pending" and "suspended" ranges

A FiberRoot can have pending work at many distinct priorities. (Note: we
refer to these levels as "expiration times" to distinguish the concept
from Scheduler's notion of priority levels, which represent broad
categories of work. React expiration times are more granualar. They're
more like a concurrent thread ID, which also happens to correspond to a
moment on a timeline. It's an overloaded concept and I'm handwaving over
some of the details.)

Given a root, there's no convenient way to read all the pending levels
in the entire tree, i.e. there's no single queue-like structure that
tracks all the levels, because that granularity of information is not
needed by our algorithms. Instead we track the subset of information
that we actually need — most importantly, the highest priority level
that exists in the entire tree.

Aside from that, the other information we track includes the range of
pending levels that are known to be suspended, and therefore should not
be worked on.

This is a refactor of how that information is tracked, and what each
field represents:

- A *pending* level is work that is unfinished, or not yet committed.
  This includes work that is suspended from committing.
  `firstPendingTime` and `lastPendingTime` represent the range of
  pending work. (Previously, "pending" was the same as "not suspended.")
- A *suspended* level is work that did not complete because data was
  missing. `firstSuspendedTime` and `lastSuspendedTime` represent the
  range of suspended work. It is a subset of the pending range. (These
  fields are new to this commit.)
- `nextAfterSuspendedTime` represents the next known level that comes
  after the suspended range.

This commit doesn't change much in terms of observable behavior. The one
change is that, when a level is suspended, React will continue working
on the next known level instead of jumping straight to the last pending
level. Subsequent commits will use this new structure for a more
substantial refactor for how tasks are scheduled per root.

* Get next expiration time from FiberRoot

Given a FiberRoot, we should be able to determine the next expiration
time that needs to be worked on, taking into account the levels that
are pending, suspended, pinged, and so on.

This removes the `expirationTime` argument from
`scheduleCallbackForRoot`, and renames it to `ensureRootIsScheduled` to
reflect the new signature. The expiration time is instead read from the
root using a new function, `getNextExpirationTimeToWorkOn`.

The next step will be to remove the `expirationTime` argument from
`renderRoot`, too.

* Don't bind expiration time to render callback

This is a fragile pattern because there's only meant to be a single
task per root, running at a single expiration time. Instead of binding
the expiration time to the render task, or closing over it, we should
determine the correct expiration time to work on using fields we
store on the root object itself.

This removes the "return a continuation" pattern from the
`renderRoot` function. Continuation handling is now handled by
the wrapper function, which I've renamed from `runRootCallback` to
`performWorkOnRoot`. That function is merely an entry point to
`renderRoot`, so I've also removed the callback argument.

So to sum up, at at the beginning of each task, `performWorkOnRoot`
determines which expiration time to work on, then calls `renderRoot`.
And before exiting, it checks if it needs to schedule another task.

* Update error recovery test to match new semantics

* Remove `lastPendingTime` field

It's no longer used anywhere

* Restart on update to already suspended root

If the work-in-progress root already suspended with a delay, then the
current render definitely won't finish. We should interrupt the render
and switch to the incoming update.

* Restart on suspend if return path has an update

Similar to the previous commit, if we suspend with a delay, and
something in the return path has a pending update, we should abort
the current render and switch to the update instead.

* Track the next unprocessed level globally

Instead of backtracking the return path. The main advantage over the
backtracking approach is that we don't have to backtrack from the source
fiber. (The main disadvantages are that it requires another module-level
variable, and that it could include updates from unrelated
sibling paths.)

* Re-arrange slightly to prevent refactor hazard

It should not be possible to perform any work on a root without
calling `ensureRootIsScheduled` before exiting. Otherwise, we could
fail to schedule a callback for pending work and the app could freeze.

To help prevent a future refactor from introducing such a bug, this
change makes it so that `renderRoot` is always wrapped in try-finally,
and the `finally` block calls `ensureRootIsScheduled`.

* Remove recursive calls to `renderRoot`.

There are a few leftover cases where `renderRoot` is called recursively.
All of them are related to synchronously flushing work before its
expiration time.

We can remove these calls by tracking the last expired level on the
root, similar to what we do for other types of pending work, like pings.

* Remove argument from performSyncWorkOnRoot

Read the expiration time from the root, like we do
in performConcurrentWorkOnRoot.
2019-09-12 14:21:57 -07:00
Dominic Gannaway
4b0b556dcf [react-interactions] Refactor TabFocusController (#16768) 2019-09-12 22:28:07 +02:00
Brian Vaughn
fb39f62925 Added upcoming changes to DevTools CHANGELOG 2019-09-12 08:34:28 -07:00
Anton Korzunov
ba932a5ad9 fix: inspect ClassComponent.render instead of constructor, fixes #16749 (#16759) 2019-09-12 08:32:42 -07:00
Dominic Gannaway
35a202d0e7 [react-events] Ensure we restore currentInstance + currentTimers (#16758) 2019-09-12 12:44:05 +02:00
Dominic Gannaway
3717c25a7e [react-interactions] More Tab Focus control handling (#16751) 2019-09-11 22:35:33 +02:00
Andrew Clark
0a2215cc0e [Scheduler][www] Put profiling feature behind flag (#16757)
Our infra currently doesn't support loading a separate profiling
build of Scheduler. Until that's fixed, the recommendation is to load
a single build and gate the profiling feature behind a flag.

Alternative to #16659
2019-09-11 13:28:03 -07:00
Brian Vaughn
8f03109cd2 Moved backend injection to the content script (#16752)
* Moved backend injection logic to content script

* Moved backend injection logic to content script

* Moved injection logic to content script

* Formatting changes

* remove ability to inject arbitrary scripts

* Removed done(), added some comments explaining the change

* Lint fixes

* Moved inline comment.

* Deleted inject() script since it was no longer being used
2019-09-11 09:51:32 -07:00
Brian Vaughn
efa780d0ab Removed DT inject() script since it's no longer being used 2019-09-11 09:51:24 -07:00
Brian Vaughn
4290967d4c Merge branch 'tt-compat' of https://github.com/onionymous/react into onionymous-tt-compat 2019-09-11 09:34:31 -07:00
Brian Vaughn
f09854a9e8 Moved inline comment. 2019-09-11 09:30:57 -07:00
Stephanie Ding
776d1c69b9 Lint fixes 2019-09-11 08:11:14 -07:00
Dominic Gannaway
3a49dff386 [react-events] Use context.objectAssign in Tap responder (#16748) 2019-09-11 17:06:40 +02:00
Stephanie Ding
2e75000f40 Removed done(), added some comments explaining the change 2019-09-11 08:05:27 -07:00
Matt Kane
56114a4b22 Change trackedTouchCount console.error to warn (#16750) 2019-09-11 14:10:26 +02:00
Dominic Gannaway
ae724be7be [react-interactions] Add TabFocusContainer and TabbableScope UI components (#16732) 2019-09-11 12:46:41 +02:00
Andrew Clark
ab4951fc03 Re-arrange slightly to prevent refactor hazard (#16743)
* Track "pending" and "suspended" ranges

A FiberRoot can have pending work at many distinct priorities. (Note: we
refer to these levels as "expiration times" to distinguish the concept
from Scheduler's notion of priority levels, which represent broad
categories of work. React expiration times are more granualar. They're
more like a concurrent thread ID, which also happens to correspond to a
moment on a timeline. It's an overloaded concept and I'm handwaving over
some of the details.)

Given a root, there's no convenient way to read all the pending levels
in the entire tree, i.e. there's no single queue-like structure that
tracks all the levels, because that granularity of information is not
needed by our algorithms. Instead we track the subset of information
that we actually need — most importantly, the highest priority level
that exists in the entire tree.

Aside from that, the other information we track includes the range of
pending levels that are known to be suspended, and therefore should not
be worked on.

This is a refactor of how that information is tracked, and what each
field represents:

- A *pending* level is work that is unfinished, or not yet committed.
  This includes work that is suspended from committing.
  `firstPendingTime` and `lastPendingTime` represent the range of
  pending work. (Previously, "pending" was the same as "not suspended.")
- A *suspended* level is work that did not complete because data was
  missing. `firstSuspendedTime` and `lastSuspendedTime` represent the
  range of suspended work. It is a subset of the pending range. (These
  fields are new to this commit.)
- `nextAfterSuspendedTime` represents the next known level that comes
  after the suspended range.

This commit doesn't change much in terms of observable behavior. The one
change is that, when a level is suspended, React will continue working
on the next known level instead of jumping straight to the last pending
level. Subsequent commits will use this new structure for a more
substantial refactor for how tasks are scheduled per root.

* Get next expiration time from FiberRoot

Given a FiberRoot, we should be able to determine the next expiration
time that needs to be worked on, taking into account the levels that
are pending, suspended, pinged, and so on.

This removes the `expirationTime` argument from
`scheduleCallbackForRoot`, and renames it to `ensureRootIsScheduled` to
reflect the new signature. The expiration time is instead read from the
root using a new function, `getNextExpirationTimeToWorkOn`.

The next step will be to remove the `expirationTime` argument from
`renderRoot`, too.

* Don't bind expiration time to render callback

This is a fragile pattern because there's only meant to be a single
task per root, running at a single expiration time. Instead of binding
the expiration time to the render task, or closing over it, we should
determine the correct expiration time to work on using fields we
store on the root object itself.

This removes the "return a continuation" pattern from the
`renderRoot` function. Continuation handling is now handled by
the wrapper function, which I've renamed from `runRootCallback` to
`performWorkOnRoot`. That function is merely an entry point to
`renderRoot`, so I've also removed the callback argument.

So to sum up, at at the beginning of each task, `performWorkOnRoot`
determines which expiration time to work on, then calls `renderRoot`.
And before exiting, it checks if it needs to schedule another task.

* Update error recovery test to match new semantics

* Remove `lastPendingTime` field

It's no longer used anywhere

* Restart on update to already suspended root

If the work-in-progress root already suspended with a delay, then the
current render definitely won't finish. We should interrupt the render
and switch to the incoming update.

* Restart on suspend if return path has an update

Similar to the previous commit, if we suspend with a delay, and
something in the return path has a pending update, we should abort
the current render and switch to the update instead.

* Track the next unprocessed level globally

Instead of backtracking the return path. The main advantage over the
backtracking approach is that we don't have to backtrack from the source
fiber. (The main disadvantages are that it requires another module-level
variable, and that it could include updates from unrelated
sibling paths.)

* Re-arrange slightly to prevent refactor hazard

It should not be possible to perform any work on a root without
calling `ensureRootIsScheduled` before exiting. Otherwise, we could
fail to schedule a callback for pending work and the app could freeze.

To help prevent a future refactor from introducing such a bug, this
change makes it so that `renderRoot` is always wrapped in try-finally,
and the `finally` block calls `ensureRootIsScheduled`.

* Remove recursive calls to `renderRoot`.

There are a few leftover cases where `renderRoot` is called recursively.
All of them are related to synchronously flushing work before its
expiration time.

We can remove these calls by tracking the last expired level on the
root, similar to what we do for other types of pending work, like pings.

* Remove argument from performSyncWorkOnRoot

Read the expiration time from the root, like we do
in performConcurrentWorkOnRoot.
2019-09-10 20:07:12 -07:00
Sebastian Markbåge
b0a8a3e041 Mark root as already hydrated after committing (#16739)
* Mark root as already hydrated after committing

* Remove current/child check for hydration and rely on the root flag instead
2019-09-10 20:02:02 -07:00
Sebastian Markbåge
e04f4259c4 Handle SuspenseListComponent getting retried (#16745)
This happens for example when a deleted boundary transfers its pending
promises to the list so that the list can be retried.

This wasn't caught by unit tests because this flag wasn't on in those
tests.
2019-09-10 19:38:44 -07:00
Stephanie Ding
8a6cd3cd12 remove ability to inject arbitrary scripts 2019-09-10 18:06:23 -07:00
Stephanie Ding
d51f062d03 Formatting changes 2019-09-10 17:46:29 -07:00
Stephanie Ding
85c7211014 Moved injection logic to content script 2019-09-10 17:45:27 -07:00
Stephanie Ding
788036c7ed Moved backend injection logic to content script 2019-09-10 17:34:12 -07:00
Stephanie Ding
c93038fabe Moved backend injection logic to content script 2019-09-10 17:22:04 -07:00
Brian Vaughn
2c98af77c3 DevTools: Props editing interface tweaks (#16740)
* Fix DevTools new prop input size
* Don't allow adding new values unless an overridePropsFn function has been provided.
* Do not show empty 'none' label ablve a new prop input
2019-09-10 14:57:33 -07:00
Brian Vaughn
2ce5801c25 Added upcoming changes to DevTools CHANGELOG 2019-09-10 13:32:53 -07:00
Hristo Kanchev
709baf1fec [DevTools] Support for adding props | Improved state/props value editing (#16700)
* Extracted sanitizeForParse

* Added canAddEntries flag to InspectedElementTree

* Added EditableKey component.

* Added support to add an additional entry.

* Added support to add more complex data structures in the EditableValue component. Added support to change the dataType of the value that is being changed.

* Fixed flow error.

* Removed unneeded fragment.

* Renamed EditableKey -> EditableName

* Removed unneeded dependency

* Removed problematic props to state hook.

* Prettified changes.

* Removed unused import.

* Fixed shouldStringify check.

* Removed testing props from EditableProps.

* Made some inline tweaks
2019-09-10 13:30:43 -07:00
Hristo Kanchev
4ef6387d6e [DevTools] [Context] Legacy Context (#16617)
* Added hasLegacyContext check.

* Passed hasLegacyContext as prop to SelectedElement

* Changing context labels based on hasLegacyContext

* Fixed flow types.

* Fixed typos.

* Added tests for hasLegacyContext.

* Renamed test.

* Removed test imports.
2019-09-10 13:30:20 -07:00
Liad Yosef
c317fc273b Correct link for troubleshooting react-dev-tools (#16690) (#16708)
* Correct link for troubleshooting react-dev-tools (#16690)

As pointed out in #16690 - the link for 'React Tab Doesn't Show Up' points to the empty README.MD.
This points it to that section in the v3 version README.MD - until an updated section will be added to the new dev-tools.

* Add a "The React Tab Doesn't Show Up" section

Add the troubleshooting section to the react dev tools readme

* point to the correct section in react-dev-tools readme

After adding the troubleshooting section to the readme - this will point to the correct place

* Moved README file to GitHub

* Update new issue link to include DevTools label
2019-09-10 13:14:19 -07:00
Nicolas Gallagher
41a78cd85c [react-events] Tap: add maximumDistance prop (#16689)
A prop for configuring the maximum distance that the active pointer can move before the tap is cancelled.
2019-09-10 12:52:43 -07:00
Dan Abramov
2400400788 react-refresh@0.4.2 2019-09-10 20:46:34 +01:00
Dan Abramov
ba6bb0fccf [Fresh] Hash signatures (#16738) 2019-09-10 20:28:13 +01:00
Dominic Gannaway
fd3e8cb0ae [react-events] Remove stopPropagation (Press) + use document for delegation (#16730) 2019-09-10 20:31:24 +02:00
Heaven
38c03ce006 Fix typo in commet (#16727) 2019-09-10 10:27:38 -07:00
Hristo Kanchev
4905590e1e Fixed font family issue in FF. (#16701) 2019-09-09 16:21:04 -07:00
Daniel Lo Nigro
35f447ddbf Remove console.log from copyWithSet (#16716) 2019-09-09 16:18:09 -07:00
Sebastian Markbåge
440cbf2ee5 Let's schedule the passive effects even earlier (#16714)
It turns out I needed to schedule mine in the mutation phase and there
are also clean up life-cycles there.
2019-09-09 15:06:03 -07:00
Sebastian Markbåge
cc2492ccf1 Schedule passive callbacks before layout effects are invoked (#16713) 2019-09-09 13:34:57 -07:00
Nicolas Gallagher
031eba789f [react-events] Tap: change order of events (#16694)
Before:

start -> change -> update -> end (cancel) -> change

Now:

start -> change -> update -> change -> end (cancel)
2019-09-09 09:08:17 -07:00
Nicolas Gallagher
f26fe8c0a7 [react-events] Keyboard: fix callback return types (#16693) 2019-09-09 09:07:42 -07:00
Heaven
9444c876d5 Remove wrong copy-paste code in test (#16695) 2019-09-09 11:34:08 +01:00
Dan Abramov
b260bef398 [Fresh] Add skipEnvCheck option to Babel plugin (#16688) 2019-09-06 20:30:16 +01:00
Dan Abramov
2f15881859 react-refresh@0.4.1 2019-09-06 20:02:43 +01:00
Dan Abramov
9044bb0fa3 [Fresh] Fix a crash with implicit arrow return (#16687) 2019-09-06 19:58:07 +01:00
Dan Abramov
21d79ce040 Add FreshRuntime WWW bundle, remove ESLint (#16684) 2019-09-06 16:48:07 +01:00
Alex Rohleder
206d61f722 fix typos on react-devtools comments (#16681) 2019-09-06 07:47:44 -07:00
Heaven
61836fba2a Fix typo: wnless -> unless (#16680) 2019-09-06 07:47:35 -07:00
Sebastian Markbåge
e11bf42cea Check for Suspense boundary in a root Container (#16673)
If we find a Container that might mean that we're on a node that is inside
a Suspense boundary that is directly inside the Container root.

Imagine the div is a Container and the span is a dehydrated instance:

```
<div>
  <!--$-->
  <span />
  <!--/$-->
</div>
```

There's no way to tests this yet since I'm not actually utilizing
the return value yet.

The solution is to just use the same path to check for a Suspense boundary
as if we find a parent instance.
2019-09-05 16:06:05 -07:00
Dan Abramov
962dfc2c33 Remove experimental scheduler flags (#16672) 2019-09-05 20:08:06 +01:00
Nicolas Gallagher
ff006451ad [react-events] Fix isTargetWithinNode type (#16671)
isTargetWithinNode passes the childTarget to getClosestInstanceFromNode which
does not account for a null value of 'node'.
2019-09-05 11:36:31 -07:00
Dan Abramov
040ca0fad7 Enable MessageLoop implementation by default (#16408) 2019-09-05 19:25:51 +01:00
Brian Vaughn
d96f478f8a use-subscription tearing fix (#16623)
* Add (failing) subscription tearing test and bugfix
* Added more inline comments to test
* Simplified tearing test case slightly
2019-09-05 11:12:46 -07:00
Luna Ruan
79e46b6778 updated flags from false to dicated on www (#16647) 2019-09-05 09:51:44 -07:00
Sebastian Markbåge
8d7c733f1f [Partial Hydration] Don't invoke listeners on parent of dehydrated event target (#16591)
* Don't invoke listeners on parent of dehydrated event target

* Move Suspense boundary check to getClosestInstanceFromNode

Now getClosestInstanceFromNode can return either a host component,
host text component or suspense component when the suspense
component is dehydrated.

We then use that to ignore events on a suspense component.

* Attach the HostRoot fiber to the DOM container

This lets us detect if an event happens on this root's subtree before it
has rendered something.

* Add todo

The approach of checking isFiberMounted answers if we might be in an
in-progress hydration but it doesn't answer which root or boundary
might be in-progress so we don't know what to wait for.

This needs some refactoring.

* Refactor isFiberMountedImpl to getNearestMountedFiber

We'll need the nearest boundary for event replaying so this prepares for
that.

This surfaced an issue that we attach Hydrating tag on the root but normally
this (and Placement) is attached on the child. This surfaced an issue
that this can lead to both Placement and Hydrating effects which is not
supported so we need to ensure that we only ever use one or the other.

* Add todo for bug I spotted

* Cache tags

* Check the ContainerInstanceKey before the InstanceKey

The container is inside the instance, so we must find it before the
instance, since otherwise we'll miss it.
2019-09-05 08:51:31 -07:00
Nicolas Gallagher
9ce8711d5a [react-events] Tap responder (#16628)
This is a partial replacement for the 'Press' responder:

1. `useTap` is scoped to pointers (no keyboard support). Our current thinking is
that "responders" should be limited to working with pointers, and that they can
be combined with 'useKeyboard' in user-space. For example, we might create a
'usePress' hook in user-space that combines 'useTap' with 'useKeyboard' to react
to both pointers and keyboard interactions.

2. `useTap` cancels the gesture once the pointer moves over an element that is
not within the responder target's subtree. This differs from `usePress` (and
React Native), where the gesture remains active after the pointer exits the
target's subtree and is restarted once the pointer reenters. One of the
drawbacks with the `usePress` behavior is that it requires repeatedly measuring
DOM elements (which can cause jank) to perform hit region tests. `useTap` avoids
doing this and relies on `document.elementFromPoint` only to support the
TouchEvent fallbacks.

3. `useTap` calls `onTapUpdate` when the active gesture's state changes,
`onTapEnd` when the gesture successfully completes. and `onTapCancel` when it
fails. There is no `onTap` callback. `usePress` did not explicitly report back
when the gesture failed, and product developers were confused about the
difference between `onPress` and `onPressEnd`.

4. `useTap` explicitly separates the PointerEvent implementation from the
MouseEvent/TouchEvent fallback.

5. `useTap` has better unit test coverage . All pointer types and the fallback
environment are tested. The shape of the gesture state object is also defined
and tested.
2019-09-04 17:09:33 -07:00
Dominic Gannaway
e86146e714 [react-events] Refine executeUserEventHandler (#16662) 2019-09-05 00:36:29 +01:00
Dominic Gannaway
c66edb9f8b [react-events] Refactor getCurrentTarget to getResponderNode (#16660) 2019-09-04 20:04:35 +01:00
Dominic Gannaway
9ff60ff16b [react-events] Fix Scope listener issue (#16658) 2019-09-04 18:57:39 +01:00
Dominic Gannaway
7126a37bf4 [react-events] Keyboard responder propagation handling (#16657) 2019-09-04 18:25:05 +01:00
Dominic Gannaway
539640d89f [react-events] Various core tweaks for event responder system (#16654) 2019-09-04 18:05:56 +01:00
Dominic Gannaway
af032764a9 [react-events] Adds preventKeys support to Keyboard responder (#16642) 2019-09-04 01:38:36 +01:00
Brian Vaughn
f705e2bac7 Updated pending CHANGELOG for DevTools 2019-09-03 08:37:12 -07:00
Hristo Kanchev
77bb102398 [DevTools] [Profiler]: Save profile now working in Firefox (#16612)
* Added anchor dom element in order to successfully download profiling data.
* Reworked downloadFile to accept a DOMElement in order for FF to successfully download profiling data.
* Prettify downloadFile changes.
2019-09-03 08:35:12 -07:00
Heaven
92f094d86d fix typo: oncurrent - concurrent (#16633) 2019-09-02 11:21:48 +01:00
Dominic Gannaway
46f912fd57 [react-core] Add more support for experimental React Scope API (#16621) 2019-08-30 18:27:14 +01:00
Paul O’Shannessy
2c1e6bf619 Adopt Contributor Covenant (#16613)
In order to foster healthy open source communities, we're adopting the
[Contributor Covenant](https://www.contributor-covenant.org/). It has been
built by open source community members and represents a shared understanding of
what is expected from a healthy community.
2019-08-29 16:04:47 -07:00
Brian Vaughn
f962feb882 Updated extensions build-from-source instructions in README 2019-08-29 08:49:08 -07:00
Simen Bekkhus
ac6193687f add integrity field in yarn.lock (#16601) 2019-08-29 16:36:02 +01:00
Sebastian Silbermann
16329bd954 chore: Update nvmrc with latest lts (#16610) 2019-08-29 16:30:35 +01:00
Dominic Gannaway
4e544cffee [react-events] Split out mixed event responder tests (#16608) 2019-08-29 16:13:37 +01:00
Gerald Monaco
f61138e068 Use renderToStaticMarkup for tests (#16516) 2019-08-29 16:08:38 +01:00
James George
980112b146 rephrase comment (#16559) 2019-08-29 14:51:07 +01:00
Bas Peeters
8a7c2e50f1 Remove duplicate character in regex group (#16572) 2019-08-29 14:49:27 +01:00
Tom Quirk
557d472fe3 add <thead>, <tfoot> to table > tr warning (#16535) 2019-08-29 14:46:27 +01:00
Simen Bekkhus
37fcd04681 chore: upgrade to danger 9 (#16602) 2019-08-29 13:46:53 +01:00
Dominic Gannaway
bd79be9b68 [react-core] Add experimental React Scope component API (#16587) 2019-08-29 12:06:51 +01:00
Brian Vaughn
996acf9036 Updated DevTools extension build script to work when run remotely (#16603) 2019-08-28 17:01:26 -07:00
Dominic Gannaway
34aaec6f90 [react-events] Ensure screen reader virtual clicks support preventDefault (#16600) 2019-08-28 17:39:07 +01:00
Dan Abramov
01fb68b9bf Don't ignore dependencies for render phase update (#16574) 2019-08-28 16:55:56 +01:00
LEE SUK JAE
1b585f630b Fix link on error-codes/README.md (#16595) 2019-08-28 15:49:45 +01:00
Brian Vaughn
0f3e82f3c4 Merge branch 'devtools-v4-merge' 2019-08-28 07:39:49 -07:00
Brian Vaughn
b8390310b1 Revert "Import React DevTools v4"
This reverts commit b438699d36.
2019-08-28 07:39:32 -07:00
Brian Vaughn
b438699d36 Import React DevTools v4
Imports the entire React DevTools v4 git repository (with history).
2019-08-28 07:35:53 -07:00
Brian Vaughn
ada5991422 Removed an unnecessary/unused DT Flow type 2019-08-28 07:28:06 -07:00
Brian Vaughn
08ce280cbc Updated DT regression fixture path 2019-08-28 07:25:52 -07:00
Brian Vaughn
b034ac6d38 Merge branch 'master' into devtools-v4-merge 2019-08-28 07:13:49 -07:00
Luna Ruan
f512537754 Babel Transform JSX to React.jsx/React.jsxDEV Plugin (#16432)
This babel transform is a fork of the @babel/plugin-transform-react-jsx transform and is for experimentation purposes only. We don't plan to own this code in the future, and we will upstream this to Babel at some point once we've proven out the concept.

As per the RFC to simplify element creation, we want to change the JSX transform from targeting React.createElement(type, props, children) to React.jsx(type, props, key). This modifies the existing @babel/plugin-transform-react-jsx (and helper) babel plugin to support React.jsx and React.jsxDEV.

The main differences between React.jsx/React.jsxDEV and React.createElement are:
1.) key is now passed as an explicit argument rather than through props
3.) children are now passed through props rather than as an explicit argument
4.) props must always be an object
5.) __source and and __self are now passed as separate arguments into React.jsxDEV rather than through props

Part of the rationale for this change is that we want to deprecate key spread through props because this is an expensive dynamic comparison operation. We want users instead always explicitly pass key as a prop. However, in the interim, we need a way to distinguish between <div {...props} key={foo} /> and <div key={foo} {...props} />. Therefore, until we completely deprecate key spreading, we will use React.createElement to transform <div {...props} key="Hi" /> and React.jsx to transform everything else.
2019-08-27 16:00:20 -07:00
Nicolas Gallagher
cb15f18dc1 [react-events] Improve mock event object accuracy (#16590)
* Better simulation for pointercancel
* Fix pressure values for different pointers
* Add describe/test helpers for pointer events
2019-08-27 15:45:54 -07:00
Brian Vaughn
bc8b15332b Updated README docs, example screenshots, etc 2019-08-27 15:20:34 -07:00
Brian Vaughn
7153dd516f Fixed a StyleEditor variable resolution regression 2019-08-27 12:53:38 -07:00
Brian Vaughn
33d439f8fd Merge branch 'master' into devtools-v4-merge 2019-08-27 11:00:41 -07:00
Brian Vaughn
fb316787cb Removed unused Chrome Flow types 2019-08-27 10:54:21 -07:00
Brian Vaughn
8e1434e80e Added FB copyright header 2019-08-27 10:54:01 -07:00
Brian Vaughn
49b0f87d10 Suppress act/renderer warning for DevTools tests 2019-08-27 10:46:27 -07:00
Brian Vaughn
8c684bf7e1 Removed forked DevTools Flow types 2019-08-27 10:42:02 -07:00
Brian Vaughn
9a016c0c2b Removed outdated snapshot 2019-08-27 10:31:36 -07:00
Brian Vaughn
f55b4f8e28 CI runs DevTools tests against built source 2019-08-27 10:28:58 -07:00
Dominic Gannaway
4ef269606c [react-events] Support screen reader virtual clicks (#16584) 2019-08-27 17:32:50 +01:00
Brian Vaughn
892ca8137e Disabled DevTools tests from yarn-build target 2019-08-27 09:08:49 -07:00
Brian Vaughn
896c993ada Fixed remaining DevTools broken tests by fixing a hydration/spread bug 2019-08-27 08:50:36 -07:00
Brian Vaughn
e3cc42be97 Fix Console patching test by resetting modules 2019-08-26 13:53:29 -07:00
Brian Vaughn
177f357d9d Updated DevTools test setup to no longer mock test renerer 2019-08-26 13:46:00 -07:00
Brian Vaughn
a48593a8d3 Iterating on DevTools tests: Trying to run tests against pre-build react-dom and react-test-renderers 2019-08-26 13:43:09 -07:00
Brian Vaughn
ee4806f47a Fixed flushing problem with tests 2019-08-26 13:08:35 -07:00
Brian Vaughn
9d4fd7a249 Merged changes from 4.0.5 -> 4.0.6 from DevTools fork 2019-08-26 10:12:18 -07:00
Brian Vaughn
4c1514495b Merge branch 'source' of github.com:bvaughn/react-devtools-experimental 2019-08-26 10:06:00 -07:00
Brian Vaughn
13a93e7b82 Configured CI to run DevTools tests. Updated other test configs not to include DevTools tests. 2019-08-26 09:58:28 -07:00
Brian Vaughn
c00a920640 Merge branch 'master' into devtools-v4-merge 2019-08-26 09:42:25 -07:00
Brian Vaughn
0da7bd0604 React DevTools CHANGELOG entry for 4.0.6 2019-08-26 09:34:06 -07:00
Brian Vaughn
a39d9c3dff 4.0.5 -> 4.0.6 2019-08-26 08:42:38 -07:00
Brian Vaughn
1e3b0b520e Added a null check around memoizedProps 2019-08-24 09:04:26 -07:00
Brian Vaughn
84b492f344 Polyfill Symbol usage 2019-08-23 17:38:45 -06:00
Dominic Gannaway
fc80772078 [react-events] Ensure updateEventListeners updates in commit phase (#16540) 2019-08-22 23:58:16 +01:00
Dan Abramov
0f6e3cd61c [Scheduler] Profiler Features (second try) (#16542)
* Revert "Revert "[Scheduler] Profiling features (#16145)" (#16392)"

This reverts commit 4ba1412305.

* Fix copy paste mistake

* Remove init path dependency on ArrayBuffer

* Add a regression test for cancelling multiple tasks

* Prevent deopt from adding isQueued later

* Remove pop() calls that were added for profiling

* Verify that Suspend/Unsuspend events match up in tests

This currently breaks tests.

* Treat Suspend and Resume as exiting and entering work loop

Their definitions used to be more fuzzy. For example, Suspend didn't always fire on exit, and sometimes fired when we did _not_ exit (such as at task enqueue).

I chatted to Boone, and he's saying treating Suspend and Resume as strictly exiting and entering the loop is fine for their use case.

* Revert "Prevent deopt from adding isQueued later"

This reverts commit 9c30b0b695d81e9c43b296ab93d895e4416ef713.

Unnecessary because GCC

* Start counter with 1

* Group exports into unstable_Profiling namespace

* No catch in PROD codepath

* No label TODO

* No null checks
2019-08-22 13:58:12 -07:00
Nicolas Gallagher
474b650cac [react-events] Rename hook exports (#16533)
For example, 'useHoverResponder' becomes 'useHover'
2019-08-22 13:30:35 -07:00
Nicolas Gallagher
2f03aa6eed [react-events] Fix middle-click for Press (#16546)
Browsers always report 'buttons' as 0 when a pointer is released.
2019-08-22 10:22:14 -07:00
Bruno Scopelliti
16c3408638 Only warn in case the fourth argument is a function (#16543) 2019-08-22 17:31:27 +01:00
Sebastian Markbåge
05f5192e81 [Partial Hydration] Dispatching events should not work until hydration commits (#16532)
* Refactor a bit to use less property access

* Add test for invoking an event before mount

* Add Hydration effect tag

This is equivalent to a "Placement" effect in that it's a new insertion
to the tree but it doesn't need an actual mutation.

It is only used to determine if a subtree has actually mounted yet.

* Use the Hydration flag for Roots

Previous roots had a Placement flag on them as a hack for this case but
since we have a special flag for it now, we can just use that.

* Add Flare test
2019-08-22 08:46:20 -07:00
Brian Vaughn
bf9415834f Fixed outdated extension popup wording 2019-08-21 14:28:57 -07:00
Brian Vaughn
6dda816102 Remove emoji prefix from Firefox extension tab labels
Firefox adds these already for React, so the extra emoji character was confusing. For now, we still prepend it for Chrome
2019-08-21 14:23:51 -07:00
Brian Vaughn
79bda69d88 Renamed DevTools Jest config to be more concistent with others 2019-08-21 13:40:24 -07:00
Dan Abramov
8a01b50fc3 eslint-plugin-react-hooks@2.0.1 2019-08-21 21:40:20 +01:00
Dan Abramov
3ed289b3b1 Clear canceled task node early (#16403) 2019-08-21 19:49:22 +01:00
Dan Abramov
0672829053 Bump ESLint plugin to 2.0 (#16528) 2019-08-21 19:14:34 +01:00
Nicolas Gallagher
2559111c21 [react-events] Rely on 'buttons' rather than 'button' (#16479)
The semantics of 'button' on events differs between PointerEvent and
MouseEvent, whereas they are the same for 'buttons'. Furthermore, 'buttons'
allows developers to determine when multiple buttons are pressed as the same
time.

https://w3c.github.io/pointerevents/#the-button-property
2019-08-21 10:07:15 -07:00
Dan Abramov
c433fbb593 Revert "Revert "[ESLint] Forbid top-level use*() calls (#16455)"" (#16525)
* Revert "Revert "[ESLint] Forbid top-level use*() calls (#16455)" (#16522)"

This reverts commit 507f0fb372.

* Update RulesOfHooks.js
2019-08-21 15:43:31 +01:00
Sunil Pai
507f0fb372 Revert "[ESLint] Forbid top-level use*() calls (#16455)" (#16522)
This reverts commit 96eb703bbf.
2019-08-21 10:20:34 +01:00
Brian Vaughn
66c9fedc34 Flow fixes 2019-08-20 13:33:33 -07:00
Brian Vaughn
fe943c339d Add custom DevTools Flow definitions to shared flowconfig 2019-08-20 11:37:45 -07:00
Brian Vaughn
2e549efae5 Moved DevTools custom Flow definitions 2019-08-20 11:37:31 -07:00
Brian Vaughn
4da836af71 Merged changes from 4.0.0 -> 4.0.5 from DevTools fork 2019-08-20 11:34:51 -07:00
Brian Vaughn
3ad50710a7 Merge branch 'source' of github.com:bvaughn/react-devtools-experimental 2019-08-20 11:00:02 -07:00
Brian Vaughn
833f206348 Merge branch 'master' into devtools-v4-merge 2019-08-20 10:41:38 -07:00
bbolek
efa5dbe7a5 Update CHANGELOG.md (#16439)
* Update CHANGELOG.md

Fixed typo
2019-08-20 09:51:01 -07:00
Heaven
da0a47bec3 fix typo in CHNAGELOG.md (#16447) 2019-08-20 09:48:03 -07:00
Morgan McCauley
69aafbf4df Fix spelling in react-devtools CHANGELOG.md (#16448) 2019-08-20 09:47:18 -07:00
Brian Vaughn
2843a1556e Fixed invalid object-assign version (4.0.4 -> 4.0.1) 2019-08-20 09:45:09 -07:00
Brian Vaughn
aa56fe34ac Improved GitHub issue repro instructions prompt 2019-08-20 09:44:41 -07:00
Sebastian Markbåge
c80678c760 Add "hydrationOptions" behind the enableSuspenseCallback flag (#16434)
This gets invoked when a boundary is either hydrated or if it is deleted
because it updated or got deleted before it mounted.
2019-08-19 13:26:39 -07:00
Dan Abramov
2d68bd0960 Fix message loop behavior when host callback is cancelled (#16407)
* Add a regression test for cancelCallback with message loop

* If there's nothing scheduled, we're not running

* Add more tests from #16271
2019-08-19 21:20:21 +01:00
Dan Abramov
96eb703bbf [ESLint] Forbid top-level use*() calls (#16455)
* Add a way to skip/only tests to RulesOfHooks test

* [ESLint] Forbid top-level use*() calls

* Add a regression test for logical expressions

This is not a change. Just adding more coverage.
2019-08-19 19:54:06 +01:00
Dan Abramov
56f93a7f38 Throw on unhandled SSR suspending (#16460)
* Throw on unhandled SSR suspending

* Add a nicer message when the flag is off

* Tweak internal refinement error message
2019-08-19 19:53:02 +01:00
Dominic Gannaway
dce430ad92 [Flare] Rework the responder dispatching/batching mechanism (#16334) 2019-08-19 19:22:46 +01:00
Brian Vaughn
6ae6a7c020 Updated React DevTools changelog for 4.0.5 2019-08-19 09:28:10 -07:00
Brian Vaughn
5441b094a4 4.0.4 -> 4.0.5 2019-08-19 09:26:55 -07:00
Nicolas Gallagher
56d1b0fb59 [react-events] DOM event testing library (#16433)
This patch formalizes the mock native events and event sequences used in unit tests.

The `createEventTarget` function returns an object that can be used to dispatch native event sequences on the target without having to manually do so across all the scenarios we need to account for. Unit tests can be written as if we were only working with PointerEvent, but they will dispatch realistic native event sequences based on the execution environment (e.g., is PointerEvent supported?) and pointer type.

```
describe.each(environments)('Suite', (hasPointerEvents) => {
  beforeEach(() => {
    // setup
  });

  test.each(pointerTypes)('Test', (pointerType) => {
    const target = createEventTarget(node);
    target.pointerdown({pointerType});
    expect(callback).toBeCalled();
  });
});
```

Every native event that is dispatched now includes a complete object by default. The properties of the events can be customized. Properties that shouldn't be relied on in responder implementations are excluded from the mock native events to ensure tests will fail. Equivalent properties are normalized across different event types, e.g., 'pointerId' is converted to 'identifier' before a TouchEvent is dispatched.
2019-08-19 09:21:55 -07:00
Brian Vaughn
01b1e7e2cf Alpha-sort props/state/context keys 2019-08-19 09:17:52 -07:00
Brian Vaughn
d2456c7572 Fixed standalone target not properly serving backend over localhost:8097 2019-08-19 07:36:41 -07:00
Brian Vaughn
14c2eab7c3 Resolved Yarn conflict for object-assign 2019-08-19 07:04:47 -07:00
Brian Vaughn
e89c19d16c Added DevTools 4.0.4 CHANGELOG entry 2019-08-18 08:55:49 -07:00
Brian Vaughn
3c6a219466 4.0.3 -> 4.0.4 2019-08-18 08:45:52 -07:00
Brian Vaughn
4697f5b379 Profiler bugfix for filtering out all commits after selecting a fiber 2019-08-18 08:34:40 -07:00
Brian Vaughn
d97af798d2 Updated DevTools CHANLOGE to add an unreleased change 2019-08-17 21:19:00 -07:00
Brian Vaughn
95ca079556 Fixed standalone bug that prevented backend from being served over localhost:8097 2019-08-17 21:11:10 -07:00
Brian Vaughn
21e793fb4f Added 4.0.1, 4.0.2, and 4.0.3 changelog entries (#16438)
* Added 4.0.1, 4.0.2, and 4.0.3 changelog entries
* Added entry about Map/Set/Immutable
2019-08-17 11:47:38 -07:00
Brian Vaughn
95ffd3ccf8 4.0.2 -> 4.0.3 2019-08-17 11:31:31 -07:00
Brian Vaughn
2935d6a18d Unserializable data type fix for standalone shell 2019-08-17 11:31:20 -07:00
Brian Vaughn
ce65df7092 Added support for unserializable types (e.g. Set/Map, Immutable) 2019-08-17 10:20:26 -07:00
Brian Vaughn
f66a20f439 Caps lock bug template request for repro steps :) 2019-08-16 14:47:55 -07:00
Brian Vaughn
69b2ecc531 Added explicit (empty) label next to empty arrays and objects 2019-08-16 13:47:09 -07:00
Brian Vaughn
024bac4263 Support single-quote strings in style editor 2019-08-16 13:35:30 -07:00
Brian Vaughn
74f4a3f972 Improved editing props demo experience for TODO list 2019-08-16 13:15:16 -07:00
Brian Vaughn
f616613059 Display hook values for components that only use context 2019-08-16 11:33:28 -07:00
Brian Vaughn
454157dd66 Multi-renderer profiling improvements
Add support for mixed v15/v16 renderers that previously caused profiling to fail with 'profiling not supported by this renderer' type errors
2019-08-16 11:25:44 -07:00
Brian Vaughn
49399aa3e7 Prettier 2019-08-16 09:05:26 -07:00
Brian Vaughn
5e043adba7 Added Set+Map to dev shell, even though we don't support deep inspecting them yet 2019-08-16 09:05:21 -07:00
Dan Abramov
c1d3f7f1a9 [DevTools Changelog] Add a note on 4.0.2 2019-08-16 16:15:19 +01:00
Brian Vaughn
2bcc6c6d04 4.0.1 -> 4.0.2 2019-08-15 17:35:30 -07:00
Brian Vaughn
527fc4a63f Refactored to remove need for new webNavigation permission 2019-08-15 17:34:34 -07:00
Brian Vaughn
c100cc7b31 4.0.0 -> 4.0.1 2019-08-15 16:29:13 -07:00
Brian Vaughn
545de6f02e Removed some unnecessary manifest permissions 2019-08-15 16:28:10 -07:00
Dan Abramov
6f86294e68 [DevTools Changelog] Add a note about restoring selection (#16409)
Also a tiny nit, "inline" spelling seems more common in this context. My eyes stumbled at it on every read.
2019-08-15 23:11:37 +01:00
Brian Vaughn
d0dcbe5594 Changed version name string to show version and date. Moved commit number into description string. 2019-08-15 14:38:16 -07:00
Brian Vaughn
0763c48ed8 Bumped all versions to 4.0.0 2019-08-15 14:28:09 -07:00
Brian Vaughn
732f3a6ef1 4.0.0-alpha.9 -> 4.0.0-alpha.10 2019-08-15 11:26:04 -07:00
Brian Vaughn
600c57a9b9 Added OVERVIEW.md and updated CHANGELOG to point to it (#16405) 2019-08-15 11:22:11 -07:00
Brian Vaughn
db9e5c9715 Updated all GitHub links to point to React repo 2019-08-15 11:17:59 -07:00
Brian Vaughn
9b5985b3c1 Added release date to DevTools CHANGELOG 2019-08-15 10:40:59 -07:00
Nicolas Gallagher
ebd1f5ddb0 [react-events] Press: improve test coverage (#16397)
1. Run the tests in both an environment without PointerEvent and one with PointerEvent.
2. Improve test coverage to include both mouse and touch pointers.
3. Change 'Press' so that it only listens to either pointer events or fallbacks events.
2019-08-15 10:28:00 -07:00
Brian Vaughn
85fbe3be3f Merge branch 'master' into devtools-v4-merge 2019-08-15 10:14:34 -07:00
Brian Vaughn
a9304e79d4 Add DevTools package placeholder package.json 2019-08-15 10:12:27 -07:00
Brian Vaughn
6edff8f5e1 Added CHANGELOG and READMEs for DevTools v4 NPM packages (#16404) 2019-08-15 10:06:16 -07:00
Brian Vaughn
7ce229d3b0 Made some incremental progress on Jest tests 2019-08-15 09:53:22 -07:00
Brian Vaughn
4c4f5fd27f Disable @babel/plugin-transform-block-scoping "throwIfClosureRequired" option for tests 2019-08-14 19:04:43 -07:00
Brian Vaughn
41db902ed4 Removed unused __TEST__ files 2019-08-14 19:03:32 -07:00
Brian Vaughn
a6aba5a587 Add explicit MIT license file (previously only in package.json) 2019-08-14 17:04:05 -07:00
Brian Vaughn
9ec9938ff4 print-warnings script should ignore DevTools packages 2019-08-14 14:02:12 -07:00
Brian Vaughn
a473dca59e Merge branch 'master' into devtools-v4-merge 2019-08-14 14:01:46 -07:00
Brian Vaughn
868d02d6c6 Added better error reporting for print-warnings errors (#16394) 2019-08-14 14:01:29 -07:00
Dan Abramov
4ba1412305 Revert "[Scheduler] Profiling features (#16145)" (#16392)
This reverts commit a34ca7bce6.
2019-08-14 20:02:41 +01:00
Brian Vaughn
4078167255 Removed (no longer necessary) node->node-events mapping 2019-08-14 11:43:59 -07:00
Brian Vaughn
d7ca8847f5 Add build-info.json to package files array for non-private DT packages 2019-08-14 11:40:09 -07:00
Brian Vaughn
39209dc5b5 Update react-devtools-inline to embed react-debug-tools since it's not published yet 2019-08-14 11:37:48 -07:00
Brian Vaughn
45dff31a75 Patched up react-devtools-core Webpack configs 2019-08-14 11:22:28 -07:00
Brian Vaughn
58b39c60db Fixed web extensions 2019-08-14 10:33:33 -07:00
Brian Vaughn
30b8ef3756 Iterated on Webpack configs until I got the inline and shell packages seemingly working 2019-08-14 09:24:35 -07:00
Brian Vaughn
44e410900d Merged master (with events -> legacy-events package rename) 2019-08-14 07:35:49 -07:00
Brian Vaughn
b1a03dfdc8 Rename legacy "events" package to "legacy-events" (#16388)
* Renamed 'events' package to 'legacy-events'
* Updated 'events' references to point to 'legacy-events'
2019-08-14 07:32:42 -07:00
Hristo Kanchev
9e64bf18e1 [eslint-plugin-react-hooks] Fixed crash when referencing arguments in arrow functions. (#16356)
* Fixed issue with def being undefined while referencing arguments.

* Removed todo comment.

* Skip exhaustive deps check if def is null.

* Fixed code formatting in ExhaustiveDeps.

* Removed unneeded comment in ExhaustiveDeps.
2019-08-14 14:44:06 +01:00
Simen Bekkhus
e308a037be chore: make tests compatible with Jest 24 (#15779)
* chore: make tests compatible with Jest 24

* remove fake rafs

* rollback jsdom for localstorage compat

* Apply suggestions from code review

Co-Authored-By: Sunil Pai <threepointone@oculus.com>

* chore: cleanup lockfile
2019-08-14 12:32:26 +01:00
Simen Bekkhus
5fa99b5aa6 chore: add eslint-plugin-jest's valid-expect rule (#16332)
* chore: add eslint-plugin-jest's valid-expect rule

* update assertion
2019-08-14 11:51:01 +01:00
Brian Vaughn
441d014cef Cleaned up some extnesions build script stuff 2019-08-13 22:15:38 -07:00
Brian Vaughn
380da5fccc Moved OVERVIEW 2019-08-13 22:09:20 -07:00
Brian Vaughn
b73e293cc5 Moved CHANGELOG 2019-08-13 22:05:45 -07:00
Brian Vaughn
ac2e861fbe Fixed a bunch of Lint issues 2019-08-13 21:59:07 -07:00
Andrew Clark
a34ca7bce6 [Scheduler] Profiling features (#16145)
* [Scheduler] Mark user-timing events

Marks when Scheduler starts and stops running a task. Also marks when
a task is initially scheduled, and when Scheduler is waiting for a
callback, which can't be inferred from a sample-based JavaScript CPU
profile alone.

The plan is to use the user-timing events to build a Scheduler profiler
that shows how the lifetime of tasks interact with each other and
with unscheduled main thread work.

The test suite works by printing an text representation of a
Scheduler flamegraph.

* Expose shared array buffer with profiling info

Array contains

- the priority Scheduler is currently running
- the size of the queue
- the id of the currently running task

* Replace user-timing calls with event log

Events are written to an array buffer using a custom instruction format.
For now, this is only meant to be used during page start up, before the
profiler worker has a chance to start up. Once the worker is ready, call
`stopLoggingProfilerEvents` to return the log up to that point, then
send the array buffer to the worker.

Then switch to the sampling based approach.

* Record the current run ID

Each synchronous block of Scheduler work is given a unique run ID. This
is different than a task ID because a single task will have more than
one run if it yields with a continuation.
2019-08-13 19:01:17 -07:00
Lee Byron
56636353d8 Partial support for React.lazy() in server renderer. (#16383)
Provides partial support for React.lazy() components from the existing PartialRenderer server-side renderer.

Lazy components which are already resolved (or rejected), perhaps with something like `react-ssr-prepass`, can be continued into synchronously. If they have not yet been initialized, they'll be initialized before checking, opening the possibility to exploit this capability with a babel transform. If they're pending (which will typically be the case for a just initialized async ctor) then the existing invariant continues to be thrown.
2019-08-13 18:51:20 -07:00
Sebastian Markbåge
6fbe630549 [Partial Hydration] Attempt hydration at a higher pri first if props/context changes (#16352)
* Test that we can suspend updates while waiting to hydrate

* Attempt hydration at a higher pri first if props/context changes

* Retrying a dehydrated boundary pings at the earliest forced time

This might quickly become an already expired time.

* Mark the render as delayed if we have to retry

This allows the suspense config to kick in and we can wait for much longer
before we're forced to give up on hydrating.
2019-08-13 18:26:21 -07:00
Brian Vaughn
51626ae2f9 Prettier 2019-08-13 18:12:19 -07:00
Brian Vaughn
f7afe1b864 Moved shell fixture into packages/react-devtools-shell 2019-08-13 18:11:59 -07:00
Brian Vaughn
183f96f2ac Prettier 2019-08-13 17:58:03 -07:00
Brian Vaughn
edc46d7be7 Misc Flow and import fixes
1. Fixed all reported Flow errors
2. Added a few missing package declarations
3. Deleted ReactDebugHooks fork in favor of react-debug-tools
2019-08-13 17:53:28 -07:00
Brian Vaughn
08743b1a8e Reorganized folders into packages/* 2019-08-13 15:59:43 -07:00
Dan Abramov
e0a521b02a Make component stack last argument for deprecation warnings (#16384) 2019-08-13 23:25:03 +01:00
Dan Abramov
1fd3906e92 Remove "Waiting for async callback" User Timing measurement (#16379)
* Remove "Waiting for async callback" User Timing measurement

* Fix User Timing in PROD mode
2019-08-13 22:03:29 +01:00
lunaruan
89bbffed6e Cleanup Babel PR (ReactFreshPlugin) (#16340)
* fix babel 7 issues

* fix babel 7 issues
2019-08-13 21:18:40 +01:00
Dan Abramov
dc3160887b [CI] Disable coverage (#16380)
Looks like it's broken. Don't know if this will work to disable it while we figure out why?
2019-08-13 21:11:51 +01:00
Brian Vaughn
ec7ef50e8b Reorganized things again into packages 2019-08-13 11:37:25 -07:00
Brian Vaughn
7cabb3946e Reorganized fixtures 2019-08-13 11:11:25 -07:00
Brian Vaughn
c8922c3dbf Updated yarn.lock file 2019-08-13 11:08:40 -07:00
Brian Vaughn
9c825b59f1 Moved dev shell into fixtures/devtools 2019-08-13 11:05:37 -07:00
Brian Vaughn
65b93cd165 Merge remote-tracking branch 'devtools-merge/master' into devtools-v4-merge 2019-08-13 10:46:18 -07:00
Brian Vaughn
56b1c20cf0 Reorganized to avoid merge conflicts with React repo folder structure 2019-08-13 10:33:56 -07:00
Brian Vaughn
e3ac9d219d Merging DevTools fork 2019-08-13 10:10:41 -07:00
Brian Vaughn
848327760f Initializing empty merge repo 2019-08-13 10:09:17 -07:00
Andrew Clark
21d6395a14 Add test case for #16359 (#16371) 2019-08-12 19:00:50 -07:00
Sebastian Markbåge
a29adc9f62 Dehydrated suspense boundaries in suspense list (#16369)
If we get an insertion after a boundary, that has not yet been hydrated,
we take our best guess at which state the HTML is showing.

isSuspenseInstancePending means that we're still waiting for more server
HTML before we can hydrate. This should mean that we're showing the
fallback state.

isSuspenseInstanceFallback means that we want to client render something.
That most likely means that the server was unable to render and is
displaying a fallback state in this slot.

Adds tests to ensure that dehydrated components don't consider the force
flag.
2019-08-12 16:28:02 -07:00
Sebastian Markbåge
50addf4c0e Refactor Partial Hydration (#16346)
* Move dehydrated to be child of regular SuspenseComponent

We now store the comment node on SuspenseState instead and that indicates
that this SuspenseComponent is still dehydrated.

We also store a child but that is only used to represent the DOM node for
deletions and getNextHostSibling.

* Move logic from DehydratedSuspenseComponent to SuspenseComponent

Forked based on SuspenseState.dehydrated instead.

* Retry logic for dehydrated boundary

We can now simplify the logic for retrying dehydrated boundaries without
hydrating. This is becomes simply a reconciliation against the dehydrated
fragment which gets deleted, and the new children gets inserted.

* Remove dehydrated from throw

Instead we use the regular Suspense path. To save code, we attach retry
listeners in the commit phase even though technically we don't have to.

* Pop to nearest Suspense

I think this is right...?

* Popping hydration state should skip past the dehydrated instance

* Split mount from update and special case suspended second pass

The DidCapture flag isn't used consistently in the same way. We need
further refactor for this.

* Reorganize update path

If we remove the dehydration status in the first pass and then do a second
pass because we suspended, then we need to continue as if it didn't
previously suspend. Since there is no fragment child etc.

However, we must readd the deletion.

* Schedule context work on the boundary and not the child

* Warn for Suspense hydration in legacy mode

It does a two pass render that client renders the content.

* Rename DehydratedSuspenseComponent -> DehydratedFragment

This now doesn't represent a suspense boundary itself. Its parent does.

This Fiber represents the fragment around the dehydrated content.

* Refactor returns

Avoids the temporary mutable variables. I kept losing track of them.

* Add a comment explaining the type.

Placing it in the type since that's the central point as opposed to spread
out.
2019-08-12 15:58:38 -07:00
Andrew Clark
c2034716a5 Fix typo in error code map (#16373)
"responer" -> "responder"

I also removed an unused error code that never shipped.
2019-08-12 14:56:09 -07:00
Andrew Clark
62b04cfa75 Remove unused import
That's why you wait for the lint job to finish, Andrew!!!!!!
2019-08-12 14:35:33 -07:00
Andrew Clark
3eeb645515 Remove flag that reverts #15650 (#16372)
The change in #15650 has fully rolled out, so we can remove the flag
that reverts it.
2019-08-12 14:31:12 -07:00
Sebastian Markbåge
2716d91ec4 Reset didReceiveUpdate in beginWork (#16359)
This is a bad bug. It means that we sometimes inherit
didReceiveUpdate from a previous component's begin.

Effectively this only means that we're overrendering in some cases.

We should refactor to get rid of this as a global flag.
2019-08-12 14:16:25 -07:00
Nicolas Gallagher
9449f8bf39 [react-events] Fix keyboard responder test (#16368) 2019-08-12 13:51:00 -07:00
Brian Vaughn
6eb04b2b16 4.0.0-alpha.8 -> 4.0.0-alpha.9 2019-08-12 11:34:00 -07:00
Brian Vaughn
2f1c100e7c Misc. Profiler tweaks
* Disabled (with a follow up TODO) the  call in the reload-and-profile toggle.
* Disabled reload-and-profile in Firefox extension for now, since it was triggering a disconnected port error.
* Fixed Safari layout bug that caused profiler charts to be hidden.
2019-08-12 11:13:38 -07:00
Brian Vaughn
8fa608d9ab Fixed a selection-sync edge case for Elements/Components tabs 2019-08-12 10:31:50 -07:00
Nicolas Gallagher
107521a952 [react-events] Focus/FocusWithin responders with fallbacks (#16343)
Separate the PointerEvent and fallback implementations.
Fix the unit tests to cover both PointerEvent and non-PointerEvent environments.
Fix the focus-visible related callbacks to get called when keys other than "Tab" are used.
2019-08-12 10:10:51 -07:00
Brian Vaughn
8001b6432c Fixed raw-loader + Jest problem 2019-08-12 08:49:26 -07:00
Brian Vaughn
b5195a5f16 Fixed a couple of edge case styling and layout issues I noticed while testing the inline target 2019-08-12 08:26:48 -07:00
Desmond Brand
7a7e792a6f Make SchedulerMinHeap flow strict (#16351)
@acdlite while browsing Twitter, I saw [an opportunity][1] to do
something more productive than browsing Twitter.

[1]: https://twitter.com/acdlite/status/1160247965908234240

Test plan:

`yarn flow-ci`, `yarn test-prod`, `yarn lint`
2019-08-10 13:44:23 -07:00
Andrew Clark
e349da19b8 [Scheduler] Temporarily remove wrapper function (#16345)
This code is being compiled incorrectly by something in the Facebook
build pipeline. I'm removing it temporarily to unblock the sync while
we investigate.
2019-08-09 18:08:29 -07:00
Brian Vaughn
5b007573ac Release script supports publishing a subset of packages (#16338)
Release script supports publishing a subset of packages (#16338)
2019-08-09 13:12:00 -07:00
Andrew Clark
0bd0c5269f Upgrade ESLint so we can use JSX Fragment syntax (#16328)
Now that we're using Babel 7, this is the last blocker.
2019-08-09 12:59:02 -07:00
Sebastian Markbåge
07d062dea8 Mark spawned work for client-rendered suspense boundary (#16341)
Currently this is getting marked as Never which is the normal continuation
for a dehydrated boundary, but if it is client-rendered it has a higher
priority. That causes us to drop the interaction tracing for that render.

This colocates the marking where we actually set the expiration time.
2019-08-09 12:37:06 -07:00
Nicolas Gallagher
07a02fb80d [react-events] Refactor unit tests for Hover (#16320)
**Problem**

The existing responders listen to pointer events by default and add fallback events if PointerEvent is not supported. However, this complicates the responders and makes it easy to create a problematic unit test environment. jsdom doesn't support PointerEvent, which means that the responders end up listening to pointer events *and* fallback events in unit tests. This isn't a direct problem in production environments, because no browser will fire pointer events if they aren't supported. But in the unit test environment, we often dispatch event sequences taken from browsers that support pointer events. This means that what we're often testing is actually a (complex) scenario that cannot even occur in production: a responder that is listening to and receives both pointer events and fallback events. Not only does this risk making responders more complicated to implement but it could also hide bugs in implementations.

**Response**

Implement the responders so that they're only listening to *either* pointer events *or* fallback events, never both. This should make the default pointer events implementations significantly simpler and easier to test, as well as free to rely on the complete PointerEvents API. In the future it should also make DCE easier for target environments that are known to support PointerEvents, as we can use build tools with an equivalent of the runtime check. The fallback events (touch and mouse) need to coexist and be resilient to browser emulated events. Our unit tests should express a suite of high-level interactions that can be run in environments with and without PointerEvents support.
2019-08-09 10:53:49 -07:00
Sunil Pai
f62b53d908 fix some missing assertions (#16336)
These were discovered by @SimenB in https://github.com/facebook/react/pull/16332. We weren't making actual assertions on some values. This PR makes the assertions, and fixes the tests.
2019-08-09 15:34:49 +01:00
Sunil Pai
b9faa3b092 [act] remove obsolete container element (#16312)
In a previous version of act(), we used a dummy dom element to flush effects. This doesn't need to exist anymore, and this PR removes it. The warning doesn't need to be there either (React will fire a wrong renderer act warning if needed).
2019-08-09 14:26:47 +01:00
Sunil Pai
66a474227b use a different link in the UNSAFE_ component warnings (#16321)
When React detects a deprectated/unsafe lifecycle method, the warning points to a page with more details on the why/what of the warning. However, the actual link (https://fb.me/react-async-component-lifecycle-hooks) uses the phrase "lifecycle-hooks" which is confusing since it doesn't have anything to do with hooks. This PR changes the link to something less confusing - https://fb.me/react-unsafe-component-lifecycles.
2019-08-09 12:18:39 +01:00
Brian Vaughn
8d54038773 Add use-subscription to Rollup bundle config (#16326) 2019-08-08 18:52:08 -07:00
lunaruan
b12a982062 Babel 7 (#16297)
Upgraded from Babel 6 to Babel 7.

The only significant change seems to be the way `@babel/plugin-transform-classes` handles classes differently from `babel-plugin-transform-es2015-classes`. In regular mode, the former injects a `_createClass` function that increases the bundle size, and in the latter it removes the safeguard checks. However, this is okay because we don't all classes in new features, and we want to deprecate class usage in the future in the react repo.

Co-authored-by: Luna Ruan <luna@fb.com>
Co-authored-by: Abdul Rauf <abdulraufmujahid@gmail.com>
Co-authored-by: Maksim Markelov <maks-markel@mail.ru>
2019-08-08 17:46:35 -07:00
Andrew Clark
d77c6232d3 [Scheduler] Store Tasks on a Min Binary Heap (#16245)
* [Scheduler] Store Tasks on a Min Binary Heap

Switches Scheduler's priority queue implementation (for both tasks and
timers) to an array-based min binary heap.

This replaces the naive linked-list implementation that was left over
from the queue we once used to schedule React roots. A list was arguably
fine when it was only used for roots, since the total number of roots is
usually small, and is only 1 in the common case of a single-page app.

Since Scheduler is now used for many types of JavaScript tasks (e.g.
including timers), the total number of tasks can be much larger.

Binary heaps are the standard way to implement priority queues.
Insertion is O(1) in the average case (append to the end) and O(log n)
in the worst. Deletion is O(log n). Peek is O(1).

* Sophie nits
2019-08-08 16:18:05 -07:00
Andrew Clark
95767acf83 Bump deps in packages/**/package.json (#16325) 2019-08-08 14:50:11 -07:00
Brian Vaughn
6536973a00 Prepare use-subscription v1 for publishing (#16324) 2019-08-08 14:45:48 -07:00
Andrew Clark
85d05b3a4d Bump package.json versions 2019-08-08 14:24:39 -07:00
Dan Abramov
96cdf33ad3 Changelog for 16.9 (#16254)
* Changelog for 16.9 (TODO: add date)

* Update CHANGELOG.md

* Add date
2019-08-08 14:12:59 -07:00
Dominic Gannaway
d9fdec6cfe [Flare] Remove contextmenu logic from Press (#16322) 2019-08-08 21:42:01 +01:00
Dan Abramov
12be8938a5 [Fresh] Support multiple renderers at the same time (#16302) 2019-08-08 19:03:38 +01:00
Sebastian Markbåge
6f3c8332d8 Reset hydration state after reentering (#16306)
We might reenter a hydration state, when attempting to hydrate a boundary.
We need to ensure that we reset it to not hydrating once we exit it.
Otherwise the next sibling will still be in hydration mode.
2019-08-07 14:56:12 -07:00
Dominic Gannaway
028c07f89c Ensure Fundamental flags are added to more locations (#16311) 2019-08-07 14:48:30 +01:00
Dan Abramov
9dfe973b52 Nit: fix inconsistent spacing in a warning (#16310) 2019-08-07 14:30:21 +01:00
lunaruan
c4f0b93703 Warn when Using String Refs (#16217) 2019-08-07 00:10:19 -07:00
Dominic Gannaway
7c838a6450 [Flare] Adds support for hydrating host components with listeners (#16304) 2019-08-06 23:05:16 +01:00
Brian Vaughn
2eb3f4e9b8 README typofix 2019-08-06 10:45:16 -07:00
Brian Vaughn
2015a39c2e 4.0.0-alpha.7 -> 4.0.0-alpha.8 2019-08-06 10:22:12 -07:00
Nicolas Gallagher
ed49700796 [react-events] Separate the Focus/FocusWithin unit tests (#16298) 2019-08-06 09:16:21 -07:00
Nicolas Gallagher
23405c9c4c [react-events] Add ContextMenu responder (#16296)
A module for responding to contextmenu events. This functionality will be
removed from the Press responder in the future.
2019-08-06 09:16:05 -07:00
Brian Vaughn
e015e3d937 Added not about sync/batched root API being required 2019-08-06 08:57:34 -07:00
Brian Vaughn
2349f04478 Handle case where :root styles aren't (yet) applied when SettingsContext mounts
This fixes a possible bug in the inline shell where line-heights are NaN so the Tree (react-window List) gets created with a itemSize of NaN
2019-08-06 08:46:42 -07:00
Sebastian Markbåge
606f76b6e4 Fix hydration bug with nested suspense boundaries (#16288)
This happens in this case: `<!--$!--><!--$!-->...<!--/$--><!--/$-->...`

getNextHydratableInstanceAfterSuspenseInstance didn't take
SUSPENSE_FALLBACK_START_DATA or SUSPENSE_PENDING_START_DATA into account
so if a boundary was in one of those states, it wouldn't be considered to
push the stack of boundaries. As a result the first end comment was
considered the end but it really should've been the second end comment.

The next comment then would've been considered something that can be
skipped. However, since the logic in there considered all comments as
"hydratable", it was considered a hydratable node. Since it was considered
a node that didn't actually correspond to anything in the React tree it got
deleted.

The HTML is now `<!--$!--><!--$!-->...<!--/$-->...` and the trailing
content is now hydrated since it did match something.

Next, since this was client rendered, we're going to delete the suspended
boundary by calling clearSuspenseBoundary and then inserting new content.
However, clearSuspenseBoundary *is* aware of SUSPENSE_FALLBACK_START_DATA
and assumes that there must be another `<!--/$-->` after the first one.
As a result it deleted the trailing content from the DOM since it should
be part of the boundary. However, those DOM nodes were already hydrated in
the React tree. So we end up in an inconsistent state.

When we then try to insert the new content we throw as a result.

I think we would have recovered correctly if clearSuspenseBoundary and
getNextHydratableInstanceAfterSuspenseInstance had the *same* bug but
because they were inconsistent we ended up in a bad place.
2019-08-05 16:36:13 -07:00
Brian Vaughn
baac1dcc52 Inline package tweaks:
* Ignore messages from the DevTools browser extension.
* Cleanup/clarify README
2019-08-05 14:00:18 -07:00
Sunil Pai
a1dbb852c2 warn if you try to use act() in prod (#16282)
We have behaviour divergence for act() between prod and dev (specifically, act() + concurrent mode does not flush fallbacks in prod. This doesn't affect anyone in OSS yet)

We also don't have a good story for writing tests in prod (and what from what I gather, nobody really writes tests in prod mode).

We could have wiped out act() in prod builds, except that _we_ ourselves use act() for our tests when we run them in prod mode.

This PR is a compromise to all of this. We will log a warning if you try to use act() in prod mode, and we silence it in our test suites.
2019-08-05 13:01:05 -07:00
Ashwin Ramaswami
dc232e6774 chore: remove outdated comment about gcc (#16232) 2019-08-05 18:18:40 +01:00
Brian Vaughn
dc8580e64d New NPM package react-devtools-inline (#363) 2019-08-05 10:09:26 -07:00
Sam Horton
6f1e283b76 feat: match HOC display names during search (#360)
* feat: match HOC display names during search

* chore: update tests for new search logic
2019-08-05 09:44:48 -07:00
Brian Vaughn
6b3ae64598 Suppress known/expected warnings and errors in local DEV shell 2019-08-04 14:33:38 -07:00
Brian Vaughn
db8542ad97 Refactor inspect/select logic so that $r contains hooks data (#364)
* Refactor inspect/select logic so that  var contains hooks data
* Legacy renderer resets $r to null when inspecting non class/function element
2019-08-03 17:59:35 -07:00
Andrew Clark
6b565ce736 Rendering tasks should not jump the queue (#16284)
When React schedules a rendering task, it passes a `timeout` option
based on its expiration time. This is intended to avoid starvation
by other React updates. However, it also affects the relative priority
of React tasks and other Scheduler tasks at the same level, like
data processing.

This adds a feature flag to disable passing a `timeout` option to
Scheduler. React tasks will always append themselves to the end of
the queue, without jumping ahead of already scheduled tasks.

This does not affect the order in which React updates within a single
root are processed, but it could affect updates across multiple roots.

This also doesn't remove the expiration from Scheduler. It only means
that React tasks are not given special treatment.
2019-08-02 17:52:32 -07:00
lunaruan
c4c9f086eb BugFix: Suspense priority warning firing when not supposed to (#16256)
Previously, the suspense priority warning was fired even if the Root wasn't suspended. Changed the warning to fire only when the root is suspended.

Also refactored the suspense priority warning so it's easier to read.
2019-08-02 13:54:11 -07:00
Dominic Gannaway
644c9c4e1c [Flare] useListener -> useResponder (#362) 2019-08-02 10:14:25 -07:00
Brian Vaughn
9727f4e88f Don't let a DevTools or React internal error interfere with logging. 2019-08-02 09:39:39 -07:00
Brian Vaughn
abbaedd264 Updated Flow type for DevTools tab id 2019-08-02 09:27:13 -07:00
Andrew Clark
05dce7598a Fix priority of clean-up function on deletion (#16277)
The clean-up function of a passive effect (`useEffect`) usually fires
in a post-commit task, after the browser has painted. However, there is
an exception when the component (or its parent) is deleted from the
tree. In that case, we fire the clean-up function during the
synchronous commit phase, the same phase we use for layout effects.

This is a concession to implementation complexity. Calling it in the
passive effect phase would require either traversing the children of the
deleted fiber again, or including unmount effects as part of the fiber
effect list.

Because the functions are called during the sync phase in this case,
the Scheduler priority is Immediate (the one used for layout) instead
of Normal. We may want to reconsider this trade off later.
2019-08-01 22:17:59 -07:00
Sebastian Markbåge
a53f5cc22e [SuspenseList] Bug fix: Reset renderState when bailing out (#16278)
If there are adjacent updates we bail out of rendering the suspense list
at all but we may still complete the node. We need to reset the render
state in that case.

I restructured so that this is in the same code path so we don't forget it
in the future.
2019-08-01 22:02:28 -07:00
Dan Abramov
0c1ec049f8 Add a feature flag to disable legacy context (#16269)
* Add a feature flag to disable legacy context

* Address review

- invariant -> warning
- Make this.context and context argument actually undefined

* Increase test coverage for lifecycles

* Also disable it on the server is flag is on

* Make this.context {} when disabled, but function context is undefined

* Move checks inside
2019-08-02 01:21:32 +01:00
Sebastian Markbåge
95674af2ef Add test of scheduler overhead (#16260) 2019-08-01 17:13:39 -07:00
Dominic Gannaway
42794557ca [Flare] Tweaks to Flare system design and API (#16264) 2019-08-01 19:08:54 +01:00
Brian Vaughn
62e5fd57a1 NPM package versions 4.0.0-alpha.5 -> 4.0.0-alpha.6 2019-08-01 08:26:32 -07:00
Brian Vaughn
51a15e0e4d Added CHANGELOG entries for HOC badges and no in-line props 2019-08-01 07:56:10 -07:00
Brian Vaughn
aed31fdf12 Element keys are selectable text
Changed truncation to be CSS-driven, and enabled double-click selection of text, so that long keys could be copied from within the tree.
2019-07-31 14:48:39 -07:00
Brian Vaughn
11e7b1d290 Updated OVERVIEW doc 2019-07-31 14:22:43 -07:00
Brian Vaughn
e4ccafc099 Updated CHANGELOG based on Dan's feedback 2019-07-31 14:08:44 -07:00
Brian Vaughn
52b0c20a62 Added dynamic indentation to change log 2019-07-31 13:44:32 -07:00
Brian Vaughn
271aa75cf2 Removed the Profiler screenshot capture feature
This wasn't reliable because of browser extension API limitations and required serious throttling to avoid harming performance, so I've decided to just remove it entirely for now.
2019-07-31 11:36:01 -07:00
Brian Vaughn
4f8b7864ee Add "Welcome to the new DevTools" notification
This dialog is shown in the browser extension the first time a user views v4. It is off by default for the standalone extension, but can be enabled via a public API.
2019-07-31 11:22:51 -07:00
Brian Vaughn
c57d2a2901 Added CHANGELOG 2019-07-31 10:50:56 -07:00
Dominic Gannaway
b5af4fe3c6 Remove FocusScope (#16267) 2019-07-31 17:40:11 +01:00
Andrew Clark
3756167885 Add missing check to unmocked Scheduler warning (#16261)
The unmocked Scheduler warning doesn't actually check if Scheduler
is mocked.
2019-07-30 20:11:11 -07:00
Andrew Clark
f939df402c [act] Wrap IsThisRendererActing in DEV check (#16259)
* [act] Wrap IsThisRendererActing in DEV check

So that it doesn't leak into the production bundle. Follow-up to #16240.

* Disable Suspense fallback test in prod
2019-07-30 17:39:42 -07:00
Andrew Clark
f440bfd559 Bugfix: Effects should never have higher than normal priority (#16257)
* Bugfix: Priority when effects are flushed early

The priority of passive effects is supposed to be the same as the
priority of the render. This fixes a bug where the priority is sometimes
wrong if the effects are flushed early.

But the priority should really never be higher than Normal Priority.
I'll change that in the next commit.

* Effects never have higher than normal priority

Effects currently have the same priority as the render that spawns them.
This changes the behavior so that effects always have normal priority,
or lower if the render priority is lower (e.g. offscreen prerendering).

The implementation is a bit awkward because of the way `renderRoot`,
`commitRoot`, and `flushPassiveEffects` are split. This is a known
factoring problem that I'm planning to address once 16.9 is released.
2019-07-30 15:46:36 -07:00
Sunil Pai
db3ae32b8f flush fallbacks in tests (#16240)
In this PR, for tests (specifically, code inside an `act()` scope), we immediately trigger work that would have otherwise required a timeout. This makes it simpler to tests loading/spinner states, and makes tests resilient to changes in React.

For some of our tests(specifically, ReactSuspenseWithNoopRenderer-test.internal), we _don't_ want fallbacks to immediately trigger, because we're testing intermediate states and such. Added a feature flag `flushSuspenseFallbacksInTests` to disable this behaviour on a per case basis.
2019-07-30 19:12:06 +01:00
Sunil Pai
e6a0473c3c Warn when rendering tests in concurrent/batched mode without a mocked scheduler (#16207)
Concurrent/Batched mode tests should always be run with a mocked scheduler (v17 or not). This PR adds a warning for the same. I'll put up a separate PR to the docs with a page detailing how to mock the scheduler.
2019-07-30 19:00:18 +01:00
Nicolas Gallagher
e276a5e850 [Flare] Remove delay props from Hover (#16248)
Moving working with delays into user-space.
2019-07-30 09:29:43 -07:00
Nicolas Gallagher
1912b4a0f1 [Flare] Remove delay props from Press (#16247)
Moving working with delays into user-space.
2019-07-30 09:29:26 -07:00
Dominic Gannaway
55bc393f72 [Flare] Ensure we check for bad polyfill when creating responders (#16243) 2019-07-29 21:16:30 +01:00
Nicolas Gallagher
47656bf2a1 [Flare] Remove longpress from press responder (#16242)
Long press will move to a separate responder.
2019-07-29 13:12:12 -07:00
Dan Abramov
9914a19190 [Fresh] Transfer refs when remounting (#16241)
* Add a failing test for refs and remounting

* Transfer ref when remounting
2019-07-29 17:19:09 +01:00
Brian Vaughn
9a36e56d34 Added missing Flow header 2019-07-28 17:21:00 -07:00
Brian Vaughn
8e2134beee Re-add try/catch inside Agent's getIDForNode() 2019-07-28 08:42:21 -07:00
Philipp Spiess
82881ab261 Allow Inspecting Elements Within Iframes (#355)
This change adds support for element inspecting within `<iframe/>`s.

The iframes are kept in a Set so that we only append listeners once and
clean them up properly. I’ve run a few tests and it seems to behave as
expected.

The fixture includes a cross-origin iframe to make sure we do not error
in this case.
2019-07-28 08:40:02 -07:00
Brian Vaughn
50512a223b Reverted a Webpack config change that broke browser extension styles 2019-07-27 09:30:23 -07:00
Brian Vaughn
ca4aac5014 Tweaked recent search changes
1. Compare element indices rather than ids (since these don't necessarily correlate)
2. Restored previous behaior when new search text reduces the number of results past the currently-selected element.
2019-07-27 09:15:53 -07:00
Fanny
29a6bf2a7b Feature: tweak search behaviour (#353)
Merge PR #353 from @fanny

This change changes search beahvior to initially select the result nearest the currently selected element (rather than selecting the first result in the set).
2019-07-27 09:04:20 -07:00
Andrew Clark
75ab53b9e1 [scheduler] Yield many times per frame, no rAF (#16214)
Adds experimental flag to yield many times per frame using a message
event loop, instead of the current approach of guessing the next vsync
and yielding at the end of the frame.

This new approach forgoes a `requestAnimationFrame` entirely. It posts a
message event and performs a small amount of work (5ms) before yielding
to the browser, regardless of where it might be in the vsync cycle. At
the end of the event, if there's work left over, it posts another
message event.

This should keep the main thread responsive even for really high frame
rates. It also shouldn't matter if the hardware frame rate changes after
page load (our current heuristic only detects if the frame rate
increases, not decreases).

The main risk is that yielding more often will exacerbate main thread
contention with other browser tasks.

Let's try it and see.
2019-07-26 15:43:57 -07:00
Dominic Gannaway
0d7141dd49 [Flare] Fix SSR issue with serializing responders prop (#16227) 2019-07-26 22:47:37 +01:00
Andrew Clark
ed57bf8ed4 [Bugfix] Check tag before calling hook effects (#16215)
* Add failing test for #16215

Next commit fixes it.

* [Bugfix] Check tag before calling hook effects

TODO: Test that triggers this
2019-07-26 14:28:49 -07:00
Brian Vaughn
3b2905b690 NPM package versions 4.0.0-alpha.4 -> 4.0.0-alpha.5 2019-07-26 10:13:52 -07:00
Brian Vaughn
7385de9fc2 react-devtools-core standalone bugfix: prevent electron crash
CSS source maps require the style-loader to use URL.createObjectURL (rather than just a <style> tag). For some reason, this crashes Electron's webview process, which completely breaks the embedded extension inside of Nuclide and other Electron apps. This commit turns (CSS) source maps off for production builds to avoid this crash.
2019-07-26 10:13:07 -07:00
Belmin Bedak
858c84206e Don't hyphenate custom CSS properties for ReactDOMServer (#16167)
* Do not hyphenate custom CSS property

* Move check into the processStyleName fn

* Formatting

* add test

* Put isCustomProperty check after conditional return

* add test to `ReactDOMServerIntegration` and supress warning

* Don't indexOf twice

* Simpler fix
2019-07-26 18:06:24 +01:00
Sunil Pai
d412eec839 [act] flush work correctly without a mocked scheduler (#16223)
Not returning the value of flushPassiveEffects() in flushWork() meant that with async act, we wouldn't flush all work with cascading effects. This PR fixes that oversight, and adds some tests to catch this in the future.
2019-07-26 17:48:42 +01:00
Sophie Alpert
b43785e151 Update use-subscription README (#16216)
It was a little confusing that the question asked when NOT to use this package, then the answer says when to use it. I think this is a little better.
2019-07-25 19:30:55 -07:00
Andrew Clark
c0830a0e63 [Scheduler] Test browser implementation details (#16198)
The Scheduler implementation uses browser APIs like `MessageChannel`,
`requestAnimationFrame`, and `setTimeout` to schedule work on the main
thread. Most of our tests treat these as implementation details;
however, the sequence and timing of these APIs are not precisely
specified, and can vary wildly across browsers.

To prevent regressions, we need the ability to simulate specific edge
cases that we may encounter in various browsers.

This adds a new test suite that mocks all browser methods used in our
implementation. It assumes as little as possible about the order and
timing of events. The only thing it assumes is that
requestAnimationFrame is passed a frame time that is equal to or less
than the time returned by performance.now. Everything else can be
controlled at will.

It also includes Scheduler-specific invariants, e.g. only one rAF
callback can be scheduled at a time.

It overlaps slightly with the existing SchedulerDOM-test suite, which
also mocks the browser APIs, but exposes a higher-level set of testing
primitives. I will consolidate the two suites in a follow-up.
2019-07-25 15:53:14 -07:00
lunaruan
857deb2ed5 Warn when Using DefaultProps on Function Components (#16210)
As part of the process to deprecate defaultProps on function components (as per a larger proposal outlined in (https://github.com/reactjs/rfcs/blob/createlement-rfc/text/0000-create-element-changes.md)), add a warning whenever someone does this.
2019-07-25 15:44:03 -07:00
Brian Vaughn
76c67399db Re-enabled packages backend build to be production mode (whoops) 2019-07-25 15:10:30 -07:00
Brian Vaughn
050cb8452d 4.0.0-alpha.3 -> 4.0.0-alpha.4 2019-07-25 10:26:52 -07:00
Dominic Gannaway
e0472709c8 [Flare] Adds Keyboard event responder (#16204) 2019-07-25 17:47:44 +01:00
Brian Vaughn
1e8aa8105a Re-enable "view source" button for standalone shell
But only do this if we can verify the element file path. This hopefully avoids the case where clicking the button does nothing because of an invalid/incomplete path.
2019-07-25 09:28:45 -07:00
Brian Vaughn
c6fb743910 Flow type cleanup 2019-07-25 09:13:45 -07:00
Dominic Gannaway
5b08f7b43f [Flare] Adds useListener implementation to ReactDebugHooks (#16205) 2019-07-25 16:55:39 +01:00
Dominic Gannaway
a7948e8342 [Flare] Remove the old EventComponent/EventTarget system (#354) 2019-07-25 08:45:59 -07:00
Dominic Gannaway
ed72f40257 [Flare] Remove references to EventComponent (#16206) 2019-07-25 16:41:26 +01:00
Brian Vaughn
270f34f7f0 Support new Flare hook, unstable_useListener 2019-07-25 08:21:41 -07:00
Sunil Pai
121bfb03bc update legacy context warning message (#16196)
The link in the legacy context message doesn't point to anything context related. This changes the link to point to https://fb.me/react-legacy-context, which points to https://reactjs.org/docs/context.html#legacy-api. Also adds a line that it'll probably be gone later.
2019-07-25 00:34:48 +01:00
Brian Vaughn
8d1c829019 Reverted style-prop hiding change because it caused a regression in the browser extension 2019-07-24 15:48:48 -07:00
Brian Vaughn
c7aff5503f 4.0.0-alpha.2 -> 4.0.0-alpha.3 2019-07-24 14:46:53 -07:00
Brian Vaughn
2e8b9fad36 Make style editor inputs more obvious resemble inputs 2019-07-24 14:43:29 -07:00
Brian Vaughn
9ae5e38f18 Add guard to ensure Profiler onRender prop is function before calling (#16197) 2019-07-24 14:20:56 -07:00
Brian Vaughn
4c610950a4 Hide "style" prop if we are showing the style editor
Also add react-native-web to test harness
2019-07-24 14:05:56 -07:00
Brian Vaughn
9a05e0b600 Disable view-source button in standalone mode if no project roots are provided 2019-07-24 13:36:51 -07:00
Brian Vaughn
722d366e9f Updated snapshot 2019-07-24 11:27:15 -07:00
Brian Vaughn
56b0017615 4.0.0-alpha.1 -> 4.0.0-alpha.2 2019-07-24 11:25:52 -07:00
Brian Vaughn
f74c89b145 Misc improvements based on user feedback from Tim
* Added shadow to modals
* Change default "collapse new nodes" to be disabled rather than enabled
* Changed setting label "Collapse newly added components by default" to "Expand component tree by default"
* Change CSS media query for settings popup to show labels at smaller size
* Hide "Inspect the matching DOM element" button (since it doesnt really serve a purpose in standalone)
* Fixed small size bug for settings icon (viewbox of 20x20 instead of 24x24)
* bugfix: window.addEventListener/window.removeEventListener is not defined in Hermes.
2019-07-24 11:25:11 -07:00
Brian Vaughn
13959aa8fb Removed accidental log statement 2019-07-24 11:13:30 -07:00
Benoit Girard
144dba1a11 Fix suspenseCallback type warning, add a test (#16194) 2019-07-24 18:32:00 +01:00
Dominic Gannaway
7ad221126f [Flare] Ensure Flare components are no-ops for TestRenderer (#16192) 2019-07-24 11:31:33 +01:00
lunaruan
06cc996994 Edit Suspense Priority Warning Message (#16186)
* move 'component that triggered the update' in suspense priority warning message to the beginning of the message

* renamed warnings
2019-07-23 19:08:41 -07:00
Benoit Girard
42b75ab007 Add suspenseCallback feature for runtime tracing of loading states (#16134)
This adds a 'SuspenseCallback' feature flag. When the property is set on
a suspense component it will be called during the commit phase with a
set of the immediate thenable for this component. This will allow user
code to build runtime tracing of the cause for a suspense boundary.
2019-07-23 17:13:46 -07:00
Sunil Pai
c73e1f236f flush work on exiting outermost act(), with nested act()s from different renderers (#16181)
Given this snippet:
```jsx
    TestRenderer.act(() => {
      TestUtils.act(() => {
        TestRenderer.create(<Effecty />);
      });
    });
```
We want to make sure that all work is only flushed on exiting the outermost act().

Now, naively doing this based on actingScopeDepth would work with a mocked scheduler, where flushAll() would flush all work across renderers.

This doesn't work without mocking the scheduler though; and where flushing work only works per renderer. So we disable this behaviour for a non-mocked scenario. This seems like an ok tradeoff.
2019-07-24 00:20:28 +01:00
Dominic Gannaway
5098891193 [Flare] Redesign core event system (#16163) 2019-07-23 23:46:44 +01:00
Andrew Clark
19354db511 [Scheduler] Add names to inline functions (#16180)
Noticed when looking at the performance profiler with Luna that it's
hard to tell which event causes `performWorkUntilDeadline` to fire
because these functions are anonymous.
2019-07-23 11:08:24 -07:00
Andrew Clark
bff7abf6ba [Scheduler][Bugfix] Multiple rAFs in same frame (#16184)
Always sets `isRAFLoopRunning` back to false when an animation frame is
scheduled. Fixes a bug where two rAFs fire in the same frame, but the
second one exits and fails to schedule a new rAF.

Fixes bug observed in Safari.
2019-07-23 10:44:27 -07:00
Brian Vaughn
afb5991686 Enable profiler+tracing for test renderer (#16178)
This commit just brings the feature flags to parity with other renderers.
2019-07-23 08:20:12 -07:00
Dan Abramov
2237efcef9 [Fresh] Track unrecoverable errors (#16183)
* [Fresh] Track unrecoverable errors

* Only initial errors set the flag
2019-07-23 16:11:13 +01:00
Brian Vaughn
1178d57257 Fixed a module resolution issue and a syntax error from a bad merge 2019-07-23 07:46:19 -07:00
Nicolas Gallagher
bbd21066e6 [Flare] Press: fix keyboard interactions (#16179)
Prevents Spacebar from scrolling the window.
Prevents Enter from triggering a navigation if preventDefault is true.
Fixes the emulated mouse events test.
2019-07-22 18:16:40 -07:00
lunaruan
03944bfb0b Update Suspense Priority Warning to Include Component that Triggered Update (#16030)
Improved warning whenever lower priority events (ex. data fetching, page load) happen during a high priority update (ex. hover/click events) to include:
1.) Name of component that triggered the high priority update or
2.) Information that the update was triggered on the root
2019-07-22 14:17:43 -07:00
Andrew Clark
3f2cafe8be [WIP][Scheduler] Use rIC to post first callback (#16166)
Scheduler uses `requestAnimationFrame` to post tasks to the browser.
If this happens at the beginning of a frame, the callback might not
fire until the subsequent frame, even if the main thread is idle.

Our theory was that this wouldn't be an issue in practice, because once
the first rAF fires, we schedule the next rAF as early as possible in
that frame. Combined with our heuristic for computing frame deadlines,
we shouldn't get any idle time in between frames — only before the
*first* frame.

This reasoning holds true when you have a small number of large tasks,
such as the ones posted by React. The idle time before the task starts
is negligible relative to the lifetime of the entire task.

However, it does not hold if you have many small tasks posted over a
span of time, perhaps spawned by a flurry of IO events. In this case,
instead of single, contiguous rAF loop preceded by an idle frame, you
get many rAF loops preceded by many idle frames. Our new theory is that
this is contributing to poor main thread utilization during page loads.

To try to reclaim as much idle time as possible, this PR adds two
experimental flags. The first one adds a `requestIdleCallback` call to
start the rAF loop, which will fire before rAF if there's idle time left
in the frame. (We still call rAF in case there isn't. We start working
in whichever event fires first.)

The second flag tries a similar strategy using `setTimeout(fn, 0)`. If
the timer fires before rAF, we'll assume that the main thread is idle.

If either `requestIdleCallback` or `setTimeout` fires before rAF, we'll
immediately peform some work. Since we don't have a real frame time that
we can use to compute the frame deadline, we'll do an entire frame
length of work. This will probably push us past the vsync, but this is
fine because we can catch up during the next frame, by which point a
real rAF will have fired and the loop can proceed the same way it
does today.

Test plan: Try this on Facebook to see if it improves load times
2019-07-22 13:12:33 -07:00
Andrew Clark
2bd88e38aa [Scheduler] Bugfix: Cancelling a continuation (#16151)
Cancelling the original task should also cancel its continuation.
2019-07-22 13:10:33 -07:00
Brian Vaughn
ffb19346c7 NPM packages 4.0.0-alpha.0 -> 4.0.0-alpha.1 2019-07-22 11:19:53 -07:00
Dominic Gannaway
783b8f4ae1 [Flare] Ensure mouse events can use target to validate press (#16172) 2019-07-22 12:31:19 +01:00
Brian Vaughn
4b34a77d29 Improve Bridge Flow types (#352)
* Updated local fork of react-window
* Updated Fow 97 -> 103
* Lint ignore NPM dist
* Improved Bridge Flow types
2019-07-20 14:08:23 -07:00
Brian Vaughn
39ad101ea2 Removed reference to setDefaultThemeName() method
This functionality was added to v3 to support external changing of theme at runtime. This isn't supported in v4.
2019-07-20 09:28:09 -07:00
Brian Vaughn
33da657178 Make console override detectable (for RN YellowBox) 2019-07-20 08:05:08 -07:00
Dominic Gannaway
2c4d61e102 Adds experimental fundamental interface (#16049) 2019-07-19 22:20:28 +01:00
Brian Vaughn
167daf7a4a Updating NPM packages as 4.0.0-alpha.0 2019-07-19 10:09:49 -07:00
Brian Vaughn
abe75b0e39 Slight tweak to avoid setting an invalid numeric value in props editor 2019-07-19 09:19:03 -07:00
Brian Vaughn
f0a4b2f8e8 Merge branch 'fix-input-number-in-props' of https://github.com/koba04/react-devtools-experimental into koba04-fix-input-number-in-props 2019-07-19 09:16:26 -07:00
Brian Vaughn
0abaefb7c2 Cleanup legacy backend event listener if modern backend is detected 2019-07-19 09:02:30 -07:00
Brian Vaughn
dbbf30a332 Make my code PRETTIER 2019-07-18 16:37:57 -07:00
Brian Vaughn
67e749a73a Tweaked modal font size style 2019-07-18 16:28:20 -07:00
Brian Vaughn
bd0a0c58fd Tweaked modal title to better fit without wrapping 2019-07-18 16:26:27 -07:00
Brian Vaughn
249a2e043d Detect React Native v3 backend and show warning 2019-07-18 16:24:22 -07:00
Paul Shen
b4178af81b clean up nextEffect pointers (#16115) 2019-07-17 17:21:19 -07:00
Nicolas Gallagher
997154bcc7 [Flare] Add FocusWithin responder (#16152)
FocusWithin is implemented as a separate responder, which keeps both focus
responders simple and allows for easier composition of behaviours.
2019-07-17 15:17:13 -07:00
Brian Vaughn
9fb753b5cd Hardened logic around when and how to patch console methods 2019-07-17 15:08:34 -07:00
Dominic Gannaway
65b80fdd94 [Flare] Add Input event responder surface (#16148) 2019-07-17 21:04:41 +01:00
Brian Vaughn
cb3fb42129 Patch console to append component stacks (#348)
* Patch console.warn and console.error to auto-append owners-only component stacks.

This setting is enabled by default and will work for React Native even if no front-end DevTools shell is being used. The setting can be disabled via a new, persisted user preference though.
2019-07-17 11:12:39 -07:00
Brian Vaughn
ce883a19d8 useSubscription hook (#15022)
* Added use-subscription package with README
2019-07-16 15:59:37 -07:00
Moti Zilberman
c45c2c3a26 Move ReactFiberErrorDialog RN fork into RN itself (#16141) 2019-07-16 09:38:14 +01:00
Sunil Pai
d9b4c55d53 unify deprecated/unsafe lifecycle warnings, pass tests (#16103)
- redoes #15431 from scratch, taking on the feedback there
- unifies the messaging between "deprecated" and UNSAFE_ lifecycle messages. It reorganizes ReactStrictModeWarnings.js to capture and flush all the lifecycle warnings in one procedure each.
- matches the warning from ReactPartialRenderer to match the above change
- passes all the tests
- this also turns on `warnAboutDeprecatedLifecycles` for the test renderer. I think we missed doing so it previously. In a future PR, I'll remove the feature flag altogether.
- this DOES NOT do the same treatment for context warnings, I'll do that in another PR too
2019-07-15 20:56:44 +01:00
Brian Vaughn
424099da60 Inject getCurrentFiber() function to DevTools (#16133)
This returns the current value of ReactCurrentFiber and enables DevTools to append a custom (owner-only) component stack to warnings and errors in DEV mode.
2019-07-15 07:38:44 -07:00
Toru Kobayashi
41c00cb0cb fix to input a number value to props 2019-07-14 23:11:08 +09:00
Brian Vaughn
0f2fb5badf Standalone NPM packages and React Native support (#335)
* Add version 4 react-devtools and react-devtools-core packages which support both React Native and e.g. Safari or iframe DOM usage.
* Replaces typed operations arrays with regular arrays in order to support Hermes. This is unfortunate, since in theory a typed array buffer could be more efficiently transferred between frontend and backend for the web extension, but this never actually worked properly in v8, only Spidermonkey, and it fails entirely in Hermes so for the time being- it's been removed.
* Adds support for React Native (paper renderer)
* Adds a style editor for react-native and react-native-web
2019-07-13 10:05:04 -07:00
Brian Vaughn
9f395904c6 Inject ReactDebugCurrentFrame into DevTools so it can append component stacks to warnings in DEV mode (#16127) 2019-07-13 08:53:21 -07:00
Sebastian Markbåge
fcff9c57bc Add tail="hidden" option to SuspenseList (#16024)
* Move misaligned comment

* Add tail="hidden" option

* isShowingAnyFallbacks -> findFirstSuspended

* We can't reset Placement tags or we'll forget to insert them

* Delete hasSuspendedChildrenAndNewContent optimization
2019-07-12 15:55:47 -07:00
Brian Vaughn
8d413bf2c3 Remove React.error and React.warn (#16126)
* Remove React.error/React.warn with React.getComponentStack
2019-07-12 15:41:47 -07:00
Andrew Clark
29b4559635 .watchmanconfig must be valid json (#16118)
faceworldproblems?
2019-07-11 19:01:02 -07:00
Nicolas Gallagher
ca4d78f9b6 [Flare] Press: fix middle-click handling (#16114)
Make sure the root events are removed after middle-click completes
2019-07-11 22:12:10 +01:00
Sunil Pai
3f1dee09a4 expose act() sigil correctly for umd builds (#16110)
after https://github.com/facebook/react/pull/16039, act was broken for umd builds. This PR fixes it.
2019-07-11 14:56:03 +01:00
Sebastian Markbåge
b7669044d9 Use Map instead of object as map in ReactNativeComponentTree (#16107)
Real Maps should now be used in RN JS engines. In theory this should
be faster (but might not actually be in practice), and it avoids hitting
upper bounds of property max counts.

We don't use these types of Maps in Fabric.
2019-07-10 19:11:36 -07:00
Andrew Clark
d2d9b1f701 [Scheduler] Support inferring priority from stack (#16105)
When executing a task, wraps the callback in an extra function whose
name includes the current priority level. Profiling tools with access
to function names can use this to determine the priority of the task.
2019-07-10 18:59:44 -07:00
Sebastian Markbåge
48f6594474 Add warning when single item or nested arrays are used with SuspenseList (#16094) 2019-07-10 11:07:28 -07:00
Nicolas Gallagher
2073a7144e [Flare] Press includes button type (#16100)
1. Allow auxillary button clicks (i.e., middle mouse button) to trigger 'onPressStart' and 'onPressEnd', but never 'onPress'.
2. Report the button type – 'primary' or 'auxillary' – on the press event.
2019-07-10 17:52:10 +01:00
Dominic Gannaway
23b8a25345 [Flare] Remove responder flags to simplify logic (#16084) 2019-07-09 15:05:45 +01:00
Eli White
8533c0a168 [Fabric] Add dispatchCommand to React Native renderers (#16085)
* Add dispatchCommand to the public export of the React Native renderers

* Fixup invalid check

* Prettier

* Prettier
2019-07-08 13:03:57 -07:00
Dominic Gannaway
2253bc81d0 [Flare] Switch from currentTarget model to responderTarget model (#16082) 2019-07-08 17:03:15 +01:00
Dominic Gannaway
67e3f3fb6e [Flare] Revise responder event types (#16081) 2019-07-08 14:35:59 +01:00
Min ho Kim
2a0f6390ed Fix typos (#16076) 2019-07-08 11:51:29 +01:00
Dominic Gannaway
aa519c17cc [Flare] Add currentTarget and unify RN and DOM codepaths (#16066) 2019-07-08 11:50:21 +01:00
Brian Vaughn
39a811debe Merge pull request #342 from marvinhagemeister/attach_configure
Fix reload-and-profile attach not configurable
2019-07-06 18:40:00 -04:00
fnll
35d2b3bb5e fix spelling error: resoltion -> resolution (#16055) 2019-07-05 16:08:13 +01:00
Vincent Riemer
bd72b04939 [Flare] Clear pressStart timeout on pointercancel (#16067) 2019-07-05 11:45:33 +01:00
Dominic Gannaway
c40075a72c [Flare] Remove capture phase Flare events (#16054) 2019-07-04 21:30:46 +01:00
Dominic Gannaway
786186c692 [Flare] createInitialState -> getInitialState (#16051) 2019-07-04 18:06:18 +01:00
Dominic Gannaway
c64f40d718 [Flare] Remove dead event target code (#16063) 2019-07-04 13:10:55 +01:00
Dominic Gannaway
e6bfa327da [Flare] Cleanup ReactFiberEvents-test (#16047) 2019-07-03 11:31:06 +01:00
Dominic Gannaway
b365ee2816 [Fire] Remove unused React fire fork (#16046) 2019-07-03 11:05:28 +01:00
Sunil Pai
b8f91e6649 [fail] reset IsThisRendererActing correctly (#16042)
* [fail] reset IsThisRendererActing correctly

I missed this in https://github.com/facebook/react/pull/16039. I'd pointed at the wrong previous state, corrupting it in further use. This PR fixes that, and adds a test to make sure it doesn't happen again.

* warn for unacted effects only in strict mode
2019-07-03 03:04:22 +01:00
Sunil Pai
bd846459d6 [fail] Only warn on unacted effects for strict / non sync modes (#16041)
* only warn on unacted effects for strict / non sync modes

(basically, when `fiber.mode !== 0b0000`)

Warnings on unacted effects may be too noisy, especially for legacy apps. This PR fires the warning only when in a non sync mode (concurrent/batched), or when in strict mode. This should make updating easier.

I also added batched mode tests to the act() suite.

* explicitly check for modes before warning, explicit tests for all modes
2019-07-03 01:29:45 +01:00
Dominic Gannaway
6b946ad9da [Flare] Add more functionality to Scroll event resonder (#16036) 2019-07-02 23:51:31 +01:00
Sunil Pai
a457e02ae3 allow nested act()s from different renderers (#16039)
* allow nested `act()`s from different renderers

There are usecases where multiple renderers need to oprate inside an act() scope
- ReactDOM.render being used inside another component tree. The parent component will be rendered using ReactTestRenderer.create for a snapshot test or something.
- a ReactDOM instance interacting with a ReactTestRenderer instance (like for the new devtools)

This PR changes the way the acting sigils operate to allow for this. It keeps 2 booleans, one attached to React, one attached to the renderer. act() changes these values, and the workloop reads them to decide what warning to trigger.

I also renamed shouldWarnUnactedUpdates to warnsIfNotActing

* s/ReactIsActing/IsSomeRendererActing and s/ReactRendererIsActing/IsThisRendererActing
2019-07-02 22:20:17 +01:00
Anton Korzunov
a865e4a642 Clone a custom hook node before use (#16019) 2019-07-02 17:54:10 +01:00
Dominic Gannaway
6cf2234a57 [Flare] Do not block mouse presses on scroll (#16033) 2019-07-02 16:58:46 +01:00
Sebastian Markbåge
5cb8f6f344 Add tail="collapsed" option to SuspenseList (#16007)
* Add tail="collapsed" option

* Fix issue with tail exceeding the CPU time limit

We used to assume that this didn't suspend but this branch happens in
both cases. This fixes it so that we first check if we suspended.

Now we can fix the tail so that it always render an additional fallback
in this scenario.
2019-07-01 19:56:34 -07:00
lunaruan
46bd11ac3e Flush sync bug (#16027)
* added flush sync test

* added code to run flushSync with ImmediatePriority

* added code to run flushSync with ImmediatePriority

* fixed flow error

* fixed flow error
2019-07-01 16:58:04 -07:00
Marvin Hagemeister
8e90194f7d Add comment about 3rd party integrations 2019-07-01 23:48:52 +02:00
Marvin Hagemeister
5ec387aa82 Mark reload-and-profile attach as configurable 2019-07-01 23:35:35 +02:00
Sebastian Markbåge
933c664ad6 SuspenseList Optimizations (#16005)
* Add a bunch of optimizations to SuspenseList

We now are able to bail out of reconciliation and splitting out the tail
during deep updates that hasn't changed the child props. This only
works while the list wasn't suspended before.

I also moved the second render of the "head" to the complete phase. This
cleans it up a bit for the tail collapsing PR.

For this second pass I also use a new technique of resetting the child
Fibers for the second pass. This is effectively a fast path to avoid
reconciling the children against props again.

* Move to didSuspend from SuspenseListState to the effectTag

The effectTag now tracks whether the previous commit was suspended.

This frees up SuspenseListState to be render-phase only state.

We use null to mean the default "independent" mode.

* Rename to SuspenseListState to SuspenseListRenderState

* Reuse SuspenseListRenderState across render passes

* Add optimization to bail out of scanning children if they can't be suspended

This optimized the deep update case or initial render without anything
suspending.

We have some information available to us that tell us if nothing has
suspended in the past and nothing has suspended this render pass.

This also fixes a bug where we didn't tag the previous render as having
suspended boundaries if we didn't need to force a rerender.

* rm printChildren

oops
2019-07-01 14:25:07 -07:00
Heaven
fbbbea16e1 fix word async -> concurrent (#15844) 2019-07-01 17:32:29 +01:00
Dominic Gannaway
eb2ace1281 [Flare] Bring Flare support to React Native Fabric (#15887) 2019-06-28 01:22:32 +01:00
Dominic Gannaway
9b0bd43550 [Flare] Re-label Flare flag (#16014) 2019-06-28 01:11:11 +01:00
Dominic Gannaway
8b88ac2592 [Flare] Remove event targets including TouchHitTarget (#16011) 2019-06-27 23:58:48 +01:00
Dan Abramov
f11540926d Handle changes at module boundaries (#16002) 2019-06-27 20:53:03 +01:00
Benedikt Meurer
915dfe6977 Slightly improve performance of hydration. (#15998)
* Slightly improve performance of hydration.

Avoid loading nodeType and data couple times from the same node in a row,
but instead load them only once, which will help engines to run this code
faster, especially during startup of the application. The general approach
is still not ideal, since hydrating this way forces the browser engine
to materialize JavaScript wrapper objects for all DOM nodes, even if they
are not interesting to hydration itself.

* Fix condition for COMMENT_NODEs.

* Improve general code readability
2019-06-27 07:23:14 -07:00
Dominic Gannaway
824e9bec7a [Flare] Fix issues with touch + pointer interactions (#15997) 2019-06-26 22:25:49 +01:00
Dominic Gannaway
dd93357aa0 [Flare] Move click handling back into target phase (#15993) 2019-06-26 20:44:44 +01:00
Andrew Clark
4d307de458 Prefix mock Scheduler APIs with _unstable (#15999)
For now this is only meant to be consumed via `act`.
2019-06-26 12:16:08 -07:00
Brandon Dail
9b55bcfc6b [Flare] Add Hooks to event modules (#15953) 2019-06-26 08:47:21 +01:00
Ricky
20da1dae4b Fix error logging in getDerivedStateFromProps (#15797)
* Fix error logging in getDerivedStateFromProps

* Update tests, don't log for both error boundary methods

* Re-add change lost in rebase
2019-06-25 18:02:27 +01:00
Dominic Gannaway
6088a201e1 [Flare] Fix Press scroll cancellation handling (#15983) 2019-06-25 14:31:48 +01:00
Dominic Gannaway
fd601fb219 [Flare] Move all event responders to dom directory (#15981) 2019-06-25 09:32:20 +01:00
Veniamin Krol
827cbc4d00 Rename StatelessComponent to FunctionComponent in react-is/README.md (#15963) 2019-06-24 16:21:58 -07:00
Dan Abramov
d48db594ec eslint-plugin-react-hooks@1.6.1 2019-06-24 22:31:14 +01:00
Thomas Broyer
7439b48cf4 Add explicit support for ESLint 6.0.0 (#15974)
Preemptively update tests wrt 'parser' requiring an absolute
path rather than a package name, even though the project is
still using ESLint 4.

Fixes #15971
2019-06-24 22:30:12 +01:00
Sunil Pai
fce15f14d3 don't fire missing act() warnings for react-art (#15975)
* use toWarnDev for dom fixture tests

forks toWarnDev from root into fixture/dom, updates tes tests to use it

* disable act() warnings for react-art()

- For 'secondary' renderers like react-act, we don't want to fire missing act() warnings; the wrapping renderer will fire warnings anyway, and when it flushes, it flushes effects *across* renderers.

- I could have used isPrimaryRenderer as the flag, but this is marked as false for react-test-renderer, and we *do* want the warning to fire for it. Hence a new flag.

* add missing dependency `art` to fixtures/dom
2019-06-24 19:18:26 +01:00
Dominic Gannaway
20f3546963 [Flare] Ensure Press event hook does not execute side-effects (#15976) 2019-06-24 18:31:49 +01:00
Dan Abramov
d420d2ccb6 [Fresh] Retry failed roots on refresh (#15966)
* Retry failed roots on refresh

* Don't prevent retry after error -> render(null) special case

The check wasn't very resilient because in Concurrent Mode it looks like we can get further follow-up commits even if we captured an error. So we can't reliably distinguish the case where after an error you _manually_ rendered null.

Retrying on an edit after a tree failed _and_ you rendered null in the same tree seems fine. It's also very unlikely a pattern like this actually exists in the wild.
2019-06-24 16:54:54 +01:00
Brian Vaughn
844cdb22d6 Merge pull request #331 from trueadm/flare_displayName
[Flare] Update event component displayName
2019-06-24 07:48:24 -07:00
Sunil Pai
04b77c6304 followup to #15763, fix failing test in ReactDOMTracing-test (#15972)
* followup to #15763, failing tests in ReactDOMTracing-test

It was me. I broke the build.

* [ignore] add a newline to trigger a build
2019-06-24 11:44:37 +01:00
Sunil Pai
e1c5e8720d warn if passive effects get queued outside of an act() call. (#15763)
* warn if passive effects get queued outside of an act() call

While the code itself isn't much (it adds the warning to mountEffect() and updateEffect() in ReactFiberHooks), it does change a lot of our tests. We follow a bad-ish pattern here, which is doing asserts inside act() scopes, but it makes sense for *us* because we're testing intermediate states, and we're manually flush/yield what we need in these tests.

This commit has one last failing test. Working on it.

* pass lint

* pass failing test, fixes another

- a test was failing in ReactDOMServerIntegrationHooks while testing an effect; the behaviour of yields was different from browser and server when wrapped with act(). further, because of how we initialized modules, act() around renders wasn't working corrrectly. solved by passing in ReactTestUtils in initModules, and checking on the finally yielded values in the specific test.
- in ReactUpdates, while testing an infinite recursion detection, the test needed to be wrapped in an act(), which would have caused the recusrsion error to throw. solived by rethrowing the error from inside the act().

* pass ReactDOMServerSuspense

* stray todo

* a better message, consistent with the state update one.
2019-06-24 11:18:24 +01:00
Dan Abramov
39b97e8eb8 Report refreshed families to the caller (#15957) 2019-06-22 23:57:54 +01:00
Dan Abramov
d271df5c99 Use function expression for custom Hook signature argument (#15956) 2019-06-22 11:54:22 +01:00
Andrew Clark
4189f712c1 [Scheduler] Increase max frame length to 300
Forgot to apply this change before merging.

https://github.com/facebook/react/pull/15959#discussion_r296429705
2019-06-22 01:38:19 -07:00
Andrew Clark
595c9414ba [Scheduler] Fix navigator.isInputPending call
Must be called as a method.
2019-06-22 00:50:13 -07:00
Andrew Clark
e7fcfe1047 [scheduler] Put isPendingInput behind a flag (#15962) 2019-06-22 00:46:27 -07:00
Andrew Clark
6568a79931 [Scheduler] requestPaint (#15960)
* [Scheduler] requestPaint

Signals to Scheduler that the browser needs to paint the screen. React
will call it in the commit phase. Scheduler will yield at the end of
the current frame, even if there is no pending input.

When `isInputPending` is not available, this has no effect, because we
yield at the end of every frame regardless.

React will call `requestPaint` in the commit phase as long as there's at
least one effect. We could choose not to call it if none of the effects
are DOM mutations, but this is so rare that it doesn't seem worthwhile
to bother checking.

* Fall back gracefully if requestPaint is missing
2019-06-22 00:15:09 -07:00
Andrew Clark
8d4ddd33ac [Scheduler] Yield less if there's no pending input (#15959)
At the end of each frame, Scheduler yields control of the main thread so
the browser can execute important tasks; most importantly, painting the
screen and responding to user input. There's some overhead involved in
regaining control of the main thread, so we'd like to yield as
infrequently as possible to keep the UI responsive.

The reason we yield on every frame is because there's no way for us to
know whether we're blocking user input.

`isInputPending` is an experimental browser API that gives us this
information. It tells us whether there's a pending user input, which
also means it tells us if there's *not* a pending user input. We can use
this signal to decide whether it's OK not to yield.

There's a max frame length after which we'll yield regardless, as a
precaution against blocking non-input tasks that we don't know about.
2019-06-22 00:05:38 -07:00
Sebastian Markbåge
d77d12510b Expire rendering the tail of SuspenseList after a timeout (#15946)
* Expire rendering the tail of SuspenseList after a timeout

This is the first Suspense feature that isn't actually dependent on IO.

The thinking here is that it's normal for a SuspenseList to show loading
states, and it'll be designed to handle it one at a time.

However, sometimes there are lists with really big items that take a long
time to CPU render. Since data can become available as we do that, it is
likely that we have all the data and become CPU bound.

In that case, the list would naively just render until the end and then
display all items at once. I think that's actually what you want for fast
lists. However, for slow ones (like News Feed), you're better off showing
a few rows at a time.

It's not necessarily one at a time because if you can do many in a short
period of time and fit them all on the screen, then it's better to do them
all at once than pop them in one at a time very quickly.

Therefore, I use a heuristic of trying to render as many rows as I can in
500ms before giving up.

This timer starts before the first row of the tail and we only check it
after. This ensures that we always make a little progress each attempt.
An alternative approach could be to start the time before doing the head
of the list but we don't want that being slow prevent us from making
further progress.

Currently, I disable this optimization at Never priority because there's
nothing intermediate that becomes visible anyway.

* Fix tracing through a SuspenseList

This ensures that we can spawn new work during render through arbitrary
priorities.

We'll need this for other features too.

Since each priority can commit separately we need to use an array to
include the current interactions on each priority.
2019-06-21 18:05:34 -07:00
Dominic Gannaway
dc298fdf91 [Flare] Refinements to useEvent hook (#15955) 2019-06-21 23:10:55 +01:00
Dominic Gannaway
696609d49a [Fiber] Clear down dependencies during detachFiber (#15947) 2019-06-21 19:54:04 +01:00
Dominic Gannaway
a5ed2f98f9 [Flare] Guard against stateNode being null (#15952) 2019-06-21 19:14:03 +01:00
Dominic Gannaway
34ce57ae75 [Flare] Refine flow type annotations (#15950) 2019-06-21 12:32:43 +01:00
Dominic Gannaway
4f92fbce5c [Flare] Move createEvent back to React object (#15943) 2019-06-21 10:12:56 +01:00
Andrew Clark
175111de72 Lazily initialize dependencies object (#15944)
Most fibers do not have events or context, so we save memory lazily
initializing this container node.

Follow-up from #15927
2019-06-20 20:12:22 -07:00
Dominic Gannaway
720db4cbe6 [Flare] Add useEvent hook implementation (#15927)
* [Flare] Add useEvent hook implementation

Validate hooks have decendent event components

Few fixes and displayName changes

Fix more responder bugs

Update error codes

* Add another test

* Address feedback
2019-06-20 19:12:40 -07:00
Nicolas Gallagher
6ff4c9de1c [Flare] Press: fix stale deactivation region state (#15931)
The responder region calculation logic wasn't updating the deactivation region
during the lifetime of an event instance, causing incorrect behaviour when the
current press ends outside the press target and if the press target has moved
since the last time the first-and-only time the deactivation region was
measured.
2019-06-20 17:10:54 -07:00
Dan Abramov
7a4c3e3b73 Make global names more obscure (#15941) 2019-06-20 20:20:09 +01:00
Sebastian Markbåge
270dc2e4de Add forwards and backwards options to SuspenseList (#15918)
* Add forwards option

* Add backwards option

* Add comment

* Add customized warning messages for case and typos

* Add some more tests for insertions and updates in start/middle/end
2019-06-20 11:03:47 -07:00
Dominic Gannaway
5368f7316c [Flare] Fix keyboard keyup regression (#15938) 2019-06-20 17:00:09 +01:00
Dan Abramov
3d0af2aea8 Don't consider require-like calls to be likely HOCs (#15940) 2019-06-20 16:13:18 +01:00
Dan Abramov
d4f384d25b [Fresh] Throw in prod and change annotation (#15939)
* Disable React Refresh Babel transform in prod

* Throw early if React Refresh runtime is imported in production

* @hot reset -> @refresh reset
2019-06-20 14:29:00 +01:00
Sunil Pai
ff91bfa58c [act] reset scope depth on synchronous errors (#15937)
* reset scope depth on synchronous errors

we weren't resetting the acting scope depth on sync errors thrown in the callback. this fixes that.

* typos

* add a test to make sure sync error propagate
2019-06-20 13:50:53 +01:00
Dominic Gannaway
e61c9e0a26 [Flare] Fix Press retention state regression (#15936) 2019-06-20 13:01:56 +01:00
Sebastian Markbåge
76864f7ff7 Add SuspenseList Component (#15902)
* Add SuspenseList component type

* Push SuspenseContext for SuspenseList

* Force Suspense boundaries into their fallback state

In the "together" mode, we do a second render pass that forces the
fallbacks to stay in place, if not all can unsuspend at once.

* Add test

* Transfer thennables to the SuspenseList

This way, we end up retrying the SuspenseList in case the nested boundary
that just suspended doesn't actually get mounted with this set of
thennables. This happens when the second pass renders the fallback
directly without first attempting to render the content.

* Add warning for unsupported displayOrder

* Add tests for nested sibling boundaries and nested lists

* Fix nested SuspenseList forwarding thennables

* Rename displayOrder to revealOrder

Display order has some "display list" connotations making it sound like
a z-index thing.

Reveal indicates that this isn't really about when something gets rendered
or is ready to be rendered. It's about when content that is already there
gets to be revealed.

* Add test for avoided boundaries

* Make SuspenseList a noop in legacy mode

* Use an explicit suspense list state object

This will be used for more things in the directional case.
2019-06-19 19:34:28 -07:00
Dan Abramov
e9d0a3ff25 [Fresh] Track mounted roots via DevTools Hook (#15928)
* Track mounted roots via DevTools Hook

* Add helper utilities to the runtime

These utilities will likely be needed by all module systems, so let's just put them here.

* Wrap more things in __DEV__

* Fix tests to also be DEV-only
2019-06-20 00:12:43 +01:00
Andrew Clark
35ef78de3e [Scheduler] Integrated timers (#15911)
Adds a `delay` option to `scheduleCallback`. When specified, the task is
not scheduled until after the delay has elapsed.

Delayed tasks are scheduled on a timer queue maintained by Scheduler,
instead of directly with the browser. The main benefit is to reduce the
number of native browser timers that Scheduler's `message` event handler
has to contend with; so, after yielding to the browser at the end of the
frame, Scheduler will more quickly regain control of the main thread.
Because we're able to flush the timer queue without yielding to browser
timer events, there's also less task switching overhead (though in the
absence of `isInputPending`, this is mostly a theoretical win since we
yield every frame regardless).

If the queue of non-delayed tasks is non-empty — that is, if there is
pending CPU bound work — Scheduler is able to avoid a browser timer
entirely by periodically checking its own timer queue while flushing
tasks (inside the `message` event handler). Once the CPU-bound work is
complete, if there are still pending delayed tasks, Scheduler will
schedule a single browser timer that fires once the earliest delay
has elapsed.
2019-06-19 16:05:07 -07:00
Andrew Clark
3af91eb8ce [Scheduler] Use continuation pattern for posting host callback (#15910)
* [scheduler] Internal rename: Callback -> Task

Rename Callback type to Task. Does not affect the public API, only
internal names, though eventually we'll probably want to align with the
WICG Main-thread Scheduling proposal
(https://github.com/WICG/main-thread-scheduling).

* [scheduler] flushFirstTask() -> flushTask(task)

Pass task as an argument to `flushTask` instead of using a module-
level variable.

* [scheduler] Add startTime field

This does not change any semantics, but in the future `startTime` may
represent a future time, to support delayed tasks.

* [Scheduler] Use continuation pattern for host cb

As I prepare to implement integrated timers, I noticed some
peculiarities in the Scheduler implementation that could afford to be
cleaned up.

This is a refactor and shouldn't affect any observable behavior; mostly
it removes some concepts that existed in earlier iterations of Scheduler
and are no longer needed.

The main change is to how the DOM implementation schedules an additional
callback before yielding to the main thread. It used to follow the same
code path for scheduling task; now it has its own branch directly
inside the message event handler. The special case for error handling
— where we call `postMessage` immediately without waiting for rAF —
has similarly been localized inside the catch block of the message
event handler.
2019-06-19 15:57:33 -07:00
Brian Vaughn
81e5e9be0b Updated @reach/tooltip to v0.2.2 for a bugfix 2019-06-19 15:43:15 -07:00
Dominic Gannaway
b62ae16429 [Flare] Rename createEventComponent -> createEvent (#15929) 2019-06-19 21:12:14 +01:00
Brian Vaughn
35600be1da Changed Chrome manifest version from 4.0.0.0 to 4.0.0 2019-06-19 11:06:36 -07:00
Nicolas Gallagher
f4e1ac8caf [Flare] Press events include defaultPrevented (#15916)
* Rename `disableContextMenu` to `preventContextMenu`
* Change the behaviour of `preventContextMenu` so that `onContextMenu` is still called when the native context menu is prevented.
2019-06-19 11:00:44 -07:00
Dominic Gannaway
89a0886872 [Flare] Update event component displayName 2019-06-19 17:43:15 +01:00
Dominic Gannaway
4a7a39b594 [Flare] Add RN build step for ReactTypes (#15926) 2019-06-19 13:27:10 +01:00
Christoph Nakazawa
0bd7551146 Remove mention of Prepack (#15922)
We aren't shipping Prepack anytime soon. FB-only: see D15585102.
2019-06-19 11:05:28 +01:00
Brian Vaughn
083bf8d98b Don't try to convert absolute paths to relative 2019-06-18 18:40:05 -07:00
Brian Vaughn
0e4005e0a1 Added command to build Chrome CRX 2019-06-18 15:44:22 -07:00
Dominic Gannaway
689beef6f5 [Flare] Move unstable_createEventComponent to ReactDOM (#15890) 2019-06-18 23:41:00 +01:00
Moti Zilberman
98454371a9 Construct Error at invariant call site for clearer stack traces (#15877) 2019-06-18 11:38:33 -07:00
Brian Vaughn
abc8ef3d5d Display unnamed custom hooks as 'Anonymous' 2019-06-18 11:37:29 -07:00
Nicolas Gallagher
f97b951666 [Flare] add disableContextMenu to Press (#15909) 2019-06-18 11:34:34 -07:00
Brian Vaughn
a2c79f2d9e Fixed hydration for events meta data 2019-06-18 10:50:19 -07:00
Brian Vaughn
cf19916be7 Tweaked overflow check 2019-06-18 08:59:27 -07:00
Brian Vaughn
46def793de Merge branch 'when-render-hidden' of https://github.com/justingrant/react-devtools-experimental into justingrant-when-render-hidden 2019-06-18 08:52:08 -07:00
Brian Vaughn
3988c27d70 Merge pull request #325 from bvaughn/hydration
Lazily send props/state/hooks across the bridge
2019-06-18 08:50:21 -07:00
Brian Vaughn
6298fd4248 Hardened the hooks dehydration check 2019-06-18 08:47:37 -07:00
Brian Vaughn
a56fd4c36d Tidied up. Added comments. Renamed a few things. 2019-06-18 08:40:58 -07:00
Brian Vaughn
8e3cd8ab1e Debounce inspect-element polling 2019-06-18 07:41:30 -07:00
Brian Vaughn
6c03f6abbd Tidied up a bit 2019-06-17 14:49:19 -07:00
Brian Vaughn
717af9f5c3 Updated the hydration test harness to cover a bit more 2019-06-17 14:37:49 -07:00
Brian Vaughn
d3d8a5d8b1 Hooks hydrate/dehydrate 2019-06-17 14:30:34 -07:00
Brian Vaughn
7a94ad4e8a Added props/state/context inspection to KeyValue 2019-06-17 11:30:53 -07:00
Dan Abramov
cd98e63b47 [Fresh] Fall back to Map/Set if Weak equivalents are not available (#15907)
* Fall back to Map/Set if Weak equivalents are not available

* Fix Prettier vs Flow fighting
2019-06-17 16:00:29 +01:00
Dan Abramov
a3c5b1fb8b [Fresh] Rename findHostNodesForHotUpdate to findHostInstancesForHotUpdate (#15904) 2019-06-17 15:06:43 +01:00
Brian Vaughn
a6d3f30f95 Initial support for hydration added to both renderer interfaces. 2019-06-16 17:32:37 -07:00
Sebastian Markbåge
7985bf7d50 Remove outdated test renderer comments (#15898) 2019-06-15 16:09:17 -07:00
Dan Abramov
f0156766dc [Fresh] react-fresh => react-refresh (#15888) 2019-06-15 19:36:46 +01:00
Justin Grant
a15f776708 fix: ensure when-rendered content is never hidden 2019-06-15 09:24:37 -07:00
Brian Vaughn
801feed95c Interaction tracing works across hidden and SSR hydration boundaries (#15872)
* Interaction tracing works across hidden and SSR hydration boundaries
2019-06-14 18:08:23 -07:00
Andrew Clark
661562fc52 Fix outdated test comments (#15892)
Comments for this unit test are confusing because they refer to an
earlier version of the same test.
2019-06-14 16:51:27 -07:00
Andrew Clark
788da69b74 [Suspense] Fix bad loading state not being delayed (#15891)
Fixes a bug where a bad loading state is initially suspended, but a
subsequent update with the same expiration time causes it to
commit immediately.
2019-06-14 16:10:39 -07:00
Dominic Gannaway
353e0ee474 [Flare] remove stopLocalPropagation option + modify responder ownership (#15889) 2019-06-14 23:11:54 +01:00
Dominic Gannaway
a146c1f9ed [Flare] Refactor of Press to fix various issues (#15878) 2019-06-14 22:52:26 +01:00
Dan Abramov
de7a09c1e0 [Fresh] Make transform resilient to plugin order (#15883)
* Run Fresh tests in two modes: with and without destructuring

Destructuring transform messes up the way we collect signatures for Hooks. This adds failing tests.

* Extract collecting calls to Hooks into a separate visitor

This introduces a bit of a perf penalty but makes our plugin resilient to presence of destructuring transform and their order. Fixes new tests.

* Inline some logic into the call visitor
2019-06-14 14:57:20 +01:00
Andrew Clark
2fe8fd290b [Suspense] Use style.setProperty to set display (#15882)
Follow up to #15861.

Turns out you can't set `!important` using a normal property assignment.
You have to use `style.setProperty`.

Maybe Andrew *should* just learn CSS.

IE9 doesn't support `style.setProperty` so we'll fall back to setting
`display: none` without `important`, like we did before #15861 Our
advice for apps that need to support IE9 will be to avoid using
`!important`. Which seems like good advice in general, but IANACSSE.

Tested on FB and using our Suspense DOM fixture.
2019-06-13 18:17:17 -07:00
Andrew Clark
b4b3a1dc66 Fix fuzz test environment variable 2019-06-13 15:59:35 -07:00
Andrew Clark
e91dd70ba2 Remove disableYielding feature flag (#15654)
Obviated by Batched Mode.
2019-06-13 15:58:40 -07:00
Brian Vaughn
5e8678a0a9 Don't send HTMLElements through the bridge when inspecting componetns 2019-06-13 09:09:31 -07:00
Brian Vaughn
9eb6d3465d Updated React version check to account for older (<15) versions 2019-06-12 18:56:39 -07:00
Brian Vaughn
96f7646a1a Updated hydration logic to handle custom objects 2019-06-12 15:43:15 -07:00
Brian Vaughn
cb10c3d6da Lintfix 2019-06-12 15:17:29 -07:00
Brian Vaughn
f6ec82553d Support toggling Suspense from within owners list 2019-06-12 15:13:51 -07:00
Brian Vaughn
f0a29984f4 Merge pull request #320 from gaearon/own
Fix owner tree for legacy backend
2019-06-12 09:58:17 -07:00
Dan
4bfabbc32b Fix owner tree for legacy backend 2019-06-12 17:56:25 +01:00
Brian Vaughn
2e40cc4b18 Merge pull request #319 from gaearon/legacy-fix
Fix some legacy backend bugs
2019-06-12 09:36:20 -07:00
Dan
fdf753021e Distinguish functions and classes 2019-06-12 17:23:29 +01:00
Dan
3137553f6d State and context are on the public instance 2019-06-12 16:50:15 +01:00
Dan
f352fe2625 Maintain rootID for lazily crawled trees 2019-06-12 16:38:35 +01:00
Dan
b5850fe304 Ignore SSR mounts 2019-06-12 16:15:58 +01:00
Timothy Yung
4d949d7641 [React Native] Replace touch discrepancy errors to warnings (#15866) 2019-06-12 11:37:41 +01:00
Dominic Gannaway
45acbdc0ba [Flare] Unsure root events are removed on contextmenu (#15862) 2019-06-12 02:19:02 +01:00
Andrew Clark
198ed661c5 [Suspense] Use !important to hide Suspended nodes (#15861)
Suspended nodes are hidden using an inline `display: none` style. We do
this instead of removing the nodes from the DOM so that their state is
preserved when they are shown again.

Inline styles have the greatest specificity, but they are superseded by
`!important`. To prevent an external style from overriding React's, this
commit changes the hidden style to `display: none !important`.

MaYBE AnDREw sHOulD JusT LEArn Css

I attempted to write a unit test using `getComputedStyle` but JSDOM
doesn't respect `!important`. I think our existing tests are sufficient
but if we were to decide we need something more robust, I would set up
an e2e test.
2019-06-11 11:40:06 -07:00
Dan Abramov
191920605f [Fresh] Implement missing features (#15860)
* Fix existing test

This test included a change in variable name. It wasn't needed, and distracts from the actual thing being tested (the annotation).

* Reset state on edits to initial state argument

* Add a way to check whether there are hot updates

prepareUpdate() now returns null if there are none.

* Add a way to query host nodes for families
2019-06-11 19:37:42 +01:00
Brian Vaughn
6c8ae706ee Merge pull request #316 from gaearon/lighter
Make children selection lighter
2019-06-11 07:13:01 -07:00
Dan Abramov
3bca6b28cd Make children selection lighter 2019-06-10 20:10:24 -06:00
Brian Vaughn
a08e9279ec Merge pull request #315 from bvaughn/settings
Settings panel inlined
2019-06-10 15:44:23 -07:00
Brian Vaughn
dd748ef574 Moved logic to only send updated filters across Bridge to the Store (and added tests) 2019-06-10 15:36:29 -07:00
Brian Vaughn
91e3f6cd4d Removed console.log 2019-06-10 15:05:12 -07:00
Brian Vaughn
e2e598c824 Remember last preferences tab via local storage 2019-06-10 15:03:05 -07:00
Brian Vaughn
19ed98d0c2 Removed Settings panel in favor of new shared Settings modal 2019-06-10 14:57:26 -07:00
Brian Vaughn
402a68d816 Fixed minor border bug in Profiling tab toolbar 2019-06-10 11:14:27 -07:00
Dominic Gannaway
c403ae4d35 [Flare] Move Press root event removal till click phase (#15854) 2019-06-10 19:08:53 +01:00
Dominic Gannaway
f4cd7a38d2 [Flare] Listen to document.body + add stopPropagation to Press (#15853) 2019-06-10 16:51:26 +01:00
Brian Vaughn
37c331533d Merge pull request #173 from bvaughn/legacy
Support legacy React versions
2019-06-09 16:24:00 -07:00
Brian Vaughn
e66fcaf17d Nit 2019-06-09 16:22:23 -07:00
Brian Vaughn
8f53235017 Fixed regression fixtures 2019-06-09 16:16:06 -07:00
Brian Vaughn
80bf1ba0eb Merge branch 'master' into legacy 2019-06-09 16:00:12 -07:00
Brian Vaughn
ea03ddd583 Added Flow type coverage for all EventEmitter subclasses 2019-06-09 15:50:17 -07:00
Brian Vaughn
b3046c6e19 Merge pull request #310 from bvaughn/track-changed-props
Add profiling option to track why a component rendered
2019-06-08 17:45:46 -07:00
Brian Vaughn
3904d634bb Added an explicit 'did not render' label 2019-06-08 17:36:17 -07:00
Brian Vaughn
341d1574cb Tweaked a few inline comments 2019-06-08 17:30:11 -07:00
Brian Vaughn
9047f371e2 Fix minor toolbar border misalignment 2019-06-08 17:18:05 -07:00
Brian Vaughn
4f92af17ea Only show "rendered at" if selected Fiber committed at least once 2019-06-08 17:17:56 -07:00
Brian Vaughn
7a72ee5ac0 Added context changes to sidebar; fixed a initial-mount detection bug 2019-06-08 17:01:38 -07:00
Brian Vaughn
5672d686dc Fixed some minor CSS issues 2019-06-08 16:45:38 -07:00
Brian Vaughn
6ab522326d Added a test for added/removed props 2019-06-08 11:41:39 -07:00
Brian Vaughn
a2f469d742 Fixed an increment bug in sidebar for fiber-commits 2019-06-08 09:22:30 -07:00
Brian Vaughn
2d48401346 Added context support to change description 2019-06-08 09:10:54 -07:00
Dan Abramov
fdc5ca4ba6 Remove dead code 2019-06-07 18:42:12 -07:00
Dan Abramov
90fa0adc0a Fix lint 2019-06-07 18:37:24 -07:00
Dan Abramov
65ac53bba4 Fixes 2019-06-07 18:33:03 -07:00
Dan Abramov
ad7458bb42 Merge branch 'master' into legacy 2019-06-07 17:54:54 -07:00
Dan Abramov
9243bc194c Rewrite to make it sturdier 2019-06-07 17:21:30 -07:00
Brian Vaughn
bd5c2e4621 Initial change tracking implemented
* User profiling setting
* Background collects changed props/state (not added/removed or hooks yet)
* Tests updated
2019-06-07 15:38:26 -07:00
Brian Vaughn
88e59277e7 Added HOC badges to Jest Store serialization 2019-06-07 14:10:49 -07:00
Brian Vaughn
21bb66a8c7 Added HOC filter test 2019-06-07 14:06:08 -07:00
Brian Vaughn
956935f915 Merge pull request #308 from bvaughn/dependabot/npm_and_yarn/js-yaml-3.13.1
Bump js-yaml from 3.12.1 to 3.13.1
2019-06-07 13:15:10 -07:00
dependabot[bot]
c2c3e8e6e5 Bump js-yaml from 3.12.1 to 3.13.1
Bumps [js-yaml](https://github.com/nodeca/js-yaml) from 3.12.1 to 3.13.1.
- [Release notes](https://github.com/nodeca/js-yaml/releases)
- [Changelog](https://github.com/nodeca/js-yaml/blob/master/CHANGELOG.md)
- [Commits](https://github.com/nodeca/js-yaml/compare/3.12.1...3.13.1)

Signed-off-by: dependabot[bot] <support@github.com>
2019-06-07 20:12:54 +00:00
Brian Vaughn
78721bde4c Backend notifies the frontend of Storage API support. Frontend disables e.g. reload-and-profile based on this. 2019-06-07 13:08:49 -07:00
Brian Vaughn
3e3c83aecd Updated reload-and-profile temp key to use sessioStorage instead of localStorage 2019-06-07 12:40:59 -07:00
Brian Vaughn
89e36e3976 Wrap all calls to localStorage/sessionStorage to avoid potential runtime errors 2019-06-07 10:51:01 -07:00
Dominic Gannaway
425473f43f [Flare] Improve runtime performance of hit target intersection (#15836) 2019-06-07 15:57:10 +01:00
Dan Abramov
def56c9797 [Fresh] Capture Hook signatures lazily on first render (#15832)
* Split the signature call into two calls

This adds a render-time signature call by making __signature__ curried. We need both calls. The init time tells us which type has which signature. The render time call says when's a good time to capture the lazy Hooks tree. This is necessary for supporting inline requires. I will do that in next commit.

* Lazily compute Hook list on first render

This ensures inline requires don't break comparisons between Hook signatures of previous and next versions by caching Hook list at the time of first render.

* Refactor computing Hook signature keys

Instead of a traversal during the comparison, explicitly compute full keys. This makes it easier to debug mismatches.
2019-06-06 10:53:12 -07:00
Brian Vaughn
a987206a36 Fixed an overflow bug. Added mode-specific CSS style for Firefox. 2019-06-06 10:39:07 -07:00
Dominic Gannaway
8cfcfe0fcb [Flare] Fix ES6 issues with IE11 (#15834) 2019-06-06 18:38:46 +01:00
Dan Abramov
d0e041aee8 [Fresh] Support classes by force-remounting them on edit (#15801)
* Remount classes during hot reload

* Fix a crash when Hook isn't in scope inside the signature

* Minor tweaks

* Support a comment annotation to force state reset

* Refactoring: pass a function instead of WeakMap

This hides the implementation a little bit and reduces how much React knows about the underlying mechanism.

* Refactor: use forceReset to remount unknown Hooks

We already have the logic to reset a component, so let's just reuse it instead of that special case.
2019-06-05 16:13:42 -07:00
Brian Vaughn
d1a88ffc5c Re-add plugin-transform-react-jsx-source plugin for tests 2019-06-05 14:36:01 -07:00
Brian Vaughn
dc9b0810f9 Changed react-window alias 2019-06-05 14:33:24 -07:00
Brian Vaughn
9d90189ee3 react-window sync flushes scroll updates 2019-06-05 14:30:43 -07:00
Brian Vaughn
6ff733873c Vendored react-window 2019-06-05 14:27:57 -07:00
Dominic Gannaway
73c27d8b49 [Flare] Add basic Scroll event responder module (#15827) 2019-06-05 18:20:34 +01:00
Dominic Gannaway
c72dceffbc [Flare] Small Swipe/Drag fixes (#15825) 2019-06-05 17:51:41 +01:00
Christoph Nakazawa
6aaa43708d Rename ReactFeatureFlags to remove the .fb suffix. (#15826) 2019-06-05 14:20:09 +01:00
Ricky
843a59ab60 [React Native] Remove eventTypes from ReactNativeBridgeEventPlugin (#15802) 2019-06-05 13:21:12 +01:00
Andrew Clark
7b28ad119e [Flare] EventPriority enum (#15823)
* Same as previous commit, but for Flare

I don't know what the public API for setting the event priority should
be. Right now it accepts a numeric enum, but is this what we want?
Maybe it should be a string enum? I've punted on this for now.

* Add test for hover events
2019-06-04 17:20:06 -07:00
Brian Vaughn
7ef5970b2f Removed __source info from production builds 2019-06-04 17:03:13 -07:00
Sunil Pai
d707a75794 nit: a quick copy edit for an act() message/comment (#15805) 2019-06-04 16:36:07 -07:00
Dominic Gannaway
cfb79ee5b3 [Flare] Fix isTouchEvent (#15824) 2019-06-04 23:58:11 +01:00
Brian Vaughn
1afc83e7cd Tweaked manifest "version_name" logic 2019-06-04 14:56:36 -07:00
Sarhan Aissi
e158768b16 fix: remove version_name from Firefox WebExtension manifest 2019-06-04 22:34:20 +01:00
Brian Vaughn
7ed3f6815c Merge pull request #295 from bvaughn/horizontal-compression
Components tree changes to improve HOCs and browsing deep trees
2019-06-04 13:59:22 -07:00
Andrew Clark
6b5deeed50 [Events] Add support for events that are both user-blocking and continuous (#15811)
* [Events] Add EventPriority enum

React DOM's DispatchConfig for synthetic events has an `isDiscrete`
field that affects how updates triggered by an event are scheduled.
Events are either discrete or continuous.

This commit adds an additional type of configuration where an event
has user-blocking priority, but is not discrete. E.g. updates triggered
by hover are more important than the default, but they don't need to
be processed serially. Because there are now three types of event
priority instead of two, I've replaced the `isDiscrete` boolean with an
enum: `eventPriority`.

This commit implements the new enum value but does not change any
behavior. I'll enable it behind a feature flag in the next commit.

I've only implemented this in the legacy event system. I'll leave Flare
for a follow-up.

* enableUserBlockingEvents feature flag

Adds a feature flag to increase the priority of events like `mouseover`,
without making them discrete.
2019-06-04 13:35:52 -07:00
Brian Vaughn
7fa5a716e3 Use Circle CI API v2 to get artifacts job ID (#15821) 2019-06-04 13:28:41 -07:00
Dominic Gannaway
8d4fb132ef [Flare] Fix nativeEvent.x/y for older browsers (#15820) 2019-06-04 20:58:20 +01:00
Dominic Gannaway
2534c0c924 [Flare] Add event position properties to Hover responder (#15819) 2019-06-04 18:10:15 +01:00
Brian Vaughn
2245206c4c Add source location to debug logging info 2019-06-04 08:56:10 -07:00
Brian Vaughn
5963998fbe Display density preference updates :root fontSize
As a result, paddings and sizes (e.g. tab bar heights) will also be impacted now by this preference. More importantly, Profile charts will also use the line height preference, so the 'comfortable' setting will hopefully make profiling data easier to read.
2019-06-04 07:24:14 -07:00
Brian Vaughn
b63a41d38a Updated release script to be Workflow aware (#15809) 2019-06-03 17:29:06 -07:00
Nicolas Gallagher
dd43cb5fb9 [Flare] Fix isPressWithinResponderRegion logic (#15808)
Compare the viewport-relative coordinates of getBoundingClientRect with those
of the event's client{X,Y} values. This fixes press within scrollable nodes.
2019-06-03 14:59:26 -07:00
Nicolas Gallagher
4f6cab547b [Flare] Ignore keyboard interactions on text input children (#15810) 2019-06-03 14:34:08 -07:00
Brian Vaughn
95a99867f7 Decreased contrast of HOC badges in selected props panel 2019-06-03 12:51:04 -07:00
Brian Vaughn
ef139a1811 Batched tweaks and bug fixes:
1. Bugfix: Hide tree grouping/background coloring when inside of collapsed subtree.
2. Bugfix: Don't measure and udpate indentation when Components tab is hidden.
3. Tweak: Lower background color for selected subtree in light theme to increase contrast for text.
4. Tweak: Remove FB-specific displayName check/hack since we will address that by modifying the internal require JS transform.
2019-06-03 12:47:26 -07:00
Simen Bekkhus
fa1e8df116 chore: use jest-serializer-raw for react-fresh snapshots (#15806) 2019-06-03 12:46:33 -07:00
Brian Vaughn
edfc1bb2b3 Simplified background highlight style now that corner radius has been removed from selected highlight 2019-06-03 10:46:37 -07:00
Brian Vaughn
06b004b5d4 Renamed <Guideline> to <SelectedTreeHighlight> 2019-06-03 09:39:31 -07:00
Brian Vaughn
fbc6e5d68a Removed outdated comment and Eslint rule ignore 2019-06-03 09:33:48 -07:00
Brian Vaughn
6ac558df2d Reset max indentation when entering/exiting the owner tree 2019-06-03 09:32:28 -07:00
Brian Vaughn
a173f4eb85 Add HOC component filter 2019-06-03 08:51:50 -07:00
Brian Vaughn
78cf211286 Only shrink indentation. Don't increase it again. This avoids 'jumping'. 2019-06-03 08:01:48 -07:00
James Ide
07da821bfd [react-native] Rewrite Haste imports in RN shims and add .fb.js extension (#15786)
This commit is a follow-up to https://github.com/facebook/react/pull/15604, which explains more of the rationale behind moving React Native to path-based imports and the work needed in the React repository. In that linked PR, the generated renderers were updated but not the shims; this commit updates the shims.

The problem is that FB needs a different copy of the built renderers than the OSS versions so we need a way for FB code to import different modules than in OSS. This was previously done with Haste, but with the removal of Haste from RN, we need another mechanism. Talking with cpojer, we are using a `.fb.js` extension that Metro can be configured to prioritize over `.js`.

This commit generates FB's renderers with the `.fb.js` extension and OSS renderers with just `.js`. This way, FB can internally configure Metro to use the `.fb.js` implementations and OSS will use the `.js` ones, letting us swap out which implementation gets bundled.

Test Plan: Generated the renderers and shims with `yarn build` and then verified that the generated shims don't contain any Haste-style imports. Copied the renderers and shims into RN manually and launched the RNTester app to verify it loads end-to-end. Added `.fb.js` to the extensions in `metro.config.js` and verified that the FB-specific bundles loaded.
2019-06-03 15:58:31 +01:00
Brian Vaughn
f713265a00 Cap indentation increase at a max 2019-06-02 21:01:24 -07:00
Brian Vaughn
8261a3f453 Removed Tree padding 2019-06-02 20:25:57 -07:00
Brian Vaughn
dc08e80037 Cache list rows by Element ID rather than index
This is important since we are caching element sizes by DOM (in a WeakMap). Toggling (as well as insertion/deletion) might otherwise break this in some cases.
2019-06-02 20:10:30 -07:00
Jordan Rome
a383c46788 [ESLint] don't warn for Flow type variables (#15804)
In Exhaustive Deps check for react-hooks don't warn if the dependency is
a Flow type variable.
2019-06-03 02:20:51 +01:00
Brian Vaughn
6b6e571c68 Added HOC badge to owners list dropdown 2019-06-02 10:50:07 -07:00
Brian Vaughn
27d4f0b24d Fixed box drawing chars comment 2019-06-02 10:40:10 -07:00
Brian Vaughn
dc945f6b81 Fixed a typo in string truncation util 2019-06-02 10:06:05 -07:00
Brian Vaughn
17b04c321c Cleaned up how we measure children and adjust indentation size 2019-06-02 10:02:22 -07:00
Brian Vaughn
3f0606f3d9 Refactored badges to share code and show +count 2019-06-01 18:48:24 -07:00
Brian Vaughn
6a69a6e991 Added HOC badge to owners stack breadcrumbs 2019-06-01 18:05:59 -07:00
Brian Vaughn
c1989448f4 Disable guide/group highlight in owners tree mode 2019-06-01 17:49:51 -07:00
Brian Vaughn
96dc003a70 Removed debounce+animation from indentation adjustment 2019-06-01 17:48:01 -07:00
Brian Vaughn
b5f8998859 Added debounce and animation for resize 2019-06-01 11:16:18 -07:00
Brian Vaughn
de9fb0a8a2 Tweaked guideline background color style 2019-06-01 09:34:39 -07:00
Brian Vaughn
ab7ae78511 Tweaked a few styles 2019-06-01 09:19:32 -07:00
Brian Vaughn
2845a7883b Whoops I broke CI (updating snapshots) 2019-06-01 08:44:55 -07:00
Brian Vaughn
aa87b125e7 Lots of tweaks
Remove selected guideline in favor of background color for selected subtree.
Add badges in grid format to selected elements prop panel.
Show badges beside owners list.
2019-06-01 08:24:24 -07:00
Andrew Clark
5763f1d4c4 [Events] Nested discrete events across systems
If an event in the old system is dispatched synchronously within an
event from the new system, or vice versa, and the inner event is a
discrete update, React should not flush pending discrete updates before
firing the inner event's handlers, even if the outer event is not
discrete.

Another way of saying this is that nested events should never force
React to flush discrete updates.

Arguably, if the outer event is not a discrete event, then the inner
event _should_ flush the pending events. However, that would be a
breaking change. I would argue this isn't so bad, however, given that
nested events are pretty rare. They don't fit nicely into our event
model regardless, since we don't support nested React renders. In the
future we should consider warning when events are nested.
2019-05-31 17:46:30 -07:00
Andrew Clark
7aa35ceae0 Fix casing of shouldflushDiscreteUpdates
shouldflushDiscreteUpdates -> shouldFlushDiscreteUpdates
2019-05-31 17:46:30 -07:00
Andrew Clark
91635dd483 Switch to "discrete" and "continuous" terminology
Events were previously described as "interactive" or "non-interactive".
2019-05-31 17:46:30 -07:00
Andrew Clark
73c380fca7 WorkPhase -> ExecutionContext
WorkPhase is an enum that represents the currently executing phase of
the React update -> render -> commit cycle. However, in practice, it's
hard to use because different "phases" can be nested inside each other.
For example, the commit phase can be nested inside the
"batched phase."

This replaces WorkPhase with a different concept: ExecutionContext.
ExecutionContext is a bitmask instead of an enum. It represents a stack
of React entry points. For example, when `batchedUpdates` is called
from inside an effect, the ExecutionContext is
`BatchedContext | CommitContext`.
2019-05-31 17:46:30 -07:00
Nicolas Gallagher
88b3963820 [Flare] Remove deprecated keypress event (#15795)
`keypress` is a deprecated event.
2019-05-31 14:53:09 -07:00
Brian Vaughn
19d95a1368 Revert "Re-added indent lines"
This reverts commit 33432b037f.
2019-05-31 14:41:20 -07:00
Mateusz Burzyński
63fe08eef5 React Events: allow Tab+Alt on Mac in Focus responder (#15679)
* Fix issue with Tab+alt not being considered as isGlobalFocusVisible candidate on Mac
* Add test for Tab+alt on Mac setting pointerType: "keyboard" on a focus event
2019-05-31 14:33:42 -07:00
Brian Vaughn
33432b037f Re-added indent lines 2019-05-31 13:34:55 -07:00
Brian Vaughn
5a269e7ced Initial POC for compressing horizontal offset for wide/deep trees 2019-05-31 11:24:34 -07:00
Dan Abramov
2794b92164 Add some support for reordering 2019-05-31 18:00:56 +01:00
Dan Abramov
c3be085910 Remove crawling for updates
It doesn't seem necessary to crawl because mounts only happen in the context of updates.

This fixes updates to not be treated as new mounts.
2019-05-31 17:41:11 +01:00
Dan Abramov
6fd83acb1d Default to showing host nodes for legacy renderer 2019-05-31 15:39:00 +01:00
Dan Abramov
9f44251ebf Remove unnecessary code for host text as we skip it anyway 2019-05-31 14:27:22 +01:00
Sebastian Markbåge
113497cc0e [Suspense] Change Suspending and Restarting Heuristics (#15769)
* Track most recent commit time of a fallback globally

This value is going to be used to avoid committing too many fallback
states in quick succession. It doesn't really matter where in the tree
that happened.

This means that we now don't really need the concept of SuspenseState
other than has a flag. It could be made cheaper/simpler.

* Change suspense heuristic

This now eagerly commits non-delayed suspended trees, unless they're
only retries in which case they're throttled to 500ms.

* Restart early if we're going to suspend later

* Use the local variable where appropriate

* Make ReactLazy tests less specific on asserting intermediate states

They're not testing the exact states of the suspense boundaries, only
the result. I keep assertions that they're not already resolved early.

* Adjust Profiler tests to the new heuristics

* Update snapshot tests for user timing tests

I also added a blank initial render to ensuree that we cover the suspended
case.

* Adjust Suspense tests to account for new heuristics

Mostly this just means render the Suspense boundary first so that it
becomes an update instead of initial mount.

* Track whether we have a ping on the currently rendering level

If we get a ping on this level but have not yet suspended, we might
still suspend later. In that case we should still restart.

* Add comment about moving markers

We should add this to throwException so we get these markers earlier.
I've had to rewrite tests that test restarting to account for the delayed
restarting heuristic.

Ideally, we should also be able to restart from within throwException if
we're already ready to restart. Right now we wait until the next yield.

* Add test for restarting during throttled retry

* Add test that we don't restart for initial render

* Add Suspense Heuristics as a comment in Throw
2019-05-30 16:37:56 -07:00
Brian Vaughn
c0f686eed9 Show indent lines preference 2019-05-30 14:30:17 -07:00
Brian Vaughn
a2a468743f Remove hover guideline in favor of showing guidelines for every nesting level 2019-05-30 14:17:12 -07:00
Brian Vaughn
a957031fe7 Fixed bad Bridge disconnections 2019-05-30 09:27:28 -07:00
Brian Vaughn
8f8ac358c6 Turn off pointer events for guidelines 2019-05-30 08:43:45 -07:00
Brian Vaughn
ec421355bd Added selected and hovered guidelines to Components tree 2019-05-30 08:22:06 -07:00
Andrew Clark
3b2302253f Fix sizebot (#15771)
The previous naming scheme used the name of the resulting bundle file.
However, there are cases where multiple bundles have the same filename.
This meant whichever bundle finishes last overwrites the previous ones
with the same name.

The updated naming scheme is `bundle-sizes-<CI_NODE_INDEX>.json`.
Instead of generating a separate info file per bundle, it now creates
one per process.
2019-05-29 21:30:16 -07:00
Nicolas Gallagher
0f7cc2ba84 React Events: check window before using navigator (#15768) 2019-05-29 20:19:31 -07:00
Andrew Clark
ad9a6df58c Move fixtures test to its own CI job
Running it in parallel to the other post-build jobs shaves ~30 seconds
off the total CI time.
2019-05-29 15:11:25 -07:00
Nicolas Gallagher
2670bc3400 React Events: support legacy browser Spacebar key value (#15766) 2019-05-29 15:00:43 -07:00
Sunil Pai
9aad17d60c using the wrong renderer's act() should warn (#15756)
* warn when using the wrong renderer's act around another renderer's updates

like it says. it uses a real object as the sigil (instead of just a boolean). specifically, it uses a renderer's flushPassiveEffects as the sigil. We also run tests for this separate from our main suite (which doesn't allow loading multiple renderers in a suite), but makes sure to run this in CI as well.

* unneeded (and wrong) comment

* run the dom fixture on CI

* update the sigil only in __DEV__

* remove the obnoxious comment

* use an explicit export for the sigil
2019-05-29 22:56:04 +01:00
Andrew Clark
8ce8b9ab81 Update name of CI job in sizebot (#15767)
Same as #15714. I moved the artifacts step to a different job, so I
need to update the name in the sizebot script to match.
2019-05-29 14:52:11 -07:00
Andrew Clark
1cc3bba004 Parallelizes the build script across multiple processes (#15716)
* Write size info to separate file per bundle

`bundle-sizes.json` contains the combined size information for every
build. This makes it easier to store and process, but it prevents us
from parallelizing the build script, because each process would need to
write to the same file.

So I've updated the Rollup script to output individual files per build.
A downstream CI job consolidates them into a single file.

I have not parallelized the Rollup script yet. I'll do that next.

* Parallelize the build script

Uses CircleCI's `parallelism` config option to spin up multiple build
processes.
2019-05-29 14:34:50 -07:00
Brian Vaughn
d5be489d5b Backed out Bridge shutdown refactor as it seems to have introduced bugs 2019-05-29 14:23:10 -07:00
Andrew Clark
30b1a8009c Don't extract errors in CI (#15758)
Removes `--extract-errors` argument from CI build script command.
Instead, the author is expected to run `yarn extract-errors` locally
or manually edit the error code map.

The lint rule should be sufficient to catch unminified errors, but
as an extra precaution, I added a post-build step that greps the
production bundles. The post-build step works even if someone disables
the lint rule for a specific line or file.
2019-05-29 14:20:29 -07:00
Andrew Clark
112168f31b Lint rule for unminified errors (#15757)
* Lint rule for unminified errors

Add a lint rule that fails if an invariant message is not part of the
error code map.

The goal is to be more disciplined about adding and modifiying
production error codes. Error codes should be consistent across releases
even if their wording changes, for continuity in logs.

Currently, error codes are added to the error code map via an automated
script that runs right before release. The problem with this approach is
that if someone modifies an error message in the source, but neglects to
modify the corresponding message in the error code map, then the message
will be assigned a new error code, instead of reusing the existing one.

Because the error extraction script only runs before a release, people
rarely modify the error code map in practice. By moving the extraction
step to the PR stage, it forces the author to consider whether the
message should be assigned a new error code. It also allows the reviewer
to review the changes.

The trade off is that it requires more effort and context to land new
error messages, or to modify existing ones, particular for new
contributors who are not familiar with our processes.

Since we already expect users to lint their code, I would argue the
additional burden is marginal. Even if they forget to run the lint
command locally, they will get quick feedback from the CI lint job,
which typically finishes within 2-3 minutes.

* Add unreleased error messages to map
2019-05-29 11:29:04 -07:00
Dominic Gannaway
142cf56cbf [Flare] Adds onContextMenu and fixes some contextmenu related issues (#15761) 2019-05-29 17:53:55 +01:00
Dan Abramov
556cc6fe19 [Fresh] Generate signatures for Hooks (#15733)
* Generate signatures for Hooks

This currently only works one level deep. For custom Hooks, we'll need to add some way to compose signatures.

* Be more resilient to plugin conflicts

This prevents a class of problems where other plugins cause our visitor to re-run.

It's a standard Babel practice, e.g.:

8c7d4b55c9/packages/babel-plugin-transform-react-constant-elements/src/index.js (L85-L86)

* Remove unnecessary stuff from debugging

* Include Foo.useHookName() calls into the signature

* Add an integration test for adding/removing an effect

* Add integration test for changing custom Hook order

* Include custom Hooks into the signatures

* Fix inferred names for function expressions

* Support export default hoc(Foo) when Foo is defined separately

* Add more built-in Hooks
2019-05-29 14:15:31 +01:00
Sebastian Markbåge
b74fa9868e Clean up (#15755)
expirationTime has already been checked if it's sync.

timeout can now be longer than 5 seconds when a suspense config is used.
We might want to adjust the heuristics but it's not internally consistent
without this.
2019-05-28 14:19:51 -07:00
Brian Vaughn
5429f651b4 Tweaks 2019-05-28 13:57:05 -07:00
Sunil Pai
388b03dd12 prettier 2019-05-28 20:24:35 +01:00
Sunil Pai
9e87e654f5 pass tests and flow 2019-05-28 20:21:55 +01:00
Sunil Pai
c7580fcd3f Merge remote-tracking branch 'upstream/master' into act-async 2019-05-28 20:21:38 +01:00
Andrew Clark
d915a4c1f1 [Suspense] Add Batched Mode variant to fuzz tester (#15734) 2019-05-28 11:41:01 -07:00
Owen Conti
7c5645ddb1 Fix double spaces. (#15641) 2019-05-28 10:34:18 -07:00
Brian Vaughn
92c2d8366b Updated Chrome installation
1. Removed auto-updates XML (since the feature doens't work for self hosted extensions)
2. Replaced CRX with packed ZIP (since people are having trouble with the CRX, and auto-udpates doesn't work anyway)
2019-05-28 08:52:21 -07:00
Caleb Meredith
401065fe5c Adds test for #15732. (#15747) 2019-05-28 14:25:22 +01:00
Dominic Gannaway
287ef30bba [Flare] Deeply prevent default on anchor elements (#15750) 2019-05-28 12:46:07 +01:00
Dominic Gannaway
a97b5c07b0 [Flare] More fixes for getAbsoluteBoundingClientRect (#15746) 2019-05-27 19:03:40 +01:00
Brian Vaughn
fa0139afbf Merged master 2019-05-26 10:47:55 -07:00
Brian Vaughn
af47c39dbb Added and view-source support for Memo components 2019-05-26 10:33:19 -07:00
Brian Vaughn
4422337562 Added another (disabled) test; refactored getChildren slightly 2019-05-26 08:37:05 -07:00
Brian Vaughn
94bebda825 Merged master 2019-05-25 09:10:43 -07:00
Andrew Clark
5fe97dbe19 Remove sizebot race condition (#15735)
Sometimes the status of the `build` job is not in the first page of
the `/statuses` endpoint. The combined `/status` endpoint consolidates
the entries, though, so it always appears there.
2019-05-24 18:55:28 -07:00
Brian Vaughn
bda8a0aa98 Decreased contrast of disabled button icons to look more obviously disabled 2019-05-24 16:00:12 -07:00
Brian Vaughn
c8411019f1 Updated profiler overview 2019-05-24 14:43:56 -07:00
Brian Vaughn
e76cee394d Added section about inspecting element to OVERVIEW 2019-05-24 14:31:05 -07:00
Dan Abramov
393924879f [Fresh] Babel plugin now handles HOCs + add integration tests (#15724)
* Refactor component search to prepare for deeper traversals

* Register HOCs with intermediate results

* Register components that are used as JSX types

* Add integration test skeleton

The integration test combines testing runtime together with the Babel plugin. It's a bit harder to debug because multiple things can go wrong, but it helps us build confidence that specific scenarios work well.

* Add HOC integration test and fix conflict with JSX transform

* Infer usage from createElement too

This helps us avoid dependency on the plugin order.

* Remove outdated comments

* Wrap tests in __DEV__

* Support export default hoc(...) for anonymous functions

* Fix test indentation

* Fix comment typo

* Use named function for test as this case is more important
2019-05-25 00:45:08 +04:00
Brian Vaughn
4cc7e748d1 Merge pull request #289 from bvaughn/cache-inspected-element
Cache inspected element data until it is updated
2019-05-24 09:26:31 -07:00
Brian Vaughn
efc2f82da2 Reorganize inspected element state vars slightly 2019-05-24 09:17:20 -07:00
Brian Vaughn
f580d0ece7 Don't (re)serialize inspected elements either unless they have re-rendered since last inspected. 2019-05-24 09:07:15 -07:00
Brian Vaughn
07db37f030 Cache inspected element data until it is updated 2019-05-24 07:37:46 -07:00
Andrew Clark
2b58797365 Typo in CircleCI config 2019-05-23 15:33:56 -07:00
Brian Vaughn
408fbee23b Fix potential RTE caused by setting (saved) profiling data while profiling is in progress 2019-05-23 14:49:47 -07:00
Sebastian Markbåge
8af1f87929 Rename ReactFiberScheduler -> ReactFiberWorkLoop and extract throwException from Unwind (#15725)
* Rename ReactFiberScheduler to ReactFiberWorkLoop

The scheduling part is mostly extracted out to the scheduler package.

What's remaining is mostly around the loop around each section of work.
I name it something with Work in it because it's very related to the
BeginWork, CompleteWork and UnwindWork sections.

* Extract throwException from UnwindWork

Our throwing works more like algebraic effects in that it's a separate
phase where we find a handler and we later unwind.
2019-05-23 14:24:18 -07:00
Andrew Clark
399cd0d16c Set up cron job to run fuzz tester (#15718)
Sets up a CircleCI workflow to run the fuzz tests with a randomly
generated seed. The workflow runs on an hourly schedule.
2019-05-23 14:09:08 -07:00
Brian Vaughn
395c02567c Handle HTTPS Git clone URLs 2019-05-23 11:55:32 -07:00
Brian Vaughn
6e8c2015fc Tweaked Bridge shutdown sequence slightly 2019-05-23 11:46:28 -07:00
Brian Vaughn
34f6fa4fab Added a sanity test for Bridge shutdown 2019-05-23 11:22:02 -07:00
Brian Vaughn
f47b40fe6c Tweaked event display name logic 2019-05-23 09:30:31 -07:00
Dominic Gannaway
9a67ba2f98 Remove snapshot 2019-05-23 09:17:50 -07:00
Dominic Gannaway
70084e881b Update snapshot tests 2019-05-23 09:17:37 -07:00
Dominic Gannaway
8eb7eddd1f Run prettier 2019-05-23 09:17:37 -07:00
Dominic Gannaway
779fd167ff Adds inspectable event components + props
[Flare] Adds inspectable event components + props
2019-05-23 09:17:37 -07:00
Brian Vaughn
e4aa3c5b33 Update profiling-supported status each time roots change (and added tests) 2019-05-23 09:09:35 -07:00
Brian Vaughn
74d8207e06 Improved visual style of Profiling-disabled button 2019-05-23 08:52:27 -07:00
Brian Vaughn
541dd6c4b6 Moved profiling-supported subscription into ProfilerContext 2019-05-23 08:48:51 -07:00
Brian Vaughn
0608b1a554 Merge pull request #281 from bvaughn/persiste-profiling-data-after-navigation
[WIP] Don't erase profiler data on navigation
2019-05-23 08:38:59 -07:00
Brian Vaughn
44fbf3cd1d Added ProfilerContext tests 2019-05-23 08:36:34 -07:00
Dominic Gannaway
025b07b610 [Flare] Ensure getAbsoluteBoundingClientRect aligns with offsetParent (#15720) 2019-05-23 13:51:14 +01:00
James Ide
61f62246c8 [react-native] Use path-based imports instead of Haste for the RN renderer (#15604)
* [react-native] Use path-based imports instead of Haste for the RN renderer

To move React Native to standard path-based imports instead of Haste, the RN renderer that is generated from the code in this repo needs to use path-based imports as well since the generated code is vendored by RN. This commit makes it so the interface between the generated renderers and RN does not rely on Haste and instead uses a private interface explicitly defined by RN. This inverts control of the abstraction so that RN decides the internals to export rather than React deciding what to import.

On RN's side, a new module named `react-native/Libraries/ReactPrivate/ReactNativePrivateInterface` explicitly exports the modules used by the renderers in this repo. (There is also a private module for InitializeCore so that we can import it just for the side effects.) On React's side, the various renderer modules access RN internals through the explicit private interface.

The Rollup configuration becomes slimmer since the only external package is now `react-native`, and the individual modules are instead listed out in `ReactNativePrivateInterface`.

Task description: https://github.com/facebook/react-native/issues/24770
Sister RN PR (needs to land before this one): https://github.com/facebook/react-native/pull/24782

Test Plan: Ran unit tests and Flow in this repo. Generated the renderers and manually copied them over to the RN repo. Ran the RN tests and launched the RNTester app.

* Access natively defined "nativeFabricUIManager" instead of importing it

Some places in the Fabric renderers access `nativeFabricUIManager` (a natively defined global) instead of importing UIManager. While this is coupling across repos that depends on the timing of events, it is necessary until we have a way to defer top-level imports to run after `nativeFabricUIManager` is defined. So for consistency we use `nativeFabricUIManager` everywhere (see the comment in https://github.com/facebook/react/pull/15604#pullrequestreview-236842223 for more context).
2019-05-23 08:23:54 +01:00
Brian Vaughn
5719454377 Persist profiling data after navigation 2019-05-22 20:00:21 -07:00
Brian Vaughn
351d5f662a Add Tab id to Tooltip 2019-05-22 20:00:06 -07:00
Brian Vaughn
f14a2fd05c Use @reach tooltips for TabBar, cleanup supports-profiling subscription 2019-05-22 18:44:43 -07:00
Dominic Gannaway
b962adfc2b [Flare] event component displayName is now mandatory (#15717) 2019-05-23 01:29:07 +01:00
Brian Vaughn
98623dfdb0 Tweak 2019-05-22 16:40:40 -07:00
Dominic Gannaway
d98161874c [Flare] Ensure DOM inspection is Flare compatible 2019-05-22 16:29:54 -07:00
Andrew Clark
d66c8f2d9d Update sizebot to match name of CircleCI build job (#15714)
The sizebot scrapes the GitHub `/statuses` endpoint to get the lastest
CircleCI build number for master, in order to fetch the bundle size
info for that build, which are stored as build artifacts. (There's gotta
be a better way to do this, but that's what we have for now.) This
updates the script to match the name of the updated CircleCI job that
generates the bundle sizes.
2019-05-22 16:12:14 -07:00
Dan Abramov
5c2124fc76 [Fresh] Initial Babel plugin implementation (#15711)
* Add initial Babel plugin implementation

* Register exported functions

* Fix missing declarations

Always declare them at the bottom and rely on hoisting.

* Remove unused code

* Don't pass filename to tests

I've decided for now that the plugin doesn't need filename, and it will be handled by module runtime integration instead.

* Fix bugs

* Coalesce variable declarations
2019-05-22 23:11:09 +01:00
Andrew Clark
101901dc2d Remove redundant test run (#15713) 2019-05-22 13:50:43 -07:00
Andrew Clark
1c0bdb710d Always run yarn after restoring modules cache (#15712) 2019-05-22 13:33:33 -07:00
Dominic Gannaway
b9ebc37c5b Fix Flow (#15710) 2019-05-22 21:04:28 +01:00
Dominic Gannaway
a25a793fe9 [Flare] update getEventCurrentTarget to use fiber tree (#15708) 2019-05-22 19:59:00 +01:00
Dominic Gannaway
b5dff62faf [Flare] Account for fixed elements in getAbsoluteBoundingClientRect (#15707) 2019-05-22 19:54:08 +01:00
Andrew Clark
f3109ad8a7 Parallelize CircleCI jobs using workflows (#15704)
Updates the CircleCI config to use the workflows features to run jobs in
parallel, instead of the `parallelism` option. This change alone doesn't
improve the overall build time much, since almost all of the total time
is spent running the Rollup script, which runs entirely sequentially.
But it does improve reporting, and should make it easier to add
additional parallel jobs in the future.
2019-05-22 11:14:14 -07:00
Brian Vaughn
eaaeb439b4 Fixed a missing remove-event-listener in ProfilerStore 2019-05-22 10:52:15 -07:00
Brian Vaughn
b556f7444d Profiler properly handles unmounted roots 2019-05-22 10:19:26 -07:00
Brian Vaughn
b4a3ef9fb2 Merge pull request #279 from bvaughn/profiling-architecture-eager-data-push
Refactor Profiler architecture
2019-05-22 10:00:52 -07:00
Brian Vaughn
962865e5bf Add datetime to the profiling export filename 2019-05-22 09:57:10 -07:00
Brian Vaughn
fbd82385d2 Fixed a state cleanup issue if Profiler data is cleared 2019-05-22 09:04:55 -07:00
Brian Vaughn
d1344768b2 Changed export code to (hopefully) support larger exports 2019-05-22 08:41:57 -07:00
Brian Vaughn
ec44eb1e4c Tweaked did-not-render text color to be slightly dimmer 2019-05-22 08:32:10 -07:00
Brian Vaughn
a03c3b5d14 Bumped Profiler exported data version 2019-05-22 08:22:33 -07:00
Brian Vaughn
d09299bf85 Cleaned up some tests 2019-05-22 08:05:34 -07:00
Brian Vaughn
99b6a44beb Updated event subscriptions and getters to use new ProfilerStore 2019-05-22 07:40:41 -07:00
Brian Vaughn
2d4bb01c01 Moved profiling data to ProfilerContext to fix re-import bug 2019-05-22 07:28:26 -07:00
Brian Vaughn
95bd6c8f63 Added export to web shell and removed 'downloads' API permission 2019-05-22 06:46:42 -07:00
Brian Vaughn
36d51f4eb6 Added root selector UI to Profiler 2019-05-22 06:40:04 -07:00
Brian Vaughn
c6de014a9a Massively overhauled profiling data architecture 2019-05-22 06:05:25 -07:00
Maksim Markelov
f50f9ba5db Fix ReactFiberNewContext spelling (#15692) 2019-05-22 11:24:31 +01:00
Dominic Gannaway
e180f656f3 Flare: change flushDiscreteUpdates invariant to warning (#15702) 2019-05-22 01:09:34 +01:00
Andrew Clark
7829d8cf99 Fix missing return pointer assignment (#15700)
* Fix missing return pointer assignment

I found a bug using the fuzz tester that manifested as incorrect
ordering of children in the host tree, but whose root cause was a
missing `return` pointer assignment on a work-in-progress fiber.

Usually return pointers are set during reconciliation
(`reconcileChildFibers`) but this particular assignment happens inside
the custom reconciliation implementation used by Suspense boundaries.

I would not be surprised if there were similar bugs related to incorrect
return pointers. You're supposed to update the return pointer
whenever a work-in-progress fiber is created, but there's nothing in
the contract of the `createFiber` or `createWorkInProgress` function
that implies this. I propose that we update their signatures to accept
the return fiber as an argument. I will do this in a follow-up.

In this commit, I rearranged `updateSuspenseComponent` slightly so that
every call to `createWorkInProgress` or a `createFiber*` function is
immediately followed by a return pointer assignment.

I hardcoded the fuzz test case that surfaced the bug.

* Update all progressed children in list

`progressedPrimaryChild` is a list, not a single fiber. Need to iterate
through every child and update their return pointers.
2019-05-21 16:56:52 -07:00
Sebastian Markbåge
d7afe23f14 Rename "loading" to "busy" in SuspenseConfig API (#15699)
loadingDelayMs -> busyDelayMs
minLoadingDurationMs -> busyMinDurationMs
2019-05-21 14:29:41 -07:00
Dominic Gannaway
ef4ac42f88 [Flare] Update interactiveUpdates flushing heuristics (#15687) 2019-05-21 22:03:45 +01:00
Dan Abramov
6d4f85b611 [Fresh] Set up infra for runtime and Babel plugin (#15698)
* Add a stub for React Fresh Babel plugin package

* Move ReactFresh-test into ReactFresh top level directory

* Add a stub for React Fresh Runtime entry point

* Extract Fresh runtime from tests into its entry point
2019-05-21 21:54:10 +01:00
Dominic Gannaway
121acae090 Flare: simplify dispatchEvent discrete argument (#15694) 2019-05-21 16:06:17 +01:00
Dominic Gannaway
a398cbd5a7 Flare: update invalid accessor warnings + add no-ops (#15693) 2019-05-21 14:12:19 +01:00
Sunil Pai
9c9ea94852 flush only on exiting outermost act() (#15682) 2019-05-21 10:41:24 +01:00
Brian Vaughn
7ce9f4859c Renamed Store importedProfilingData -> profilingData 2019-05-20 10:45:16 -07:00
Brian Vaughn
f1561e9e17 Merge pull request #274 from bvaughn/commit-priority-level
Show commit priority levels in Profiler UI (if available)
2019-05-20 09:56:58 -07:00
Brian Vaughn
d440380719 Upgraded to canary with priority level info 2019-05-20 09:54:07 -07:00
Brian Vaughn
53de5b69cc Updated test snapshot 2019-05-20 09:42:37 -07:00
Brian Vaughn
16a81feb72 Moved priority level constants into rendeer interface 2019-05-20 09:39:26 -07:00
Brian Vaughn
9a6a19456f Show commit priority levels in Profiler UI 2019-05-20 09:39:26 -07:00
Brian Vaughn
50b50c26f6 Inform DevTools of commit priority level (#15664)
* Pass inferred priority level to DevTools commit hook in PROFILE mode
2019-05-20 08:37:25 -07:00
Dan Abramov
0bd9b5d006 [Fresh] Support re-rendering lazy() without losing state (#15686)
* Support re-rendering lazy() without losing state

* Clearer naming
2019-05-20 15:47:27 +01:00
Dan Abramov
ec38def44f [Fresh] Don't traverse remounted trees (#15685)
* Don't traverse children when hot reloading needs a remount

If we're gonna remount that tree anyway, there is no use in traversing its children beforehand.

* Add a test verifying hot reload batches updates

Otherwise there is a risk of it being super slow due to cascades.
2019-05-20 14:55:01 +01:00
Dan Abramov
5731e522d4 [Fresh] Support lazy() and add Suspense tests (#15681)
* Test that state is not leaked between components

* Support lazy and add Suspense tests

* Nits
2019-05-20 14:11:18 +01:00
Dan Abramov
31487dd82e [Fresh] Set up initial scaffolding (#15619)
* Add a minimal failing test for hot reload

* Set up scaffolding for React Fresh

* Consider type family when comparing elementType

Rendering an element with stale type should not cause it to remount.

We only do this for FunctionComponent tag since checking is unnecessary for classes or host components.

* Add support for forwardRef()

Initially I thought I would compare families of inner .render functions.

However, there is a corner case where this can create false positives. Such as when you forwardRef(X) the same X twice. Those are supposed to be distinct. But if we compare .render functions, we wouldn't be able to distinguish them after first reload.

It seems safer to rely on explicit registration for those. This should be easy when forwardRef() call is in the same file, and usually it would be. For cases like HOCs and style.div`...` factories that return forwardRef(), we could have the __register__ helper itself "dig deeper" and register the inner function.

* Show how forwardRef inner identity can be inferred

The __register__ implementation can read the inner identity itself.

* Add missing __DEV__ to tests

* Add support for memo() (without fixing bailouts)

This adds rudimentary support for memo components. However, we don't actually skip bailouts yet, so this is not very useful by itself alone. Tests have TODOs that we need to remove after bailout skipping is done.

* Refactor type comparison for clarity

* Hot update shouldn't re-render ancestor components unnecessarily

My code had a bug where it checked for a wrong thing in a wrong set, leading us to always re-render.

This fixes the checks so that we only schedule updates for things that were actually edited.

* Add test coverage for memo(fn, areEqual)

* Explicitly skip bailouts for hot reloading fibers

This forces even memo() with shallow comparison to re-render on hot update.

* Refactor scheduling update to reduce duplication

* Remove unused variable in test

* Don't check presence in a set while not hot reloading

* Make scheduleHotUpdate() take named arguments

* Don't keep unedited component types in the type => family map

It's unnecessary because if they haven't been edited, there's no special reconciliation logic.

* Add signatures that force remounting

Signatures let us force a remount of a type even if from React's point of view, type is the same.

A type has one current signature. If that signature changes during next hot update, all Fibers with that type should be deleted and remounted.

We do this by mutating elementType scheduling a parent.

This will be handy to force remount of mismatching Hooks, as well as failed error boundaries.

For this to fully work, we'll need to add a way to skip built-in bailouts for all Fiber types. This will be the most invasive and annoying change. I did it for HostRoot in this PR but there's more. I'll add an automated test case that catches the missing bailout bailouts.

* Support forced remounting for all component types

This teaches all parent component types to remount their child if necessary.

It also adds tests for them.

* Remount effects while preserving state for hot reloaded components

This makes sure that changes to *code* always propagate.

It can break components that aren't resilient to useEffect over-firing, but that seems like a good constraint since you might need to add a dependency later anyway, and this helps avoid coding yourself into the corner.

* Add missing __DEV__ blocks to tests

* Fix unused variables in tests

* Remove outdated TODO

* Expose scheduleHotUpdate directly

* Inline isCompatibleType

* Run one check per component for invalidating deps

This also makes the bailouts more targeted--no need to remount useEffect for a parent component of remounted fiber.

* Resolve .type early

This moves resolving to set up the right .type early instead of doing this before render.
A bit more future-proof in case we want to restructure the begin phase later.

ForwardRef is special because its type is a wrapper but it can be hot reloaded by itself.
So we have a special overload for it that reconstucts the wrapper type if needed.

* Add a Suspense todo

* Use current.type !== workInProgress.type for ignoring deps

This gets rid of one of the sets.

* Use workInProgress.type !== current.type check for force re-render

We still use a set for forced remount though.

* Use wip.type !== current.type check in more places

This also disables the remounting tests. They need a separate approach.

* Use a dedicated remount mechanism

* Add a test for offscreen trees

It has a TODO because it seems like offscreen updates are incorrectly applied too soon.

* Enable offscreen test now that it is fixed

* Fix corner cases in the new remounting mechanism

* Remount failed error boundaries on hot reload

* Fix test now that act() flushes

This test is manual so I don't actually want act here.

* Nits

* Add comments
2019-05-18 01:38:13 +01:00
Brian Vaughn
146fd2ad3d Fixed snapshot diff 2019-05-17 07:54:07 -07:00
Brian Vaughn
629e500fe2 Merge pull request #275 from lucasecdb/fix/undefined-chartnode
Fix undefined chart node when switching commits in profiler
2019-05-17 07:52:07 -07:00
Lucas Cordeiro
1e025edb9a Fix undefined chart node when switching commits in profiler 2019-05-17 09:35:10 -03:00
Sebastian Markbåge
9c6de716d0 Add withSuspenseConfig API (#15593)
* Add suspendIfNeeded API and a global scope to track it

Adds a "current" suspense config that gets applied to all updates scheduled
during the current scope.

I suspect we might want to add other types of configurations to the "batch"
so I called it the "batch config".

This works across renderers/roots but they won't actually necessarily go
into the same batch.

* Add the suspenseConfig to all updates created during this scope

* Compute expiration time based on the timeout of the suspense config

* Track if there was a processed suspenseConfig this render pass

We'll use this info to suspend a commit for longer when necessary.

* Mark suspended states that should be avoided as a separate flag

This lets us track which renders we want to suspend for a short time vs
a longer time if possible.

* Suspend until the full expiration time if something asked to suspend

* Reenable an old test that we can now repro again

* Suspend the commit even if it is complete if there is a minimum delay

This can be used to implement spinners that don't flicker if the data
and rendering is really fast.

* Default timeoutMs to low pri expiration if not provided

This is a required argument in the type signature but people may not
supply it and this is a user facing object.

* Rename to withSuspenseConfig and drop the default config

This allow opting out of suspending in some nested scope.

A lot of time when you use this function you'll use it with high level
helpers. Those helpers often want to accept some additional configuration
for suspense and if it should suspend at all. The easiest way is to just
have the api accept null or a suspense config and pass it through. However,
then you have to remember that calling suspendIfNeeded has a default.

It gets simpler by just saying tat you can pass the config. You can have
your own default in user space.

* Track the largest suspense config expiration separately

This ensures that if we've scheduled lower pri work that doesn't have a
suspenseConfig, we don't consider its expiration as the timeout.

* Add basic tests for functionality using each update mechanism

* Fix issue when newly created avoided boundary doesn't suspend with delay

* Add test for loading indicator with minLoadingDurationMs option
2019-05-16 16:51:18 -07:00
Dominic Gannaway
1160b37691 Event API: Add responder allowMultipleHostChildren flag (#15646) 2019-05-16 19:03:38 +01:00
Dominic Gannaway
95e06ac3d0 Event API: isTargetWithinEventResponderScope on unmounted event components (#15672) 2019-05-16 18:59:59 +01:00
Sunil Pai
d278a3ff8b act() - s / flushPassiveEffects / Scheduler.unstable_flushWithoutYielding (#15591)
* s/flushPassiveEffects/unstable_flushWithoutYielding

a first crack at flushing the scheduler manually from inside act(). uses unstable_flushWithoutYielding(). The tests that changed, mostly replaced toFlushAndYield(...) with toHaveYielded(). For some tests that tested the state of the tree before flushing effects (but still after updates), I replaced act() with bacthedUpdates().

* ugh lint

* pass build, flushPassiveEffects returns nothing now

* pass test-fire

* flush all work (not just effects), add a compatibility mode

of note, unstable_flushWithoutYielding now returns a boolean much like flushPassiveEffects

* umd build for scheduler/unstable_mock, pass the fixture with it

* add a comment to Shcduler.umd.js for why we're exporting unstable_flushWithoutYielding

* run testsutilsact tests in both sync/concurrent modes

* augh lint

* use a feature flag for the missing mock scheduler warning

I also tried writing a test for it, but couldn't get the scheduler to unmock. included the failing test.

* Update ReactTestUtilsAct-test.js

- pass the mock scheduler warning test,
- rewrite some tests to use Scheduler.yieldValue
- structure concurrent/legacy suites neatly

* pass failing tests in batchedmode-test

* fix pretty/lint/import errors

* pass test-build

* nit: pull .create(null) out of the act() call
2019-05-16 17:12:36 +01:00
Dominic Gannaway
aad5a264d2 Event API: ensure calculateResponderRegion accounts for page offset (#15671) 2019-05-16 17:09:41 +01:00
Dan Abramov
bb89b4eacc Bail out of updates in offscreen trees (#15666)
* Bail out of updates in offscreen trees

* Address review
2019-05-16 11:12:05 +01:00
Andrew Cherniavskii
4bf88ddeca Fix <embed> not triggering onLoad (#15614) 2019-05-16 11:05:20 +02:00
Andrew Clark
f961050a37 Always flushPassiveEffects before rendering
I  mistakenly wrapped this in the revertPassiveEffectsChange feature
flag. It should flush regardless of the flag.
2019-05-15 18:13:05 -07:00
Andrew Clark
b899819e77 Use dynamic flag in test renderer in www (#15662)
Uses a dynamic flag in www's test renderer build so we can condtionally
disable the passive effects bugfix. Matches the dynamic flag used in
the www React DOM build.
2019-05-15 14:55:50 -07:00
Brian Vaughn
f10a6b379c Improve scanning Profiler chart for deep renders 2019-05-15 14:20:36 -07:00
Andrew Clark
d34b457ce2 Feature flag to revert #15650 (#15659)
PR #15650 is a bugfix but it's technically a semantic change that could
cause regressions. I don't think it will be an issue, since the
previous behavior was both broken and incoherent, but out of an
abundance of caution, let's wrap it in a flag so we can easily revert
it if necessary.
2019-05-15 13:38:06 -07:00
Andrew Clark
668fbd651b Fix serial passive effects (#15650)
* Failing test for false positive warning

* Flush passive effects before discrete events

Currently, we check for pending passive effects inside the `setState`
method before we add additional updates to the queue, in case those
pending effects also add things to the queue.

However, the `setState` method is too late, because the event that
caused the update might not have ever fired had the passive effects
flushed before we got there.

This is the same as the discrete/serial events problem. When a serial
update comes in, and there's already a pending serial update, we have to
do it before we call the user-provided event handlers. Because the event
handlers themselves might change as a result of the pending update.

This commit moves the `flushPassiveEffects` call to before the discrete
event handlers are called, and removes it from the `setState` method.
Non-discrete events will not cause passive effects to flush, which is
fine, since by definition they are not order dependent.
2019-05-14 18:08:10 -07:00
Dominic Gannaway
b0657fde6a Event API: ensure getFocusableElementsInScope handles suspended trees (#15651) 2019-05-15 01:08:30 +01:00
Sebastian Markbåge
8af90c8972 Add test for nested avoided boundaries (#15636)
* Add test for nested avoided boundaries

* Add test for top level avoided boundaries
2019-05-14 14:41:45 -07:00
Brian Vaughn
6fd2e72b5e Minor nits 2019-05-14 11:01:41 -07:00
Dominic Gannaway
af19e2eb2f Event API: adds pointerType to Focus events (#15645) 2019-05-14 15:59:36 +01:00
Ivan Babak
76e569992b Cleanup profile export/import data types, add export/import test
Strengthened the I/O-boundary type conversion logic.

Fixed type inconsistencies uncovered by removing `any` and
by making explicit type annotations and transformations.

In particular, these were likely malformed when restored from a file:
- `commitDetails`
- `interactions`
- `initialTreeBaseDurations`

The mismatches were Map vs interleaved Array.
2019-05-13 23:59:01 -07:00
Andrew Clark
cc24d0ea56 Invariant that throws when committing wrong tree (#15517)
If React finishes rendering a tree, delays committing it (e.g.
Suspense), then subsequently starts over or renders a new tree, the
pending tree is no longer valid. That's because rendering a new work-in
progress mutates the old one in place.

The current structure of the work loop makes this hard to reason about
because, although `renderRoot` and `commitRoot` are separate functions,
they can't be interleaved. If they are interleaved by accident, it
either results in inconsistent render output or invariant violations
that are hard to debug.

This commit adds an invariant that throws if the new tree is the same as
the old one. This won't prevent all bugs of this class, but it should
catch the most common kind.

To implement the invariant, I store the finished tree on a field on the
root. We already had a field for this, but it was only being used for
the unstable `createBatch` feature.

A more rigorous way to address this type of problem could be to unify
`renderRoot` and `commitRoot` into a single function, so that it's
harder to accidentally interleave the two phases. I plan to do something
like this in a follow-up.
2019-05-13 16:15:50 -07:00
Andrew Clark
83fc258f29 Remove <ConcurrentMode /> (#15532)
Use createSyncRoot instead.
2019-05-13 16:10:00 -07:00
Andrew Clark
283ce53204 Add ReactDOM.unstable_createSyncRoot (#15504)
* Add ReactDOM.unstable_createSyncRoot

- `ReactDOM.unstable_createRoot` creates a Concurrent Mode root.
- `ReactDOM.unstable_createSyncRoot` creates a Batched Mode root. It
does not support `createBatch`.
- `ReactDOM.render` creates a Legacy Mode root. It will eventually be
deprecated and possibly moved to a separate entry point, like
`react-dom/legacy`.

* Rename internal ReactRoot types
2019-05-13 15:30:03 -07:00
Brian Vaughn
1723c5d316 Changed "Unknown" fallback displayName to "Anonymous". Added memo/forwardRef labels to Profiler charts. 2019-05-13 15:26:14 -07:00
Brian Vaughn
6b4c758338 CSS tweaks 2019-05-13 14:51:56 -07:00
Andrew Clark
862f499fac Add Batched Mode (#15502)
* Add Batched Mode

React has an unfortunate quirk where updates are sometimes synchronous
-- where React starts rendering immediately within the call stack of
`setState` — and sometimes batched, where updates are flushed at the
end of the current event. Any update that originates within the call
stack of the React event system is batched. This encompasses most
updates, since most updates originate from an event handler like
`onClick` or `onChange`. It also includes updates triggered by lifecycle
methods or effects. But there are also updates that originate outside
React's event system, like timer events, network events, and microtasks
(promise resolution handlers). These are not batched, which results in
both worse performance (multiple render passes instead of single one)
and confusing semantics.

Ideally all updates would be batched by default. Unfortunately, it's
easy for components to accidentally rely on this behavior, so changing
it could break existing apps in subtle ways.

One way to move to a batched-by-default model is to opt into Concurrent
Mode (still experimental). But Concurrent Mode introduces additional
semantic changes that apps may not be ready to adopt.

This commit introduces an additional mode called Batched Mode. Batched
Mode enables a batched-by-default model that defers all updates to the
next React event. Once it begins rendering, React will not yield to
the browser until the entire render is finished.

Batched Mode is superset of Strict Mode. It fires all the same warnings.
It also drops the forked Suspense behavior used by Legacy Mode, in favor
of the proper semantics used by Concurrent Mode.

I have not added any public APIs that expose the new mode yet. I'll do
that in subsequent commits.

* Suspense in Batched Mode

Should have same semantics as Concurrent Mode.

* Use RootTag field to configure type of root

There are three types of roots: Legacy, Batched, and Concurrent.

* flushSync should not flush batched work

Treat Sync and Batched expiration times separately. Only Sync updates
are pushed to our internal queue of synchronous callbacks.

Renamed `flushImmediateQueue` to `flushSyncCallbackQueue` for clarity.
2019-05-13 14:30:39 -07:00
Brian Vaughn
e2746ffd0e Merge branch 'enhancement/display-change' of https://github.com/submetu/react-devtools-experimental into submetu-enhancement/display-change 2019-05-13 14:12:27 -07:00
Brian Vaughn
982eb84a13 Merge pull request #271 from tux-tn/master
Replaced adm-zip with node-archiver
2019-05-13 14:10:21 -07:00
Brian Vaughn
d9a0c42652 Bumped Profiler export version (since self durations are now included) 2019-05-13 14:04:53 -07:00
Brian Vaughn
cf99c3ee6c Moved calculation of self duration to the backend/renderer
This enables self duration to be computed accurately despite component filters
2019-05-13 10:13:29 -07:00
Subhan
74706b0c86 updates snapshots 2019-05-13 19:00:11 +02:00
Subhan
ec89ae88b6 Changes display of ForwardRef and Memo components 2019-05-13 18:58:03 +02:00
Dominic Gannaway
fec74f99da Event API: ensure preventDefault works for nested targets (#15633) 2019-05-13 13:45:48 +01:00
Sarhan Aissi
ad94f9ef08 Replaced adm-zip with node-archiver 2019-05-13 03:55:05 +01:00
Brian Vaughn
ffef7ffc57 Merge pull request #268 from frankcalise/master
Fixed build chrome not working on Windows due to rm command not existing
2019-05-12 07:43:19 -07:00
Brian Vaughn
faea8ed6a9 Delete package-lock.json 2019-05-12 07:43:07 -07:00
Frank Calise
285568825b Fixed build chrome not working on Windows due to rm command not existing 2019-05-12 10:12:17 -04:00
Andrew Clark
edfedf3ae9 Fork ReactSharedInternals for UMD builds (#15617) 2019-05-10 13:51:39 -07:00
Andrew Clark
39ef609e7c Update test to fix CI 2019-05-10 11:12:24 -07:00
Andrew Clark
5b6eb55e1c Remove scheduler from React package dependencies (#15616)
Scheduler is used by the renderers, but not the isomorphic package.
2019-05-10 11:01:04 -07:00
Sebastian Markbåge
0803d22479 Don't consider "Never" expiration as part of most recent event time (#15606)
* Don't consider "Never" expiration as part of most recent event time

This doesn't happen with deprioritization since those are not "updates"
by themselves so they don't go into this accounting.

However, they are real updates if they were scheduled as Idle pri using
the scheduler explicitly. It's unclear what suspense should do for these
updates. For offscreen work, we probably want them to commit immediately.
No point in delay them since they're offscreen anyway. However if this is
an explicit but very low priority update that might not make sense.
So maybe this means that these should have different expiration times?

In this PR I just set the suspense to the lowest JND.

However, we don't want is for these things to commit earlier in case
they got batched in with other work so I also ensured that they're not
accounted for in in the workInProgressRootMostRecentEventTime calculation
at all. This makes them commit immediately if they're by themselves, or
after the JND of whatever they were batched in with.

Ultimately, I think that we should probably never schedule anything at
Never that isn't truly offscreen so this should never happen.

However, that begs the question what happens with very low pri work that
suspends. Do we always work at that level first?

* Adjust test to account for the new shorter suspense time
2019-05-10 10:53:20 -07:00
Brian Vaughn
b74f3f507a Added basic tests for InspectedElementContext 2019-05-10 09:13:54 -07:00
Brian Vaughn
61ab40c15c Test utils actSuspense -> actAsync 2019-05-10 08:27:14 -07:00
Brian Vaughn
8536995b11 Merge pull request #264 from bvaughn/filter-owners-list
Fetch owners list from renderer (using suspense)
2019-05-10 08:10:24 -07:00
Brian Vaughn
ac0022bf4a Added more tree context tests 2019-05-10 08:07:27 -07:00
Dominic Gannaway
90f54d77f3 Event API: add follow up event unwind test (#15612) 2019-05-10 13:36:54 +01:00
Dominic Gannaway
91a044e31f Event API: add key modifiers to Press events (#15611) 2019-05-10 13:32:11 +01:00
Sunil Pai
7aaef6f41f reverting the rename 2019-05-10 12:18:40 +01:00
Sunil Pai
6243d19b9c pretty, witty, fine 2019-05-10 12:16:43 +01:00
Sunil Pai
ae3b98f5ad rewrite test act helpers based on react/#15591
This simplifies your test helpers to loop until all timers are flushed (including the ones that get queued after updates), and works in concurrent mode. I also renamed actSuspense to actAsync to be clearer.
2019-05-10 12:13:14 +01:00
Brian Vaughn
7160f6f584 Fixed owners stack direction and added current element to stack 2019-05-09 18:11:17 -07:00
Brian Vaughn
427f0f63c1 Added TreeContext tests 2019-05-09 15:52:50 -07:00
Brian Vaughn
5daf9b626f Fixed test describe name 2019-05-09 14:31:48 -07:00
Brian Vaughn
b6c135c165 Added Jest tests for OwnersListContext 2019-05-09 14:21:22 -07:00
Brian Vaughn
564a223368 Fetch owners list from renderer (using suspense)
Owners in the list may have been filtered out of the Store, but in the owners list view- it's important to still show them. The frontend cannot do this on its own, so this list needs to come from the renderer interface.
2019-05-09 11:47:22 -07:00
Dominic Gannaway
3d8b836e22 Event API: ensure we pop context for event system fibers (#15599) 2019-05-09 17:01:18 +01:00
Dominic Gannaway
e33e32db04 Event API: normalize event timeStamp property to be in event system (#15598) 2019-05-09 16:05:25 +01:00
Dominic Gannaway
3669b90101 Event API: add more warnings for responder based events (#15597) 2019-05-09 15:31:18 +01:00
Brian Vaughn
17516b76ae Dim owners that have been filtered from the tree in rendered-by list 2019-05-08 18:23:54 -07:00
Brian Vaughn
0722a5a024 Tweaked REAMDE 2019-05-08 17:58:31 -07:00
Brian Vaughn
ee099124e2 Fixed a Profiler memoization bug and improved test coverage 2019-05-08 15:41:57 -07:00
Brian Vaughn
d42f86bb50 Updated Profiling chart tests to cover components with duration=0 2019-05-08 14:35:43 -07:00
Brian Vaughn
df10afba51 Merge pull request #262 from submetu/enhancement/label-improvement
Profiler: Improve labels for times that round to 0.0ms
2019-05-08 14:26:16 -07:00
Brian Vaughn
4f1d347c04 Custom filters are applied by default after extension reload 2019-05-08 14:22:06 -07:00
Subhan
34a38dc4f0 updates snapshots and removes extra formatting from formatTime 2019-05-08 23:33:26 +03:00
Subhan
d3522f1f66 Uses FormDuration and FormTime to format times that are 0 into something more readable 2019-05-08 23:18:43 +03:00
Brian Vaughn
98260f8614 Added installation instructions to README 2019-05-08 12:53:22 -07:00
Dominic Gannaway
05d08500b2 Experimental Event API: Press event properties (#15586) 2019-05-08 20:29:03 +01:00
Dominic Gannaway
51e66cf9fa Experimental Event API: reduce code size of event modules (#15590) 2019-05-08 19:09:32 +01:00
Dominic Gannaway
8abf243b86 Ensure touch events are properly handled for pageX and pageY (#15587) 2019-05-08 19:08:15 +01:00
Brian Vaughn
703706b40f Add toggle-suspense button to all elements
This button is disabled if the renderer returns canToggleSuspense=false.
2019-05-08 10:50:32 -07:00
Brian Vaughn
dbe68f7a67 Updated lint ignore for new dev shell dist folder 2019-05-08 08:52:48 -07:00
Subhan
60511aadc0 Profiler: Improve labels for times that round to 0.0ms 2019-05-08 10:11:52 +03:00
Sebastian Markbåge
c7398f3396 Add Suspense Boundary Context (and unstable_avoidThisFallback) (#15578)
* Avoidable suspense boundaries

* Move the context out of SuspenseComponent

* Use setDefaultShallowSuspenseContext instead of passing 0
2019-05-07 18:08:05 -07:00
Andrew Clark
f9e60c8a19 Warn when suspending at wrong priority (#15492)
* Warn when suspending at wrong priority

Adds a warning when a user-blocking update is suspended.

Ideally, all we would need to do is check the current priority level.
But we currently have no rigorous way to distinguish work that was
scheduled at user- blocking priority from work that expired a bit and
was "upgraded" to a higher priority. That's because we don't schedule
separate callbacks for every level, only the highest priority level per
root. The priority of subsequent levels is inferred from the expiration
time, but this is an imprecise heuristic.

However, we do store the last discrete pending update per root. So we
can reliably compare to that one. (If we broaden this warning to include
high pri updates that aren't discrete, then this won't be sufficient.)

My rationale is that it's better for this warning to have false
negatives than false positives.

Potential follow-ups:
- Bikeshed more on the message. I don't like what I landed on that much
but I think it's good enough to start.
- Include the names of the components that updated. (The ideal place to
fire the warning is during the setState call but we don't know if
something will suspend until the next update. Maybe we could be clever
and warn during a subsequent update to the same component?)

* Move Suspense priority check to throwException
2019-05-07 16:50:04 -07:00
Brian Vaughn
a54581c2dd Fixed invalid DOM nesting warning 2019-05-07 15:25:17 -07:00
Brian Vaughn
44e90e6ef4 Upgrade @reach UI and remove tooltip fork 2019-05-07 15:22:57 -07:00
Brian Vaughn
97b7fdd2d9 Fixed a deprecated prop warning from react-window 2019-05-07 14:47:37 -07:00
Brian Vaughn
278661715c Show import error dialog if profiling data import fails 2019-05-07 14:38:11 -07:00
Brian Vaughn
acdc9bae67 Added export+import profiling data test coverage
Also fixed an incomplete import feature as well as a regression in export that had gone unnoticed due to previous lack of test coverage.
2019-05-07 13:08:46 -07:00
Nicolas Gallagher
89d8d1435f Add React.unstable_createEventComponent (#15580)
API for creating event components from event responders.
2019-05-07 12:36:42 -07:00
Brian Vaughn
90701815b6 Merge pull request #258 from bvaughn/profiler-test-experiments
Added profiler tests
2019-05-06 14:00:45 -07:00
Brian Vaughn
7ead699714 Prettier 2019-05-06 13:58:49 -07:00
Brian Vaughn
6ab8972345 Update to React canary release for interaction tracing bugfix 2019-05-06 13:52:27 -07:00
Brian Vaughn
c2bf71f406 Added commit tree builder test 2019-05-06 13:41:36 -07:00
Brian Vaughn
b25d996fc4 Added profiling chart data tests 2019-05-06 13:37:06 -07:00
Brian Vaughn
d86bc1020e Hardened tests to ensure expectations are flushed 2019-05-06 13:04:14 -07:00
Brian Vaughn
6da04b5d88 Fix interaction tracing for batched update mounts (#15567)
* Added failing test for act+interaction tracing
* Mark pending interactions on root for legacy unbatched phase
2019-05-06 12:59:48 -07:00
Dominic Gannaway
d38cfd452f Ensure TouchHitTarget element is server side rendered with hit slop (#15385)
* Follow up to 15381

* Add back in hit slop properties

* Prettier

* Fix lint

* move hydration update out of DEV block

* Remove pointer-events:auto
2019-05-06 20:13:23 +01:00
Brian Vaughn
705cd9b109 Added Flow types to profiling test 2019-05-06 09:44:01 -07:00
Brian Vaughn
c29483122c Removed outdated TODO comment 2019-05-05 09:56:54 -07:00
Brian Vaughn
269969b645 Updated snapshot data after ReactDOM batch fix 2019-05-05 09:52:27 -07:00
Brian Vaughn
1c49a7ef59 Added remaining profiling tests. One currently fails because of a bug with act() and interaction tracing 2019-05-04 14:22:50 -07:00
Brian Vaughn
da1e5776b1 Added a second Profiling test (for CommitDetails) and fixed some module reset prolems 2019-05-04 13:11:56 -07:00
Brian Vaughn
dd96b3314c Cleaned up tests a bit. Profiling test uses mock timers now. 2019-05-04 09:36:13 -07:00
Nicolas Gallagher
2e5d1a8b9e React Events: fix cancel events for Press (#15563)
* Fixes a bug in the cancellation logic. The cancel events are now correctly listened to on the root.
* Fixes cancellation in Safari by using the dragstart event as a proxy for cancellation (i.e., the event dispatched when move-during-press occurs on an anchor tag)
2019-05-03 15:33:21 -07:00
Brian Vaughn
f7c8e3a05c Experimenting with profiler tests 2019-05-03 15:01:26 -07:00
Brian Vaughn
a8ed95445c Store profiler snapshot data by root (and clear on root unmount) 2019-05-03 14:59:20 -07:00
Nicolas Gallagher
307e0a7d7d React Events: cancel onLongPress for large enough moves (#15562)
Implements the behaviour from React Native's Pressability.
2019-05-03 12:59:55 -07:00
Dominic Gannaway
339366c461 Event API: Support press reentry for pointer events (#15560) 2019-05-03 18:32:50 +01:00
Brian Vaughn
a552b7b5f7 Only clear Profiling snapshot on root-unmount 2019-05-03 10:12:45 -07:00
Brian Vaughn
73cf0fa32b Merge branch 'master' into sompylasar-232-clear-profiling-data-for-unmounted-root 2019-05-03 10:01:43 -07:00
Brian Vaughn
542409954a Merge pull request #257 from bvaughn/right-align-flame-graph
Right-align flame graph children
2019-05-03 10:01:23 -07:00
Brian Vaughn
8585ee37db Renamed assertOneMap -> assertEmptyMap 2019-05-03 09:30:48 -07:00
Brian Vaughn
8850a9a64a Merge branch '232-clear-profiling-data-for-unmounted-root' of https://github.com/sompylasar/react-devtools-experimental into sompylasar-232-clear-profiling-data-for-unmounted-root 2019-05-03 09:24:58 -07:00
Brian Vaughn
e71bda5257 Right-align flame graph children 2019-05-03 09:21:26 -07:00
Brian Vaughn
435e22ad1b Fixed deploy script 2019-05-03 08:55:31 -07:00
Brian Vaughn
07281993d1 Merge pull request #242 from sompylasar/improve-flow-coverage-any
Improve Flow coverage by reducing typecasts through `any`
2019-05-03 08:00:47 -07:00
Brian Vaughn
868cf67aa4 Removed findCurrentFiberUsingSlowPath() in favor of findCurrentFiberUsingSlowPathById() 2019-05-03 07:56:24 -07:00
Brian Vaughn
7f4482e438 Removed optional_chaining from Flow config 2019-05-03 07:48:30 -07:00
Brian Vaughn
40ed0ca839 Merge branch '165-add-flow-types-for-fiber' of https://github.com/sompylasar/react-devtools-experimental into sompylasar-165-add-flow-types-for-fiber 2019-05-03 07:48:21 -07:00
Brian Vaughn
4bf3ac1910 Fixed broken path-selection after filter changes 2019-05-02 15:21:29 -07:00
Brian Vaughn
d7447a8458 Fixed bug in Store.getIndexOfElementID() that caused roots with multiple top-level children to return an incorrect item index 2019-05-02 15:12:57 -07:00
Brian Vaughn
4e04907d13 Added badge for enabled filter count 2019-05-02 10:53:40 -07:00
Brian Vaughn
ef596be1ef Merge pull request #207 from sompylasar/131-highlight-all-children
Support highlighting of all DOM elements of Fragments, not just first
2019-05-02 08:31:22 -07:00
Brian Vaughn
1473e9efc8 Merge pull request #245 from bvaughn/custom-filtering
Add configurable component filters
2019-05-01 17:52:27 -07:00
Brian Vaughn
83b521c7b4 Updated Flamechart to support multiple nodes at root 2019-05-01 17:44:38 -07:00
Brian Vaughn
4a4786ac2f Misc cleanup 2019-05-01 14:18:20 -07:00
Brian Vaughn
e6da4b9058 Renamed FilterType -> ComponentFilterType 2019-05-01 14:01:03 -07:00
Brian Vaughn
e45deb5471 Removed $FlowFixMe comments 2019-05-01 13:59:54 -07:00
Brian Vaughn
540207901d Added some component filtering tests 2019-05-01 13:31:55 -07:00
Brian Vaughn
8429220164 Added filter UI (but with a lot of $FlowFixMe comments) 2019-05-01 10:45:18 -07:00
Brian Vaughn
0b4bfbc98f Add support for hide-by-name and hide-by-path component filter regexps 2019-05-01 10:45:18 -07:00
Brian Vaughn
a2ba90bf96 Fixed a path selection bug when filter pereferences are updated 2019-05-01 10:45:18 -07:00
Brian Vaughn
c4c51c0821 Prevent filter preference changes while profiling is active 2019-05-01 10:45:18 -07:00
Brian Vaughn
eb9705abc8 Removed FilterList UI for now (collapsed into Settings component) 2019-05-01 10:45:18 -07:00
Brian Vaughn
a241780dc2 Filter changes are applied to the renderer without reloading 2019-05-01 10:45:18 -07:00
Brian Vaughn
27a1820039 Refactored filter preferences a bit more to be stored in the Store 2019-05-01 10:45:18 -07:00
Brian Vaughn
ee1b38e4db Added filter preference types and plugged into renderer partly. Lots of work to do still. 2019-05-01 10:45:18 -07:00
Brian Vaughn
9db209ee64 Initial pass at adding filter-by-type Flow types and support to renderer 2019-05-01 10:45:18 -07:00
Brian Vaughn
17c5feb66a Reorganized types shared between backend and frontend slightly. 2019-05-01 10:45:18 -07:00
Brian Vaughn
18b34b4926 Rearranged Settings UI in prep for custom filter controls 2019-05-01 10:45:18 -07:00
Brian Vaughn
a9aa9f2106 Merge pull request #251 from gaearon/devserver
Use WebpackDevServer for local testing
2019-05-01 09:29:43 -07:00
Dan Abramov
b9ae9393b9 Use WebpackDevServer for local testing 2019-05-01 17:19:26 +01:00
Ivan Babak
cd89c0d75f Clear profiling data for root when the root is unmounted
Fixes https://github.com/bvaughn/react-devtools-experimental/issues/232
2019-05-01 01:46:47 -07:00
Ivan Babak
c6c71ef8f9 Fix profiling screenshots data structure to map rootID to commitIndex
Propagate `rootID` throughout the code for `captureScreenshot`.

Rename private profiling maps of `store` to make relations more clear.

Fix missing cleanup for screenshots data in `set importedProfilingData` of `store`.
2019-05-01 01:07:36 -07:00
Ivan Babak
d1f6e762e4 Improve Flow coverage by reducing typecasts through any
There are many unnecessary typecasts through `any` which
break the Flow of types across the program.

It's more bulletproof to avoid lying to ourselves about types.

Also fixed sketchy null check where zero ID would be skipped:
```diff
-  } else if (selectedElementID) {
+  } else if (selectedElementID !== null) {
```
2019-05-01 00:31:13 -07:00
Dominic Gannaway
ec6691a687 Event API: remove isTargetDirectlyWithinEventComponent (#15546) 2019-04-30 17:38:48 +01:00
Brian Vaughn
abcb613223 Minor Bridge code tweaks:
1. Renamed a variable
2. Coerced undefined to null
3. Added a couple of console.warn() for unexpected paths
2019-04-30 09:23:11 -07:00
Brian Vaughn
5204ae87bc Merge pull request #229 from sompylasar/217-workaround-disconnected-port-error
Fix for 'Attempting to use a disconnected port object'
2019-04-30 09:15:52 -07:00
Brian Vaughn
b24216a7b1 Merge pull request #234 from gaearon/nested-suspense-test
Add test coverage for nested Suspense
2019-04-30 08:51:58 -07:00
Brian Vaughn
9e1b1e8c91 Merge pull request #233 from gaearon/preset-env
Start using @babel/preset-env
2019-04-30 08:50:17 -07:00
Brian Vaughn
da951ec9bb Merge pull request #243 from sompylasar/rename-profiler-types-to-frontend-backend-to-disambiguate
Rename Profiler types to disambiguate which is Frontend and Backend
2019-04-30 08:47:05 -07:00
Brian Vaughn
44205f16d9 Merge pull request #247 from sompylasar/fix-flow-on-circleci
Fix Flow failure on CircleCI due to the number of workers
2019-04-30 08:32:37 -07:00
Dominic Gannaway
a6e30001fb Delete duplicate Focus.js (#15540)
This file was renamed to the lower case version, but as Mac filesystems are typically case insensitive, it was never removed.
2019-04-30 12:20:44 +01:00
Dominic Gannaway
f7993d5477 Delete duplicate Hover.js (#15539)
This file was renamed to the lower case version, but as Mac filesystems are typically case insensitive, it was never removed.
2019-04-30 12:13:07 +01:00
Dominic Gannaway
c8ee10037a Delete duplicate Swipe.js (#15541)
This file was renamed to the lower case version, but as Mac filesystems are typically case insensitive, it was never removed.
2019-04-30 12:11:26 +01:00
Dominic Gannaway
494716c9b4 Delete duplicate Drag.js (#15537)
This file was renamed to the lower case version, but as Mac filesystems are typically case insensitive, it was never removed.
2019-04-30 12:07:24 +01:00
Dominic Gannaway
377846fef8 Delete duplicate Press.js (#15538)
This file was renamed to the lower case version, but as Mac filesystems are typically case insensitive, it was never removed.
2019-04-30 12:06:44 +01:00
Dominic Gannaway
379515e83e Follow up to 15535 (#15536) 2019-04-30 12:04:19 +01:00
Dominic Gannaway
bd88982fbf Event API: use capture for all event listeners using experimental responder system (#15526) 2019-04-30 11:40:45 +01:00
Ivan Babak
bfbde71657 Fix Flow failure on CircleCI due to the number of workers
https://github.com/flowtype/flow-bin/issues/138#issuecomment-448416874
https://github.com/flowtype/flow-bin/issues/138#issuecomment-450367472

> This will stop flow from trying to consume too many virtual CPUs (which CircleCI doesn't actually provide), letting it run to completion without first running out of memory and killing its sub processes.

The log output in CircleCI was:
https://circleci.com/gh/bvaughn/react-devtools-experimental/201
```
#!/bin/bash -eo pipefail
yarn flow
yarn run v1.10.1
$ /home/circleci/repo/node_modules/.bin/flow
Launching Flow server for /home/circleci/repo
Spawned flow server (pid=259)
Logs will go to /tmp/flow/zShomezScirclecizSrepo.log
Monitor logs will go to /tmp/flow/zShomezScirclecizSrepo.monitor_log
Launching Flow server for /home/circleci/repo
Spawned flow server (pid=361)
Logs will go to /tmp/flow/zShomezScirclecizSrepo.log
Monitor logs will go to /tmp/flow/zShomezScirclecizSrepo.monitor_log
Launching Flow server for /home/circleci/repo
Spawned flow server (pid=464)
Logs will go to /tmp/flow/zShomezScirclecizSrepo.log
Monitor logs will go to /tmp/flow/zShomezScirclecizSrepo.monitor_log
Launching Flow server for /home/circleci/repo
Spawned flow server (pid=567)
Logs will go to /tmp/flow/zShomezScirclecizSrepo.log
Monitor logs will go to /tmp/flow/zShomezScirclecizSrepo.monitor_log
Lost connection to the flow server (0 retries remaining): -Out of retries, exiting!
error Command failed with exit code 7.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Exited with code 1
```
2019-04-29 21:56:53 -07:00
Andrew Clark
72ca3c60e7 Bump scheduler version to 0.14.0 (#15395) 2019-04-29 18:10:11 -07:00
Andrew Clark
7882c41f60 Use lowercase entry points for event modules (#15535)
Matches npm convention
2019-04-29 16:25:56 -07:00
Nathan Schloss
43c4e5f348 Add method for forcing a lower framerate 2019-04-29 15:51:58 -07:00
Brian Vaughn
1b752f1914 Fixed potential interaction tracing leak in Suspense thennable memoization (#15531)
Audited the other places we call unstable_wrap() in React DOM and verified that they didn't have this similar problem.
2019-04-29 15:04:52 -07:00
Eli White
12e5a13cf2 [React Native] Inline calls to FabricUIManager in shared code (#15490)
* [React Native] Inline calls to FabricUIManager in shared code

* Call global.nativeFabricUIManager directly as short term fix

* Add flow types

* Add nativeFabricUIManager global to eslint config

* Adding eslint global to bundle validation script
2019-04-29 14:31:16 -07:00
Nicolas Gallagher
2cca18728e React Events: add onFocusVisibleChange to Focus (#15516)
Called when focus visibility changes. Focus is only considered visible if a
focus event occurs after keyboard navigation. This provides a way for people to
provide visual focus styles for keyboard accessible UIs without those styles
appearing if focus is triggered by mouse, touch, pen.
2019-04-29 13:52:15 -07:00
Ivan Babak
d35cf80921 Remove Fiber type properties we don't use in DevTools 2019-04-28 12:57:28 -07:00
Dan Abramov
d351b46aee Merge pull request #238 from sompylasar/fix-typo-recursivelyinitializetree
Fix typo `recursivelyIniitliazeTree` -> `recursivelyInitializeTree`
2019-04-28 13:38:49 +01:00
Dan Abramov
7c04883f8d Merge pull request #239 from sompylasar/remove-agent-addbridge
Remove Agent addBridge: there can only be one bridge, add in constructor
2019-04-28 13:38:34 +01:00
Ivan Babak
1b5f043e01 Fix for 'Attempting to use a disconnected port object'
Fixes https://github.com/bvaughn/react-devtools-experimental/issues/217

The error reproduces with any two React websites, e.g. `https://reactjs.org` and `https://nextjs.org`, by keeping the DevTools Components tab open and switching between these websites in the same browser tab.

There are several issues with the code that contribute to this:
1. `Bridge` leaves behind a dangling timer that fires `_flush` after the bridge has been abandoned ("shutdown").
2. `bridge.send('shutdown')` is asynchronous, so the event handlers do not get unsubscribed in time.
3. `port.onDisconnect` does not trigger on in-tab navigation like new URL or back/forward navigation.
4. State management design of the code that uses shared variables and callbacks makes it hard to handle race conditions originating from the browser.

This commit cleans up some of the lacking symmetry when using `addListener`/`removeListener`, but the code in `shells/browser/shared/src/main.js` is hard to reason about with regards to race conditions, and there are many possible race conditions originating from the browser, so maybe there could be a better design paradigm (like a formal state machine) to manage the state changes in response to sequences of events than plain old event listeners, callbacks, and shared variables.

Unrelated, but clicking Chrome Back/Forward/Back/Forward very fast makes the browser and the DevTools and the DevTools of DevTools stall and become unresponsive for some time, then recovers but the Back/Forward/Stop/Refresh button and favicon loading indicator may remain broken. Looks like a Chrome bug, some kind of a temporary deadlock in handling the browser history.
2019-04-28 04:45:57 -07:00
Ivan Babak
d3e5fcd81c Rename Profiler types to disambiguate which is Frontend and Backend
Flow IDE shows the original type, not the file-scoped alias,
so it's confusing to see incompatible variables that have types
with the same name.

This started from `src/devtools/ProfilingCache.js` where
`ProfilingSummary` was incompatible, but I decided to make a bigger
change for consistency and to avoid similar mistakes in the future.
2019-04-28 04:40:39 -07:00
Ivan Babak
9f06bc345f Add Flow types for Fiber
Fixes https://github.com/bvaughn/react-devtools-experimental/issues/165
2019-04-28 04:18:27 -07:00
Ivan Babak
0b817777b4 Remove Agent addBridge: there can only be one bridge, add in constructor
Let's make impossible states truly impossible, and fix Flow types, too.

All three usages of Agent called addBridge right after constructing it.
Agent has one field `_bridge` which is force-typed as not-null despite
there's a temporary zone between the constructor end and addBridge start
where `_bridge` is null.
2019-04-28 04:03:28 -07:00
Ivan Babak
19bfba7943 Fix typo recursivelyIniitliazeTree -> recursivelyInitializeTree 2019-04-28 03:52:33 -07:00
Nicolas Gallagher
cc5a49379b React Events: FocusScope tweaks and docs (#15515)
* FocusScope: rename trap to contain.
* FocusScope: avoid potential for el.focus() errors.
* FocusScope: add docs.
* Update docs formatting.
2019-04-26 13:38:01 -07:00
Dominic Gannaway
796c67a25f Event API: responder event types should not re-register on EventComponent update (#15514) 2019-04-26 21:33:54 +01:00
Dan Abramov
d81d74b236 Add test coverage for nested Suspense 2019-04-26 20:04:28 +01:00
Dan Abramov
e5ed266873 Start using @babel/preset-env 2019-04-26 19:37:23 +01:00
Dan Abramov
2118b1fe1b Merge pull request #230 from gaearon/assert-maps
Assert empty maps when there are no roots
2019-04-26 18:15:04 +01:00
Dan Abramov
b6a55989f5 Assert empty maps when there are no roots 2019-04-26 17:47:00 +01:00
Brian Vaughn
c28acc5d47 Changed owners back button label to say 'Up to <...>' 2019-04-26 09:38:25 -07:00
Dominic Gannaway
c4d1dcb533 React Events: core API documentation followup (#15506) 2019-04-26 15:47:28 +01:00
Dan Nate
41ef1961c1 Update TopLevelEventTypes.js (#15511)
Fix grammar of code comment.
2019-04-26 14:58:32 +02:00
Dominic Gannaway
7a482af5d8 Event API: Fix bug where Press root events were not being cleared (#15507) 2019-04-26 10:30:38 +01:00
Ivan Babak
281616f462 Support highlighting of all DOM elements of Fragments, not just first
Fixes https://github.com/bvaughn/react-devtools-experimental/issues/131

Uses the new function `findAllCurrentHostFibers`.

Removes dependency on React's `renderer.findHostInstanceByFiber` function
which used to highlight only the first DOM element of a Fragment.

Reworked `src/backend/views/Overlay` to support highlighting
more than one element rectangle annotated with one tooltip.
Fixed minor issues with the tooltip position calculation.
2019-04-26 01:22:49 -07:00
Nicolas Gallagher
a14e24efab React Events: core API documentation (#15505) 2019-04-26 08:11:40 +01:00
Dominic Gannaway
8658611b6c Event API: ensure event keys are unique + add validation (#15501) 2019-04-26 08:00:57 +01:00
Brian Vaughn
707b44834f Merge pull request #213 from wldcordeiro/fix-firefox-perms
fix: correct permissions for Firefox
2019-04-25 19:11:39 -07:00
Nicolas Gallagher
d9839740ef React events: remove unused types (#15503) 2019-04-25 15:11:53 -07:00
Brian Vaughn
043b73e0a8 Merge pull request #223 from bvaughn/owners-list-intermediate-components
Owners list view should drill through intermediate components
2019-04-25 15:10:08 -07:00
Brian Vaughn
09029acf00 Refactored owners list to use cached metadata (and added more tests) 2019-04-25 15:06:24 -07:00
Brian Vaughn
15eacae02c Moved owners list calculations into the store and added tests
This is being done to fix a drill-through bug, although the initial fix is perhaps not the most performant one. At least we have test coverage now and a temporary fix.
2019-04-25 15:06:24 -07:00
Brian Vaughn
b6d617ac7f Added 'back to owner' button when owners stack is collapsed 2019-04-25 15:05:39 -07:00
Brian Vaughn
e88819a22e Reverse direction of menu items within drop-down owners list 2019-04-25 14:10:51 -07:00
Nicolas Gallagher
0b34311705 React events: fix press end event dispatching (#15500)
This patch fixes an issue related to determining whether the end event occurs
within the responder region. Previously we only checked if the event target was
within the responder region for moves, otherwise we checked if the target was
within the event component. Since the dimensions of the child element can
change after activation, we need to recalculate the responder region before
deactivation as well if the target is not within the event component.
2019-04-25 13:00:22 -07:00
Dominic Gannaway
d1f667acc0 Event API: follow up fixes for FocusScope + context changes (#15496) 2019-04-25 20:10:33 +01:00
Dan Abramov
a0b1fb37fb Merge pull request #227 from gaearon/string-table
Transfer strings in a string table
2019-04-25 17:54:11 +01:00
Dan Abramov
1bea469db0 Remove unneeded variable 2019-04-25 17:46:48 +01:00
Dan Abramov
af2d1374c4 Let -> const 2019-04-25 17:39:13 +01:00
Dan Abramov
3920ebd0a1 Clarify encoding in overview 2019-04-25 17:32:46 +01:00
Dan Abramov
c8f8943c9a Transfer strings in a string table 2019-04-25 17:11:24 +01:00
Kunuk Nykjær
c530639dd2 Minor code structure adjustments to the bundles.js file (#15079)
* simplify

* fix error

* use deepFreeze

* move comments
2019-04-25 16:24:01 +01:00
Dan Abramov
c1363b7e17 Merge pull request #226 from gaearon/mutate-children
Improve performance by mutating the children array
2019-04-25 15:27:36 +01:00
Dan Abramov
2e423c21b0 Merge pull request #221 from gaearon/heuristic
Use a heuristic for locating roots
2019-04-25 15:22:34 +01:00
Dan Abramov
e1383c666d Allow to set tracked path multiple times
Fixes #225. This happens when you close and reopen DevTools while on the same page.
2019-04-25 14:57:39 +01:00
Dan Abramov
2993b168e5 Mutate the children array 2019-04-25 14:47:05 +01:00
Dan Abramov
d5319566a1 Fix broken start:prod command 2019-04-25 14:21:58 +01:00
Alec Larson
ed36df46c6 add --watch mode to "yarn build" (#15116)
* wip: add --watch mode to "yarn build"

* fix: handle error events
2019-04-25 12:55:44 +01:00
Redmond Tran
793ef9b855 test(eslint-plugin-react-hooks): add coverage for unused custom hook (#15130) 2019-04-25 12:15:29 +01:00
Jeffrey Berry
d61da93878 test(accumulate): add test suite for accumulate function (#15159)
* refactor(typo): remove typo 'be'

* test(accumulate): add test suite for accumulate function
2019-04-25 12:12:25 +01:00
Adam Comella
a187e9b5e4 React Native: Allow Views to be nested inside of Text (#15464)
This feature is now supported on both iOS and Android. The Android feature was merged a couple of weeks ago: https://github.com/facebook/react-native/pull/23195.
2019-04-25 12:06:39 +01:00
Radu-Sebastian Amarie
f85aadefc0 ADD: disablePictureInPicture attribute for HTML5 videos (#15334)
* ADD: disablePictureInPicture attribute for HTML5 videos

* ADD: disablePictureInPicture as DOMProperty and attribute

* Update: Replace camelCase with lowercase and vice-versa

* FIX: Missing comma on attribute (prettier)
2019-04-25 12:02:27 +01:00
FUJI Goro
1eb2b892df give canUseDOM with a possibility to be a constant (#14194)
https://webpack.js.org/plugins/define-plugin/

Webpack's DefinePlugin has the ability to replace `typeof expr` to a constant in compile-time, which should lead to better dead-code-elimination.
2019-04-25 11:28:53 +01:00
shubham
de26d6dd36 typo fix (#15493)
changed ReactResponderContext.dispatchEvent otpions keys to options.
2019-04-25 09:37:35 +01:00
Dominic Gannaway
64e3da286f Event API: Add FocusScope surface (#15487) 2019-04-25 02:01:09 +01:00
Dan Abramov
80597a2377 Use a heuristic for locating roots 2019-04-24 23:02:41 +01:00
Dan Abramov
942f67c936 Merge pull request #220 from gaearon/removed-ids
Select parent node if selection is removed
2019-04-24 19:25:05 +01:00
Dominic Gannaway
3f058debc2 Event API: various bug fixes (#15485) 2019-04-24 17:56:21 +01:00
Brian Vaughn
7bae48f00c Fixed minor CSS overflow issue 2019-04-24 09:07:53 -07:00
Brian Vaughn
c855a862c3 Merge pull request #218 from gaearon/bump-react
Bump React versions
2019-04-24 08:45:16 -07:00
Dan Abramov
949384f4ca Select parent node if selection is removed 2019-04-24 16:29:23 +01:00
Dan Abramov
52deada495 Bump React versions 2019-04-24 15:57:43 +01:00
Dan Abramov
54aecf487e Merge pull request #215 from bvaughn/persist-selection
Try to restore selection between reloads
2019-04-24 15:50:29 +01:00
Dan Abramov
f123763fe1 Read index off the Fiber 2019-04-24 15:05:33 +01:00
Dan Abramov
5d2d4213ec Delete stale paths 2019-04-24 15:05:21 +01:00
Dan Abramov
e050529c7d Read renderer ID from operations 2019-04-24 15:00:46 +01:00
Dan Abramov
26162988aa Fix tests 2019-04-24 14:37:46 +01:00
Dan Abramov
7eb7c5a350 Match Fibers to saved selection as they mount
This implements matching Fibers against the tracked selection path.

The algorithm is optimized to do as little checks as possible:

* When not trying to restore selection, we don't do anything
* When restoring selection, we only check .return pointers of new mounts
* Only when .return pointers match our current deepest match, we compare the frames
2019-04-24 14:37:46 +01:00
Dan Abramov
3bb837b683 Implement getPathForElement to serialize the selected path
Note this doesn't restore the selection yet.
2019-04-24 14:37:46 +01:00
Dan Abramov
b1a7007cc5 Keep track of root insertion order in the renderer
Normally, Fibers have key or index which we'll use to match things up between reloads. However, roots don't have such a concept. We'll use their insertion order as an approximation. If it's consistent, we'll be able to restore the selection.
2019-04-24 14:37:46 +01:00
Dan Abramov
d8abecdcf9 Persist and restore selection in agent
This implements the infrastructure for saving and restoring renderer-specific selection state in the session storage.

Note this doesn't actually implement the calculation and tracking of paths in the renderer. It only simulates that the renderer can do it. The actual implementation will come in a later commit.
2019-04-24 14:37:46 +01:00
Brendan McLoughlin
fb28e90482 Add missing word to code comment for clarity (#15443) 2019-04-24 11:03:51 +01:00
Dominic Gannaway
fa2fa3564d Experimental event API: adds context.isTargetDirectlyWithinEventComponent (#15481) 2019-04-24 11:02:47 +01:00
Dominic Gannaway
d3af2f2a5d Experimental Event API: add event component mount phase callback (#15480) 2019-04-24 10:41:24 +01:00
Brian Vaughn
085d00e877 Merge pull request #196 from bvaughn/selected-element-suspense
Convert inspected element (right panel) to use Suspense
2019-04-23 18:33:05 -07:00
Brian Vaughn
7262a30cf3 Reverted optimization to avoid re-sending inspected fiber unless it committed 2019-04-23 18:04:25 -07:00
Andrew Clark
ce126fbb23 Fix priority inference of next level of work (#15478)
Bugfix for `inferPriorityFromExpirationTime` function. It happened to
work in our existing tests because we use virtual time.

Flow would have caught this if expiration times were an opaque type. We
should consider that in the future. (The downside of opaque types is
that all operations would have to go through helper functions, which may
or may not get inlined by Closure.)
2019-04-23 16:41:05 -07:00
Andrew Clark
71c8759ceb Measure callback timeout relative to current time (#15479)
Fixes a bug where the timeout passed to `scheduleCallback` represented
an absolute timestamp, instead of the amount of time until that
timestamp is reached. The solution is to subtract the current time
from the expiration.

The bug wasn't caught by other tests because we use virtual times that
default to 0, and most tests don't advance time.

I also moved the `initialTimeMs` offset to the
`SchedulerWithReactIntegration` module so that we don't have to remember
to subtract the offset every time. (We should consider upstreaming this
to the Scheduler package.)
2019-04-23 16:40:55 -07:00
Andrew Clark
9c6ff136c7 Remove timeout from performance flamegraph (#15477)
The implementation is wrong, but also it's not that useful for
debugging. Implementing it properly would involve tracking more
information than we do currently. Perhaps including the priority
of the callback in the message would be helpful, but not sure. For now
I'll just remove it.
2019-04-23 15:42:25 -07:00
Dan Abramov
299a2714c3 Use stricter equality check (#15474) 2019-04-23 23:28:02 +01:00
Brian Vaughn
0aa7d2f800 Reverted optimization to avoid re-sending inspected fiber unless it committed 2019-04-23 14:03:58 -07:00
Brian Vaughn
1e5c0b7856 Re-added the selection message 2019-04-23 13:43:38 -07:00
Dominic Gannaway
017d6f14b7 Experimental Event API: add rootEventTypes support to event responders (#15475)
* Adds rootEventTypes
2019-04-23 19:55:50 +01:00
Brian Vaughn
4dcb34ea32 Fixed Flow error 2019-04-23 11:32:07 -07:00
Brian Vaughn
53c7338420 Updated flow-bin to attempt to fix the error 2019-04-23 09:00:25 -07:00
Brian Vaughn
d85f566d66 Merged master (tooltip changes) 2019-04-23 08:49:40 -07:00
Brian Vaughn
8b33dd673d Added @reach/tooltip 2019-04-23 08:41:52 -07:00
Dominic Gannaway
784ebd8fa9 Experimental event API: rework the propagation system for event components (#15462) 2019-04-23 11:50:48 +01:00
Brian Vaughn
ec7536704d Locked down canary versions 2019-04-22 19:32:16 -07:00
Brian Vaughn
7f1531044b Differentiate between no-change and no-element-found when inspecting element 2019-04-22 15:37:55 -07:00
Brian Vaughn
00872e2e51 Fixed suspense fallback issue by moving inspection message side effect before suspending render 2019-04-22 15:25:55 -07:00
Brian Vaughn
64bb2d31f9 Fixed bug with cache invalidation 2019-04-22 15:18:32 -07:00
Brian Vaughn
64bc49d523 Run first setState with explicit priority in case of non-React event handlers 2019-04-22 15:11:04 -07:00
Wellington Cordeiro
2d8c28733d fix: correct permissions for Firefox
remove the `background` permissions as it's not used by Firefox, but `activeTab` is and we needed
it.

fix #136
2019-04-22 15:12:33 -06:00
Brian Vaughn
e31ae91023 Removed duplicate scheduler module 2019-04-22 13:10:47 -07:00
Brian Vaughn
ba640df982 Merge branch 'master' into selected-element-suspense 2019-04-22 10:47:34 -07:00
Brian Vaughn
433934f55e Refactored TreeContext to use less memoization (based on feedback from Sebastian) 2019-04-22 10:39:21 -07:00
Brian Vaughn
d53ae2ea8a Refactored TreeContext to use less memoization (based on feedback from Sebastian) 2019-04-22 10:19:59 -07:00
Brian Vaughn
70be637d48 Don't schedule an update with React unless the curent element was invalidated 2019-04-22 09:37:55 -07:00
Brian Vaughn
5970bf4b40 Changed polling approach. Fixed remove event typo. 2019-04-22 09:37:55 -07:00
Brian Vaughn
3de18de25e Tried to implement two setState pattern, but it does not feel right 2019-04-22 09:37:55 -07:00
Brian Vaughn
957c389566 Adding polling and initial stab at not serializing duplicate inspected Element props 2019-04-22 09:37:34 -07:00
Brian Vaughn
c6b19cc141 Refactored insepected element cache to use the context API 2019-04-22 09:37:34 -07:00
Brian Vaughn
09b023a6e6 Naive suspense implementation for selected element panel
This commit leaves a few major things uunresolved:
* We aren't yet polling for updates
* We aren't yet using the two setState pattern
* The resource cache will grow unbounded over time because we aren't yet clearing items from it
* The renderer interface is not smart enough to avoid resending unchanged data between requests
2019-04-22 09:37:34 -07:00
Brian Vaughn
76b29ad0a9 Merge pull request #201 from gaearon/scroll-fix
Fix scrolling to selected row in collapsed mode
2019-04-22 09:37:15 -07:00
Nicolas Gallagher
587676900f React events: initial implementation of disabled prop (#15458) 2019-04-21 18:17:18 -07:00
Nicolas Gallagher
59c7aef91d React events: add a test for focusable descendants (#15457) 2019-04-21 17:47:52 -07:00
Nicolas Gallagher
0a8da33916 React events: README update types and remove stopPropagation prop (#15456) 2019-04-21 17:46:07 -07:00
Brian Vaughn
52652f3456 Toggle method no longer emits 'mutated' event unless it mutated the store 2019-04-21 12:20:23 -07:00
Brian Vaughn
129466ed91 Yarn deploy sets production NODE_ENV 2019-04-21 09:05:55 -07:00
Brian Vaughn
a01fc44a78 Merge pull request #205 from bvaughn/@reach/tooltip
[BLOCKED] Use new @reach/tooltip
2019-04-21 09:01:23 -07:00
Brian Vaughn
91f74a5134 Fixed focus styles for OwnersStack dropdown toggle button 2019-04-21 08:59:24 -07:00
Brian Vaughn
09b995ab1c Tidied up CSS variables 2019-04-21 08:38:58 -07:00
Brian Vaughn
66df03d179 Renamed CSS var color-text-color to color-text 2019-04-21 08:29:51 -07:00
Brian Vaughn
8220df734c Tweaked hover and focus colors. Temporarily disabled Tooltip. 2019-04-21 08:23:20 -07:00
Brian Vaughn
a129089891 Tweaking focus/active colors and only showing focus rect on tab 2019-04-20 15:44:24 -07:00
Brian Vaughn
403bf49a78 Use new @reach/tooltip 2019-04-20 14:29:03 -07:00
Brian Vaughn
4218dcbf99 Merge pull request #203 from gaearon/push-ops
Push operations directly to the array
2019-04-20 14:27:53 -07:00
Brian Vaughn
740993baa9 Merge branch 'master' into push-ops 2019-04-20 14:26:46 -07:00
Brian Vaughn
72156c744f Merge pull request #204 from gaearon/no-weakset
Replace WeakSet with return pointer check
2019-04-20 14:23:59 -07:00
Brian Vaughn
94d9f61a7d Merge pull request #206 from gaearon/leading
Ignore leading edge of find-by-DOM throttle
2019-04-20 14:22:49 -07:00
Dan Abramov
006e03c38e Ignore leading edge of find-by-DOM throttle 2019-04-20 22:17:12 +01:00
Dan Abramov
c0d7023a88 Replace WeakSet with return pointer check 2019-04-20 21:42:30 +01:00
Dan Abramov
02a3a22753 Push operations directly to the array 2019-04-20 21:05:52 +01:00
Brian Vaughn
4b9082eea1 Changed style and position of search-for-element button to more closely matchin Chrome ( based on user testing) 2019-04-20 10:44:03 -07:00
Dan Abramov
4ffdffb598 Fix scrolling to selected row in collapsed mode 2019-04-20 16:20:03 +01:00
Brian Vaughn
3697ed2bba Merge pull request #199 from gaearon/another-check
Filter out dehydrated Suspense nodes
2019-04-20 08:00:14 -07:00
Brian Vaughn
da2ed30471 Merge pull request #200 from gaearon/clear-stuff
Clear DOM overlay on shutdown
2019-04-20 07:57:11 -07:00
Dan Abramov
d05106e364 Clear DOM overlay on shutdown 2019-04-20 14:34:13 +01:00
Dan Abramov
a186dc2e8d Filter out dehydrated Suspense nodes 2019-04-20 13:57:33 +01:00
Nicolas Gallagher
d584fcdc6e React events: use passive events where possible (#15454) 2019-04-19 13:09:03 -07:00
Nicolas Gallagher
051513bfa0 React Events: consolidate logic for Press event component (#15451)
Refactor of Press and additional regression coverage.

The logic for "start", "move", "end", and "cancel" events is consolidated into a single block to reduce duplication and improve consistency of the UX across input-types. Also reduces code size.

The bailout logic for anchor tags is removed since we preventDefault for click by default. We can discuss scenarios where it makes sense to limit functionality around interactions on anchor tags.

The logic for ignoring emulated events is simplified and improved. Pointer events can produce emulated touch (immediately after pointer) and mouse events (delayed) which is now accounted for and tested.
2019-04-19 10:05:28 -07:00
Nicolas Gallagher
cdfce1ad23 React events: consolidate logic of Hover event component (#15450)
Minor refactor of Hover and additional regression coverage.
2019-04-19 09:51:36 -07:00
Nicolas Gallagher
5857c89da2 React events: extract common helper functions (#15449) 2019-04-19 08:40:18 -07:00
Brian Vaughn
d7e8fccd1a Fixed an OVERVIEW typo 2019-04-19 07:54:30 -07:00
Brian Vaughn
5b0b9c9fbc Merge pull request #193 from gaearon/no-reorder
Don't reorder a single child
2019-04-19 07:51:51 -07:00
Dan
9a395c2f2c No need to reorder empty children either 2019-04-19 13:21:09 +01:00
Dan
fb8ad3486e Don't reorder a single child 2019-04-19 13:19:58 +01:00
Dan Abramov
2adbfd9607 Merge pull request #186 from gaearon/more-suspensey-stuff
Fix more Suspense issues
2019-04-19 13:18:50 +01:00
Dan
efb5855c8c Nits 2019-04-19 13:17:17 +01:00
Dan
3e657a6031 Prettier 2019-04-19 13:09:25 +01:00
Dan Abramov
37dd1ec8f8 Merge branch 'master' into more-suspensey-stuff 2019-04-19 13:09:01 +01:00
Brian Vaughn
f286c0d901 Increased contrast for selected+inactive background color 2019-04-18 18:19:10 -07:00
Brian Vaughn
c6a27d1fea Merge branch 'master' of github.com:bvaughn/react-devtools-experimental 2019-04-18 18:13:43 -07:00
Brian Vaughn
c0b414d581 Node scripts should fail if not NODE_ENV specified 2019-04-18 18:13:34 -07:00
Brian Vaughn
131e2e52db Merge pull request #188 from gaearon/humble-search
Don't select search result unless user does something
2019-04-18 18:04:28 -07:00
Brian Vaughn
60b614f527 Renamed TREE_OPERATION_RESET_CHILDREN -> TREE_OPERATION_REORDER_CHILDREN 2019-04-18 17:59:53 -07:00
Brian Vaughn
24736e4ff5 Hardened reorder child invariants 2019-04-18 17:58:48 -07:00
Dan Abramov
3d09b4aaa5 Don't select search result unless user does something 2019-04-19 01:54:39 +01:00
Brian Vaughn
21afd6ea20 Merge pull request #184 from bvaughn/harden
Harden assertions
2019-04-18 17:50:17 -07:00
Dan Abramov
b0c0a11f1b Revert accidental change 2019-04-19 01:41:00 +01:00
Dan Abramov
72e67b343f Add Concurrent Mode test 2019-04-19 01:18:25 +01:00
Dan Abramov
534dfb0ca2 Optimize: don't recreate ID arrays all the time 2019-04-19 01:13:25 +01:00
Dan Abramov
8830ba890c Fix more Suspense traversal bugs 2019-04-19 01:09:57 +01:00
Dan Abramov
346b628b43 Add failing tests for Suspense with same type 2019-04-19 00:36:55 +01:00
Dan Abramov
d44bf272ad Refactor: materialize typed array in one place 2019-04-19 00:32:29 +01:00
Dan Abramov
ccecde76d1 Harden assertions 2019-04-19 00:29:49 +01:00
Brian Vaughn
3dfbf8ad6b Added a new invariant to the store (bridge operations handler) 2019-04-18 15:40:50 -07:00
Brian Vaughn
7930bad8c6 Deploy production extension builds 2019-04-18 14:45:24 -07:00
Brian Vaughn
e2aedb2ea7 Merge pull request #181 from gaearon/consoleerror
Fail tests on errors in renderer
2019-04-18 10:08:44 -07:00
Dan Abramov
d0b5e3a7cb Update setupTests.js 2019-04-18 18:06:34 +01:00
Brian Vaughn
d6e829d7a5 Fixed bug in reset-children to properly calculate new root weight 2019-04-18 09:54:26 -07:00
Brian Vaughn
89f7a0c048 Merge pull request #182 from bvaughn/suspense-toggle
Fixed a Suspense toggling bug that incorrectly impacted tree weight
2019-04-18 09:45:22 -07:00
Brian Vaughn
358e63ac3d Fixed a Suspense toggling bug that incorrectly impacted tree weight 2019-04-18 09:38:41 -07:00
Dan Abramov
8c5794eab3 Fail tests on errors in renderer 2019-04-18 17:03:04 +01:00
Brian Vaughn
b45e743f52 Merge pull request #180 from gaearon/suspense-more-fixes
Fix unmounting in Concurrent Mode
2019-04-18 08:52:30 -07:00
Dan Abramov
6a13ffd231 Traverse the previous current tree when switching from primary to fallback 2019-04-18 16:22:50 +01:00
Dan Abramov
24309fde06 Add failing Concurrent Mode stress tests 2019-04-18 16:22:50 +01:00
Dan Abramov
0f44e9fb98 Move sync stress tests in their own file 2019-04-18 16:22:50 +01:00
Brian Vaughn
456e937b83 Merge pull request #178 from gaearon/removal-integrity
Assert removal happens in the right order
2019-04-18 08:16:22 -07:00
Dan Abramov
d02d93712e Assert removal happens in the right order 2019-04-18 16:02:08 +01:00
Brian Vaughn
08279fb342 Merge pull request #174 from robertknight/mousedown-tab-select
Select tab when the mouse is pressed
2019-04-18 08:00:01 -07:00
Brian Vaughn
d995f19339 Merge pull request #175 from lucasecdb/assign-timeout
Assign timeoutID to avoid multiple requests
2019-04-18 07:56:32 -07:00
Lucas Cordeiro
6df050e726 Assign timeoutID to avoid multiple requests 2019-04-18 06:46:06 -03:00
Robert Knight
c2865dbab9 Select tab when the mouse is pressed
Selecting the tab when the mouse is pressed rather than only when it is
released makes tab switching feel faster and also matches how the Chrome dev
tools behave.

The previous tab selection handler which listens for the radio button's
selection has been kept for the benefit of interaction methods which
don't trigger the mousedown handler.
2019-04-18 08:16:52 +01:00
Brian Vaughn
29811cd24e Added legacy (v15) tests 2019-04-17 15:30:20 -07:00
Brian Vaughn
7ab93402a8 Initial support for v15+ via new legaacy renderer 2019-04-17 14:36:15 -07:00
Brian Vaughn
0d932d770b Merge pull request #168 from bvaughn/collapse-nodes-by-default
Configurable tree default collapsed/expanded behavior
2019-04-17 13:29:25 -07:00
Brian Vaughn
75e1e1431b Expanded the reorder tests slightly 2019-04-17 13:11:18 -07:00
Nicolas Gallagher
0b50fb29f7 Include rootEventTypes in DOMEventResponderSystem stopPropagation tests (#15433) 2019-04-17 13:08:36 -07:00
Brian Vaughn
634d4fece2 Added more inline comments 2019-04-17 13:03:18 -07:00
Brian Vaughn
29d43a2230 Merge pull request #171 from bvaughn/improve-contrast-light-mode
Improve contrast for light mode
2019-04-17 11:44:25 -07:00
Brian Vaughn
3fb9f6cdaa Improve contrast for light mode 2019-04-17 11:40:55 -07:00
Nicolas Gallagher
1ae409d2c7 React events: fix nested Hover components error (#15428)
* Add failing test for nested Hover
* Fix error caused by nested Hover event components
2019-04-17 11:33:32 -07:00
Brian Vaughn
c107e03132 Flow fix 2019-04-17 09:45:03 -07:00
Brian Vaughn
74be389124 Fixed a bug with re-ordering of children within a collapsed node 2019-04-17 09:39:54 -07:00
Brian Vaughn
178e89927a Fixed some edge cases with collapsed by default. Still some bugs existing. 2019-04-17 07:45:33 -07:00
Brian Vaughn
037bb0034c Throw if root node is collapsed 2019-04-16 14:10:06 -07:00
Brian Vaughn
4b64d7c017 Support configurable node/tree collapsed by default behavior 2019-04-16 13:59:36 -07:00
Nicolas Gallagher
c73ab39c1f React events: make nested Focus work as expected (#15421)
This patch makes a change to the Focus module so that it only reports
focus/blur on the host node that's a direct child of the event component. This
brings the expected behaviour in line with the browser default of focus/blur
events not bubbling for Pressable.
2019-04-16 11:16:27 -07:00
Dan Abramov
85179fe4a7 Merge pull request #164 from gaearon/fix-lots-of-stuff
Fix reordering and Suspense logic
2019-04-16 19:11:28 +01:00
Dan Abramov
3a6d656090 Remove unnecessary condition 2019-04-16 19:10:39 +01:00
Dan Abramov
9182d0b0aa Bump alpha to get Andrew's fix 2019-04-16 19:09:52 +01:00
Dan Abramov
58bb7cea41 Remove unused lines 2019-04-16 18:21:40 +01:00
Dan Abramov
8576c85b0d Move stress tests to their own file 2019-04-16 18:10:15 +01:00
Dan Abramov
d4db178d33 Bump to canary 2019-04-16 17:39:26 +01:00
Dan Abramov
3cf67ab859 Harden the tests and fix Flow 2019-04-16 17:02:42 +01:00
Dan Abramov
b1dea26251 Fix the remaining issue when primary child is null
This lets us unlock the rest of the Suspense test.
2019-04-16 16:57:10 +01:00
Dan Abramov
fe21ee7ca0 Enable part of Suspense test that was failing before
This PR fixes it.
2019-04-16 16:47:26 +01:00
Dan Abramov
f4e223bceb When resetting Suspense children, use the fallback child set if needed
This fixes the bug I introduced in the previous refactor which Suspense test caught.
2019-04-16 16:45:56 +01:00
Dan Abramov
dd935ea178 Propagate the need to reset children to closest visible Fiber
This fixes the bug.
2019-04-16 16:34:08 +01:00
Dan Abramov
57e8513a30 Refactor: remove early returns from updateFiberRecursively
This doesn't change any logic, just the shape of the control flow.
I want to unify some branches at the end, so it's easier if there are no early returns.
2019-04-16 16:34:08 +01:00
Dan Abramov
f4c3008cf5 Refactor: split recordUpdate() into profiling and reorder
This doesn't change the actual algorithm but splits unrelated parts.
2019-04-16 16:34:08 +01:00
Dan Abramov
b081ffc518 Add stress test for reordering 2019-04-16 16:34:08 +01:00
Brian Vaughn
20193f03c0 Merge pull request #162 from gaearon/suspense-test
Add Suspense stress test
2019-04-16 07:49:11 -07:00
Dan
d89f79d6e6 Add Suspense stress test 2019-04-16 00:14:49 +01:00
Andrew Clark
4221565e15 Cancel pending commit before starting on root
Moves the cancelTimeout call to right before creating a new work-in-
progress root. Fixes a class of bugs where a pending commit is not
cancelled, causing an incomplete tree to accidentally commit.

In the interest of fixing downstream bugs quickly, I'm landing this
without a test case; I'll add one in a follow up.
2019-04-15 16:00:18 -07:00
Brian Vaughn
8c974ae432 Flow and lint fix 2019-04-15 09:43:52 -07:00
Brian Vaughn
97636fa7fc Merge pull request #161 from gaearon/fast
Don't materialize typed array until the transfer
2019-04-15 09:40:33 -07:00
Brian Vaughn
2b3ecc63b3 Merge pull request #158 from gaearon/stress-test
Add a stress test for tree traversal
2019-04-15 09:34:40 -07:00
Dan Abramov
6b9b80faac Don't materialize typed array until the transfer 2019-04-15 16:27:19 +01:00
Brian Vaughn
b3546e0e02 Merge pull request #160 from gaearon/add-prod-shell
Add production mode to dev shell
2019-04-15 07:40:39 -07:00
Dan Abramov
947e3c2c04 Add production mode to dev shell 2019-04-15 15:39:25 +01:00
Brian Vaughn
7489b8508b Merge pull request #159 from gaearon/l-to-the-r-to-the-u
Use LRU for encoded strings
2019-04-15 07:09:10 -07:00
Dan Abramov
255385d255 Use LRU for encoded strings 2019-04-15 14:42:12 +01:00
Dan
f569d27f86 Add a stress test for tree traversal 2019-04-15 01:52:15 +01:00
Brian Vaughn
b76372c93d Fixed an edge case profiling bug where the number of commits was wrong 2019-04-13 18:29:39 -07:00
Brian Vaughn
7f6fdfea95 Add package commands for creating dev builds for easier debugging 2019-04-13 18:25:56 -07:00
Brian Vaughn
00f6466ec1 Temporarily disabled hooks lint failure for Tree useEffect 2019-04-13 15:49:06 -07:00
Brian Vaughn
97f089bdfe Merge pull request #148 from gaearon/scroll-consistent
Consistently scroll component name into view
2019-04-13 15:39:25 -07:00
Brian Vaughn
518f3d75f8 Tweaked an inline comment. 2019-04-13 15:38:56 -07:00
Brian Vaughn
b2cf896e8c Fixed misplaced padding in Tree 2019-04-13 15:33:10 -07:00
Brian Vaughn
236f47f073 Tweaked .eslintignore and .gitignore 2019-04-13 15:32:26 -07:00
Brian Vaughn
86f9293376 Merge pull request #154 from gaearon/resize-hilite
Adjust highlighting on window resize
2019-04-13 15:25:17 -07:00
Brian Vaughn
d5266f9409 Merge pull request #155 from gaearon/view-dom-inspect
View DOM button opens Elements tab
2019-04-13 15:23:09 -07:00
Brian Vaughn
453a06a465 Merge pull request #150 from gaearon/bump-hooks-plugin
Bump React Hooks plugin
2019-04-13 15:20:08 -07:00
Brian Vaughn
826cac0070 Merge pull request #149 from gaearon/dont-reset
Don't reset selected item on search mismatch or exit
2019-04-13 15:19:38 -07:00
Dominic Gannaway
9ebe1768a8 Experimental Event API: Redesign event responder propagation (#15408)
* Event API: Redesign event instance propagation
2019-04-13 20:37:39 +01:00
Dan
ce335b8975 View DOM button opens Elements tab 2019-04-13 18:59:47 +01:00
Dan
6d53a2ec10 Adjust highlighting on window resize 2019-04-13 18:24:59 +01:00
Dan
9162b7165a Prefer to keep the start anchor visible 2019-04-13 16:49:10 +01:00
Dan
6d70028a26 Bump React Hooks plugin 2019-04-13 16:38:34 +01:00
Dan
55dcfe25e8 Don't reset selected item on search mismatch or exit 2019-04-13 16:20:16 +01:00
Brian Vaughn
ca7eb3c829 Changed highlight-on-search behavior to use TreeContext 2019-04-12 18:14:46 -07:00
Dan Abramov
097d0386b1 Track search navigation in DOM 2019-04-12 18:14:46 -07:00
Brian Vaughn
7145c78325 Merge pull request #147 from gaearon/no-propagation
Polish some mouse interactions
2019-04-12 18:09:16 -07:00
Dan
ba9c763954 Consistently scroll component name into view 2019-04-13 01:58:05 +01:00
Dan
454bcf1e01 Polish some mouse interactions 2019-04-13 01:07:35 +01:00
Philipp Spiess
a30e7d992e act() tests - Reuse and properly unmount containers (#14974) 2019-04-12 23:53:36 +01:00
Brian Vaughn
1e08261975 Added missing instruction to Chrome install steps 2019-04-12 15:08:14 -07:00
Brian Vaughn
818255dfde Merge pull request #145 from bvaughn/deploy-chrome-updates
Auto-update Chrome extension
2019-04-12 15:02:11 -07:00
Brian Vaughn
801bb5e33a Udpated Firefox installation instructions 2019-04-12 14:45:39 -07:00
Brian Vaughn
670d1348f1 Chrome build+deploy script auto-increment a prerelease version 2019-04-12 14:42:34 -07:00
Brian Vaughn
26361427ae Auto-update Chrome extension 2019-04-12 13:46:05 -07:00
Nicolas Gallagher
8cf963c6c3 React events: ignore device buttons that aren't for primary interactions (#15402)
The Pointer Events spec mentions that the value of `button` in a nativeEvent
can be anything between 0 and 5 for "down" events. We only care about those
with a value of 0.
2019-04-12 13:36:00 -07:00
Andrew Clark
38bd570d41 Stop tracking bundle sizes (#15404)
* [sizebot] Fail gracefully if CI returns invalid response

Moves the `response.json()` call into the catch block.

* Stop tracking bundle sizes
2019-04-12 13:33:27 -07:00
Brian Vaughn
9c1dad5059 react-window 1.8.0 2019-04-12 10:57:56 -07:00
Brian Vaughn
b18c836ef5 Merge branch 'smart-scroll' of https://github.com/gaearon/react-devtools-experimental into gaearon-smart-scroll 2019-04-12 10:56:27 -07:00
Brian Vaughn
dbd1d6b0bd Firefox only supports peristent background extensions so I've removed the persistent:false flag 2019-04-12 10:20:23 -07:00
Dan Abramov
403f150ade Use smart scrolling 2019-04-12 18:13:26 +01:00
Brian Vaughn
8f17ade7e5 Circle CI config changes 2019-04-12 09:27:53 -07:00
Brian Vaughn
af8a5d9311 Added devEngines entry to package.json 2019-04-12 09:24:16 -07:00
Brian Vaughn
a57b6dbef5 Merge pull request #133 from bvaughn/tests
Automated tests [WIP]
2019-04-12 09:22:11 -07:00
Brian Vaughn
be930d5490 Use Circle CI to run lint, prettier, flow, and tests 2019-04-12 09:17:42 -07:00
Brian Vaughn
7bb2299de4 Moved __DEV__ setup from setupTests to setupEnv 2019-04-12 08:55:29 -07:00
Brian Vaughn
e0ffa2b88d Moved a few vars inside of the setupTest beforeEach block 2019-04-12 08:55:29 -07:00
Brian Vaughn
158b0b5567 Added expand/collapse tests; chronologically ordered snapshots 2019-04-12 08:55:29 -07:00
Brian Vaughn
16a7119bf2 Added a simple Suspense test 2019-04-12 08:55:29 -07:00
Brian Vaughn
4ad85b26c0 Cleaned up setup/polyfills 2019-04-12 08:55:29 -07:00
Brian Vaughn
81183b1492 Named snapshots. Tests use act() abstraction. 2019-04-12 08:55:29 -07:00
Brian Vaughn
5d6a2082cc Updated React test utils for newer version of act() 2019-04-12 08:55:29 -07:00
Brian Vaughn
1bdae952b5 Added separate mount+update tests 2019-04-12 08:55:29 -07:00
Brian Vaughn
25e918b4d9 Added [root] indicator to Store snapshot reprensentation 2019-04-12 08:55:29 -07:00
Brian Vaughn
4926d160d6 Removed unnecessary configurable Bridge batch duration 2019-04-12 08:55:29 -07:00
Brian Vaughn
9fb794b6ed Added multi-test setup logic 2019-04-12 08:55:29 -07:00
Brian Vaughn
7621df5baf Initial example test. Will iterate from here. 2019-04-12 08:55:29 -07:00
Brian Vaughn
7aadcdf624 Use :hidden attribute to collapse props/hooks 2019-04-12 08:53:41 -07:00
Brian Vaughn
ae7ea00e06 Fix small sizing issue with expand collapse toggle 2019-04-12 08:42:27 -07:00
Brian Vaughn
da4accda31 Added expand/collapse toggles to custom hooks 2019-04-12 08:39:03 -07:00
Dominic Gannaway
3438e5ce87 Experimental Event API: Add Hover onUnmount support (#15394) 2019-04-12 13:26:27 +01:00
Nicolas Gallagher
805e7f8733 React events: add unmounting to Focus (#15396) 2019-04-12 12:23:03 +01:00
Dominic Gannaway
543353a043 Experimental Event API: Remove "listener" from event objects (#15391) 2019-04-12 11:53:40 +01:00
Andrew Clark
ed6798405d Better message when CI for base commit is pending 2019-04-11 19:24:22 -07:00
Andrew Clark
9055e31e5c Replace old Fiber Scheduler with new one (#15387)
The new Fiber Scheduler has been running in Facebook for several days
without issues. Let's switch to it.
2019-04-11 19:15:34 -07:00
Brian Vaughn
94810b2b5a Add Git revision to extension manifests 2019-04-11 19:06:07 -07:00
Nicolas Gallagher
4e59d4f5d2 React events: add onHoverMove support (#15388) 2019-04-11 18:59:05 -07:00
Brian Vaughn
9a0cf68a4d Add Git revision to build version 2019-04-11 18:44:44 -07:00
Brian Vaughn
3ea5fac959 Enable text to wrap within error boundary stacks 2019-04-11 18:29:06 -07:00
Brian Vaughn
f32b65d7b0 Merge pull request #135 from lucasecdb/fiber-info-overflow
Fix fiber info sidepanel not scrollable
2019-04-11 18:21:57 -07:00
Lucas Cordeiro
2671e7e0e0 Fix fiber info sidepanel not scrollable 2019-04-11 21:38:57 -03:00
Andrew Clark
cdfb06e38b Fix path to results.json 2019-04-11 17:20:14 -07:00
Brian Vaughn
9642d26674 Added ErrorBoundary with GitHub bug link 2019-04-11 17:19:16 -07:00
Dan Abramov
da508fc23f Merge pull request #126 from bvaughn/js-hover
Ignore hover when navigating with keyboard
2019-04-12 01:16:26 +01:00
Andrew Clark
de75903272 Fix CI (#15393)
* Revert "Bump scheduler version to 0.14.0"

This reverts commit 687e4fb6f7.

* Store results.json as CI build artifact
2019-04-11 16:43:33 -07:00
Brian Vaughn
367249c175 Don't drill into owners list if no owner metadata is available 2019-04-11 14:00:27 -07:00
Andrew Clark
687e4fb6f7 Bump scheduler version to 0.14.0
Releasing this early for React Native
2019-04-11 13:42:34 -07:00
Nicolas Gallagher
45473c94cd React events: Press event fixes (#15386)
1. Fix hiding context menu for longpress via touch.
2. Fix scrolling of viewport for longpress via spacebar key.
3. Add tests for anchor-related behaviour and preventDefault.
4. Add a deactivation delay for forced activation
5. Add pointerType to Press events.

NOTE: this currently extends pointerType to include `keyboard`.

NOTE: React Native doesn't have a deactivation delay for forced activation, but this is possibly because of the async bridge meaning that the events aren't dispatched sync.
2019-04-11 13:20:21 -07:00
Dominic Gannaway
9672cf621b Experimental Event API: adds stopPropagation by default to Press (#15384) 2019-04-11 20:00:20 +01:00
Brian Vaughn
75657c81e8 Merge branch 'keyboard-stuff' of https://github.com/gaearon/react-devtools-experimental 2019-04-11 11:55:39 -07:00
Dan Abramov
38b7cf5693 Ignore hover when navigating with keyboard 2019-04-11 13:27:49 +01:00
Dan Abramov
0281a0d905 Add a missing dep 2019-04-11 13:20:32 +01:00
Dominic Gannaway
a9eff329c6 Remove TouchHitTarget SSR logic to prevent issues with mouse events (#15381) 2019-04-11 12:05:26 +01:00
Dominic Gannaway
c9841001b0 Experimental Event API: preventDefault handling for anchors (#15383) 2019-04-11 12:04:39 +01:00
Brian Vaughn
a5eb96fbc0 Merge pull request #134 from sophiebits/bridge-batch
Improve bridge batching logic
2019-04-10 17:21:30 -07:00
Sebastian Markbåge
c25c59c808 Apply the Just Noticeable Difference to suspense timeouts (#15367)
* Apply the Just Noticeable Difference boundary

* Clamp suspense timeout to expiration time
2019-04-10 17:16:27 -07:00
Sophie Alpert
7c13ea2f2b Improve bridge batching logic
Fixes #132.
2019-04-10 16:31:11 -07:00
Brian Vaughn
40469a190e Fixed horizontal alignment for collapsable hooks 2019-04-10 12:47:51 -07:00
Brian Vaughn
84a5a13525 Editable name not text-selectable 2019-04-10 12:37:20 -07:00
Brian Vaughn
e9f385591e Double clicking on a name toggles expanded state in KeyValue 2019-04-10 12:36:26 -07:00
Brian Vaughn
4f254c0a05 Refactored KeyValue toggle so columns with toggles align better below those without 2019-04-10 11:44:45 -07:00
Dominic Gannaway
3e2e930d62 Fixes a Flow type merge conflict (#15378) 2019-04-10 19:33:05 +01:00
Dan Abramov
952c8cda00 Fix a bug that caused it to jump over nodes when pressing too fast 2019-04-10 19:30:45 +01:00
Brian Vaughn
f0fb1805fe Added new color-expand-collapse-toggle CSS var 2019-04-10 11:03:32 -07:00
Brian Vaughn
3e19b164b5 Merge branch 'collapse-props' of https://github.com/lucasecdb/react-devtools-experimental into lucasecdb-collapse-props 2019-04-10 11:03:04 -07:00
Lucas Cordeiro
944a6192e2 Use button instead of div for a11y 2019-04-10 15:01:05 -03:00
Nicolas Gallagher
7fc91f17c9 React events: add onPressMove and pressRetentionOffset to Press (#15374)
This implementation differs from equivalents in React Native in the following ways:

1. A move during a press will not cancel onLongPress.
2. A move to outside the retention target will cancel the press and not
reactivate when moved back within the retention target.
2019-04-10 10:52:50 -07:00
Dominic Gannaway
dd9cef9fc0 Experimental Event API: Add targets and responder utility method for finding targets (#15372) 2019-04-10 18:52:34 +01:00
Dan Abramov
6420f11d65 Left and right arrows only traverse parents 2019-04-10 18:49:52 +01:00
Lucas Cordeiro
2d516199ea Update opener icon and remove negative margin 2019-04-10 14:47:39 -03:00
Brian Vaughn
0aacc2547e Merge pull request #123 from gaearon/focus-keyboard
Picking a DOM node focuses the tree
2019-04-10 10:31:05 -07:00
Lucas Cordeiro
99a1e07aa6 Fix flow type 2019-04-10 14:28:48 -03:00
Lucas Cordeiro
0f955980a3 Add collapsible icon for object and array types 2019-04-10 14:28:48 -03:00
Dan Abramov
1c381c588a Picking a DOM node focuses the tree 2019-04-10 18:27:40 +01:00
Brian Vaughn
88e51adc35 Merge pull request #122 from gaearon/prevent
Prevent default on all key navigations
2019-04-10 10:17:12 -07:00
Brian Vaughn
4b0424fbed Flow fix 2019-04-10 10:16:09 -07:00
Brian Vaughn
268a7cb5b4 Moved blur/focus up to the AutoSizer wrapper and removed an effect+ref 2019-04-10 10:14:21 -07:00
Brian Vaughn
caa74472f2 Replaced nested ternary 2019-04-10 10:01:03 -07:00
Brian Vaughn
6836f15924 Tweaked inactive CSS colors 2019-04-10 09:56:21 -07:00
Brian Vaughn
d9ef0839a4 Merge branch 'inactive-window' of https://github.com/lucasecdb/react-devtools-experimental into lucasecdb-inactive-window 2019-04-10 09:51:29 -07:00
Dan Abramov
5b480a85cb Prevent default on all key navigations 2019-04-10 17:46:34 +01:00
Brian Vaughn
11c03bf7bc Merge pull request #120 from gaearon/mutation-index
Update selected index after mutation
2019-04-10 09:35:00 -07:00
Brian Vaughn
7263e768e5 Merge pull request #116 from bvaughn/issues/105
Add collapse/toggle UI to Tree
2019-04-10 09:31:12 -07:00
Brian Vaughn
56be358847 Merge pull request #114 from gaearon/lazy-sync
Send the bridge sync event lazily
2019-04-10 09:28:54 -07:00
Dan Abramov
f1a8bd2923 Update selected index after mutation 2019-04-10 17:28:36 +01:00
Brian Vaughn
f89f2b2146 Reverted misguided index/collapsed behavior 2019-04-10 09:23:24 -07:00
Brian Vaughn
ba46f2df0a Merge pull request #118 from gaearon/required-title
Add missing Button titles
2019-04-10 09:10:24 -07:00
Brian Vaughn
98240f18ae Merge pull request #117 from gaearon/hide-shell
Put DevTools in dev shell above the inspector
2019-04-10 09:10:10 -07:00
Brian Vaughn
74c9904e5d Rewrote weightDelta calculation to be more readable based on PR feedback 2019-04-10 08:59:43 -07:00
Brian Vaughn
dd84e8ff2b Newly selected components always auto-expand their ancestors 2019-04-10 08:57:42 -07:00
Brian Vaughn
1f7f0ea691 Update Store.getIndexOfElementID to take isCollapsed into account 2019-04-10 07:53:06 -07:00
Brian Vaughn
b004a79415 Reverted some unnecessary changes to TreeContext after Dan's PR 101 was merged 2019-04-10 07:45:45 -07:00
Brian Vaughn
102267b1d6 Renamed _numElements attribute based on PR feedback 2019-04-10 07:42:32 -07:00
Brian Vaughn
61203f77cf Hide toggle arrows in owners list mode 2019-04-10 07:42:32 -07:00
Brian Vaughn
55b3635f28 Left/right arrow toggles node collapsed state as well 2019-04-10 07:42:32 -07:00
Brian Vaughn
f7212d8035 Upgrade react-window to fix a scroll-to bug 2019-04-10 07:42:32 -07:00
Brian Vaughn
4c522c4c38 Selected search result auto-opens collapsed nodes when necessary.
Also fixed an unrelated bug about when we reset search index when text changes.
2019-04-10 07:42:32 -07:00
Brian Vaughn
b6df86c90c Added toggle button to Tree > Element views 2019-04-10 07:38:40 -07:00
Brian Vaughn
79827c535b Added isToggled boolean to tree nodes and toggleIsCollapsed() method to Store 2019-04-10 07:38:40 -07:00
Brian Vaughn
0decb17837 Merge pull request #101 from gaearon/find-nit
Pressing next forces search to select
2019-04-10 07:38:28 -07:00
Dan Abramov
1102fc5c11 Refactor: extract a variable 2019-04-10 15:25:03 +01:00
Dan Abramov
3eca0bbe61 Use heuristic suggested by @sophiebits 2019-04-10 15:08:13 +01:00
Dan
07299828c9 Pressing next forces search to select 2019-04-10 14:57:39 +01:00
Dan Abramov
75a4312d87 Add missing Button titles 2019-04-10 14:40:41 +01:00
Dan Abramov
84478a41ff Put DevTools in dev shell above the inspector 2019-04-10 14:26:33 +01:00
Dominic Gannaway
c64b330032 Move EventTypes to ReactTypes (#15364) 2019-04-10 09:55:56 +01:00
Sebastian Markbåge
4c78ac0b9d Track Event Time as the Start Time for Suspense (#15358)
* Track the earliest event time in this render

Rebase

* Track the time of the fallback being shown as an event time

When we switch back from fallback to content, we made progress and we track
the time from when we showed the fallback in the first place as the
last time we made progress.

* Don't retry if synchronous

* Only suspend when we switch to fallback mode

This ensures that we don't resuspend unnecessarily if we're just retrying
the same exact boundary again. We can still unnecessarily suspend
for nested boundaries.

* Rename timedOutAt to fallbackExpirationTime

* Account for suspense in devtools suspense test
2019-04-09 18:59:39 -07:00
Brian Vaughn
6d222080ad Format logElementToConsole() slightly 2019-04-09 18:13:11 -07:00
Andrew Clark
875d05d553 Include full error messages in React Native build (#15363)
The React Native build does not minify error messages in production,
but it still needs to run the error messages transform to compile
`invariant` calls to `ReactError`. To do this, I added a `noMinify`
option to the Babel plugin. I also renamed it from
`minify-error-messages` to the more generic `transform-error-messages`.
2019-04-09 16:40:19 -07:00
Eli White
1b2159acc3 [React Native] measure calls will now call FabricUIManager (#15324)
* [React Native] Add tests to paper renderer for measure, measureLayout

* [React Native] measure calls will now call FabricUIManager

The Fabric renderer was previously calling the paper UIManager's measure calls and passing the react tag. This PR changes the renderer to now call FabricUIManager passing the node instead.

One of the parts of this that feels more controversial is making NativeMethodsMixin and ReactNative.NativeComponent warn when calling measureLayout in Fabric. As Seb and I decided in https://github.com/facebook/react/pull/15126, it doesn't make sense for a component created with one of these methods to require a native ref but not work the other way around. For example: a.measureLayout(b) might work but b.measureLayout(a) wouldn't. We figure we should keep these consistent and continue migrating things off of NativeMethodsMixin and NativeComponent.

If this becomes problematic for the Fabric rollout then we should revisit this.

* Fixing Flow

* Add FabricUIManager to externals for paper renderer

* import * as FabricUIManager from 'FabricUIManager';

* Update tests

* Shouldn't have removed UIManager import

* Update with the new tests
2019-04-09 15:10:15 -07:00
Lucas Cordeiro
1c57ca0a1c Use focus state from elements tree instead of ownerDocument 2019-04-09 19:04:03 -03:00
Lucas Cordeiro
26106a4b9d Add check for inactive window on selected element 2019-04-09 19:03:59 -03:00
Eli White
c7a959982b [React Native] Add tests to paper renderer for measure, measureLayout (#15323)
* [React Native] Add tests to paper renderer for measure, measureLayout

* Update tests

* Shouldn't have removed UIManager import
2019-04-09 14:49:07 -07:00
Dan Abramov
43bb821f60 Send the bridge sync event lazily 2019-04-09 20:04:33 +01:00
Brian Vaughn
edc598e62a Fixed Tree minWidth initial case to fill 100% width 2019-04-09 11:43:49 -07:00
Brian Vaughn
1cc219009a Tweaked owners stack CSS to fix another overflow issue 2019-04-09 11:12:39 -07:00
Brian Vaughn
49f6a22b5b Remember max Tree width as new nested items are rendered 2019-04-09 10:58:43 -07:00
Brian Vaughn
d6bd3dc503 Fixed owner stack size calculation bug that sometimes caused bad overflow 2019-04-09 10:18:04 -07:00
Brian Vaughn
f1fc4b0331 Merge pull request #108 from bvaughn/reach-ui-menubutton
Use @reach MenuButton for owner stack menu [WIP]
2019-04-09 08:58:08 -07:00
Brian Vaughn
dbf6942512 Added (local) fork of @reach/portal to unblock OwnersStack MenuButton PR 2019-04-09 08:54:43 -07:00
Brian Vaughn
a29ab9ab79 Tree arrow navigation respects event.defaultPrevented
This prevents Reach MenuButton operations from also changing the tree selection in the background
2019-04-09 08:37:34 -07:00
Brian Vaughn
163bc234df Disable text selection for OwnersStack buttons 2019-04-09 08:36:54 -07:00
Brian Vaughn
db629fa073 Updated OwnersStack CSS to properly override React styles 2019-04-09 08:30:24 -07:00
Dan Abramov
4bde8f6503 Merge pull request #103 from gaearon/sad-one-way
Make DOM selection binding one-way
2019-04-09 13:25:08 +01:00
Dominic Gannaway
aece8119cf Refactor EventComponent logic + add onOwnershipChange callback (#15354) 2019-04-09 12:47:32 +01:00
Dan Abramov
153666b484 Merge pull request #107 from sophiebits/flicker
pointer-events: none to fix flicker on Overlay "tip"
2019-04-09 11:40:47 +01:00
Andrew Clark
183d1f42ed Fix: Measure expiration times relative to module initialization (#15357)
We use bitwise operations to compute expiration times, which means they
need to be smaller than 31 bits. So we measure times relative to module
initialization, similar to `performance.now`.

This was already working in the old fiber scheduler, but we didn't have
a test for it.
2019-04-08 19:44:06 -07:00
Brian Vaughn
ba99444515 Use @reach MenuButton for owner stack menu 2019-04-08 18:34:48 -07:00
Sophie Alpert
a2d84fa613 pointer-events: none to fix flicker on Overlay "tip"
If click-to-inspect then hover an element in just the right place, it flickers between two elements because this "tip" element catches the hover. This should fix it.
2019-04-08 18:26:30 -07:00
Dan
72eccb465d Make DOM selection binding one-way 2019-04-09 01:30:40 +01:00
Dan Abramov
267ab34fbd Merge pull request #99 from gaearon/sync-tabs
Sync DevTools Elements and Components tabs
2019-04-08 23:55:16 +01:00
Dan
3b793953b1 Keep DOM selection if last $0 resolves to same component 2019-04-08 23:46:47 +01:00
Dan
436912ab2d Remove unnecessary logic 2019-04-08 23:35:01 +01:00
Dan
7aecd58d81 Nits 2019-04-08 23:28:31 +01:00
Dan
c91676b557 Don't change browser selection unless React selection changed 2019-04-08 21:57:13 +01:00
Brian Vaughn
5db5e40bf1 Replaced Agent setInterval with throttle+memoize 2019-04-08 13:50:04 -07:00
Dan Abramov
388677fcbc Merge branch 'master' into continuous-select 2019-04-08 20:50:58 +01:00
Dan Abramov
4a301bd0e0 Sync DevTools Elements and Components tabs 2019-04-08 20:41:01 +01:00
Brian Vaughn
44ecff31e3 Fixed an unpleasant interaction with owners modal "..." button 2019-04-08 12:20:45 -07:00
Brian Vaughn
e43cfa0239 Don't re-measure owners stack sizes unnecessarily 2019-04-08 12:05:07 -07:00
Brian Vaughn
174125c854 Merge branch 'master' of github.com:bvaughn/react-devtools-experimental 2019-04-08 11:41:56 -07:00
Brian Vaughn
58ae3c63a8 Added export-log icon. Removed unnecessary variable assignment. 2019-04-08 11:41:25 -07:00
Dan Abramov
ab89d6500f Fix missing key 2019-04-08 19:01:28 +01:00
Brian Vaughn
fefb2bc99b Merge branch 'inspect-log' of https://github.com/gaearon/react-devtools-experimental into gaearon-inspect-log 2019-04-08 10:41:58 -07:00
Brian Vaughn
b3ba758798 Updated flow-bin 2019-04-08 10:40:46 -07:00
Brian Vaughn
7115408751 Added for itemData 2019-04-08 10:40:40 -07:00
Dan Abramov
5b120d6b24 Add a separate button for logging values 2019-04-08 18:39:37 +01:00
Dan Abramov
b176cd4414 Refactor: split inspectElementRaw 2019-04-08 18:37:36 +01:00
Brian Vaughn
14105e865a Merge pull request #92 from gaearon/highlight-on-hover
Select DOM nodes on hover
2019-04-08 10:23:56 -07:00
Dan Abramov
52014671bf Make Flow happy 2019-04-08 18:03:48 +01:00
Dan Abramov
c6ee445ea9 Address review 2019-04-08 18:00:48 +01:00
Dan Abramov
6538e7141a Add a comment 2019-04-08 17:58:12 +01:00
Dan Abramov
39223239bb Select DOM nodes on hover 2019-04-08 17:58:12 +01:00
Dan Abramov
cb164eb9fb Merge pull request #91 from gaearon/fix-scroll
Fix spurious autoscroll
2019-04-08 17:51:35 +01:00
砖家
b4bc33a584 Fix areHookInputsEqual method warning params order (#15345)
* Fix areHookInputsEqual method  warning params order

* FIX areHookInputsEqual test
2019-04-08 17:14:42 +01:00
Brian Vaughn
c619d56b1c Merge pull request #93 from gaearon/keep-mounted
Preserve state when switching tabs
2019-04-08 08:43:31 -07:00
Brian Vaughn
e86d7b51ea Merge pull request #94 from gaearon/rendered-by
Rename "owner stack" label to "rendered by"
2019-04-08 08:20:56 -07:00
Dominic Gannaway
29fb5862fb Move EventComponent state creation to complete phase + tests (#15352) 2019-04-08 16:02:20 +01:00
Dan Abramov
edfab66104 Rename "owner stack" label to "rendered by" 2019-04-08 15:40:40 +01:00
Dan Abramov
132529da79 Preserve state when switching tabs 2019-04-08 15:29:51 +01:00
Dan
0a6d637619 Fix spurious autoscroll 2019-04-08 00:51:31 +01:00
Brian Vaughn
2ba3ee6c1c Merge pull request #86 from gaearon/owner-stack-id
Preserve selection on exiting owner mode
2019-04-07 15:42:43 -07:00
Brian Vaughn
7e2ef6a34e Merge pull request #87 from gaearon/bump-overscan
Bump overscan to 3
2019-04-07 15:36:20 -07:00
Brian Vaughn
77267e8544 Fixed Toggle Flow prop types 2019-04-07 15:34:35 -07:00
Brian Vaughn
f61507158e Merge branch 'hristo-kanchev-owner-stack-enhancement' 2019-04-07 15:33:42 -07:00
Brian Vaughn
e489c8ac8e Owners stack modal behaves and looks more like a modal 2019-04-07 15:32:13 -07:00
Brian Vaughn
2ac815784b Removed unnecessary layout effect in favor of a setState 2019-04-07 15:19:17 -07:00
Dan Abramov
a9c20f0b36 Merge pull request #88 from gaearon/remove-ring
Remove tree focus ring
2019-04-07 20:16:06 +01:00
Ricky Vetter
745baf2e06 Provide new jsx transform target for reactjs/rfcs#107 (#15141)
* adding jsx function

* add more feature flag defaults

* flip ReactElement order back
2019-04-07 15:02:34 -04:00
Brian Vaughn
ae2e8128bd Merge pull request #89 from gaearon/toggle-fix
Pass Toggle label through
2019-04-07 10:54:35 -07:00
Dan
5a118701b0 Pass Toggle label through 2019-04-07 18:44:11 +01:00
Brian Vaughn
2e5e88e127 Cleaned up is-overflowing hook and dependencies 2019-04-07 10:34:44 -07:00
Dan
2607b39fe1 Remove tree focus ring 2019-04-07 18:20:34 +01:00
Brian Vaughn
5b6dbb8dd7 Replaced some passive effects with layout effects to avoid flash of overflowed owners 2019-04-07 10:01:18 -07:00
Brian Vaughn
df00a9639e Removed some unnecessary functions 2019-04-07 09:58:34 -07:00
Dan
a42a3a2d72 Bump overscan 2019-04-07 17:55:27 +01:00
Brian Vaughn
850dda0fb9 Cleaned up an old Overlay helper function 2019-04-07 09:53:34 -07:00
Brian Vaughn
252a87efe5 Use 'classnames' in TabBar to simplify an attribute 2019-04-07 09:51:54 -07:00
Brian Vaughn
9255ad1025 Replaced "colon" icon with more standard 3-dot "more" 2019-04-07 09:46:44 -07:00
Dan
f2951fb51f Preserve selection on exiting owner mode 2019-04-07 17:43:10 +01:00
Brian Vaughn
9a2f9ac880 Moved getElementDimensions() back into Overlay component 2019-04-07 09:42:52 -07:00
Brian Vaughn
d686b9d890 Merge branch 'owner-stack-enhancement' of https://github.com/hristo-kanchev/react-devtools-experimental into hristo-kanchev-owner-stack-enhancement 2019-04-07 09:13:33 -07:00
Brian Vaughn
2b868821d5 Improved keyboard navigation for tabs, interactions, and fiber-commits 2019-04-07 09:00:52 -07:00
Brian Vaughn
44c0febd23 Profiler shows commit times and durations for selected fiber 2019-04-07 08:36:37 -07:00
Hristo Kanchev
2620050abf Removed unneeded min-height. Using throttle for resize function. 2019-04-07 11:48:35 +02:00
Hristo Kanchev
ce04f531d4 Implemented new OwnerStack UI enhancement 2019-04-07 11:37:12 +02:00
Brian Vaughn
5334249bda Fixed a typo in flamegraph duration label 2019-04-06 18:01:44 -07:00
Brian Vaughn
d766d3b2e5 Throttle screenshots to reduce impact on performance. 2019-04-06 13:58:55 -07:00
Nicolas Gallagher
81a61b1d1a React events: add delay props to Press module (#15340)
* Add delay props to Press event module
* Minor naming changes to Hover events
* Add examples to react-events README
2019-04-06 13:47:28 -07:00
Brian Vaughn
bfcef10af3 Merge pull request #84 from gaearon/dead
Remove dead code
2019-04-06 13:37:50 -07:00
Dan
9fc2a3400c Remove dead code 2019-04-06 21:36:08 +01:00
Dan
99593444b9 Address review 2019-04-06 21:30:57 +01:00
Dan
785bb9f56c Continuously update tree selection in DOM inspection mode 2019-04-06 20:27:36 +01:00
Dan Abramov
985fe59826 Merge pull request #81 from gaearon/overlay-owner
Show owner in DOM highilght overlay
2019-04-06 18:26:50 +01:00
Dan
5eec8aed33 Nit 2019-04-06 18:26:17 +01:00
Dan
ab9c1b84c8 Show owner in DOM highilght overlay 2019-04-06 17:07:06 +01:00
Dominic Gannaway
4064ea9fa6 Experimental event API: Support EventComponent onUnmount responder callback (#15335) 2019-04-06 08:16:57 +01:00
Dominic Gannaway
4fbbae8afa Add full TouchHitTarget hit slop (experimental event API) to ReactDOM (#15308) 2019-04-06 07:51:21 +01:00
Dan Abramov
72d9f0597a Merge pull request #71 from gaearon/suspense-special
Fix Suspense fragment edge cases
2019-04-05 23:59:17 +01:00
Dan
d3d5c050bd Naming 2019-04-05 23:45:34 +01:00
Dan
7a03c5a885 Update the commit tree to assume operations do not repeat 2019-04-05 23:42:02 +01:00
Dan
80d9d8d841 Fix profiler and nits 2019-04-05 23:34:27 +01:00
Dan
0f536bba5c Rewrite the Suspense logic 2019-04-05 23:12:57 +01:00
Dan Abramov
d6257d382d Expand the test fixture 2019-04-05 21:49:37 +01:00
Dan
9bcd5b2576 Fix Suspense fragment edge cases 2019-04-05 21:49:37 +01:00
Dan Abramov
387ad54d80 Merge pull request #75 from gaearon/fix-double-add
Fix double-adding fibers when traversing
2019-04-05 18:45:42 +01:00
Dan Abramov
2a5b8a9206 Hard crash 2019-04-05 18:41:26 +01:00
Dan Abramov
96a7adf49e Add error logs in __DEBUG__ 2019-04-05 18:27:02 +01:00
Dan Abramov
9170e5695a Fix double-adding fibers when traversing 2019-04-05 18:18:39 +01:00
Brian Vaughn
0c8129c78a Sync selected Profiler node back to the Components tab
Also show element keys in Profiler charts
2019-04-05 08:47:23 -07:00
Brian Vaughn
d1a5346c48 Improved keyboard UX and focus UI for Tree and OwnersStack 2019-04-05 08:08:02 -07:00
Dan Abramov
632647fbac Merge pull request #61 from gaearon/toggle-suspense-2
Allow to toggle Suspense in Components pane
2019-04-05 13:22:41 +01:00
Dan
b8245de5a1 Nits 2019-04-05 13:19:39 +01:00
Dan Abramov
48a5aca127 Fix highlighting timed out Suspense DOM node 2019-04-05 13:19:35 +01:00
Dan Abramov
4f5437edf7 Allow to toggle Suspense in Components pane 2019-04-05 13:19:30 +01:00
Nicolas Gallagher
958b6173fd Add delay props to Hover event module (#15325) 2019-04-05 12:23:51 +01:00
Nicolas Gallagher
c3cc936dae Add Hover,Focus,Press docs to REAMDE (#15328) 2019-04-05 11:58:04 +01:00
Brian Vaughn
bfbb4ac545 Merge pull request #72 from gaearon/search-bug
Don't move selection unless search text increased length
2019-04-04 17:55:12 -07:00
Dan
a8e46c67e6 Don't move selection unless search text increased length 2019-04-05 00:49:27 +01:00
Andrew Clark
49595e921d [New Scheduler] Fix: Suspending an expired update (#15326)
When an async update expires, React renders at the expiration time that
corresponds to the current time, not at the original update's expiration
time. That way, all the expired work in the tree is flushed in a
single batch.

This is implemented inside `renderRoot` by comparing the next render
expiration time to the current time. If the current time is later,
`renderRoot` will restart at the later time.

Because of poor factoring, the check is currently performed right before
entering the work loop. But the work loop is usually entered multiple
times in a single callback: each time a component throws or suspends.
This led to an infinite loop where React would detect that an update
expired, restart at the current time, make a bit of progress, suspend,
check for expired work again, and start the loop again.

I fixed this by moving the expired work check to the beginning of
`renderRoot`, so that it is not performed every time something suspends.
This isn't ideal, because you could technically still fall into a loop
if more than 10ms lapse in between exiting `renderRoot` and entering it
again. The proper fix is to lift the check outside of `renderRoot`
entirely so that the function can restart without checking for expired
work again. Since this is exceedingly unlikely (and this whole thing is
still behind a flag), I'll do the better fix in an already-planned
follow up to fork `renderRoot` into separate functions for sync and
async work.
2019-04-04 16:31:22 -07:00
Brian Vaughn
16951fe7fb Merge pull request #70 from gaearon/free-debug
Explicitly guard debug calls
2019-04-04 16:12:45 -07:00
Dan
2928a0be74 Explicitly guard debug calls 2019-04-05 00:03:17 +01:00
Dominic Gannaway
b93a8a9bb8 Experimental event API: refactor responder modules for lifecycle inclusion (#15322) 2019-04-04 23:28:23 +01:00
Brian Vaughn
9b05184ccb Merge pull request #63 from gaearon/smarter-search-match
Match search at word boundaries
2019-04-04 14:41:08 -07:00
Brian Vaughn
6c5c2cd3ad Renamed innerElementType -> InnerElementType to avoid confusing hooks lint rule 2019-04-04 14:10:14 -07:00
Brian Vaughn
8d435595cd Added truncation UI indicator for hooks. Addressed lint rule violations. 2019-04-04 14:09:10 -07:00
Brian Vaughn
11d068d794 Merge branch 'fix-nested-hooks' of https://github.com/gaearon/react-devtools-experimental into gaearon-fix-nested-hooks 2019-04-04 13:54:41 -07:00
Brian Vaughn
64b0fd8ecd Fixed owners header font family too 2019-04-04 13:52:53 -07:00
Brian Vaughn
43782e6696 Merge branch 'larger-items' of https://github.com/gaearon/react-devtools-experimental into gaearon-larger-items 2019-04-04 13:48:24 -07:00
Brian Vaughn
93f83d27dd Merge pull request #66 from gaearon/dont-dismiss-menu
Stop mouseup propagation while inspecting
2019-04-04 13:47:59 -07:00
Dan Abramov
9351c8070d Fix it all 2019-04-04 19:54:56 +01:00
Dan Abramov
18e337707a Stop mouseup propagation while inspecting 2019-04-04 19:52:18 +01:00
Dan Abramov
194f523331 Add size to owner stack items 2019-04-04 19:36:04 +01:00
Dan Abramov
8478a526e6 Don't crash for deeply nested Hooks 2019-04-04 19:28:42 +01:00
Brian Vaughn
ded2ce03ee Renamed TreeWrapper to innerElementType 2019-04-04 10:08:48 -07:00
Brian Vaughn
c86793ef18 Merge branch 'a11y-tree' of https://github.com/gaearon/react-devtools-experimental into gaearon-a11y-tree 2019-04-04 09:54:46 -07:00
Dan Abramov
2afda3de37 Add back regex support 2019-04-04 17:05:34 +01:00
Dan Abramov
0f0062a71c Fix special cases 2019-04-04 17:00:35 +01:00
Nicolas Gallagher
937d262f55 React events: keyboard press, types, tests (#15314)
* Add HoverProps type
* Add more Hover event module tests
* Add more Press event module tests
* Change default longPress delay from 1000 to 500
* Rename dispatchPressEvent -> dispatchEvent
* Consolidate state updates in Press event module
* Add keyboard support for Press events
* Add FocusProps type and unit tests
2019-04-04 08:55:35 -07:00
Dan Abramov
39da33a7bf Fix regex 2019-04-04 16:38:49 +01:00
Brian Vaughn
a9fced9b0d Prettier 2019-04-04 08:35:42 -07:00
Brian Vaughn
8c3a97401f Chagned owner div to be actual button 2019-04-04 08:35:25 -07:00
Brian Vaughn
485f389d05 Merge branch 'tab-owner' of https://github.com/gaearon/react-devtools-experimental into gaearon-tab-owner 2019-04-04 08:32:16 -07:00
Dan Abramov
8cfb0e20c7 Match search at word boundaries 2019-04-04 16:22:21 +01:00
Brian Vaughn
14969c24a9 Merge pull request #62 from gaearon/search-fix
Move selection when typing in search field
2019-04-04 08:14:57 -07:00
Dan Abramov
ec71171bec Move selection when typing in search field 2019-04-04 15:59:06 +01:00
Dan Abramov
7a2dc48539 Allow DevTools to toggle Suspense fallbacks (#15232)
* Allow DevTools to toggle Suspense state

* Change API to overrideSuspense

This lets detect support for overriding Suspense from DevTools.

* Add ConcurrentMode test

* Newlines

* Remove unnecessary change

* Naming changes
2019-04-04 15:32:32 +01:00
Dan
b1c675b8b1 Make owner stack reachable by keyboard 2019-04-04 09:56:37 +01:00
Kunuk Nykjær
e221972818 update gcc version (#15034) 2019-04-04 08:56:09 +01:00
Brian Vaughn
7fbdfd9f5a Copied findCurrentFiberUsingSlowPath Suspense bug fix from recent PR https://github.com/facebook/react/pull/15312/files 2019-04-03 18:20:18 -07:00
Brian Vaughn
99f2e0da6f Hardened background script against potential errors 2019-04-03 18:16:00 -07:00
Andrew Clark
1dcab970fa Store entire build directory as CI artifacts (#15310)
* Store FB bundles as CI artifacts

Updates the Circle CI config to store Facebook bundles as build
artifacts. We already do this for our npm packages.

* Might as well store everything in build/

* Store build directory as a tarball

So it's easy to download
2019-04-03 18:15:33 -07:00
Andrew Clark
43b1f74c88 Alternate fix for #14198
This doesn't rely on checking the tag. When the alternate of a parent
is missing, it assumes it's a fragment indirection and moves onto the
next parent fiber.
2019-04-03 15:07:09 -07:00
Brian Vaughn
ed6e34da8e Added option to disable screenshot capturing while profiling 2019-04-03 14:32:16 -07:00
Dan Abramov
41aa345d2b Fix a crash in Suspense with findDOMNode 2019-04-03 13:21:27 -07:00
Andrew Clark
6d0effad76 Expose extra internals in FB build of react-dom/unstable-new-scheduler (#15311)
The Facebook build of React DOM uses a forked entry point that exposes
additional secret internals. I didn't account for this when I added
the react-dom/unstable-new-scheduler build, so the extra internals
are currently missing. This commit adds them.
2019-04-03 12:20:42 -07:00
Brian Vaughn
07bf8e53c1 Renamed GlobalHook content script references to injectGlobalHook to avoid confusion 2019-04-03 11:01:28 -07:00
Dan Abramov
c60f991d87 Make tree reachable by focus 2019-04-03 19:01:04 +01:00
Andrew Clark
3a44ccefed Fix feature flags react-dom/unstable-new-scheduler (#15309)
I forgot to account for the CommonJS builds. (I had this change in
my local checkout but accidentally didn't commit it.)
2019-04-03 10:36:18 -07:00
Brian Vaughn
5b879ac095 Fixed a name typo in a radio button 2019-04-03 09:57:13 -07:00
Brian Vaughn
f92d2bbf83 Fixed editing props for memo and forwardRef components 2019-04-03 09:29:33 -07:00
Sunil Pai
92a1d8feac mark react-events as private so we publish script skips it for now (#15307) 2019-04-03 17:22:51 +01:00
Brian Vaughn
5bc5e31cee Merge pull request #51 from gaearon/tweak-el-display
Add a space in <Foo />
2019-04-03 09:09:11 -07:00
Dan Abramov
b2cd77d2e6 Add a space in <Foo /> 2019-04-03 17:04:31 +01:00
Brian Vaughn
6493db4acc Fixed an arrow navigation bug 2019-04-03 08:12:43 -07:00
Dan Abramov
e5c59359c4 Prevent bundling of Node polyfills when importing TestUtils/TestRenderer (#15305) 2019-04-03 16:12:31 +01:00
Brian Vaughn
6772f2a9e1 Revert fa317be (temporarily show previously selected element props) 2019-04-03 07:52:30 -07:00
Behzad Abbasi
73187239af writing unit tests in experimental event Drag API (#15297)
* writing unit tests in experimental event Drag API

* add onDragMove unit test

* fix dragstart event type
2019-04-03 12:30:57 +01:00
Dominic Gannaway
89064fe68d Adds displayName to EventComponent and EventTarget (#15268)
* Adds displayName to EventComponent and EventTarget
2019-04-03 12:24:25 +01:00
Nicolas Gallagher
fc6a9f1a1e Add test for async event dispatching (#15300)
Verified that a variant of this test fails as follows when the
`context.withAsyncDispatching` function is excluded (i.e., reproduces the
issue).

    Expected value to equal:
      ["press", "longpress", "longpresschange"]
    Received:
      ["press", "longpress", "longpress", "longpresschange"]
2019-04-03 10:43:18 +01:00
Dominic Gannaway
38fa84088a Experiemental event API - wrap async dispatched events (#15299) 2019-04-03 10:25:40 +01:00
Brian Vaughn
d1a68c4b14 Merge pull request #45 from gaearon/rename
Tab name: "Elements" -> "Components"
2019-04-02 17:55:01 -07:00
Andrew Clark
4d5cb64aa2 Rewrite ReactFiberScheduler for better integration with Scheduler package (#15151)
* Rewrite ReactFiberScheduler

Adds a new implementation of ReactFiberScheduler behind a feature flag.
We will maintain both implementations in parallel until the new one
is proven stable enough to replace the old one.

The main difference between the implementations is that the new one is
integrated with the Scheduler package's priority levels.

* Conditionally add fields to FiberRoot

Some fields only used by the old scheduler, and some by the new.

* Add separate build that enables new scheduler

* Re-enable skipped test

If synchronous updates are scheduled by a passive effect, that work
should be flushed synchronously, even if flushPassiveEffects is
called inside batchedUpdates.

* Passive effects have same priority as render

* Revert ability to cancel the current callback

React doesn't need this anyway because it never schedules callbacks if
it's already rendering.

* Revert change to FiberDebugPerf

Turns out this isn't neccessary.

* Fix ReactFiberScheduler dead code elimination

Should initialize to nothing, then assign the exports conditionally,
instead of initializing to the old exports and then reassigning to the
new ones.

* Don't yield before commit during sync error retry

* Call Scheduler.flushAll unconditionally in tests

Instead of wrapping in enableNewScheduler flag.
2019-04-02 15:49:07 -07:00
Brian Vaughn
c111288c54 Store screenshots after each commit when profiling 2019-04-02 15:04:04 -07:00
Sunil Pai
aed0e1c30c await act(async () => ...) (#14853)
This took a while, but I'm happy I went through it. Some key moments - recursively flushing effects, flushing microtasks on each async turn, and my team's uncompromising philosophy on code reuse. Really happy with this. I still want to expand test coverage, and I have some more small related todos, but this is good to land. On to the next one. 

Soundtrack to landing this - https://open.spotify.com/track/0MF8I8OUo8kytiOo8aSHYq?si=gSWqUheKQbiQDXzptCXHTg

* hacked up act(async () => {...})

* move stuff around

* merge changes

* abstract .act warnings and stuff. all renderers. pass all tests.

* move testutils.act back into testutils

* move into scheduler, rename some bits

* smaller bundle

* a comment for why we don't do typeof === 'function'

* fix test

* pass tests - fire, prod

* lose actContainerElement

* tighter

* write a test for TestRenderer

it's an odd one, because not only does sync act not flush effects correctly, but the async one does (wut). verified it's fine with the dom version.

* lint

* rewrote to move flushing logic closer to the renderer

the scheduler's `flushPassiveEffects` didn't work as expected for the test renderer, so I decided to go back to the hack (rendering a dumb container) This also makes reactdom not as heavy (by a few bytes, but still).

* move it around so the delta isn't too bad

* cleanups

fix promise chaining
propagate errors correctly
test for thenable the 'right' way
more tests!
tidier!
ponies!

* Stray comment

* recursively flush effects

* fixed tests

* lint, move noop.act into react-reconciler

* microtasks when checking if called, s/called/calledLog, cleanup

* pass fb lint

we could have globally changed our eslint config to assume Promise is available, but that means we expect a promise polyfill on the page, and we don't yet. this code is triggered only in jest anyway, and we're fairly certain Promise will be available there. hence, the once-off disable for the check

* shorter timers, fix a test, test for Promise

* use global.Promise for existence check

* flush microtasks

* a version that works in browsers (that support postMessage)

I also added a sanity fixture inside fixtures/dom/ mostly for me.

* hoist flushEffectsAndMicroTasks

* pull out tick logic from ReactFiberScheduler

* fix await act (...sync) hanging

- fix a hang when awaiting sync logic
- a better async/await test for test renderer

* feedback changes

- use node's setImmediate if available
- a warning if MessageChannel isn't available
- rename some functions

* pass lint/flow checks (without requiring a Promise polyfill/exclusion)

* prettier

the prettiest, even.

* use globalPromise for the missed await warning

* __DEV__ check for didWarnAboutMessageChannel

* thenables and callbacks instead of promises, pass flow/lint

* tinier. better.

- pulled most bits out of FiberScheduler
- actedUpdates uses callbacks now

* pass build validation

* augh prettier

* golfing 7 more chars

* Test that effects are not flushed without also flushing microtasks

* export doesHavePendingPassiveEffects, nits

* createAct()

* dead code

* missed in merge?

* lose the preflushing bits

* ugh prettier

* removed `actedUpdates()`, created shared/actingUpdatesScopeDepth

* rearrange imports so builds work, remove the hack versions of flushPassiveEffects

* represent actingUpdatesScopeDepth as a tuple [number]

* use a shared flag on React.__SECRET...

* remove createAct, setup act for all relevant renderers

* review feedback

shared/enqueueTask

import ReactSharedInternals from 'shared/ReactSharedInternals';

simpler act() internals

ReactSharedInternals.ReactShouldWarnActingUpdates

* move act() implementation into createReactNoop

* warnIfNotCurrentlyActingUpdatesInDev condition check order
2019-04-02 22:33:31 +01:00
Sebastian Markbåge
4c75881ee3 Remove maxDuration from tests (#15272)
We instead assume a 150ms duration.
2019-04-02 14:27:44 -07:00
Dominic Gannaway
9307932fe5 Refactor event object creation for the experimental event API (#15295)
* Refactor event object creation for the experimental event API
2019-04-02 20:03:11 +01:00
Dan Abramov
83bd211c9e Elements -> Components (naming) 2019-04-02 19:58:18 +01:00
Dan Abramov
de730da230 Elements -> Components (label) 2019-04-02 19:54:22 +01:00
Brian Vaughn
f415e2447e Added missing Flow annotation 2019-04-02 11:53:18 -07:00
Dominic Gannaway
6a1e6b2f78 Experimental event API: loosen EventTarget constraints and warnings (#15292)
* Remove warning for event targets being direct children of event component

* Addressed feedback and added more test coverage + warnings
2019-04-02 19:49:28 +01:00
Brian Vaughn
fa317bed61 Merge pull request #41 from gaearon/smoother-right-pane
Avoid flashing "Loading..." in right pane
2019-04-02 10:09:43 -07:00
Nicolas Gallagher
f243deab82 Add tests for Press responder event module (#15290)
* Add Press responder event tests

Behavior being tested takes cues from React Native's Pressability.
A couple of these tests fail and require the Press implementation to be patched.
2019-04-02 16:49:41 +01:00
Nicolas Gallagher
296c4393da Add Press event prop types and fix a check in Safari (#15288)
* Add PressProps type to event module

* Move default Press event delays to constants

* Fix right-click press check for Safari

* Prettier and Linter

* Use event.key in press responder

event.keyCode is a deprecated API

* Remove unused props from Press event module
2019-04-02 14:42:37 +01:00
Brian Vaughn
b8ada905ff Merge pull request #35 from bvaughn/reload-and-profile
Eagerly inject renderer (before document) to support reload-and-profile
2019-04-01 14:47:51 -07:00
Brian Vaughn
2a80f8ca9c Show is-recording indicator earlier after a reload-and-profile 2019-04-01 14:43:46 -07:00
Brian Vaughn
f5f7cb5bdf Fixed some missing operations that could happen after reload-and-profile 2019-04-01 14:29:52 -07:00
Dominic Gannaway
4482fddeda Fix host context issues around EventComponents and EventTargets (#15284) 2019-04-01 19:33:39 +01:00
Brian Vaughn
74cd1a5d29 Misc cleanup of comments and localStorage key names 2019-04-01 09:05:40 -07:00
Behzad Abbasi
5ef0d1d29d Rename hover props in experimental event API and write unit tests (#15283)
* Rename hover props in experimental event API and write unit tests
2019-04-01 16:19:16 +01:00
Brian Vaughn
2c14f3e88e Inject early on when reloading-and-profiling 2019-04-01 07:48:14 -07:00
Dominic Gannaway
9444a54720 Warn on nested EventTragets in experimental event API (#15287) 2019-04-01 15:47:03 +01:00
Brian Vaughn
37ed5a7175 Merge pull request #38 from lucasecdb/patch-1
Fix casing on store import
2019-04-01 07:25:03 -07:00
Lucas Cordeiro
e634777027 Fix casing on store import 2019-04-01 10:25:57 -03:00
Brian Vaughn
628c1b2f08 Disable export profiling data option in Firefox. (downloads.download seems to just fail silently.) 2019-03-31 19:18:06 -07:00
Brian Vaughn
bfb152f160 Import/export feature 2019-03-31 17:02:30 -07:00
Sebastian Markbåge
a050f3d459 Delete Suspense Fixture (#15273)
As far as I can tell this build is broken. Let's fix or delete. If I can't
test, I can't patch it up when I break it.
2019-03-30 15:35:08 -07:00
Brian Vaughn
e5400f76f0 Added save profiling data button to Profiler 2019-03-30 14:16:34 -07:00
Nicolas Gallagher
7f1f5ddc33 Rename press props in experimental event API (#15263)
Note: this is for an experimental event API that we're testing out internally at Facebook.

* onPressIn -> onPressStart
* onPressOut -> onPressEnd
* longPressCancelsPress -> onLongPressShouldCancelPress
2019-03-30 16:23:41 +00:00
Brian Vaughn
7cac619c68 Added initial support for EventComponent/EventTarget 2019-03-30 09:02:02 -07:00
Brian Vaughn
7bd8c02f10 Added export and clear buttons for Profiler, cleaned up record toggle 2019-03-30 09:01:52 -07:00
Dan Abramov
b223ec3b39 Avoid flashing "Loading..." in right pane 2019-03-29 23:58:42 -07:00
Eli White
2e02469fa2 ReactNative's ref.measureLayout now takes a ref (#15126)
* ReactNative's ref.measureLayout now takes a ref

* Use Object as the additional param type

* Remove unnecessary whitespace

* Not supporting ref in mixin or subclass
2019-03-29 15:57:06 -07:00
Eli White
1b94fd215d Make setNativeProps a no-op with Fabric renderer (#15094)
* Make setNativeProps a no-op with Fabric renderer

* Remove unnecessary __DEV__ check
2019-03-29 15:44:15 -07:00
Nicolas Gallagher
08055a625e Fix Press module in experimental event API (#15262)
Note: this is for an experimental event API that we're testing out internally at Facebook.

Fixes a regression in f4625f5182
2019-03-29 14:26:55 -07:00
Nicolas Gallagher
f4625f5182 Fix on(Long)PressChange events in experimental press event API (#15256)
Make sure that `onPressChange` is only called if `longPressCancelsPress` is `false`.
And make sure that `onLongPressChange` is called when a long press ends.
2019-03-29 11:58:29 -07:00
Dominic Gannaway
a41b217708 Add additional event API responder surfaces (#15248)
* Add rest of event modules + small fixes
2019-03-29 10:31:18 -07:00
Brian Vaughn
a450a23e31 Improved Profiler suspense boundary UI 2019-03-29 08:53:39 -07:00
Nicolas Gallagher
700f17be67 Fix longpress in experimental Press event module (#15246)
The 'longpress' event is dispatched during a press interaction, rather than
after it has ended.

The 'longPressCancelsPress' prop can be used to prevent 'press' being
dispatched if 'longpress' has already been dispatched.
2019-03-28 21:44:28 -07:00
Dominic Gannaway
5d336df706 Allow for null targetFiber for root event handling (#15247) 2019-03-28 21:43:19 -07:00
Dominic Gannaway
c6f3524df5 Adds React event component and React event target support to SSR renderer (#15242)
* Adds React event component and React event target support to SSR renderer
2019-03-28 15:36:21 -07:00
Sebastian Markbåge
c7a2dce50a Disable JS urls at build level for www (#15230)
This will be on by default in open source for the next major.
2019-03-28 14:36:36 -07:00
Dan Abramov
fb6b50871b Update versions for 16.8.6 2019-03-27 23:58:16 -07:00
Dan Abramov
4148b0511d Changelog 2019-03-27 23:58:06 -07:00
Dominic Gannaway
1cfd256685 Fix circular module imports causing file size increase (#15231)
* Fix circular module imports causing file size increase
2019-03-27 21:17:58 -07:00
Dominic Gannaway
669cafb36f Adds experimental event component responder surfaces (#15228)
* Adds Press and Hover event modules + more features to the Event Responder System
2019-03-27 16:42:17 -07:00
Brian Vaughn
d8cb10f11f Enabled warnAboutDeprecatedLifecycles flag by default (#15186) 2019-03-27 16:30:49 -07:00
Brian Vaughn
61a251f01a Disable reload-and-profile button if no renderers support profiling 2019-03-27 09:50:19 -07:00
Brian Vaughn
7d24e83989 Implemented reload-and-profile. Also fixed an couple of minor profiling bugs along the way 2019-03-27 09:41:12 -07:00
Dominic Gannaway
80f8b0d512 Add part of the event responder system for experimental event API (#15179)
* Add part of the event responder system
2019-03-26 16:55:25 -07:00
Dan Abramov
d03ac4b231 Fix tracing fixture 2019-03-26 13:59:32 -07:00
Brian Vaughn
ea5f310fe1 Webpack config injects a __DEV_ constant 2019-03-26 13:22:55 -07:00
Brian Vaughn
0d5e4c7e09 Remove coverage badge from README (#15216) 2019-03-26 12:37:05 -07:00
Brian Vaughn
691068b0a3 Suppress horizontal scroll bars in snapshot selector 2019-03-26 11:23:19 -07:00
Brian Vaughn
894990919c Fixed a tab restoration bug in browser extension 2019-03-26 11:13:40 -07:00
Brian Vaughn
3fa951d3c3 Cleaned up a no-selection state 2019-03-25 10:34:22 -07:00
Brian Vaughn
030914fdca Moved some shared CSS vars into CSS 2019-03-25 10:29:25 -07:00
Brian Vaughn
3ba64e5955 Cleaned up edge cases around filtered commits 2019-03-25 10:18:38 -07:00
Brian Vaughn
5718eaf0f3 Added arrow key navigation for commits and interactions 2019-03-24 18:53:59 -07:00
Brian Vaughn
d973452c36 Removed some outdated TODO comments 2019-03-24 10:14:28 -07:00
Brian Vaughn
9d942b486a Show commit boxes in interaxctions sidebar 2019-03-24 09:58:56 -07:00
Brian Vaughn
afba752034 Clicking commits and interactions link to each other 2019-03-24 09:46:54 -07:00
Brian Vaughn
5602fc5371 Added interaction tracing test harness to shell 2019-03-24 09:21:37 -07:00
Brian Vaughn
69cdd38c9d Interaction chart with commit blocks rendering 2019-03-24 09:07:00 -07:00
Dan Abramov
5c2b2c0852 Warn about async infinite useEffect loop (#15180)
* Warn about async infinite useEffect loop

* Make tests sync
2019-03-22 20:04:34 +00:00
Dan Abramov
8e9a013c07 Release 16.8.5 2019-03-22 16:47:59 +00:00
Dan Abramov
db96d637d8 Changelog 2019-03-22 16:47:54 +00:00
Dan Abramov
8127a57c44 Update CHANGELOG.md 2019-03-22 16:47:44 +00:00
Dan Abramov
bfb5a0cfef Add 16.8.5 changelog 2019-03-22 16:47:39 +00:00
Dan Abramov
f33e5790b8 eslint-plugin-react-hooks@1.6.0 2019-03-22 13:56:07 +00:00
Dan Abramov
b1cccd1ed1 Warn about setState directly in dep-less useEffect (#15184) 2019-03-22 13:41:10 +00:00
Dominic Gannaway
78f2775ed0 Flip event passive logic on passiveBrowserEventsSupported (#15190) 2019-03-22 10:28:03 +00:00
Brian Vaughn
f161ee2eb7 React.warn() and React.error() (#15170) 2019-03-21 14:44:08 -07:00
Dan Abramov
78968bb3d9 Validate useEffect without deps too (#15183) 2019-03-21 20:42:13 +00:00
Sebastian Markbåge
4b8e1641b7 Fork performWork instead of using boolean flag (#15169)
I inline it into performAsyncWork instead.

Code that was only relevant to the async callback had leaked into the
performWork call which is an indication that this was a bad abstraction
and therefore the wrong place to DRY.

By inlining I also discovered that minExpirationTime is actually irrelevant
in the yieldy case so we can clean that up.
2019-03-21 13:20:52 -07:00
Brian Vaughn
56035dac64 unstable_Profiler -> Profiler (#15172) 2019-03-21 09:18:34 -07:00
Dan Abramov
31518135c2 Strengthen nested update counter test coverage (#15166)
* Isolate ReactUpdates-test cases

This ensures their behavior is consistent when run in isolation, and that they actually test the cases they're describing.

* Add coverage for cases where we reset nestedUpdateCounter

These cases explicitly verify that we reset the counter in right places.

* Add a mutually recursive test case

* Add test coverage for useLayoutEffect loop
2019-03-21 14:52:51 +00:00
Dominic Gannaway
66f280c87b Add internal logic for listening to event responders (#15168)
* Add the logic for listening to event responders
2019-03-21 12:32:40 +00:00
Andrew Clark
b1a56abd6a Fork ReactFiberScheduler with feature flag
Adds a feature flag `enableNewScheduler` that toggles between two
implementations of ReactFiberScheduler. This will let us land changes in
master while preserving the ability to quickly rollback.

Ideally this will be a short-lived fork. Once we've tested the new
scheduler for a week or so without issues, we will get rid of it. Until
then, we'll need to maintain two parallel implementations and run tests
against both of them. We rarely land changes to ReactFiberScheduler, so
I don't expect this will be a huge burden.

This commit does not implement anything new. The flag is still off and
tests run against the existing implementation.

Use `yarn test-new-scheduler` to run tests against the new one.
2019-03-20 16:28:33 -07:00
Andrew Clark
45f571736c ReactFiberScheduler -> ReactFiberScheduler.old
Doing this in its own commit so history and blame are preserved.
2019-03-20 16:27:59 -07:00
Brian Vaughn
64e355bb74 Added basic Interactions view (without graph for now) 2019-03-20 11:12:46 -07:00
Brian Vaughn
17a966651c Added suspense to TODO list and added interactions to 'Commit Info' panel 2019-03-20 09:39:14 -07:00
Dan Abramov
c05b4b81f9 Link to useLayoutEffect gist in a warning (#15158) 2019-03-20 13:40:36 +00:00
Renan Valentin
061d6ce3c0 fix(react-dom): access iframe contentWindow instead of contentDocument (#15099)
MDN has a list of methods for obtaining the window reference of an
iframe:

https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage#Syntax

fix(react-dom): check if iframe belongs to the same origin

Accessing the contentDocument of a HTMLIframeElement can cause the browser
to throw, e.g. if it has a cross-origin src attribute.
Safari will show an error in the console when the access results in "Blocked a frame with origin". e.g:

```javascript
try {
 $0.contentDocument.defaultView
} catch (err) {
  console.log('err', err)
}

> Blocked a frame with origin X from accessing a frame with origin Y. Protocols, domains, and ports must match.
> err – TypeError: null is not an object (evaluating '$0.contentDocument.defaultView')
```

A safety way is to access one of the cross origin properties: Window or Location
Which might result in "SecurityError" DOM Exception and it is compatible to Safari.

```javascript
try {
 $0.contentWindow.location.href
} catch (err) {
 console.log('err', err)
}

> err – SecurityError: Blocked a frame with origin "http://localhost:3001" from accessing a cross-origin frame. Protocols, domains, and ports must match.
```

https://html.spec.whatwg.org/multipage/browsers.html#integration-with-idl
2019-03-20 13:11:54 +00:00
Dominic Gannaway
b83e01cade Adds more scaffolding for experimental event API (#15112)
* Adds more scaffolding for experimental event API
2019-03-20 11:20:17 +00:00
Brian Vaughn
3e82e4152e Added getInteractions message 2019-03-19 18:13:44 -07:00
Dominic Gannaway
daeda44d8f Follow up to 15150 (#15152) 2019-03-19 20:55:04 +00:00
Sebastian Markbåge
acd65db5bc Deprecate module pattern (factory) components (#15145) 2019-03-19 12:55:27 -07:00
Brian Vaughn
433b6aadd6 Added placeholder Profiler sidebar views 2019-03-19 12:41:49 -07:00
Brian Vaughn
ac1a986ace Handle RTE in profiler when commit does not contain selected node 2019-03-19 11:19:30 -07:00
Brian Vaughn
1846d4fe59 Fixed a bug where treeBaseDurations were undefined for fibers that were unmounted during profiling 2019-03-19 11:08:51 -07:00
Dominic Gannaway
55cc921c5d Adds react-events package for internal testing (#15150)
* Adds react-events package for internal testing
2019-03-19 15:12:45 +00:00
Dan Abramov
7ad7386308 Improve warning for invalid class contextType (#15142)
* Improve warning for invalid class contextType

* Don't warn for null

* Grammar
2019-03-19 13:31:26 +00:00
Sebastian Markbåge
1e3364e764 Test that we don't suspend when disabling yielding (#15143) 2019-03-18 15:21:49 -07:00
Brian Vaughn
2fc03eb151 Fixed keyboard/mouse events inside of extension by using ref.ownerDocument 2019-03-18 15:11:41 -07:00
Andrew Clark
42c3c967d1 Compile invariant directly to throw expressions (#15071)
* Transform invariant to custom error type

This transforms calls to the invariant module:

```js
invariant(condition, 'A %s message that contains %s', adj, noun);
```

Into throw statements:

```js
if (!condition) {
  if (__DEV__) {
    throw ReactError(`A ${adj} message that contains ${noun}`);
  } else {
    throw ReactErrorProd(ERR_CODE, adj, noun);
  }
}
```

The only thing ReactError does is return an error whose name is set
to "Invariant Violation" to match the existing behavior.

ReactErrorProd is a special version used in production that throws
a minified error code, with a link to see to expanded form. This
replaces the reactProdInvariant module.

As a next step, I would like to replace our use of the invariant module
for user facing errors by transforming normal Error constructors to
ReactError and ReactErrorProd. (We can continue using invariant for
internal React errors that are meant to be unreachable, which was the
original purpose of invariant.)

* Use numbers instead of strings for error codes

* Use arguments instead of an array

I wasn't sure about this part so I asked Sebastian, and his rationale
was that using arguments will make ReactErrorProd slightly slower, but
using an array will likely make all the functions that throw slightly
slower to compile, so it's hard to say which way is better. But since
ReactErrorProd is in an error path, and fewer bytes is generally better,
no array is good.

* Casing nit
2019-03-18 13:58:03 -07:00
Brian Vaughn
b64a76e6bd Reset selected commit and fiber between profiling sessions 2019-03-18 13:53:10 -07:00
Brian Vaughn
9b6ee0bb22 Merge pull request #33 from bvaughn/portals
Experimenting with portals [WIP]
2019-03-18 13:37:56 -07:00
Brian Vaughn
5f154b376e Added profiling-not-supported message for browser extension 2019-03-18 13:37:37 -07:00
Brandon Dail
df7b87d25e Warn for Context.Consumer with contextType (#14831) 2019-03-18 19:27:05 +00:00
Jared Palmer
2b93d686e3 Add more info to invalid hook call error message (#15139)
* Add more info to invalid hook call error message

* Update other renderers + change call to action

* Update related tests for new hooks error message

* Fix lint errors
2019-03-18 18:22:38 +00:00
Brian Vaughn
be48150fc6 innerTagName -> innerElementType 2019-03-18 10:09:09 -07:00
Brian Vaughn
50b6b1d5f9 Added some inline comments about portal props 2019-03-18 09:57:08 -07:00
Brian Vaughn
e728ebc7b9 Unmount and remount when main URL changes to avoid staleness problems 2019-03-18 09:36:47 -07:00
Brian Vaughn
c9920f0954 Added a few inline comments 2019-03-18 09:20:00 -07:00
Brian Vaughn
2664036dbe Tweaked profiling did-not-render color to be dimmer 2019-03-18 09:18:22 -07:00
Brian Vaughn
11573bf8d9 Refactored portaling and fixed disconnected CSS vars 2019-03-18 09:11:28 -07:00
Brian Vaughn
f3f4643a3a Experimenting with portals 2019-03-17 13:52:37 -07:00
Brian Vaughn
d3ee02cd35 Added "Profiler" tab 2019-03-17 10:58:20 -07:00
Brian Vaughn
d685efd72f Fixed mutation bug in CommitTreeBuilder 2019-03-17 10:25:40 -07:00
Brian Vaughn
c82a7fb560 First pass at flame graph chart 2019-03-17 09:49:10 -07:00
Brian Vaughn
01ad9f1da6 Implemented ranked chart 2019-03-16 14:06:41 -07:00
Brian Vaughn
734e4146e7 Added Ranked chart data generation; fixed some logic errors in backend tree base duration tracking 2019-03-16 10:52:08 -07:00
Brian Vaughn
a93dab7f83 Reset commit tree cache between profiles 2019-03-16 08:50:28 -07:00
Brian Vaughn
821a6504b8 Added commit tree reconstruction 2019-03-15 20:05:52 -07:00
Andrew Clark
d926936f0b Eager bailout optimization should always compare to latest reducer (#15124)
* Eager bailout optimization should always compare to latest reducer

* queue.eagerReducer -> queue.lastRenderedReducer

This name is a bit more descriptive.

* Add test case that uses preceding render phase update
2019-03-15 19:03:59 -07:00
Sebastian Markbåge
4162f6026c Add feature flag to disable yielding (#15119) 2019-03-15 15:54:22 -07:00
Dan Abramov
8d60bd4dc2 [Shallow] Implement setState for Hooks and remount on type change (#15120)
* Throw away old shallow renderer state on type change

This worked in function components but was broken for classes. It incorrectly retained the old instance even if the type was different.

* Remove _previousComponentIdentity

We only needed this because we didn't correctly reset based on type. Now we do so this can go away.

* Use _reset when unmounting

* Use arbitrary componentIdentity

There was no particular reason it was set to element.type. We just wanted to check if something is a render phase update.

* Support Hook state updates in shallow renderer
2019-03-15 22:30:32 +00:00
Dominic Gannaway
035e4cffbd Change passive checker to use defineProperty (#15121) 2019-03-15 22:24:25 +00:00
Brandon Dail
b283d75c17 Support React.memo in ReactShallowRenderer (#14816)
* Support React.memo in ReactShallowRenderer

ReactShallowRenderer uses element.type frequently, but with React.memo
elements the actual type is element.type.type. This updates
ReactShallowRenderer so it uses the correct element type for Memo
components and also validates the inner props for the wrapped
components.

* Allow Rect.memo to prevent re-renders

* Support memo(forwardRef())

* Dont call memo comparison function on initial render

* Fix test

* Small tweaks
2019-03-15 22:17:09 +00:00
Dan Abramov
f0621fe232 Use same example code for async effect warning (#15118) 2019-03-15 19:27:55 +00:00
Kayla Ngan
ff4fb6d368 Remove facts tracker (#15111)
* Removed Travis references

* Remove used facts tracker
2019-03-15 19:25:06 +00:00
Brian Vaughn
8a7be78ed7 Finished iterating on commit selector UI for now 2019-03-15 11:51:35 -07:00
Brian Vaughn
585c1cb3d2 Refactored Profiler tree to better work with suspense 2019-03-15 10:26:21 -07:00
Brian Vaughn
e8f84dd5c4 Iterating on Profiling tab suspense. Stashing changes but planning to refactor immediately. 2019-03-15 08:34:08 -07:00
Sebastian Silbermann
52c870c8d9 Fix shallow renderer not allowing hooks in forwardRef render functions (#15100)
* test: Add test for shallow + forwardRef + hook

* fix(react-test-renderer): shallow forwardRef hooks
2019-03-15 15:28:34 +00:00
Dan Abramov
f1ff4348c1 Don't suggest a function as its own dep (#15115) 2019-03-15 15:14:01 +00:00
Dominic Gannaway
371bbf36bb Add infrastructure for passive/non-passive event support for future API exploration (#15036)
* Add infrastructure for passive/non-passive event support for future event API experimentation
2019-03-15 09:39:43 +00:00
Mateusz
ab5fe174c6 Don't set the first option as selected in select tag with size attribute (#14242)
* Set 'size' attribute to select tag if it occurs before appending options

* Add comment about why size is assigned on select create. Tests

I added some more clarification for why size must be set on select
element creation:

- In the source code
- In the DOM test fixture
- In a unit test

* Use let, not const in select tag stub assignment
2019-03-14 14:40:09 -07:00
Dan Abramov
935f60083f eslint-plugin-react-hooks@1.5.1 2019-03-14 20:11:22 +00:00
Dominic Gannaway
0c03a47436 Adds experimental event API scaffolding (#15108)
* Adds experimental event API scaffolding
2019-03-14 17:02:42 +00:00
Brian Vaughn
210c2371cf Naive pass at commit durationfiltering 2019-03-13 17:00:44 -07:00
Brian Vaughn
8b3546b437 Profiler CSS/layout tweaks 2019-03-13 16:25:29 -07:00
Nathan Hunzaker
679402a66b Improve hydration fixture, support older versions of React (#14118)
* Hydration Fixture: Only load ReactDOMServer if it exists

Fixes an issue where the hydration fixture would try to load in
ReactDOMServer below version 14. In version 13, string markup methods
exist on the React namespace.

* DOM Fixtures: Use class component for App.js

This was breaking React 0.13.0.

* Hydration Fixture: better findDOMNode compatibility

This commit fixes an issue where the Hydration DOM fixture was
unusable in React 0.13.0 or lower because of newer API usage.

It fixes that by avoiding the use of refs to get the textarea
reference in the code editor component, using various versions of
findDOMNode as required.

* Hydration Fixture: Do not show dropdown for single-line errors

If an error showed for the hydration fixture, a detail element was
used even if no additional lines could display. In that case, this
commit changes the component such that it returns a div.

* Deeper React version support for hydration fixture

This commit adds support for versions 0.4.0 of React and higher for
the hydration fixture.

The DOM test fixtures themselves do not support down to React 0.4.0,
which would be exhaustive. Instead, the Hydration fixture can pick a
version to use for its own purposes. By default, this is the version
of React used by the fixtures.

In the process of doing this, I had to make some updates to the
renderer.html document associated with the hydration fixture, and I've
added some comments to better document the history of API changes.
2019-03-13 15:12:49 -07:00
Brian Vaughn
0edf4e9dc1 Plugged react-window into commit selector 2019-03-13 14:57:52 -07:00
Sophie Alpert
1204c78977 [eslint] Wording tweaks (#15078)
* [eslint] Wording tweaks

I think these are a little clearer.

* fix tests
2019-03-13 18:31:39 +00:00
Dan Abramov
9d77a317bf Improve async useEffect warning (#15104) 2019-03-13 16:20:13 +00:00
Brian Vaughn
b8a52078c6 Added initial Suspense cache and loaded commit metadata 2019-03-12 15:50:29 -07:00
Sebastian Markbåge
103378b1ea Warn for javascript: URLs in DOM sinks (#15047)
* Prevent javascript protocol URLs

* Just warn when disableJavaScriptURLs is false

This avoids a breaking change.

* Allow framesets

* Allow <html> to be used in integration tests

Full document renders requires server rendering so the client path
just uses the hydration path in this case to simplify writing these tests.

* Detect leading and intermediate characters and test mixed case

These are considered valid javascript urls by browser so they must be
included in the filter.

This is an exact match according to the spec but maybe we should include
a super set to be safer?

* Test updates to ensure we have coverage there too

* Fix toString invocation and Flow types

Right now we invoke toString twice when we hydrate (three times
with the flag off). Ideally we should only do it once even in this case
but the code structure doesn't really allow for that right now.

* s/itRejects/itRejectsRendering

* Dedupe warning and add the unsafe URL to the warning message

* Add test that fails if g is added to the sanitizer

This only affects the prod version since the warning is deduped anyway.

* Fix prod test
2019-03-11 16:39:49 -07:00
Sebastian Markbåge
5d0c3c6c7d [Partial Hydration] Render client-only content at normal priority (#15061)
* Split props changing from permanent fallback state

These will need different logic. In this commit, no logic has changed,
only moved.

* Delete terminal fallback content in first pass

If the dehydrated suspense boundary's fallback content is terminal there
is nothing to show. We need to get actual content on the screen soon.

If we deprioritize that work to offscreen, then the timeout heuristics will
be wrong.

Therefore, if we have no current and we're already at terminal fallback
state we'll immediately schedule a deletion and upgrade to real suspense.

* Show failing case when there is another wrapper boundary

* Revert "Delete terminal fallback content in first pass"

This reverts commit ad67ba8928c23f5d9ba22d7e5c202bf27d0e49d3.

* Use the new approach of leaving work at normal pri to replace fallback
2019-03-11 13:50:19 -07:00
Brian Vaughn
e7e62acbf9 Merge pull request #32 from reznord/fix/long-props-fix
Break the text into next line for long props
2019-03-11 11:26:41 -07:00
Brian Vaughn
f5ba99e6ba Moved some things from ProfilerContext reducer into (root) Store 2019-03-11 11:26:30 -07:00
Andrew Clark
6a4a261ee8 Test suspended children are hidden before layout in persistent mode (#15030)
Refs behave differently in persistent mode, so instead of a ref, the
persistent mode version of this test asserts on the output of the
host tree.
2019-03-11 11:19:20 -07:00
Anup
896c9a79b2 Fixes #19 - Break the text into next line for long props 2019-03-11 23:37:39 +05:30
Andrew Clark
bc8bd24c14 Run persistent mode tests in CI (#15029)
* Add command to run tests in persistent mode

* Convert Suspense fuzz tester to use noop renderer

So we can run it in persistent mode, too.

* Don't mutate stateNode in appendAllChildren

We can't mutate the stateNode in appendAllChildren because the children
could be current.

This is a bit weird because now the child that we append is different
from the one on the fiber stateNode. I think this makes conceptual
sense, but I suspect this likely breaks an assumption in Fabric.

With this approach, we no longer need to clone to unhide the children,
so I removed those host config methods.

Fixes bug surfaced by fuzz tester. (The test case that failed was the
one that's already hard coded.)

* In persistent mode, disable test that reads a ref

Refs behave differently in persistent mode. I added a TODO to write
a persistent mode version of this test.

* Run persistent mode tests in CI

* test-persistent should skip files without noop

If a file doesn't reference react-noop-renderer, we shouldn't bother
running it in persistent mode, since the results will be identical to
the normal test run.

* Remove module constructor from placeholder tests

We don't need this now that we have the ability to run any test file in
either mutation or persistent mode.

* Revert "test-persistent should skip files without noop"

Seb objected to adding shelljs as a dep and I'm too lazy to worry about
Windows support so whatever I'll just revert this.

* Delete duplicate file
2019-03-11 10:56:34 -07:00
Brian Vaughn
22a3c757fb Tidied up Profiler toolbar UI 2019-03-11 09:50:20 -07:00
Brian Vaughn
e5280307c9 Added snapshot selector placeholder UI 2019-03-10 19:16:34 -07:00
Brian Vaughn
565d739569 Added commit time filter 2019-03-10 10:13:20 -07:00
Brian Vaughn
2d68007288 Initial profiling shell added
Lots of TODOs and unfinished views here.
2019-03-10 09:01:05 -07:00
Brian Vaughn
2606d119be Merge branch 'master' of github.com:bvaughn/react-devtools-experimental 2019-03-09 14:09:04 -08:00
Brian Vaughn
c687252b6a Updated Profiling overview/proposal again 2019-03-09 14:08:51 -08:00
Andrew Clark
3f4852fa5f Run Placeholder tests in persistent mode, too (#15013)
* Convert ReactSuspensePlaceholder tests to use noop

Instead of the test renderer, since test renderer does not support
running in persistent mode.

* Run Placeholder tests in persistent mode, too

* Fix Flow and lint

* Hidden text instances should have correct host context

Adds a test for a subtle edge case that only occurs in persistent mode.

* createHiddenTextInstance -> cloneHiddenTextInstance

This sidesteps the problem where createHiddenTextInstance needs access
to the host context.
2019-03-08 18:53:14 -08:00
Brian Vaughn
a5de36b0c2 Merge pull request #29 from tsriram/fix-import
Fix import file name
2019-03-08 17:41:58 -08:00
Sriram Thiagarajan
3118dae375 fix import file name 2019-03-09 07:03:42 +05:30
Brian Vaughn
5386917f59 Refined OVERVIEW a little more 2019-03-07 14:31:03 -08:00
Brian Vaughn
20b613dcde Updated Profiler OVERVIEW 2019-03-07 14:15:12 -08:00
Dan Abramov
d0289c7e3a eslint-plugin-react-hooks@1.5.0 2019-03-07 19:43:07 +00:00
Dan Abramov
03ad9c73e4 [ESLint] Tweak setState updater message and add useEffect(async) warning (#15055)
* Use first letter in setCount(c => ...) suggestion

In-person testing showed using original variable name confuses people.

* Warn about async effects
2019-03-07 19:40:23 +00:00
Dan Abramov
eb6247a9ab More concise messages (#15053) 2019-03-07 15:21:44 +00:00
Dan Abramov
197703ecc7 [ESLint] Add more hints to lint messages (#15046)
* A clearer message for props destructuring where applicable

* Add line number to the "move function" message

* Add a hint for how to fix callbacks from props

* Simplify code and harden tests

* Collect all dependency references for better warnings

* Suggest updater or reducer where appropriate
2019-03-07 12:39:15 +00:00
Brian Vaughn
0ac84f3065 Added explicit Profiler goals to OVERVIEW 2019-03-06 18:30:17 -08:00
Brian Vaughn
4257ba4983 Changed profilerSummary messages to be lazy as well 2019-03-06 18:21:38 -08:00
Brian Vaughn
181e8aff30 Added planned Profiler architecture to OVERVIEW doc to share with others 2019-03-06 18:12:11 -08:00
Dan Abramov
6d2666bab1 Fix ESLint rule crash (#15044) 2019-03-07 00:39:39 +00:00
Dan Abramov
9b7e1d1389 [ESLint] Suggest moving inside a Hook or useCallback when bare function is a dependency (#15026)
* Warn about bare function deps and suggest moving or useCallback

* Clearer wording
2019-03-06 23:50:02 +00:00
Andrew Clark
1e3b6192b5 Import Scheduler directly, not via host config (#14984)
* Import Scheduler directly, not via host config

We currently schedule asynchronous tasks via the host config. (The host
config is a static/build-time dependency injection system that varies
across different renderers — DOM, native, test, and so on.) Instead of
calling platform APIs like `requestIdleCallback` directly, each renderer
implements a method called `scheduleDeferredCallback`.

We've since discovered that when scheduling tasks, it's crucial that
React work is placed in the same queue as other, non-React work on the
main thread. Otherwise, you easily end up in a starvation scenario where
rendering is constantly interrupted by less important tasks. You need a
centralized coordinator that is used both by React and by other
frameworks and application code. This coordinator must also have a
consistent API across all the different host environments, for
convention's sake and so product code is portable — e.g. so the same
component can work in both React Native and React Native Web.

This turned into the Scheduler package. We will have different builds of
Scheduler for each of our target platforms. With this approach, we treat
Scheduler like a built-in platform primitive that exists wherever React
is supported.

Now that we have this consistent interface, the indirection of the host
config no longer makes sense for the purpose of scheduling tasks. In
fact, we explicitly do not want renderers to scheduled task via any
system except the Scheduler package.

So, this PR removes `scheduleDeferredCallback` and its associated
methods from the host config in favor of directly importing Scheduler.

* Missed an extraneous export
2019-03-06 14:41:45 -08:00
Brian Vaughn
e9028d1d35 Re-organized views slightly in preparation for Profiler UI 2019-03-06 14:01:52 -08:00
Brian Vaughn
c18449326d Disabled transferrables for now (to avoid a Chrome runtime error) 2019-03-06 13:17:20 -08:00
Dan Abramov
5d49dafac8 Enforce deps array in useMemo and useCallback (#15025) 2019-03-06 18:17:54 +00:00
Brian Vaughn
a9aa24ed8d 16.8.4 and changelog 2019-03-05 15:17:42 -08:00
Dan Abramov
db8d466554 Fix heading in changelog 2019-03-05 22:40:04 +00:00
Dan Abramov
fa5d4ee43b [ESLint] Treat functions that don't capture anything as static (#14996)
* Treat functions that don't capture anything as static

* Fix comment
2019-03-05 21:07:37 +00:00
Dan Abramov
fd557d453d Warn on mount when deps are not an array (#15018)
* Warn on mount when deps are not an array

* Check other Hooks

* I can't figure out how to fix error/warning nesting lint

But it doesn't really matter much because we test other cases in the other test.
2019-03-05 17:41:27 +00:00
Farhad Yasir
ff596e3efb fix(auto-version-update): update root package version while publishing (#15005)
* fix(auto-version-update): update root package version while publishing

* fix(remove-version): remove version field from package json
2019-03-04 12:36:17 -08:00
Andrew Clark
ce45ca9ba3 Prettier 2019-03-04 11:38:08 -08:00
Andrew Clark
757a70b25d ReactNoop.yield -> Scheduler.yieldValue (#15008)
These used to be different things, but now ReactNoop.yield merely
re-exports Scheduler.yieldValue, so let's get rid of it.
2019-03-04 11:23:00 -08:00
Brian Vaughn
0db7770cf7 Merged master 2019-03-03 12:41:08 -08:00
Brian Vaughn
235851da87 Merge pull request #27 from gaurav5430/master
Update OVERVIEW.md
2019-03-03 08:14:05 -08:00
Gaurav Gupta
f94401c10e Update OVERVIEW.md
Fixed the superscript reference
2019-03-03 18:29:58 +05:30
Andrew Clark
9d756d903f Revert #14756 changes to ReactFiberScheduler (#14992)
* Revert #14756 changes to ReactFiberScheduler

This PR introduced some bugs in concurrent mode during internal testing.
Until we figure out a proper solution, I'm going to try reverting it.

Not totally certain this is sufficient to unbreak the bugs we found, but
I'm using this branch to determine that.

* Add back commented out Scheduler import

With a note not to use named imports next time we import Scheduler
in this module.
2019-03-01 13:10:12 -08:00
Dan Abramov
f16442a106 eslint-plugin-react-hooks@1.4.0 2019-03-01 20:29:06 +00:00
Dan Abramov
e1e45fb367 [ESLint] Suggest to destructure props when they are only used as members (#14993)
* Suggest to destructure props when they are only used as members

* Add more tests

* Fix a bug
2019-03-01 19:48:48 +00:00
Dan Abramov
59ef28437a Warn about dependencies outside of render scope (#14990) 2019-03-01 18:16:17 +00:00
Brian Vaughn
515b60cc5e Fixed a typo in OVERVIEW 2019-03-01 08:38:05 -08:00
Brian Vaughn
8aa6f96279 Fixed selecterd element background color being cut-off when tree scrolls
This required a bit of unusual CSS but seems to work well for Firefox and Chrome. We can remove it and revisit other approaches (like PR#24) in the future if needed.
2019-03-01 08:28:16 -08:00
Dan Abramov
df7b4768c7 [ESLint] Deduplicate suggested dependencies (#14982)
* Deduplicate suggested dependencies

* Tweak test cases
2019-03-01 16:10:22 +00:00
Dan Abramov
02404d793b Avoid dynamic dispatch for scheduler calls (#14968) 2019-03-01 15:04:15 +00:00
Brian Vaughn
0401f34f55 Removed unnecessary relative position style from Element CSS 2019-02-28 14:50:27 -08:00
Brian Vaughn
bb2939ccc2 Support editable useState hooks in DevTools (#14906)
* ReactDebugHooks identifies State and Reducer hooks as editable
* Inject overrideHookState() method to DevTools to support editing in DEV builds
* Added an integration test for React DevTools, react-debug-tools, and overrideHookState
2019-02-28 14:37:55 -08:00
Brian Vaughn
90001e892d Udpated param name in injected renderer overrideHookState type 2019-02-28 13:55:49 -08:00
Brian Vaughn
d70dbfdb65 Added intro to OVERVIEW 2019-02-28 13:46:36 -08:00
Brian Vaughn
c249e31932 Fixed docs typo: chlid -> child 2019-02-28 13:26:39 -08:00
Brian Vaughn
7da5f83a28 Updated to account for facebook/react/pull/14906/commits/cdd9ba4 2019-02-28 13:22:27 -08:00
Brian Vaughn
c7f8557202 Improve selected node highlighting by using minWidth instead of width 2019-02-28 12:56:49 -08:00
Andrew Clark
69060e1da6 Swap expect(ReactNoop) for expect(Scheduler) (#14971)
* Swap expect(ReactNoop) for expect(Scheduler)

In the previous commits, I upgraded our custom Jest matchers for the
noop and test renderers to use Scheduler under the hood.

Now that all these matchers are using Scheduler, we can drop
support for passing ReactNoop and test roots and always pass
Scheduler directly.

* Externalize Scheduler in noop and test bundles

I also noticed we don't need to regenerator runtime in noop anymore.
2019-02-28 12:54:47 -08:00
Andrew Clark
ccb2a8a44e Replace test renderer's fake Scheduler implementation with mock build (#14970)
* Replace test renderer's fake Scheduler implementation with mock build

The test renderer has its own mock implementation of the Scheduler
interface, with the ability to partially render work in tests. Now that
this functionality has been lifted into a proper mock Scheduler build,
we can use that instead.

* Fix Profiler tests in prod
2019-02-28 10:50:38 -08:00
Brian Vaughn
bffa72c601 Add placeholders to clarify between empty string, null, and undefined 2019-02-28 10:46:17 -08:00
Andrew Clark
53e787b45f Replace noop's fake Scheduler implementation with mock Scheduler build (#14969)
* Replace noop's fake Scheduler implementation with mock Scheduler build

The noop renderer has its own mock implementation of the Scheduler
interface, with the ability to partially render work in tests. Now that
this functionality has been lifted into a proper mock Scheduler build,
we can use that instead.

Most of the existing noop tests were unaffected, but I did have to make
some changes. The biggest one involved passive effects: previously, they
were scheduled on a separate queue from the queue that handles
rendering. After this change, both rendering and effects are scheduled
in the Scheduler queue. I think this is a better approach because tests
no longer have to worry about the difference; if you call `flushAll`,
all the work is flushed, both rendering and effects. But for those few
tests that do care to flush the rendering without the effects, that's
still possible using the `yieldValue` API.

Follow-up: Do the same for test renderer.

* Fix import to scheduler/unstable_mock
2019-02-28 10:30:46 -08:00
Brian Vaughn
d34a32d389 Disable text selection in tree 2019-02-28 09:44:04 -08:00
Brian Vaughn
d6a2ba2616 Added OVERVIEW doc 2019-02-28 08:52:54 -08:00
Brian Vaughn
bcb6c2fd9f Removed an unnecessary entry from add-root operation array 2019-02-28 08:52:46 -08:00
Brian Vaughn
13ca37384d Maybe fixed checkbox alignment issue Dan reported? 2019-02-27 13:54:53 -08:00
Brian Vaughn
0153eaedee Left arrow selects parent in tree 2019-02-27 13:49:46 -08:00
Brian Vaughn
bf02b2ffbf Select DOM element mode should useCapture to prevent clicks from passing through 2019-02-27 13:33:10 -08:00
Brian Vaughn
05ef0ad7dc Disable view-source button rather than hiding it to avoid jumping when selecting new components 2019-02-27 13:30:03 -08:00
Brian Vaughn
1e4434ecc4 Changed select-on-click to select-on-mouse-down and fixed a scrollIntoView problem 2019-02-27 13:11:23 -08:00
Brian Vaughn
8041bfb92f Add .vscode to .gitignore 2019-02-27 13:07:09 -08:00
Brian Vaughn
bc4e8950f6 Updated test code to include a deeply nested DIV 2019-02-27 13:05:43 -08:00
Brian Vaughn
4d9e7e75c6 Merge branch 'scroll-into-view' of https://github.com/Jessidhia/react-devtools-experimental into Jessidhia-scroll-into-view 2019-02-27 12:58:03 -08:00
Dan Abramov
3ada82b741 Allow extraneous effect dependencies (#14967)
This makes cases like

  useEffect(() => {
    window.scrollTo(0, 0);
  }, [activeTab]);

not warn.

However, it still warns for unused useCallback/useMemo deps.
2019-02-27 16:59:11 +00:00
Andrew Clark
00748c53e1 Add new mock build of Scheduler with flush, yield API (#14964)
* Add new mock build of Scheduler with flush, yield API

Test environments need a way to take control of the Scheduler queue and
incrementally flush work. Our current tests accomplish this either using
dynamic injection, or by using Jest's fake timers feature. Both of these
options are fragile and rely too much on implementation details.

In this new approach, we have a separate build of Scheduler that is
specifically designed for test environments. We mock the default
implementation like we would any other module; in our case, via Jest.
This special build has methods like `flushAll` and `yieldValue` that
control when work is flushed. These methods are based on equivalent
methods we've been using to write incremental React tests. Eventually
we may want to migrate the React tests to interact with the mock
Scheduler directly, instead of going through the host config like we
currently do.

For now, I'm using our custom static injection infrastructure to create
the two builds of Scheduler — a default build for DOM (which falls back
to a naive timer based implementation), and the new mock build. I did it
this way because it allows me to share most of the implementation, which
isn't specific to a host environment — e.g. everything related to the
priority queue. It may be better to duplicate the shared code instead,
especially considering that future environments (like React Native) may
have entirely forked implementations. I'd prefer to wait until the
implementation stabilizes before worrying about that, but I'm open to
changing this now if we decide it's important enough.

* Mock Scheduler in bundle tests, too

* Remove special case by making regex more restrictive
2019-02-26 20:51:17 -08:00
Brian Vaughn
4186952a6f Fixed incompatibility between react-debug-tools and useContext() (#14940)
* Refactor hook ordering check to use DEV-only data structure. This enables us to warn about more cases (e.g. useContext, useDebugValue) withou the need to add any overhead to production bundles.
2019-02-26 14:24:52 -08:00
Dan Abramov
0b8efb229c Allow omitting constant primitive deps (#14959) 2019-02-26 16:12:15 +00:00
Andrew Clark
8e25ed20bd Unify noop and test renderer assertion APIs (#14952)
* Throw in tests if work is done before emptying log

Test renderer already does this. Makes it harder to miss unexpected
behavior by forcing you to assert on every logged value.

* Convert ReactNoop tests to use jest matchers

The matchers warn if work is flushed while the log is empty. This is
the pattern we already follow for test renderer. I've used the same APIs
as test renderer, so it should be easy to switch between the two.
2019-02-25 19:01:45 -08:00
Eli White
870214f37a Deprecate ref.setNativeProps in favor of ReactNative.setNativeProps (#14912)
* Deprecate ref.setNativeProps in favor of ReactNative.setNativeProps

* Using a feature flag for the setNativeProps warning

* Removing extra line breaks

* Set the FB native feature flag to true

* Prettier
2019-02-25 15:00:39 -08:00
Dan Abramov
3989c09500 eslint-plugin-react-hooks@1.3.0 2019-02-25 17:27:37 +00:00
Dan Abramov
1bbfbc98d2 [ESLint] Add more cases to exhaustive-deps rule (#14930)
* Add better message for literal dependencies

* Warn about ref.current in cleanup phase

* Fix wrong comment

* Tweak wording
2019-02-25 16:00:29 +00:00
Farhad Yasir
412f882968 fix(eslint-plugin-react-hooks): node engine updated to version 7 because of object.entries (#14951) 2019-02-25 15:37:06 +00:00
Brian Vaughn
89df0a6363 Yarn upgrade 2019-02-24 18:32:29 -08:00
Marco
1d6b1660a2 Fixed typo (#14943) 2019-02-24 09:50:23 -08:00
Brian Vaughn
9f24e8c7a2 Renamed overrideHook -> overrideHookState (to stay in sync with React PR) 2019-02-23 09:12:17 -08:00
Brian Vaughn
9b96b1f809 Updated deploy scripts and pre-release template 2019-02-23 08:59:21 -08:00
Andrew Clark
ba708fa79b Remove ReactNoop.flushDeferredPri and flushUnitsOfWork (#14934)
* Remove ReactNoop.flushDeferredPri and flushUnitsOfWork

Some of our older tests worked by counting how many times React checked
whether it should yield to the main thread, instead of something
publicly observable like how many times a component is rendered.

Our newer tests have converged on a style where we push into a log and
make assertions on the log. This pattern is less coupled to the
implementation while still being sufficient to test performance
optimizations, like resuming (whenever we add that back).

This commit removes flushDeferredPri and flushUnitsOfWork and upgrades
the affected tests.

* Remove shouldYieldToRenderer indirection

This wrapper is no longer necessary.
2019-02-22 17:27:30 -08:00
Andrew Clark
920b0bbb3c [scheduler] Pass didTimeout argument to callbacks (#14931)
As I prepare to refactor the Fiber scheduler, I've noticed some quirks
in our implementation. This PR addressed one of them.

---

There's no reason for a timed out Scheduler callback to check
`shouldYield`, because the value will always be false until the work
has completed. The `didTimeout` argument provides this information to
the callback so it can avoid the redundant checks.

React's existing check for whether a callback has timed out didn't make
any sense, but happened to work anyway. I don't think the wrongness of
the old implementation is observable via React APIs but it's
incoherent regardless.
2019-02-22 16:39:10 -08:00
Brian Vaughn
7b2f06e3d3 Added (temporary) deploy scripts for pre-release extensions 2019-02-22 14:36:10 -08:00
Brian Vaughn
53632883b6 Implemented view-source button for DOM extension 2019-02-22 13:24:03 -08:00
Brian Vaughn
105b53f0fb Split :active and :focus styles for Button+Toggle 2019-02-22 10:54:18 -08:00
Brian Vaughn
5fd9cb5dfb Added copy props/state/hooks/context button 2019-02-22 09:39:05 -08:00
Brian Vaughn
1edbfbf6cb Fixed some small overflow/scrollbar issues 2019-02-22 08:44:05 -08:00
Brian Vaughn
33cb3f04f1 Release script clarifies which test fixture failed (#14922) 2019-02-22 07:43:27 -08:00
Brian Vaughn
f708f9e307 Improve pactch release process docs (#14923) 2019-02-22 07:43:18 -08:00
Matt Thomson
f99fca3cb2 Fix sample ESLint configuration (#14926)
See [ESLint docs](https://eslint.org/docs/user-guide/configuring#configuring-rules)
2019-02-22 12:22:07 +00:00
Brian Vaughn
0c346ceea8 Re-added transferrables (after 'shutdown' evt fix) and guard against a tree mutation race 2019-02-21 14:56:11 -08:00
Brian Vaughn
caf2eb973a Split large InspectedElementTree file into separate component-files 2019-02-21 14:20:14 -08:00
Brian Vaughn
9898db02d1 Restore input focus after clicking reset value button 2019-02-21 14:13:48 -08:00
Brian Vaughn
4f64c9ef9e Tweaked colors; Esc key to undo edits 2019-02-21 14:11:06 -08:00
Brian Vaughn
ddeb78001c Tweaked colors based on Andrew's feedback 2019-02-21 14:02:45 -08:00
Brian Vaughn
290e8c6926 Fixed null input value. Tweaked useReducer test harness. 2019-02-21 13:40:23 -08:00
Brian Vaughn
bdf8065137 Merge branch 'master' of github.com:bvaughn/react-devtools-experimental 2019-02-21 13:24:15 -08:00
Brian Vaughn
6f118497e8 Updated editable hooks UI and added limited undo feature 2019-02-21 13:24:01 -08:00
Brian Vaughn
2b27f63a61 Updated ESLint hooks rule 2019-02-21 11:55:28 -08:00
Dan Abramov
22bb947642 Release eslint-plugin-react-hooks@1.2.0 2019-02-21 19:41:35 +00:00
Dan Abramov
a77bbf1a1c [ESLint] Warn against assignments from inside Hooks (#14916)
* [ESLint] Warn against assignments from inside Hooks

* Include variable name

* Add a test for the legit case
2019-02-21 19:23:00 +00:00
Dan Abramov
219ce8a9cc Fix tracing fixture (#14917) 2019-02-21 18:14:32 +00:00
Dan Abramov
8c1966590a Release 16.8.3 2019-02-21 18:09:18 +00:00
Dan Abramov
7de4d23919 Fix UMD builds by re-exporting the scheduler priorities (#14914) 2019-02-21 17:20:28 +00:00
Brian Vaughn
df4a09d9b8 Updated flow-bin from 91 -> 93 and removed unnecessary fixmes 2019-02-21 09:15:47 -08:00
Brian Vaughn
e35819e68d Renamed nativeHookIndex -> index 2019-02-21 08:59:46 -08:00
Nathan Hunzaker
d0318fb3f9 Updating copyright headers, dropping the year (#14893)
* Updating copyright headers, dropping the year
* Update copyright in ReactDOMHooks-test and react-cache LRU.js
2019-02-21 08:46:13 -08:00
Brian Vaughn
532cca8013 Merge pull request #4 from mishaor/linux-support
Added support for Linux
2019-02-21 08:24:33 -08:00
Michael Orishich
b0ccd9d89e added basic support for Linux 2019-02-21 20:00:11 +02:00
Eli White
f978d5fde4 Fix warning message for new setNativeProps method. on -> with (#14909) 2019-02-20 23:53:21 -08:00
Eli White
b0f45c0fc6 Adding ReactNative.setNativeProps that takes a ref (#14907)
* Adding ReactNative.setNativeProps that takes a ref

* Adding test for components rendered with Fabric with Paper's setNativeProps

* Fixing flow types

* Fix prettier

* Rename ReactNativeSetNativeProps.js to be more general
2019-02-20 23:20:42 -08:00
Brian Vaughn
8cd8b29015 Added support for editable hook values (pending facebook/react/pull/14906) 2019-02-20 15:58:52 -08:00
Eli White
4f4aa69f1b Adding setNativeProps tests for NativeMethodsMixin (#14901) 2019-02-20 13:16:35 -08:00
Brian Vaughn
90f98372a9 Fixed broken 'shutdown' event that lead to CPU problems when reloading DevTools 2019-02-20 11:55:48 -08:00
Eli White
b96b61dc4d Use the canonical nativeTag for Fabric's setNativeProps (#14900)
* Use the canonical nativeTag for Fabric's setNativeProps

* Fix prettier
2019-02-20 11:09:31 -08:00
Brian Vaughn
42795b22bf Installed eslint-plugin-react-hooks@next and added to ESLint config 2019-02-20 11:03:50 -08:00
Dan Abramov
dab2fdbbbd Add eslint-plugin-react-hooks/exhaustive-deps rule to check stale closure dependencies (#14636)
* Add ESLint rule for useEffect/useCallback/useMemo Hook dependencies

* Fix ReactiveDependencies rule

* fix lint errors

* Support useLayoutEffect

* Add some failing tests and comments

* Gather dependencies in child scopes too

* If we don't find foo.bar.baz in deps, try foo.bar, then foo

* foo is enough for both foo.bar and foo.baz

* Shorter rule name

* Add fixable meta

* Remove a bunch of code and start from scratch

* [WIP] Only report errors from dependency array

This results in nicer editing experience. Also has autofix.

* Fix typo

* [Temp] Skip all tests

* Fix the first test

* Revamp the test suite

* Fix [foo] to include foo.bar

* Don't suggest call expressions

* Special case 'current' for refs

* Don't complain about known static deps

* Support useImperativeHandle

* Better punctuation and formatting

* More uniform message format

* Treat React.useRef/useState/useReducer as static too

* Add special message for ref.current

* Add a TODO case

* Alphabetize the autofix

* Only alphabetize if it already was

* Don't add static deps by default

* Add an undefined variable case

* Tweak wording

* Rename to exhaustive-deps

* Clean up / refactor a little bit
2019-02-20 18:18:58 +00:00
Josh R
1493abd7e0 Deleted empty App.css (#14149) 2019-02-19 15:49:34 -08:00
Brian Vaughn
bec073365d Fix hooks warnings identified by prerelease version of react-hooks ESLint plugin 2019-02-19 13:15:57 -08:00
Sebastian Markbåge
13645d224d Deal with fallback content in Partial Hydration (#14884)
* Replace SSR fallback content with new suspense content

* The three states of a Dehydrated Suspense

This introduces three states for dehydrated suspense boundaries

Pending - This means that the tree is still waiting for additional data or
to be populated with its final content.

Fallback - This means that the tree has entered a permanent fallback state
and no more data from the server is to be expected. This means that the
client should take over and try to render instead. The fallback nodes will
be deleted.

Normal - The node has entered its final content and is now ready to be
hydrated.

* Rename retryTimedOutBoundary to resolveRetryThenable

This doesn't just retry. It assumes that resolving a thenable means that
it is ok to clear it from the thenable cache.

We'll reuse the retryTimedOutBoundary logic separately.

* Register a callback to be fired when a boundary changes away from pending

It's now possible to switch from a pending state to either hydrating
or replacing the content.
2019-02-19 13:07:41 -08:00
Dan Abramov
c506ded3b2 Don't discard render phase state updates with the eager reducer optimization (#14852)
* Add test cases for setState(fn) + render phase updates

* Update eager state and reducer for render phase updates

* Fix a newly firing warning
2019-02-19 18:40:10 +00:00
Brian Vaughn
a31415011d Removed numeric key code 2019-02-19 08:59:27 -08:00
Brian Vaughn
3376daaa41 Merge pull request #2 from Jessidhia/fix-utf-encoding
Fix encoding of Unicode keys greater than U+00FF
2019-02-19 08:56:21 -08:00
Jessica
044e6ba9cd Pass options to scrollIntoView 2019-02-19 16:36:43 +09:00
Jessica
65d493cae9 Just use codepoints as it'll be copied into an Uint32Array anyway 2019-02-19 16:03:53 +09:00
Jessica
4ee74f7e6c Fix encoding of Unicode keys greater than U+00FF (greater than U+FFFF handled by surrogate pairs) 2019-02-19 15:52:24 +09:00
Jessica
28ea0a352e Scroll to newly selected component if it's out of view 2019-02-19 12:22:19 +09:00
Brian Vaughn
a4212dcdce Support editable props, state, and context values 2019-02-17 13:07:39 -08:00
Brian Vaughn
6c226b0c80 Added link to now.sh preview to README 2019-02-16 09:46:10 -08:00
Brian Vaughn
c4d6fdbfdb Fixed overlay position bug 2019-02-16 08:33:38 -08:00
Brian Vaughn
1d95098177 Implemented select-DOM-element button 2019-02-16 08:29:26 -08:00
Brian Vaughn
2fbacbff01 Tab bar resizes properly for narrow screens 2019-02-15 11:42:55 -08:00
Brian Vaughn
0e67969cb1 Prompt to include UMD build artifact links in GitHub release (#14864) 2019-02-15 10:48:20 -08:00
Brian Vaughn
fad0842fd4 Release scripts documentation (#14863)
* Improve release script process documentation
* Improved pre-publish instructions/message based on feedback
* Added reminder to attach build artifacts to GitHub release
2019-02-15 10:00:43 -08:00
Brian Vaughn
0008bb00d7 Inspectable complex hook values 2019-02-14 21:55:09 -08:00
Brian Vaughn
47a5fd59cb Reduced tree padding (left) slightly to make larger trees easier to inspect 2019-02-14 15:13:43 -08:00
Brian Vaughn
04a0d24f0f Fixed a potential source of duplicate key 2019-02-14 15:06:38 -08:00
Brian Vaughn
3f40d38203 Fixed edge case mutation bugs in selected element and tree context 2019-02-14 14:36:29 -08:00
Brian Vaughn
bf2f13d32a Removed some stale TODO comments 2019-02-14 13:37:40 -08:00
Brian Vaughn
9cfa25bdcc Tidied up Flow types for Bridge and Store 2019-02-14 13:32:30 -08:00
Brian Vaughn
b167dd339b Style, theme, and button CSS cleanup 2019-02-14 13:20:24 -08:00
Brian Vaughn
a07d9862ca Fixed edge-case display density bug 2019-02-14 12:46:27 -08:00
overlookmotel
ab7a67b1dc Fix react-dom/server context leaks when render stream destroyed early (#14706)
* Fix react-dom/server context memory retention

* Test for pollution of later renders

* Inline loop

* More tests
2019-02-14 19:50:23 +00:00
Brian Vaughn
15c5396169 Re-added "Settings" panel to browser extension and (hopefully) fixed a lot of sources of error 2019-02-14 11:45:11 -08:00
Dan Abramov
3e55560438 Release 16.8.2 2019-02-14 19:13:15 +00:00
Brian Vaughn
5a301cd26e Tweaked the owner stack exit icon 2019-02-14 09:23:54 -08:00
Dan Abramov
dfabb77a97 Include another change in 16.8.2 2019-02-14 17:21:27 +00:00
Sunil Pai
c555c008b6 Include component stack in 'act(...)' warning (#14855)
* add a component stack trace to the act() warning

* pass tests

* nit
2019-02-14 17:20:49 +00:00
Brian Vaughn
36e596ecd1 Changed dark theme to have more React blues 2019-02-14 09:17:29 -08:00
Brian Vaughn
94aab74253 Avoid NPE in Agent if renderer can't be found for an ID 2019-02-14 08:13:35 -08:00
Dan Abramov
ff188d666b Add React 16.8.2 changelog (#14851) 2019-02-14 14:51:01 +00:00
Deniz Susman
c4d8ef6430 Fix typo in code comment (#14836) 2019-02-13 20:49:37 -08:00
Brian Vaughn
c229837f33 Temporarily disabled Settings panel 2019-02-13 11:36:43 -08:00
Brian Vaughn
79f57532b9 Split demo app into multiple roots and fixed a multi-root bug 2019-02-13 11:22:22 -08:00
Sebastian Markbåge
08e9554357 Statically enable suspense/partial hydration flag in www (#14842)
It doesn't hurt to have this always on since it is only when we use
Suspense that it matters. This saves some code/checks.
2019-02-13 10:55:13 -08:00
Dan Abramov
0e4135e8c2 Revert "[ShallowRenderer] Queue/rerender on dispatched action after render component with hooks (#14802)" (#14839)
This reverts commit 6d4038f0a6.
2019-02-13 16:52:14 +00:00
Brian Vaughn
4ea81337f3 Initial pass at adding Settings panel to browser extension 2019-02-13 10:59:49 -05:00
Rodrigo Ribeiro
6d4038f0a6 [ShallowRenderer] Queue/rerender on dispatched action after render component with hooks (#14802)
* [shallow-renderer] Rerender on dispatched action out of render
2019-02-13 15:59:02 +00:00
Brandon Dail
fa6205d522 Special case crossOrigin for SVG image elements (#14832) 2019-02-12 20:13:17 -08:00
Brian Vaughn
aed1713154 Added NOW config file for dev shell 2019-02-12 21:09:50 -05:00
Brian Vaughn
95b859209f Fixed NaN warning for pre-mount CSS prop read 2019-02-12 21:09:33 -05:00
Brian Vaughn
d203ebf165 Added new tabs UI and theme/display-density preferences 2019-02-12 20:41:39 -05:00
Dan Abramov
c6bee765ba Remove false positive warning and add TODOs about current being non-null (#14821)
* Failing test for false positive warning

* Add tests for forwardRef too

* Remove the warning and add TODOs
2019-02-13 00:00:10 +00:00
Dan Abramov
3ae94e1885 Fix ignored sync work in passive effects (#14799)
* Fix ignored sync work in passive effects

* Fix batching
2019-02-12 20:18:35 +00:00
Brian Vaughn
8e5a35b762 Misc cleanup and prep for dark mode CSS 2019-02-12 09:45:00 -05:00
Sebastian Markbåge
f3a14951ab Partial Hydration (#14717)
* Basic partial hydration test

* Render comments around Suspense components

We need this to be able to identify how far to skip ahead if we're not
going to hydrate this subtree yet.

* Add DehydratedSuspenseComponent type of work

Will be used for Suspense boundaries that are left with their server
rendered content intact.

* Add comment node as hydratable instance type as placeholder for suspense

* Skip past nodes within the Suspense boundary

This lets us continue hydrating sibling nodes.

* A dehydrated suspense boundary comment should be considered a sibling

* Retry hydrating at offscreen pri or after ping if suspended

* Enter hydration state when retrying dehydrated suspense boundary

* Delete all children within a dehydrated suspense boundary when it's deleted

* Delete server rendered content when props change before hydration completes

* Make test internal

* Wrap in act

* Change SSR Fixture to use Partial Hydration

This requires the enableSuspenseServerRenderer flag to be manually enabled
for the build to work.

* Changes to any parent Context forces clearing dehydrated content

We mark dehydrated boundaries as having child work, since they might have
components that read from the changed context.

We check this in beginWork and if it does we treat it as if the input
has changed (same as if props changes).

* Wrap in feature flag

* Treat Suspense boundaries without fallbacks as if not-boundaries

These don't come into play for purposes of hydration.

* Fix clearing of nested suspense boundaries

* ping -> retry

Co-Authored-By: sebmarkbage <sebastian@calyptus.eu>

* Typo

Co-Authored-By: sebmarkbage <sebastian@calyptus.eu>

* Use didReceiveUpdate instead of manually comparing props

* Leave comment for why it's ok to ignore the timeout
2019-02-11 21:25:44 -08:00
Dan Abramov
f24a0da6e0 Fix useImperativeHandle to have no deps by default (#14801)
* Fix useImperativeHandle to have no deps by default

* Save a byte?

* Nit: null
2019-02-11 18:42:28 +00:00
Dan Abramov
1fecba9230 Fix crash unmounting an empty Portal (#14820)
* Adds failing test for https://github.com/facebook/react/issues/14811

* Fix removeChild() crash when removing an empty Portal
2019-02-11 18:37:53 +00:00
Alexey Raspopov
e15542ee0f use functional component as a first example in readme (#14819) 2019-02-11 14:41:37 +00:00
zhuoli99
c11015ff4f fix spelling mistakes (#14805) 2019-02-09 16:43:49 -08:00
Deniz Susman
3e295edd52 Typo fix in comment (#14787) 2019-02-09 16:42:55 -08:00
Sebastian Markbåge
1d48b4a684 Fix hydration with createRoot warning (#14808)
It's suggesting an API that doesn't exist. Fixed it to reference the actual
API.
2019-02-09 17:12:11 +00:00
Brian Vaughn
f3f497f40f Cleaned up CSS vars and reduced font size a bit 2019-02-08 20:27:10 -05:00
Brian Vaughn
a6126c9e27 Initial stab at 'View in DOM' button 2019-02-08 18:48:29 -05:00
Brian Vaughn
baa6142801 Removed non-functioning tree arrows (for now) 2019-02-08 16:16:15 -05:00
Brian Vaughn
c6b0338f13 Reverted immutable element change (for now) 2019-02-08 16:05:48 -05:00
Brian Vaughn
872d0f78d4 Tweaked owners breadcrumb style to batter match tree colors 2019-02-08 15:49:52 -05:00
Brian Vaughn
41514d67f0 Small refinements to Store: read-only Elements in map, added revision to guard against tearing 2019-02-08 15:37:52 -05:00
Brian Vaughn
0380186501 Refactored tree, search, selection, and owners contexts 2019-02-08 14:44:07 -05:00
Brian Vaughn
45641e98e5 Added owner tree exploration view 2019-02-07 14:34:24 +00:00
Brian Vaughn
fc924d136a Combined search and selection contexts to avoid complicated dependencies 2019-02-07 09:29:42 +00:00
Brian Vaughn
9c093ac731 Fixed regexp parsing 2019-02-06 21:33:44 +00:00
Brian Vaughn
aa9423701e Tweaked publish canary message to show newly published version 2019-02-06 18:24:51 +00:00
Brian Vaughn
45fc46bfa0 16.8.1 packages 2019-02-06 18:21:33 +00:00
Dan Abramov
b7cc6b2e6f Add 16.8.1 changelog 2019-02-06 18:19:35 +00:00
Brian Vaughn
c61e0f0d54 Added a clarifying comment to SearchInput 2019-02-06 17:09:46 +00:00
Brian Vaughn
f2e2637c8e Backwards compat fix for ReactCurrentDispatcher on older react versions (#14770)
* Add current owner ref fallback for newer renderers with older react versions
* Replaced current owner forward with current:null
2019-02-06 17:02:14 +00:00
Brian Vaughn
e77ba00336 Replaced SearchContext useStates with useReducer and fixed an edge-case search bug 2019-02-06 16:31:02 +00:00
Sunil Pai
1107b9673c [TestUtils.act] warn when using TestUtils.act in node (#14768)
* warn when using TestUtils.act in node

* s/warns/throws

* s/throw/warn

* consistent ellipses
2019-02-06 16:25:26 +00:00
Brian Vaughn
0975ea3278 eslint-plugin-react-hooks v1.0.0 2019-02-06 10:14:57 +00:00
Dan Abramov
d827445a50 Add 16.8.0 changelog and update some READMEs (#14692)
* Add 16.8.0 changelog

* Mention ESLint plugin

* Remove experimental notices from the ESLint plugin README

* Update CHANGELOG.md

* Add more details for Hooks

* fix

* Set a date

* Update CHANGELOG.md

Co-Authored-By: gaearon <dan.abramov@gmail.com>

* Update CHANGELOG.md

* useReducer in changelog

* Add to changelog

* Update date

* Add #14119 to changelog

* Add #14744 to changelog

* Fix PR links

* act() method was added to test utils, too

* Updated release date to February 6th
2019-02-06 08:31:00 +00:00
Andrew Clark
bc9818f24d Scheduler.unstable_next (#14756)
* Add Scheduler.unstable_next

* Use Scheduler to prioritize updates

Changes the implementation of syncUpdates, deferredUpdates, and
interactiveUpdates to use runWithPriority, so

This is the minimum integration between Scheduler and React needed to
unblock use of the Scheduler.next API.

* Add Scheduler.unstable_next

* Use Scheduler to prioritize updates

Changes the implementation of syncUpdates, deferredUpdates, and
interactiveUpdates to use runWithPriority, so

This is the minimum integration between Scheduler and React needed to
unblock use of the Scheduler.next API.
2019-02-06 08:16:41 +00:00
Dan Abramov
b5398a9130 Add 16.8.0 changelog and update some READMEs (#14692)
* Add 16.8.0 changelog

* Mention ESLint plugin

* Remove experimental notices from the ESLint plugin README

* Update CHANGELOG.md

* Add more details for Hooks

* fix

* Set a date

* Update CHANGELOG.md

Co-Authored-By: gaearon <dan.abramov@gmail.com>

* Update CHANGELOG.md

* useReducer in changelog

* Add to changelog

* Update date

* Add #14119 to changelog

* Add #14744 to changelog

* Fix PR links

* act() method was added to test utils, too

* Updated release date to February 6th
2019-02-06 08:05:54 +00:00
Dan Abramov
ce6ecd3fbf Add 16.8.0 changelog and update some READMEs (#14692)
* Add 16.8.0 changelog

* Mention ESLint plugin

* Remove experimental notices from the ESLint plugin README

* Update CHANGELOG.md

* Add more details for Hooks

* fix

* Set a date

* Update CHANGELOG.md

Co-Authored-By: gaearon <dan.abramov@gmail.com>

* Update CHANGELOG.md

* useReducer in changelog

* Add to changelog

* Update date

* Add #14119 to changelog

* Add #14744 to changelog

* Fix PR links

* act() method was added to test utils, too

* Updated release date to February 6th
2019-02-06 08:05:18 +00:00
Brian Vaughn
008a2ab9cd 16.8.0 2019-02-06 08:04:00 +00:00
Sunil Pai
d1326f466a [TestUtils.act] fix return result checking (#14758)
* fix .act return value testing when result === null

* nit
2019-02-05 17:34:21 +00:00
Brian Vaughn
998e69a10d Added search support 2019-02-05 17:14:06 +00:00
Sunil Pai
267ed98146 expose TestUtils.act() for batching actions in tests (#14744)
* expose unstable_interact for batching actions in tests

* move to TestUtils

* move it all into testutils

* s/interact/act

* warn when calling hook-like setState outside batching mode

* pass tests

* merge-temp

* move jsdom test to callsite

* mark failing tests

* pass most tests (except one)

* augh IE

* pass fuzz tests

* better warning, expose the right batchedUpdates on TestRenderer for www

* move it into hooks, test for dom

* expose a flag on the host config, move stuff around

* rename, pass flow

* pass flow... again

* tweak .act() type

* enable for all jest environments/renderers; pass (most) tests.

* pass all tests

* expose just the warning from the scheduler

* don't return values

* a bunch of changes.

can't return values from .act
don't try to await .act calls
pass tests

* fixes and nits

* "fire events that udpates state"

* nit

* 🙄

* my bad

* hi andrew

(prettier fix)
2019-02-05 16:10:16 +00:00
Brian Vaughn
e723ec82bc Added $r support 2019-02-05 13:19:08 +00:00
Brian Vaughn
ce7f060e26 Cleaned up property borders 2019-02-05 11:26:37 +00:00
Brian Vaughn
6dc3fa6fbd Cleaned up style vars 2019-02-05 11:23:37 +00:00
Andrew Clark
fb3f7bfde9 Avoid importing Scheduler directly (#14757)
* Avoid importing Scheduler directly

The reconciler should not depend directly on Scheduler. This adds it to
the host config for the renderer instead.

(Except for `scheduler/tracing` imports, which are used only by the
profiling build. I've left those imports as-is, though I'm open to
directing those through the host config, too.)

* Make throwaway root id longer to appease Brian
2019-02-05 03:21:25 -08:00
Brian Vaughn
1566141177 Strip React elements from serialized data (and display <name/> instead 2019-02-05 10:25:33 +00:00
Brian Vaughn
33deb79ce4 Added simple hooks support (same as in legacy DevTools for now)
I had to add a couple of  comments because Flow was being a mysterious little shit and I got tired of trying to work around it.
2019-02-05 09:23:14 +00:00
Brian Vaughn
d0d5b677de Added better context support 2019-02-05 08:32:02 +00:00
Brian Vaughn
6f952ede2f Fixed regression in browser shell 2019-02-04 18:01:44 +00:00
Brian Vaughn
b56bc1a626 Initial pass at properties panel. Lots of TODOs remaining. 2019-02-04 17:49:30 +00:00
Dan Abramov
81470a0027 Add missing 16.6.1 changelog entry 2019-02-04 13:28:26 +00:00
Jessica Franco
e602b5291c Use SameValue instead of === to check for dispatchAction equivalence (#14752) 2019-02-04 04:56:21 -08:00
SToneX
e489c3f9c1 Update the version with Hooks proposal in README (#14751) 2019-02-04 09:36:56 +00:00
Brian Vaughn
406df2a617 Added properties panel and selected element context 2019-02-02 13:57:32 -08:00
Dan Abramov
c21c41ecfa Tweak invalid Hook warning and error (#14747) 2019-02-01 21:05:13 +00:00
Brian Vaughn
9aa6e13d5f Tidied up devtools frontend a little 2019-02-01 09:25:54 -08:00
Deniz Susman
fec00a869c Typo in comment (#14739)
"synchronously" instead of "syncrhonously".
2019-02-01 13:26:24 +01:00
Brian Vaughn
ad74c54670 Adding tearing warning to Store 2019-01-31 15:59:08 -08:00
Brian Vaughn
1866aef67c Fixed small CSS bug 2019-01-31 15:48:47 -08:00
Brian Vaughn
1eccdd6f8a Moved search icon into separate React component 2019-01-31 14:46:18 -08:00
Brian Vaughn
89f4955b93 Don't show roots in Elements tree 2019-01-31 14:31:12 -08:00
Brian Vaughn
bdfaeede6d Fixed potential race cases in bridge/store/backend initialization 2019-01-31 14:27:16 -08:00
Andrew Clark
66eb293742 Restrict effect return type to a function or nothing (#14119)
* Restrict effect return type to a function or nothing

We already warn in dev if the wrong type is returned. This updates the
Flow type.

* Restrict return type further

* Assume Effect hook returns either a function or undefined

* Tweak warning message
2019-01-31 10:11:47 -08:00
Brian Vaughn
62f8c985df Added stub search row (not connected to anythign yet) 2019-01-31 09:42:07 -08:00
Dan Abramov
51c07912ac Warn when second argument is passed to useCallback (#14729) 2019-01-31 13:56:48 +00:00
Brian Vaughn
6363fc0767 Tweaked error message to provide more helpful info if shown 2019-01-30 14:39:37 -08:00
Brian Vaughn
ca6151ca01 Reload extension on navigate 2019-01-30 14:16:55 -08:00
Brian Vaughn
6d37857df3 Fixed an Array type bug in Store 2019-01-30 11:31:13 -08:00
Brian Vaughn
a60c8e139a Renamed app.js to App.js for consistency 2019-01-30 10:49:50 -08:00
Brian Vaughn
037071c0e1 Remove root from "roots" list on unmount 2019-01-30 10:41:53 -08:00
Brian Vaughn
1f46df66cb Tidying up 2019-01-30 10:38:52 -08:00
Andrew Clark
70d4075832 Move Hook mismatch warning to first mismatch site (#14720)
* Move Hook mismatch warning to first mismatch site

Allows us to localize the warning logic in one place.

* Nit
2019-01-30 08:11:18 -08:00
Andrew Clark
ba6477aa3c Improve Reducer Hook's lazy init API (#14723)
* Improve Reducer Hook's lazy init API

* Use generic type for initilizer input

Still requires an `any` cast in the case where `init` function is
not provided.
2019-01-29 17:39:24 -08:00
Andrew Clark
cb1ff430e8 Phased dispatcher (#14701)
* Move DEV-only function right above where it's used

I don't like looking at this top-level function #petty

* Use different dispatchers for functions & classes

Classes support readContext, but not any of the other dispatcher
methods. Function support all methods.

This is a more robust version of our previous strategy of checking
whether `currentlyRenderingFiber` is null.

As a next step, we can use a separate dispatcher for each phase of the
render cycle (mount versus update).

* Use separate dispatchers for mount and update

* Remove mount code from update path

Deletes mount-specific code from the update path, since it should be
unreachable. To continue supporting progressive enhancement (mounting
new hooks at the end of the list), we detect when there are no more
current hooks and switch back to the mount dispatcher. Progressive
enhancement isn't officially supported yet, so it will continue to warn.

* Factoring nits

* Fix Flow

Had to cheat more than I would like

* More Flow nits

* Switch back to using a special dispatcher for nested hooks in DEV

In order for this strategy to work, I had to revert progressive
enhancement support (appending hooks to the end). It was previously a
warning but now it results in an error. We'll reconsider later.

* Always pass args to updateState and updateReducer

Even though the extra args are only used on mount, to ensure
type consistency.
2019-01-29 16:32:15 -08:00
Brian Vaughn
f542f879d6 Added inline comments for types 2019-01-29 14:04:00 -08:00
Brian Vaughn
fc4af4d018 Fixed text wrap bug in extension panel 2019-01-29 13:48:35 -08:00
Brian Vaughn
fdfadef928 Refactored bridge to support transferrables (e.g. typed array buffers) and added transferable param to postMessage for op codes 2019-01-29 13:17:37 -08:00
Brian Vaughn
3f93b029a4 Replaced node objects with typed array of tree operations; windowing works in small test harness 2019-01-28 15:50:48 -08:00
Brian Vaughn
c9a5f8cc29 Stashing partial windowing implementation 2019-01-27 16:04:17 -08:00
Brian Vaughn
b7cbd38214 Misc updates to better handle tearing and add some future TODOs 2019-01-27 07:58:09 -08:00
Peter Donald
9d483dcfd6 Spelling abitrarily -> arbitrarily (#14710) 2019-01-27 14:54:37 +00:00
DeepCold
6d5ea54eee change codeofconduct link (#14711) 2019-01-27 14:54:21 +00:00
Yurick
e19c9e1064 Fix issue with multiple code branches in hooks linter (#14661)
* Fix issue with multiple code branches

* Add solution by @calebmer

* Add performance test

* Undo unrelated change
2019-01-25 17:06:33 +00:00
Brian Vaughn
f11a9c1cb0 State update bug in concurrent mode (#14698)
* State update bug in concurrent mode

* Fix bug introduced by double-rendering Functions using hooks
2019-01-24 16:10:13 -08:00
Brian Vaughn
13ca26e153 Removed throttling. It's too error prone because of mutations (Fibers). We'll optimize later by using the effects list for updates. 2019-01-24 13:45:29 -08:00
Greg Hurrell
e679a4b6e2 Fix typo in code comment (#14696) 2019-01-24 20:19:53 +00:00
Dan Abramov
8bcc88f2e7 Make all readContext() and Hook-in-a-Hook checks DEV-only (#14677)
* Make readContext() in Hooks DEV-only warning

* Warn about readContext() during class render-phase setState()

* Warn on readContext() in SSR inside useMemo and useReducer

* Make all Hooks-in-Hooks warnings DEV-only

* Rename stashContextDependencies

* Clean up warning state on errors
2019-01-24 19:31:20 +00:00
Brian Vaughn
d57ec69561 Added initial Chrome/Firefox shells 2019-01-23 18:06:21 -08:00
Brian Vaughn
6cb26774e2 Enable hooks! (#14679)
* Turned enableHooks feature flag on everywhere
* Removed useHooks feature flag from tests (now that it's on by default)
* Remove useHooks feature flag entirely
2019-01-23 13:28:09 -08:00
Dan Abramov
73962c3664 Revert "Revert "Double-render function components with Hooks in DEV in StrictMode" (#14652)" (#14654)
This reverts commit 3fbebb2a0b.
2019-01-23 19:12:18 +00:00
Dan Abramov
9944392285 Put DEV-only code into DEV blocks (#14673) 2019-01-23 16:59:55 +00:00
Brian Vaughn
f881c32304 Added Prettier (and formatted code) 2019-01-23 08:45:19 -08:00
Brian Vaughn
d02b4a2784 Throttle bridge traffic for Elements tree updates 2019-01-23 08:27:40 -08:00
Dan Abramov
f0befae657 Tweak context invariant message (#14671) 2019-01-23 16:14:32 +00:00
Dan Abramov
a129259ad6 Disallow reading context during useMemo etc (#14653)
* Revert "Revert "Double-render function components with Hooks in DEV in StrictMode" (#14652)"

This reverts commit 3fbebb2a0b.

* Revert "Revert "Disallow reading context during useMemo etc" (#14651)"

This reverts commit 5fce6488ce.

* Add extra passing test for an edge case

Mentioned by @acdlite to watch out for

* More convoluted test

* Don't rely on expirationTime

Addresses @acdlite's concerns

* Edge case: forbid readContext() during eager reducer
2019-01-23 15:51:57 +00:00
Sebastian Markbåge
c068d31cca Add unit tests for concurrent mode event dispatching (#14415) 2019-01-23 15:28:19 +00:00
Dan Abramov
db695c4d32 Bump GCC (#14657) 2019-01-23 14:28:03 +00:00
SamCortopassi
38247cba36 --save is no longer needed (#14302)
`--save` is on by default as of npm 5. `npm install create-subscription` is equivalent to `npm install --save create-subscription` now
2019-01-23 14:13:05 +00:00
Ramón Chancay Ortega
3f0bcaf0db Importing React for the first example. (#14346) 2019-01-23 14:10:03 +00:00
Sunil Pai
ecd919a2f9 RFC: warn when returning different hooks on subsequent renders (#14585)
* warn when returning different hooks on next render

like it says. adds a field to Hook to track effect 'type', and compares when cloning subsequently.

* lint

* review changes

- numbered enum for hook types
- s/hookType/_debugType
- better dce

* cleaner detection location

* redundant comments

* different EffectHook / LayoutEffectHook

* prettier

* top level currentHookType

* nulling currentHookType

need to verify dce still works

* small enhancements

* hook order checks for useContext/useImperative

* prettier

* stray whitespace

* move some bits around

* better errors

* pass tests

* lint, flow

* show a before - after diff

* an error stack in the warning

* lose currentHookMatches, fix a test

* tidy

* clear the mismatch only in dev

* pass flow

* side by side diff

* tweak warning

* pass flow

* dedupe warnings per fiber, nits

* better format

* nit

* fix bad merge, pass flow

* lint

* missing hooktype enum

* merge currentHookType/currentHookNameInDev, fix nits

* lint

* final nits
2019-01-22 22:40:07 +00:00
Brian Vaughn
7b9a8e9843 Added a super basic README 2019-01-22 11:07:56 -08:00
Brian Vaughn
5e0dfdac54 Initial commit 2019-01-22 11:04:37 -08:00
Dan Abramov
3fbebb2a0b Revert "Double-render function components with Hooks in DEV in StrictMode" (#14652)
* Revert "Revert "Disallow reading context during useMemo etc" (#14651)"

This reverts commit 5fce6488ce.

* Revert "Add test coverage for readContext() on the server (#14649)"

This reverts commit fe2ecd276e.

* Revert "Warn about incorrect use of useImperativeHandle() (#14647)"

This reverts commit 8f45a7fdc4.

* Revert "Disallow reading context during useMemo etc (#14648)"

This reverts commit 1fcbd22431.

* Revert "Warn about refs on lazy function components (#14645)"

This reverts commit 2a084f51a9.

* Revert "Fix typo (#14560)"

This reverts commit b5a3df6e88.

* Revert "fix typo (#14316)"

This reverts commit 9c146e6751.

* Revert "Mention forwardRef() in <Fn ref={...} /> errors and warnings (#14644)"

This reverts commit baa6d40fc8.

* Revert "Double-render function components with Hooks in DEV in StrictMode (#14643)"

This reverts commit a1414e8949.
2019-01-21 20:34:38 +00:00
Dan Abramov
5fce6488ce Revert "Disallow reading context during useMemo etc" (#14651)
* Revert "Add test coverage for readContext() on the server (#14649)"

This reverts commit fe2ecd276e.

* Revert "Warn about incorrect use of useImperativeHandle() (#14647)"

This reverts commit 8f45a7fdc4.

* Revert "Disallow reading context during useMemo etc (#14648)"

This reverts commit 1fcbd22431.
2019-01-21 20:28:36 +00:00
Dan Abramov
fe2ecd276e Add test coverage for readContext() on the server (#14649)
* Rename context variables

I just spent half an hour debugging why readContext(PurpleContext) doesn't work.

* Add test coverage for readContext() on the server
2019-01-21 19:55:26 +00:00
Dan Abramov
8f45a7fdc4 Warn about incorrect use of useImperativeHandle() (#14647) 2019-01-21 19:44:18 +00:00
Dan Abramov
1fcbd22431 Disallow reading context during useMemo etc (#14648)
* Disallow reading context during useMemo etc

* Continue allowing readContext() in classes and context consumers

The previous commit check was too broad and incorrectly restricted classes from calling readContext(). This check is more precise and only targets components that are Hook-capable. It exploits the fact that `renderExpirationTime` is never `NoWork` after `renderWithHooks` -- something we already rely on.
2019-01-21 19:06:09 +00:00
Dan Abramov
2a084f51a9 Warn about refs on lazy function components (#14645) 2019-01-21 16:57:55 +00:00
Linchengyi
b5a3df6e88 Fix typo (#14560)
fix typo
2019-01-21 16:18:29 +00:00
liunian
9c146e6751 fix typo (#14316) 2019-01-21 16:18:02 +00:00
Dan Abramov
baa6d40fc8 Mention forwardRef() in <Fn ref={...} /> errors and warnings (#14644) 2019-01-21 16:01:48 +00:00
Dan Abramov
a1414e8949 Double-render function components with Hooks in DEV in StrictMode (#14643)
* Double-render functions in strict mode

* Double-invoke first function component render too

* Mark TestRendererAsync test as internal and revert changes to it

TestRenderer is built with strict mode doublerender off.

We could change that but I'm not sure we want to. So I'll just flip the flag off for this test.

* Only double-invoke components using Hooks

* Revert unintentional change
2019-01-21 15:35:47 +00:00
Dan Abramov
10a7a5b5ce Fix synchronous thenable rejection (#14633)
* Fix handling of sync rejection

Reverts #14632 and adds a regression test.

* Handle rejection synchronously too

Fewer footguns and seems like nicer behavior anyway.
2019-01-19 00:42:43 +00:00
Dan Abramov
a2fa6eb98d Move lazy._result assignment (#14632) 2019-01-18 21:57:26 +00:00
Dan Abramov
9120f6c2d8 Support sync thenables for lazy() (#14626)
* Support sync thenables for lazy()

* Don't commit twice
2019-01-18 21:16:02 +00:00
Grey Baker
b66e6e41e6 Add directory details to the package.json of all packages (#14628)
Specifying the directory as part of the `repository` field in a `package.json`
allows third party tools to provide better support when working with monorepos.
For example, it allows them to correctly construct a commit diff for a specific
package.

This format was accepted by npm in https://github.com/npm/rfcs/pull/19.
2019-01-18 20:21:12 +00:00
Brian Vaughn
8c1614a2fd Tidy up NPM checkout process (#14631) 2019-01-18 11:40:50 -08:00
Dan Abramov
177fb76353 Warn when second callback is passed to setState/dispatch in Hooks (#14625) 2019-01-18 18:48:58 +00:00
Sebastian Silbermann
d17d0b99c1 Use public context.report interface in eslint rules (#14623) 2019-01-18 09:26:11 +00:00
Yi-Shan, Chen
4f332885a2 Fix shallow renderer set instance state after gDSFP before calling sCU (#14613)
* Fix shallow renderer set instance state after gDSFP before calling sCU

* Update ReactShallowRenderer.js

* Unwind abstraction

* Fewer names
2019-01-18 02:31:14 +00:00
Sunil Pai
e1cd83e49d Throw an error when using hooks inside useMemo/useState/useReducer, or .memo's comparator (#14608)
* hooks inside useMemo/.memo - failing tests

* throw an error when using hooks inside useMemo

* throw when using hooks inside .memo's compare fn

* faster/better/stronger

* same logic for useReducer, tests for the server, etc

* Update ReactDOMServerIntegrationHooks-test.internal.js

ack lint

* nits

* whitespace

* whitespace

* stray semi

* Tweak comment

* stray unmatched fiber reset

* nit
2019-01-18 02:15:21 +00:00
Dan Abramov
be457ca685 Small tweaks to SSR to match #14594 (#14618)
* Small tweaks to SSR to match #14594

* Remove unnecessary comparison
2019-01-18 00:52:13 +00:00
Dan Abramov
17d70df919 Warn when mixing createRoot() and old APIs (#14615)
* Warn when mixing createRoot() and old APIs

* Move container checks to entry points

This way further warning check doesn't crash on bad inputs.

* Fix Flow

* Rename flag to be clearer

* managed by -> passed to

* Revert accidental change

* Fix Fire shim to match
2019-01-18 00:20:21 +00:00
Brian Vaughn
4846809370 Prune NPM metadata fields from packages before re-publishing (#14617) 2019-01-17 14:34:34 -08:00
Dominic Gannaway
4feab7fc92 Add hooks support to ReactShallowRenderer (#14567)
* Add hook support to ReactShallowRenderer
2019-01-17 17:42:27 +00:00
Andrew Clark
1454a8be03 Don't bother comparing constructor when deps are not provided (#14594)
* Don't bother comparing constructor when deps are not provided

When no dependencies are passed to an effect hook, what we used to do is
compare the effect constructor. If there was no change, then we would
skip firing the effect. In practice, this is a useless optimization
because the constructor will always be different when you pass an inline
closure. And if you don't pass an inline closure, then you can't access
any props or state.

There are some edge cases where an effect that doesn't close over props
or state could be useful, like reference counting the number of mounted
components. But those are rare and can be addressed by passing an empty
array of dependencies.

By removing this "optimization," we can avoid retaining the constructor
in the majority of cases where it's a closure that changes on
every render.

I made corresponding changes to the other hooks that accept
dependencies, too (useMemo, useCallback, and useImperativeHandle).

* Improve hook dependencies warning

It now includes the name of the hook in the message.

* Nits
2019-01-16 17:53:48 -08:00
Andrew Clark
71b64d5211 Warn if number of hooks increases (#14591)
Eventually, we'll likely support adding hooks to the end (to enable
progressive enhancement), but let's warn until we figure out how it
should work.
2019-01-16 17:25:32 -08:00
Andrew Clark
790c8ef041 Allow useReducer to bail out of rendering by returning previous state (#14569)
* Allow useReducer to bail out of rendering by returning previous state

This is conceptually similar to `shouldComponentUpdate`, except because
there could be multiple useReducer (or useState) Hooks in a single
component, we can only bail out if none of the Hooks produce a new
value. We also can't bail out if any the other types of inputs — state
and context — have changed.

These optimizations rely on the constraint that components are pure
functions of props, state, and context.

In some cases, we can bail out without entering the render phase by
eagerly computing the next state and comparing it to the current one.
This only works if we are absolutely certain that the queue is empty at
the time of the update. In concurrent mode, this is difficult to
determine, because there could be multiple copies of the queue and we
don't know which one is current without doing lots of extra work, which
would defeat the purpose of the optimization. However, in our
implementation, there are at most only two copies of the queue, and if
*both* are empty then we know that the current queue must be.

* Add test for context consumers inside hidden subtree

Should not bail out during subsequent update. (This isn't directly
related to this PR because we should have had this test, anyway.)

* Refactor to use module-level variable instead of effect bit

* Add test combining state bailout and props bailout (memo)
2019-01-16 17:23:35 -08:00
Dan Abramov
8a120095bf Add ESLint rule playground (#14609)
* Add ESLint rule playground

* Update index.js

* Update index.js
2019-01-16 23:52:33 +00:00
Brian Vaughn
7ab8a8e979 Added Flow type to keep hooks dispatchers in-sync (#14599)
* Added Flow type to keep hooks dispatchers in-sync
2019-01-16 12:49:31 -08:00
Brian Vaughn
4392e3821d useDebugValue should throw if used in a class component (#14601) 2019-01-15 13:49:39 -08:00
Brian Vaughn
153a0b5980 Add noop useDebugValue hook to partial/server renderer (#14597) 2019-01-15 11:00:03 -08:00
Brian Vaughn
0ca628b216 Rename release script fixture test scheduler->tracing (#14590) 2019-01-14 17:52:03 -08:00
Brandon Dail
7ad9806d11 Tweak to avoid property read (#14593) 2019-01-14 17:39:27 -08:00
Brandon Dail
0fc1547513 Avoid new Set([iterable]) for thenables (#14592)
Fixes https://github.com/facebook/react/issues/14583

Using `new Set([iterable])` does not work with IE11's non-compliant Set
implementation. By avoiding this pattern we don't need to require a Set
polyfill for IE11
2019-01-15 01:00:15 +00:00
Brian Vaughn
edb1f59564 Support configurable labels for custom hooks (#14559)
* react-debug-tools accepts currentDispatcher ref as param

* ReactDebugHooks injected dispatcher ref is optional

* Support custom values for custom hooks

* PR feedback:

1. Renamed useDebugValueLabel hook to useDebugValue
2. Wrapped useDebugValue internals in if-DEV so that it could be removed from production builds.

* PR feedback:

1. Fixed some minor typos
2. Added inline comment explaining the purpose of  rollupDebugValues()
3. Refactored rollupDebugValues() to use a for loop rather than filter()
4. Improve check for useDebugValue hook to lessen the chance of a false positive
5. Added optional formatter function param to useDebugValue

* Nitpick renamed a method
2019-01-14 14:53:22 -08:00
Sunil Pai
3e15b1c690 make a fork for ReactCurrentDispatcher (#14588) 2019-01-14 16:35:56 +00:00
Carl Mungazi
0005d1e3f5 Fix typo (#14576) 2019-01-11 21:46:05 -08:00
Brian Vaughn
f290138d32 react-debug-tools accepts currentDispatcher ref as param (#14556)
* react-debug-tools accepts currentDispatcher ref as param

* ReactDebugHooks injected dispatcher ref is optional
2019-01-10 12:56:52 -08:00
Sunil Pai
b4ad8e9471 rename useImperativeMethods -> useImperativeHandle (#14565) 2019-01-10 13:37:50 +00:00
Brian Vaughn
ab03e3d651 Inject ReactCurrentDispatcher ref to DevTools (#14550) 2019-01-08 21:25:26 -08:00
Brian Vaughn
19ef0ec116 Separate current owner and dispatcher (#14548) 2019-01-08 14:39:52 -08:00
Maksim Markelov
a9b035b0c2 Separate Object.is polyfill (#14334)
* Separate_Object_Is_Polyfill
2019-01-08 14:21:12 +00:00
Sophie Alpert
547e059f0b Simplify wording of key warning (#14503)
I don't think "array or iterator" is adding anything, and it may well be confusing, especially since this is one of the first and most common warnings that devs see.
2019-01-07 08:30:23 -08:00
Carl Mungazi
3494ee57e6 Update ReactUpdateQueue.js (#14521)
Fix comment typo
2019-01-02 20:53:05 +00:00
Ilja Daderko
fef40c061e Allow node 11 as devEngine (#14450)
Using node 11 throws incompatibility error. This fixes it. Only test I performed was to run `yarn build -- --type=RN_OSS` everything seemed ok.
2018-12-25 17:05:31 +00:00
Carl Mungazi
659c13963e Update ReactFiberScheduler.js (#14477)
Fixed typo
2018-12-20 08:51:47 -08:00
Andrew Clark
84b86471ea Update CHANGELOG for 16.7 2018-12-19 17:29:25 -08:00
Andrew Clark
c695b2384f React v16.7.0 2018-12-19 17:23:14 -08:00
Andrew Clark
1c5aa2f23a Move SchedulerFeatureFlags fork to src directory to fix lint 2018-12-18 11:09:44 -08:00
Andrew Clark
653bc582f9 Create separate SchedulerFeatureFlags instead of using ReactFeatureFlags (#14455) 2018-12-17 17:55:34 -08:00
Andrew Clark
8bfef0da55 Make scheduler debugging feature flag static 2018-12-17 16:50:38 -08:00
Andrew Clark
4a1072194f Memoize promise listeners to prevent exponential growth (#14429)
* Memoize promise listeners to prevent exponential growth

Previously, React would attach a new listener every time a promise is
thrown, regardless of whether the same listener was already attached
during a previous render. Because React attempts to render every time
a promise resolves, the number of listeners grows quickly.

This was especially bad in synchronous mode because the renders that
happen when the promise pings are not batched together. So if a single
promise has multiple listeners for the same root, there will be multiple
renders, which in turn results in more listeners being added to the
remaining unresolved promises. This results in exponential growth in
the number of listeners with respect to the number of IO-bound
components in a single render.

Fixes #14220

* Memoize on the root and Suspense fiber instead of on the promise

* Add TODO to fix persistent mode tests
2018-12-14 11:03:23 -08:00
Brian Vaughn
535804f5c8 Removed Fabric-specific feature flag files and updated Rollup to use the (non-Fabric) React Native flag files. (#14437) 2018-12-14 07:54:46 -08:00
Brian Vaughn
2743fb7b23 Enable hooks by default for FB React Native renderer (#14435)
* Enable hooks by default for FB React Native renderer
* Updated RN+FB feature flags to make some of the dynamic ones static
2018-12-13 13:20:23 -08:00
Brian Vaughn
7325ebe4d6 Inject overrideProps() fn to DevTools (#14427)
* Inject overrideProps() fn to DevTools

This function will enable editing props for function components, host nodes, and special types like memo and forwardRef.
2018-12-13 09:40:59 -08:00
Pleun Vanderbauwhede
a22880e5e5 Add support for Suspense & lazy() to the react-is package (#14423)
* Add support for lazy & Suspense to react-is
2018-12-12 10:56:52 -08:00
Heaven
947bddd5cf Remove redundant argument of getPlugins function (#14419) 2018-12-12 10:07:07 -08:00
Brian Vaughn
ce43a8cd07 Updated version incrementing suggestion in release script based on team discussion (#14389) 2018-12-07 09:08:39 -08:00
Brian Vaughn
f64906fba1 Dangerfile exits early if build failed (#14400)
* Dangerfile exits early (without leaving an error comment) if build failed
2018-12-07 09:06:47 -08:00
Kevin Chavez
8df4d59be5 Implement pauseExecution, continueExecution, dumpQueue for Scheduler (#14053)
* Implement pauseExecution, continueExecution, dumpQueue

* Expose firstCallbackNode. Fix tests. Revert results.json

* Put scheduler pausing behind a feature flag
2018-12-06 13:57:23 -08:00
Brian Vaughn
5bb4ad7376 Added ErrorBoundary tests for useEffect and useLayoutEffect (#14401) 2018-12-06 13:55:38 -08:00
Brian Vaughn
98eb5ae531 TestRenderer toJSON should not expose the Array wrapper Suspense uses for hidden trees (#14392) 2018-12-05 11:09:51 -08:00
Spencer Ahrens
39489e7674 Enable hooks in fabric (#14301)
because hooks are awesome.
2018-12-04 19:34:52 -08:00
Brian Vaughn
1dc108e582 Tweaked wording for v8 "performance cliff" issue 2018-12-04 07:49:33 -08:00
AGCB
d9871729c8 fix spelling error: differen -> different (#14378) 2018-12-03 23:29:29 -08:00
Brian Vaughn
6bf5e85986 Fix scheduler setTimeout() re-entrancy check (#14384) 2018-12-03 10:54:01 -08:00
Brian Vaughn
7a48c900b7 Prevent a v8 deopt when profiling (#14383) 2018-12-03 09:22:46 -08:00
Brian Vaughn
e382b0ba95 Don't prompt to tag or create GitHub release for canary releases (#14376) 2018-12-03 09:16:17 -08:00
Brian Vaughn
8482cbe22d Automated fixture tests (#14370)
* Renamed snapshot test from test.js to snapshot-test.js
* Automate fixtures tests
2018-12-02 11:25:45 -08:00
Brian Vaughn
f00c2755b9 Removed unnecessary externals from Jest bundles (#14372) 2018-12-01 17:26:12 -08:00
Brian Vaughn
52bea95cfc Fixed scheduler setTimeout fallback (#14358)
* Fixed scheduler setTimeout fallback
* Moved unit-test-specific setTimeout code into a new NPM package, jest-mock-scheduler.
2018-12-01 13:03:19 -08:00
Sebastian Markbåge
1d25aa5787 [Fizz] New Server Rendering Infra (#14144)
* [Fizz] Add Flow/Jest/Rollup build infra

Add a new package for react-stream which allows for custom server renderer
outputs. I picked the name because it's a reasonable name but also
because the npm name is currently owned by a friend of the project.

The react-dom build has its own inlined server renderer under the
name `react-dom/fizz`.

There is also a noop renderer to be used for testing. At some point
we might add a public one to test-renderer but for now I don't want to have
to think about public API design for the tests.

* Add FormatConfig too

We need to separate the format (DOM, React Native, etc) from the host
running the server (Node, Browser, etc).

* Basic wiring between Node, Noop and DOM configs

The Node DOM API is pipeToNodeStream which accepts a writable stream.

* Merge host and format config in dynamic react-stream entry point

Simpler API this way but also avoids having to fork the wrapper config.

Fixes noop builds.

* Add setImmediate/Buffer globals to lint config

Used by the server renderer

* Properly include fizz.node.js

Also use forwarding to it from fizz.js in builds so that tests covers
this.

* Make react-stream private since we're not ready to publish

or even name it yet

* Rename Renderer -> Streamer

* Prefix react-dom/fizz with react-dom/unstable-fizz

* Add Fizz Browser host config

This lets Fizz render to WHATWG streams. E.g. for rendering in a
Service Worker.

I added react-dom/unstable-fizz.browser as the entry point for this.

Since we now have two configurations of DOM. I had to add another
inlinedHostConfigs configuration called `dom-browser`. The reconciler
treats this configuration the same as `dom`. For stream it checks
against the ReactFizzHostConfigBrowser instead of the Node one.

* Add Fizz Browser Fixture

This is for testing server rendering - on the client.

* Lower version number to detach it from react-reconciler version
2018-11-30 11:38:22 -08:00
Imre Osswald
f1bf281605 Fix bug in cloneHook (#14364)
* Fixes #14360 and adds a test for mixed priority dispatches.

It was broken because `cloneHook` assigned `memoizedState` instead of
`baseState` from the original hook to `baseState` of the clone.

* tweak comments
2018-11-30 15:02:19 +00:00
Dan Abramov
16e120438c [Fire] Add initial build infrastructure (#14359) 2018-11-30 11:52:34 +00:00
Dan Abramov
d14ba87b1b Validate propTypes for lazy() and memo() and warn about invalid patterns (#14298)
* Add a test for current defaultProps behavior in lazy

* Add a warning against definining defaultProps on the outer wrapper

* Warn about setting propTypes too

* Remove redundant async

* Validate propTypes for resolved lazy types

Note this only works for elements created after resolving. So it's not ideal. But it provides the best stack trace for those cases.

* Add a test for lazy(forwardRef()) propTypes check

* Validate memo() inner propTypes and warn about shadowing

* Add test verifying nested lazy is unsupported

* Change error wording to remove "Promise elements"

* Improve error message for nested lazy() and add tests

* Validate propTypes for memo in the reconciler when necessary

* Add comments for why we're calling checkPropTypes

* Fix Flow and lint

* Undo unintentional formatting changes

* Remove unnecessary case (it is handled by function code path)

* Add test coverage for memo(fn.defaultProps).propTypes

* Test should be agnostic of where resolving happens

That's an implementation detail and we might want to change it later. Let's keep it easy by making tests just check that validation happened, not at which stage.

* Unify traversal logic in createElement

This moves all type traversal into createElement. When lazy resolves, we call createElement once to re-check.

* Match prod behavior for propTypes/defaultProps shims closer

* Revert "Unify traversal logic in createElement"

This reverts commit 2e77ca47fe80ebe6595333542a8c5c138c68643f.

See https://github.com/facebook/react/pull/14298#issuecomment-442687775

* Undo unnecessary change to getComponentName
2018-11-29 20:06:28 +00:00
Brian Vaughn
88ada98198 Release script auto-determine the latest Canary build if none specified (#14339)
* Release script auto-determine the latest Canary build if none specified
2018-11-28 13:56:45 -08:00
Jinto Jose
4f964f09c1 Adding isMemo check to react-is package (#14313) 2018-11-28 12:51:21 -08:00
Sophie Alpert
c2a2d8a539 Remove useMutationEffect (#14336)
useMutationEffect has problems (namely, refs aren't attached at the time that it runs) and we're not positive it's necessary. useLayoutEffect runs at the same time as componentDidMount/Update so it's sufficient for all existing use cases; it can be used in any case that useEffect happens too late. Until we figure out what we want to do, let's delete it.
2018-11-27 13:05:13 -08:00
chun shang
48f1e5b3ce Add a null type test for memo (#14325) 2018-11-27 13:25:24 +00:00
Dan Abramov
f93f3402f7 Make useEffect(async) warning more verbose (#14327)
* Make useEffect(async) warning more verbose

* Nit
2018-11-27 13:05:10 +00:00
Pelle Wessman
ee3ef3a079 Fix regression: Errors not emitted in streams (#14314)
Regression introduced in #14182 resulted in errors no longer being emitted on streams, breaking many consumers.

Co-authored-by: Elliot Jalgard <elliot.j@live.se>
2018-11-27 13:00:46 +00:00
Christoph Nakazawa
33f6f5e532 Remove usage of fbjs/lib/invariant in ReactNativeViewConfigRegistry. (#14330) 2018-11-26 21:48:08 +00:00
Brian Vaughn
409066a0a1 Add progress bars to longer running async release tasks (#14322)
* Add progress bars to longer running async release tasks
* Updated to 0.2 progress estimator version
2018-11-26 09:28:37 -08:00
Sunil Pai
a7f270c550 update fixtures/packaging/README.md (#14320)
I had some confusion yesterday with this, figured this reads a little better.  Ran these steps locally to verify they work.
2018-11-24 21:40:56 +00:00
Brian Vaughn
ed4c4a51cd Add basic release script snapshot test (#14280)
Added regression test for release scripts
2018-11-23 12:53:39 -08:00
Brian Vaughn
686f1060ad Publish a local release (canary or stable) to NPM (#14260)
New release scripts.

Learn more at https://github.com/facebook/react/blob/master/scripts/release/README.md
2018-11-23 12:37:18 -08:00
Dan Abramov
7475120ce7 Prevent deopts from modifying exports object in stable builds (#14309) 2018-11-23 14:10:57 +00:00
Dan Abramov
0c7189d923 Fix resolution of outer props with React.memo() (#14312)
* Add failing test for defaultProps between lazy() and memo()

* Add another regression test for defaultProps resolution order

* Resolve outer props for MemoComponent
2018-11-22 19:40:42 +00:00
Dan Abramov
14be29b2b9 Add more test coverage for nested memo() (#14311) 2018-11-22 19:30:56 +00:00
Dan Abramov
dc0dd4bbff Use |0 to coerce to number (#14297) 2018-11-22 15:44:00 +00:00
Dan Abramov
dd8205cef9 List ignored types instead of included types in the stack (#14308) 2018-11-22 15:41:29 +00:00
Isaiah Nields
1da310809e fix spelling error: Here's -> Here (#14307)
"Here's" should be changed to "Here" in the given sentence.
2018-11-22 14:47:20 +00:00
Dan Abramov
a9fdf8a326 Warn about reassigning this.props (#14277)
* Warn about reassigning this.props

* Improve the warning

* Don't show the spammy bug warning if we suspect it's a component bug
2018-11-20 16:40:01 +00:00
Dan Abramov
327cf0ee33 Fix support for mixing react-dom/server@16.6 and react@<16.6 (#14291) 2018-11-20 13:09:44 +00:00
Sebastian Markbåge
c954efa70f Remove import * as pattern from the codebase (#14282)
Whenever we do this, Rollup needs to materialize this as an object.
This causes it to also add the Babel compatibility property which is
unnecessary bloat. However, since when we use these, we leak the object
this often also deopts any compiler optimizations.

If we really need an object we should export default an object.

Currently there is an exception for DOMTopLevelEventTypes since
listing out the imports is a PITA and it doesn't escape so it should
get properly inlined. We should probably move to a different pattern
to avoid this for consistency though.
2018-11-19 15:32:54 -08:00
Dan Abramov
ccb14e270c Fix SSR useCallback in render phase (#14279) 2018-11-19 20:47:38 +00:00
Dominic Gannaway
0e9cb3f5d0 Clear fields on unmount of fiber to avoid memory leak (#14276)
* Clear fields on unmount of fiber to avoid memory leak
2018-11-19 16:09:11 +00:00
Dominic Gannaway
592676503c Revert "Clear memoizedState on unmount of fiber to avoid memory leak (#14218)" (#14275)
This reverts commit 9b2fb24f99.
2018-11-19 15:24:46 +00:00
Dominic Gannaway
9b2fb24f99 Clear memoizedState on unmount of fiber to avoid memory leak (#14218)
* Clear properties on unmount of fiber to ensure objects are not retained
2018-11-19 10:58:14 +00:00
Jason Miller
a22fabc2a1 Reduce scheduler serialization overhead (#14249)
In the process of switching to MessageChannel, it seems the postMessage call was modified to pass `"*"` (originally the target origin value from `window.postMessage`). This actually ends up triggering serialization, whereas passing `undefined` bypasses.

To save some investigation, passing a Number like `0` still incurs serialization overhead - `undefined` has special behavior.
2018-11-16 10:39:27 -08:00
Andrew Clark
21d5f7d32d Wrap shorthand CSS property collision warning in feature flag (#14245)
Disables the recently introduced (#14181) warning for shorthand
CSS property collisions by wrapping in a feature flag. Let's hold off
shipping this until at least the next minor.
2018-11-15 13:36:52 -08:00
Jan Pöschko
5f06576f51 Add a checkbox to fixtures UI to choose React production build (#13786)
* Add a checkbox to fixtures UI to choose React production build

* Assign header__label class name to label directly, instead of using a separate span

* center the production checkbox vertically
2018-11-14 15:34:46 -08:00
Andrew Clark
8feeed10d8 [scheduler] Remove window.postMessage fallback
Every browser we can about supports MessageChannel. The ones we don't
care about will fallback to the setTimeout implementation.
2018-11-14 14:44:26 -08:00
Andrew Clark
5bce0ef10a [scheduler] Post to MessageChannel instead of window (#14234)
Scheduler needs to schedule a task that fires after paint. To do this,
it currently posts a message event to `window`. This happens on every
frame until the queue is empty. An unfortunate consequence is that every
other message event handler also gets called on every frame; even if
they exit immediately, this adds up to significant per-frame overhead.

Instead, we'll create a MessageChannel and post to that, with a
fallback to the old behavior if MessageChannel does not exist.
2018-11-14 12:02:00 -08:00
Dan Abramov
d7fd679a31 Add 16.6.3 Changelog (#14223)
* Add 16.6.3 Changelog

* Remove unreleased fix

* Drop another unreleased fix
2018-11-13 20:32:33 +00:00
Andrew Clark
3cd89daed9 Update error codes 2018-11-13 20:29:30 +00:00
Brian Vaughn
85f5a81eb7 Save CI-built node_modules as build artifacts (#14205)
* Store node_modules generated by CI script as an artifact
* NPM pack artifacts before archiving
2018-11-13 11:00:30 -08:00
Dan Abramov
f55795c8ee Add regression test for #14188 (#14197) 2018-11-13 11:23:01 +00:00
Maksim Markelov
d204747bef Update Readme (#14176)
Replace core with react, dom-client with react-dom
2018-11-12 16:25:32 +00:00
Sophie Alpert
b98adb648a Simplify CSS shorthand property warning (#14183)
I figured out a simpler way to do #14181. It does allocate some but I think that's OK. Time complexity might even be better since we avoid the nested loops the old one had.
2018-11-09 16:56:51 -08:00
Sebastian Markbage
f8bfd58680 fix typo 2018-11-09 16:16:25 -08:00
Sebastian Markbåge
961eb65b4b 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-09 15:38:20 -08:00
Sophie Alpert
1a6ab1e9b5 SimpleMemoComponent should warn if a ref is given (#14178)
Fixes #13964.
2018-11-09 15:29:41 -08:00
Sophie Alpert
8ae867e6b5 Warn about conflicting style values during updates (#14181)
This is one of the most insidious quirks of React DOM that people run into. Now we warn when we think an update is dangerous.

We still allow rendering `{background, backgroundSize}` with unchanging values, for example. But once you remove either one or change `background` (without changing `backgroundSize` at the same time), that's bad news. So we warn.

Fixes #6348.
2018-11-09 15:21:47 -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
2768 changed files with 472821 additions and 146307 deletions

View File

@@ -1,26 +0,0 @@
{
"presets": ["react"],
"ignore": ["third_party"],
"plugins": [
"fbjs-scripts/babel-6/dev-expression",
"syntax-trailing-function-commas",
"transform-es2015-template-literals",
"transform-es2015-literals",
"transform-es2015-arrow-functions",
"transform-es2015-block-scoped-functions",
["transform-es2015-classes", { "loose": true }],
"transform-es2015-object-super",
"transform-es2015-shorthand-properties",
"transform-es2015-computed-properties",
"transform-es2015-for-of",
"check-es2015-constants",
["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"
]
}

538
.circleci/config.yml Normal file
View File

@@ -0,0 +1,538 @@
version: 2
aliases:
- &docker
- image: circleci/openjdk:8-jdk-node-browsers
- &environment
TZ: /usr/share/zoneinfo/America/Los_Angeles
- &restore_yarn_cache
restore_cache:
name: Restore node_modules cache
keys:
- v2-node-{{ arch }}-{{ .Branch }}-{{ checksum "yarn.lock" }}
- v2-node-{{ arch }}-{{ .Branch }}-
- v2-node-{{ arch }}-
- &run_yarn
run:
name: Install Packages
command: yarn --frozen-lockfile
- &attach_workspace
at: build
- &process_artifacts
docker: *docker
environment: *environment
steps:
- checkout
- attach_workspace: *attach_workspace
- *restore_yarn_cache
- *run_yarn
- run: node ./scripts/rollup/consolidateBundleSizes.js
- run: ./scripts/circleci/pack_and_store_artifact.sh
- store_artifacts:
path: ./node_modules.tgz
- store_artifacts:
path: ./build.tgz
- store_artifacts:
path: ./build/bundle-sizes.json
- store_artifacts:
# TODO: Update release script to use local file instead of pulling
# from artifacts.
path: ./scripts/error-codes/codes.json
- persist_to_workspace:
root: build
paths:
- bundle-sizes.json
jobs:
setup:
docker: *docker
environment: *environment
steps:
- checkout
- run:
name: Nodejs Version
command: node --version
- *restore_yarn_cache
- *run_yarn
- save_cache:
name: Save node_modules cache
key: v2-node-{{ arch }}-{{ .Branch }}-{{ checksum "yarn.lock" }}
paths:
- ~/.cache/yarn
yarn_lint:
docker: *docker
environment: *environment
steps:
- checkout
- *restore_yarn_cache
- *run_yarn
- run: node ./scripts/prettier/index
- run: node ./scripts/tasks/eslint
- run: ./scripts/circleci/check_license.sh
- run: ./scripts/circleci/check_modules.sh
- run: ./scripts/circleci/test_print_warnings.sh
yarn_flow:
docker: *docker
environment: *environment
steps:
- checkout
- *restore_yarn_cache
- *run_yarn
- run: node ./scripts/tasks/flow-ci
RELEASE_CHANNEL_stable_yarn_test:
docker: *docker
environment: *environment
steps:
- checkout
- *restore_yarn_cache
- *run_yarn
- run: yarn test --release-channel=stable --ci
yarn_test:
docker: *docker
environment: *environment
steps:
- checkout
- *restore_yarn_cache
- *run_yarn
- run: yarn test --ci
RELEASE_CHANNEL_stable_yarn_test_www:
docker: *docker
environment: *environment
steps:
- checkout
- *restore_yarn_cache
- *run_yarn
- run: yarn test --release-channel=www-classic --ci
RELEASE_CHANNEL_stable_yarn_test_www_variant:
docker: *docker
environment: *environment
steps:
- checkout
- *restore_yarn_cache
- *run_yarn
- run: yarn test --release-channel=www-classic --variant --ci
RELEASE_CHANNEL_stable_yarn_test_prod_www:
docker: *docker
environment: *environment
steps:
- checkout
- *restore_yarn_cache
- *run_yarn
- run: yarn test --release-channel=www-classic --prod --ci
RELEASE_CHANNEL_stable_yarn_test_prod_www_variant:
docker: *docker
environment: *environment
steps:
- checkout
- *restore_yarn_cache
- *run_yarn
- run: yarn test --release-channel=www-classic --prod --variant --ci
yarn_test_www:
docker: *docker
environment: *environment
steps:
- checkout
- *restore_yarn_cache
- *run_yarn
- run: yarn test --release-channel=www-modern --ci
yarn_test_www_variant:
docker: *docker
environment: *environment
steps:
- checkout
- *restore_yarn_cache
- *run_yarn
- run: yarn test --release-channel=www-modern --variant --ci
yarn_test_prod_www:
docker: *docker
environment: *environment
steps:
- checkout
- *restore_yarn_cache
- *run_yarn
- run: yarn test --release-channel=www-modern --prod --ci
yarn_test_prod_www_variant:
docker: *docker
environment: *environment
steps:
- checkout
- *restore_yarn_cache
- *run_yarn
- run: yarn test --release-channel=www-modern --prod --variant --ci
RELEASE_CHANNEL_stable_yarn_test_persistent:
docker: *docker
environment: *environment
steps:
- checkout
- *restore_yarn_cache
- *run_yarn
- run: yarn test --release-channel=stable --persistent --ci
RELEASE_CHANNEL_stable_yarn_test_prod:
docker: *docker
environment: *environment
steps:
- checkout
- *restore_yarn_cache
- *run_yarn
- run: yarn test --release-channel=stable --prod --ci
yarn_test_prod:
docker: *docker
environment: *environment
steps:
- checkout
- *restore_yarn_cache
- *run_yarn
- run: yarn test --release-channel=experimental --prod --ci
RELEASE_CHANNEL_stable_yarn_build:
docker: *docker
environment: *environment
parallelism: 20
steps:
- checkout
- *restore_yarn_cache
- *run_yarn
- run:
environment:
RELEASE_CHANNEL: stable
command: |
./scripts/circleci/add_build_info_json.sh
./scripts/circleci/update_package_versions.sh
yarn build
- run: echo "stable" >> build/RELEASE_CHANNEL
- persist_to_workspace:
root: build
paths:
- RELEASE_CHANNEL
- facebook-www
- facebook-react-native
- node_modules
- react-native
- dist
- sizes/*.json
yarn_build:
docker: *docker
environment: *environment
parallelism: 20
steps:
- checkout
- *restore_yarn_cache
- *run_yarn
- run:
environment:
RELEASE_CHANNEL: experimental
command: |
./scripts/circleci/add_build_info_json.sh
./scripts/circleci/update_package_versions.sh
yarn build
- run: echo "experimental" >> build/RELEASE_CHANNEL
- persist_to_workspace:
root: build
paths:
- RELEASE_CHANNEL
- facebook-www
- facebook-react-native
- node_modules
- react-native
- dist
- sizes/*.json
build_devtools_and_process_artifacts:
docker: *docker
environment: *environment
parallelism: 20
steps:
- checkout
- attach_workspace: *attach_workspace
- *restore_yarn_cache
- *run_yarn
- run:
environment:
RELEASE_CHANNEL: experimental
command: ./scripts/circleci/pack_and_store_devtools_artifacts.sh
- store_artifacts:
path: ./build/devtools.tgz
# These jobs are named differently so we can distinguish the stable and
# and experimental artifacts
process_artifacts: *process_artifacts
process_artifacts_experimental: *process_artifacts
sizebot_stable:
docker: *docker
environment: *environment
steps:
- checkout
- attach_workspace: *attach_workspace
- *restore_yarn_cache
- *run_yarn
# This runs in the process_artifacts job, too, but it's faster to run
# this step in both jobs instead of running the jobs sequentially
- run: node ./scripts/rollup/consolidateBundleSizes.js
- run:
environment:
RELEASE_CHANNEL: stable
command: node ./scripts/tasks/danger
sizebot_experimental:
docker: *docker
environment: *environment
steps:
- checkout
- attach_workspace: *attach_workspace
- *restore_yarn_cache
- *run_yarn
# This runs in the process_artifacts job, too, but it's faster to run
# this step in both jobs instead of running the jobs sequentially
- run: node ./scripts/rollup/consolidateBundleSizes.js
- run:
environment:
RELEASE_CHANNEL: experimental
command: node ./scripts/tasks/danger
yarn_lint_build:
docker: *docker
environment: *environment
steps:
- checkout
- attach_workspace: *attach_workspace
- *restore_yarn_cache
- *run_yarn
- run: yarn lint-build
- run: scripts/circleci/check_minified_errors.sh
RELEASE_CHANNEL_stable_yarn_lint_build:
docker: *docker
environment: *environment
steps:
- checkout
- attach_workspace: *attach_workspace
- *restore_yarn_cache
- *run_yarn
- run:
environment:
RELEASE_CHANNEL: stable
command: yarn lint-build
- run: scripts/circleci/check_minified_errors.sh
RELEASE_CHANNEL_stable_yarn_test_build:
docker: *docker
environment: *environment
steps:
- checkout
- attach_workspace: *attach_workspace
- *restore_yarn_cache
- *run_yarn
- run: yarn test --release-channel=stable --build --ci
yarn_test_build:
docker: *docker
environment: *environment
steps:
- checkout
- attach_workspace: *attach_workspace
- *restore_yarn_cache
- *run_yarn
- run: yarn test --release-channel=experimental --build --ci
yarn_test_build_devtools:
docker: *docker
environment: *environment
steps:
- checkout
- attach_workspace: *attach_workspace
- *restore_yarn_cache
- *run_yarn
- run: yarn test --project=devtools --build --ci
RELEASE_CHANNEL_stable_yarn_test_dom_fixtures:
docker: *docker
environment: *environment
steps:
- checkout
- attach_workspace: *attach_workspace
- *restore_yarn_cache
- run:
name: Run DOM fixture tests
environment:
RELEASE_CHANNEL: stable
command: |
cd fixtures/dom
yarn --frozen-lockfile
yarn prestart
yarn test --maxWorkers=2
test_fuzz:
docker: *docker
environment: *environment
steps:
- checkout
- *restore_yarn_cache
- *run_yarn
- run:
name: Run fuzz tests
command: |
FUZZ_TEST_SEED=$RANDOM yarn test fuzz --ci
FUZZ_TEST_SEED=$RANDOM yarn test --prod fuzz --ci
RELEASE_CHANNEL_stable_yarn_test_build_prod:
docker: *docker
environment: *environment
steps:
- checkout
- attach_workspace: *attach_workspace
- *restore_yarn_cache
- *run_yarn
- run: yarn test --release-channel=stable --build --prod --ci
yarn_test_build_prod:
docker: *docker
environment: *environment
steps:
- checkout
- attach_workspace: *attach_workspace
- *restore_yarn_cache
- *run_yarn
- run: yarn test --release-channel=experimental --build --prod --ci
workflows:
version: 2
stable:
jobs:
- setup
- yarn_lint:
requires:
- setup
- yarn_flow:
requires:
- setup
- RELEASE_CHANNEL_stable_yarn_test:
requires:
- setup
- RELEASE_CHANNEL_stable_yarn_test_prod:
requires:
- setup
- RELEASE_CHANNEL_stable_yarn_test_persistent:
requires:
- setup
- RELEASE_CHANNEL_stable_yarn_test_www:
requires:
- setup
- RELEASE_CHANNEL_stable_yarn_test_www_variant:
requires:
- setup
- RELEASE_CHANNEL_stable_yarn_test_prod_www:
requires:
- setup
- RELEASE_CHANNEL_stable_yarn_test_prod_www_variant:
requires:
- setup
- RELEASE_CHANNEL_stable_yarn_build:
requires:
- setup
- process_artifacts:
requires:
- RELEASE_CHANNEL_stable_yarn_build
- sizebot_stable:
requires:
- RELEASE_CHANNEL_stable_yarn_build
- RELEASE_CHANNEL_stable_yarn_lint_build:
requires:
- RELEASE_CHANNEL_stable_yarn_build
- RELEASE_CHANNEL_stable_yarn_test_build:
requires:
- RELEASE_CHANNEL_stable_yarn_build
- RELEASE_CHANNEL_stable_yarn_test_build_prod:
requires:
- RELEASE_CHANNEL_stable_yarn_build
- RELEASE_CHANNEL_stable_yarn_test_dom_fixtures:
requires:
- RELEASE_CHANNEL_stable_yarn_build
experimental:
jobs:
- setup
- yarn_test:
requires:
- setup
- yarn_test_prod:
requires:
- setup
- yarn_test_www:
requires:
- setup
- yarn_test_www_variant:
requires:
- setup
- yarn_test_prod_www:
requires:
- setup
- yarn_test_prod_www_variant:
requires:
- setup
- yarn_build:
requires:
- setup
- process_artifacts_experimental:
requires:
- yarn_build
- sizebot_experimental:
requires:
- yarn_build
- yarn_test_build:
requires:
- yarn_build
- yarn_test_build_prod:
requires:
- yarn_build
- yarn_lint_build:
requires:
- yarn_build
- yarn_test_build_devtools:
requires:
- yarn_build
# FIXME: Temporarily disabled to unblock master.
# - build_devtools_and_process_artifacts:
# requires:
# - yarn_build
fuzz_tests:
triggers:
- schedule:
# Fuzz tests run hourly
cron: "0 * * * *"
filters:
branches:
only:
- master
jobs:
- setup
- test_fuzz:
requires:
- setup

10
.codesandbox/ci.json Normal file
View File

@@ -0,0 +1,10 @@
{
"packages": ["packages/react", "packages/react-dom", "packages/scheduler"],
"buildCommand": "build --type=NODE react/index,react-dom/index,react-dom/server,scheduler/index,scheduler/tracing",
"publishDirectory": {
"react": "build/node_modules/react",
"react-dom": "build/node_modules/react-dom",
"scheduler": "build/node_modules/scheduler"
},
"sandboxes": ["new"]
}

View File

@@ -1,4 +1,4 @@
# http://editorconfig.org
# https://editorconfig.org
root = true
[*]

View File

@@ -1,16 +1,21 @@
# We can probably lint these later but not important at this point
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/
packages/react-devtools-core/dist
packages/react-devtools-extensions/chrome/build
packages/react-devtools-extensions/firefox/build
packages/react-devtools-extensions/shared/build
packages/react-devtools-inline/dist
packages/react-devtools-shell/dist

View File

@@ -1,19 +1,30 @@
'use strict';
const {
es5Paths,
esNextPaths,
} = require('./scripts/shared/pathsByLanguageVersion');
const restrictedGlobals = require('confusing-browser-globals');
const OFF = 0;
const WARNING = 1;
const ERROR = 2;
module.exports = {
extends: ['fbjs', 'prettier'],
// Stop ESLint from looking for a configuration file in parent folders
root: true,
plugins: ['jest', 'no-for-of-loops', 'react', 'react-internal'],
parser: 'babel-eslint',
extends: './node_modules/fbjs-scripts/eslint/.eslintrc.js',
plugins: [
'react',
'react-internal',
],
ecmaFeatures: {
modules: false
parserOptions: {
ecmaVersion: 8,
sourceType: 'script',
ecmaFeatures: {
experimentalObjectRestSpread: true,
},
},
// We're stricter than the default config, mostly. We'll override a few rules
@@ -21,53 +32,153 @@ module.exports = {
rules: {
'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,
// We use console['error']() as a signal to not transform it:
'dot-notation': [ERROR, {allowPattern: '^(error|warn)$'}],
'eol-last': ERROR,
'eqeqeq': [ERROR, 'allow-null'],
'indent': [ERROR, 2, {SwitchCase: 1}],
eqeqeq: [ERROR, 'allow-null'],
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,
'no-restricted-globals': [ERROR].concat(restrictedGlobals),
'no-restricted-syntax': [ERROR, 'WithStatement'],
'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': OFF,
'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,
// Enforced by Prettier
// TODO: Prettier doesn't handle long strings or long comments. Not a big
// deal. But I turned it off because loading the plugin causes some obscure
// syntax error and it didn't seem worth investigating.
'max-len': OFF,
// 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/warning-and-invariant-args': ERROR,
}
'react-internal/no-primitive-constructors': ERROR,
'react-internal/no-to-warn-dev-within-to-throw': ERROR,
'react-internal/invariant-args': ERROR,
'react-internal/warning-args': ERROR,
'react-internal/no-production-logging': ERROR,
'react-internal/no-cross-fork-imports': 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: {
ecmaVersion: 8,
sourceType: 'module',
},
rules: {
'no-var': ERROR,
'prefer-const': ERROR,
strict: OFF,
},
},
{
files: ['**/__tests__/*.js'],
rules: {
// https://github.com/jest-community/eslint-plugin-jest
'jest/no-focused-tests': ERROR,
'jest/valid-expect': ERROR,
'jest/valid-expect-in-promise': ERROR,
},
},
{
files: [
'**/__tests__/**/*.js',
'scripts/**/*.js',
'packages/*/npm/**/*.js',
'packages/dom-event-testing-library/**/*.js',
'packages/react-devtools*/**/*.js',
],
rules: {
'react-internal/no-production-logging': OFF,
'react-internal/warning-args': OFF,
},
},
{
files: ['packages/react-native-renderer/**/*.js'],
globals: {
nativeFabricUIManager: true,
},
},
{
files: ['packages/react-transport-dom-webpack/**/*.js'],
globals: {
__webpack_chunk_load__: true,
__webpack_require__: true,
},
},
],
globals: {
SharedArrayBuffer: true,
spyOnDev: true,
spyOnDevAndProd: true,
spyOnProd: true,
__PROFILE__: true,
__UMD__: true,
__EXPERIMENTAL__: true,
__VARIANT__: true,
gate: true,
trustedTypes: true,
},
};

41
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@@ -0,0 +1,41 @@
---
name: "🐛 Bug Report"
about: Report a reproducible bug or regression.
title: 'Bug: '
labels: 'Status: Unconfirmed'
---
<!--
Please provide a clear and concise description of what the bug is. Include
screenshots if needed. Please test using the latest version of the relevant
React packages to make sure your issue has not already been fixed.
-->
React version:
## Steps To Reproduce
1.
2.
<!--
Your bug will get fixed much faster if we can run your code and it doesn't
have dependencies other than React. Issues without reproduction steps or
code examples may be immediately closed as not actionable.
-->
Link to code example:
<!--
Please provide a CodeSandbox (https://codesandbox.io/s/new), a link to a
repository on GitHub, or provide a minimal code example that reproduces the
problem. You may provide a screenshot of the application if you think it is
relevant to your bug report. Here are some tips for providing a minimal
example: https://stackoverflow.com/help/mcve.
-->
## The current behavior
## The expected behavior

7
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@@ -0,0 +1,7 @@
contact_links:
- name: 📃 Documentation Issue
url: https://github.com/reactjs/reactjs.org/issues/new
about: This issue tracker is not for documentation issues. Please file documentation issues here.
- name: 🤔 Questions and Help
url: https://reactjs.org/community/support.html
about: This issue tracker is not for support questions. Please refer to the React community's help and discussion forums.

27
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View File

@@ -0,0 +1,27 @@
<!--
Thanks for submitting a pull request!
We appreciate you spending the time to work on these changes. Please provide enough information so that others can review your pull request. The three fields below are mandatory.
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/) type checks (`yarn flow`).
10. If you haven't already, complete the CLA.
Learn more about contributing: https://reactjs.org/docs/how-to-contribute.html
-->
## Summary
<!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? -->
## Test Plan
<!-- Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes the user interface. -->

34
.github/stale.yml vendored Normal file
View File

@@ -0,0 +1,34 @@
# Configuration for probot-stale - https://github.com/probot/stale
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 90
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
# Issues with these labels will never be considered stale
exemptLabels:
- "Partner"
- "React Core Team"
- "Resolution: Backlog"
- "Type: Bug"
- "Type: Discussion"
- "Type: Needs Investigation"
- "Type: Regression"
# Label to use when marking an issue as stale
staleLabel: "Resolution: Stale"
issues:
# Comment to post when marking an issue as stale.
markComment: >
This issue has been automatically marked as stale.
**If this issue is still affecting you, please leave any comment** (for example, "bump"), and we'll keep it open.
We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!
# Comment to post when closing a stale issue.
closeComment: >
Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you!
pulls:
# Comment to post when marking a pull request as stale.
markComment: >
This pull request has been automatically marked as stale.
**If this pull request is still relevant, please leave any comment** (for example, "bump"), and we'll keep it open.
We are sorry that we haven't been able to prioritize reviewing it yet. Your contribution is very much appreciated.
# Comment to post when closing a stale pull request.
closeComment: >
Closing this pull request after a prolonged period of inactivity. If this issue is still present in the latest release, please ask for this pull request to be reopened. Thank you!

29
.gitignore vendored
View File

@@ -1,23 +1,18 @@
.DS_STORE
node_modules
scripts/flow/*/.flowconfig
.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 +21,17 @@ chrome-user-data
.idea
*.iml
.vscode
*.swp
*.swo
packages/react-devtools-core/dist
packages/react-devtools-extensions/chrome/build
packages/react-devtools-extensions/chrome/*.crx
packages/react-devtools-extensions/chrome/*.pem
packages/react-devtools-extensions/firefox/build
packages/react-devtools-extensions/firefox/*.xpi
packages/react-devtools-extensions/firefox/*.pem
packages/react-devtools-extensions/shared/build
packages/react-devtools-extensions/.tempUserDataDir
packages/react-devtools-inline/dist
packages/react-devtools-shell/dist

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>
@@ -90,6 +88,7 @@ Kevin Coughlin <kevintcoughlin@gmail.com> <kevincoughlin@tumblr.com>
Krystian Karczewski <karcz.k@gmail.com>
Kunal Mehta <k.mehta@berkeley.edu> <kunalm@fb.com>
Laurence Rowe <l@lrowe.co.uk> <laurence@lrowe.co.uk>
Lea Rosema <terabaud@gmail.com>
Marcin K. <katzoo@github.mail>
Mark Anderson <undernewmanagement@users.noreply.github.com>
Mark Funk <mfunk86@gmail.com> <mark@boomtownroi.com>
@@ -137,6 +136,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 @@
v12.16.2

6
.prettierignore Normal file
View File

@@ -0,0 +1,6 @@
packages/react-devtools-core/dist
packages/react-devtools-extensions/chrome/build
packages/react-devtools-extensions/firefox/build
packages/react-devtools-extensions/shared/build
packages/react-devtools-inline/dist
packages/react-devtools-shell/dist

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: 'babel',
overrides: [
{
files: esNextPaths,
options: {
trailingComma: 'all',
},
},
],
};

View File

@@ -1,101 +0,0 @@
---
language: node_js
node_js:
- 4
sudo: false
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 "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
./node_modules/.bin/grunt jest:normal
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
else
./node_modules/.bin/grunt $TEST_TYPE
fi
env:
matrix:
- TEST_TYPE=build
- TEST_TYPE=test
- TEST_TYPE=lint
- 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

1
.watchmanconfig Normal file
View File

@@ -0,0 +1 @@
{}

437
AUTHORS

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

76
CODE_OF_CONDUCT.md Normal file
View File

@@ -0,0 +1,76 @@
# Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to make participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies within all project spaces, and it also applies when
an individual is representing the project or its community in public spaces.
Examples of representing a project or community include using an official
project e-mail address, posting via an official social media account, or acting
as an appointed representative at an online or offline event. Representation of
a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at <opensource-conduct@fb.com>. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq

View File

@@ -1,100 +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)
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,160 +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', require('./grunt/tasks/eslint'));
grunt.registerTask('lint', ['eslint']);
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 npmReactAddonsTasks = require('./grunt/tasks/npm-react-addons');
grunt.registerTask('npm-react-addons:release', npmReactAddonsTasks.buildReleases);
grunt.registerTask('npm-react-addons:pack', npmReactAddonsTasks.packReleases);
grunt.registerTask('version-check', require('./grunt/tasks/version-check'));
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-addons:release',
'npm-react-addons: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.

137
README.md
View File

@@ -1,116 +1,75 @@
# [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) [![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.
* **Just the UI:** Lots of people use React as the V in MVC. Since React makes no assumptions about the rest of your technology stack, it's easy to try it out on a small feature in an existing project.
* **Virtual DOM:** React abstracts away the DOM from you, giving a simpler programming model and better performance. React can also render on the server using Node, and it can power native apps using [React Native](https://facebook.github.io/react-native/).
* **Data flow:** React implements one-way reactive data flow which reduces boilerplate and is easier to reason about than traditional data binding.
* **Declarative:** React makes it painless to create interactive UIs. Design simple views for each state in your application, and React will efficiently update and render just the right components when your data changes. Declarative views make your code more predictable, simpler to understand, and easier to debug.
* **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://reactnative.dev/).
**NEW**! Check out our newest project [React Native](https://github.com/facebook/react-native), which uses React and JavaScript to create native mobile apps.
[Learn how to use React in your own project](https://reactjs.org/docs/getting-started.html).
[Learn how to use React in your own project](https://facebook.github.io/react/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/package/react).
## 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() {
return <div>Hello {this.props.name}</div>;
}
});
```jsx
function HelloMessage({ name }) {
return <div>Hello {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-0.14.8.js"></script>
<!-- The ReactDOM Library -->
<script src="https://fb.me/react-dom-0.14.8.js"></script>
```
### [Code of Conduct](https://code.fb.com/codeofconduct)
We've also built a [starter kit](https://facebook.github.io/react/downloads/react-0.14.8.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.fb.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 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).

7
SECURITY.md Normal file
View File

@@ -0,0 +1,7 @@
# Reporting Security Issues
If you believe you have found a security vulnerability in React, we encourage you to let us know right away. We will investigate all legitimate reports and do our best to quickly fix the problem.
Please refer to the following page for our responsible disclosure policy, reward guidelines, and those things that should not be reported:
https://www.facebook.com/whitehat

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"

27
babel.config.js Normal file
View File

@@ -0,0 +1,27 @@
'use strict';
module.exports = {
plugins: [
'@babel/plugin-syntax-jsx',
'@babel/plugin-transform-react-jsx',
'@babel/plugin-transform-flow-strip-types',
['@babel/plugin-proposal-class-properties', {loose: true}],
'syntax-trailing-function-commas',
[
'@babel/plugin-proposal-object-rest-spread',
{loose: true, useBuiltIns: true},
],
['@babel/plugin-transform-template-literals', {loose: true}],
'@babel/plugin-transform-literals',
'@babel/plugin-transform-arrow-functions',
'@babel/plugin-transform-block-scoped-functions',
'@babel/plugin-transform-object-super',
'@babel/plugin-transform-shorthand-properties',
'@babel/plugin-transform-computed-properties',
'@babel/plugin-transform-for-of',
['@babel/plugin-transform-spread', {loose: true, useBuiltIns: true}],
'@babel/plugin-transform-parameters',
['@babel/plugin-transform-destructuring', {loose: true, useBuiltIns: true}],
['@babel/plugin-transform-block-scoping', {throwIfClosureRequired: true}],
],
};

295
dangerfile.js Normal file
View File

@@ -0,0 +1,295 @@
/**
* 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:
//
// 0a7d5c3cad9a6dbec2d9 9a5222cf49062a4c1ef7
//
// (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, warn} = require('danger');
const fetch = require('node-fetch');
const {generateResultsArray} = require('./scripts/rollup/stats');
const {existsSync, readFileSync} = require('fs');
const {exec} = require('child_process');
// This must match the name of the CI job that creates the build artifacts
const RELEASE_CHANNEL =
process.env.RELEASE_CHANNEL === 'experimental' ? 'experimental' : 'stable';
const artifactsJobName =
process.env.RELEASE_CHANNEL === 'experimental'
? 'process_artifacts_experimental'
: 'process_artifacts';
if (!existsSync('./build/bundle-sizes.json')) {
// This indicates the build failed previously.
// In that case, there's nothing for the Dangerfile to do.
// Exit early to avoid leaving a redundant (and potentially confusing) PR comment.
warn(
'No bundle size information found. This indicates the build ' +
'job failed.'
);
process.exit(0);
}
const currentBuildResults = JSON.parse(
readFileSync('./build/bundle-sizes.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;
if (upstreamRepo !== 'facebook/react') {
// Exit unless we're running in the main repo
return;
}
markdown(`## Size changes (${RELEASE_CHANNEL})`);
const upstreamRef = danger.github.pr.base.ref;
await git(`remote add upstream https://github.com/facebook/react.git`);
await git('fetch upstream');
const baseCommit = await git(`merge-base HEAD upstream/${upstreamRef}`);
let previousBuildResults = null;
try {
let baseCIBuildId = null;
const statusesResponse = await fetch(
`https://api.github.com/repos/facebook/react/commits/${baseCommit}/status`
);
const {statuses, state} = await statusesResponse.json();
if (state === 'failure') {
warn(`Base commit is broken: ${baseCommit}`);
return;
}
for (let i = 0; i < statuses.length; i++) {
const status = statuses[i];
if (status.context === `ci/circleci: ${artifactsJobName}`) {
if (status.state === 'success') {
baseCIBuildId = /\/facebook\/react\/([0-9]+)/.exec(
status.target_url
)[1];
break;
}
if (status.state === 'pending') {
warn(`Build job for base commit is still pending: ${baseCommit}`);
return;
}
}
}
if (baseCIBuildId === null) {
warn(`Could not find build artifacts for base commit: ${baseCommit}`);
return;
}
const baseArtifactsInfoResponse = await fetch(
`https://circleci.com/api/v1.1/project/github/facebook/react/${baseCIBuildId}/artifacts`
);
const baseArtifactsInfo = await baseArtifactsInfoResponse.json();
for (let i = 0; i < baseArtifactsInfo.length; i++) {
const info = baseArtifactsInfo[i];
if (info.path.endsWith('bundle-sizes.json')) {
const resultsResponse = await fetch(info.url);
previousBuildResults = await resultsResponse.json();
break;
}
}
} catch (error) {
warn(`Failed to fetch build artifacts for base commit: ${baseCommit}`);
return;
}
if (previousBuildResults === null) {
warn(`Could not find build artifacts for base commit: ${baseCommit}`);
return;
}
// Take the JSON of the build response and
// make an array comparing the results for printing
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: ${baseCommit}...${danger.github.pr.head.sha}</p>
${allTables.join('\n')}
</details>
`;
markdown(summary);
} else {
markdown('No significant bundle size changes to report.');
}
})();

View File

@@ -1,8 +0,0 @@
---
layout: single
title: Page Not Found
---
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,19 +0,0 @@
source 'https://rubygems.org'
gem 'rake'
# jekyll, which builds it all
# 2.0 includes sass processing
gem 'jekyll', '~>2.0'
# Auto redirect pages
gem 'jekyll-redirect-from'
# JSON
gem 'json'
# For `rake watch`
gem 'rb-fsevent'
# For markdown header cleanup
gem 'sanitize', '~>2.0'

View File

@@ -1,85 +0,0 @@
GEM
remote: https://rubygems.org/
specs:
blankslate (2.1.2.4)
celluloid (0.15.2)
timers (~> 1.1.0)
classifier (1.3.4)
fast-stemmer (>= 1.0.0)
coffee-script (2.3.0)
coffee-script-source
execjs
coffee-script-source (1.7.1)
colorator (0.1)
execjs (2.2.1)
fast-stemmer (1.0.2)
ffi (1.9.3)
jekyll (2.2.0)
classifier (~> 1.3)
colorator (~> 0.1)
jekyll-coffeescript (~> 1.0)
jekyll-gist (~> 1.0)
jekyll-paginate (~> 1.0)
jekyll-sass-converter (~> 1.0)
jekyll-watch (~> 1.0)
kramdown (~> 1.3)
liquid (~> 2.6.1)
mercenary (~> 0.3.3)
pygments.rb (~> 0.6.0)
redcarpet (~> 3.1)
safe_yaml (~> 1.0)
toml (~> 0.1.0)
jekyll-coffeescript (1.0.0)
coffee-script (~> 2.2)
jekyll-gist (1.1.0)
jekyll-paginate (1.0.0)
jekyll-redirect-from (0.5.0)
jekyll (~> 2.0)
jekyll-sass-converter (1.2.0)
sass (~> 3.2)
jekyll-watch (1.1.0)
listen (~> 2.7)
json (1.8.1)
kramdown (1.4.1)
liquid (2.6.1)
listen (2.7.9)
celluloid (>= 0.15.2)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
mercenary (0.3.4)
mini_portile (0.6.0)
nokogiri (1.6.3.1)
mini_portile (= 0.6.0)
parslet (1.5.0)
blankslate (~> 2.0)
posix-spawn (0.3.9)
pygments.rb (0.6.0)
posix-spawn (~> 0.3.6)
yajl-ruby (~> 1.1.0)
rake (10.3.2)
rb-fsevent (0.9.4)
rb-inotify (0.9.5)
ffi (>= 0.5.0)
redcarpet (3.1.2)
safe_yaml (1.0.4)
sanitize (2.0.6)
nokogiri (>= 1.4.4)
sass (3.3.14)
timers (1.1.0)
toml (0.1.1)
parslet (~> 1.5.0)
yajl-ruby (1.1.0)
PLATFORMS
ruby
DEPENDENCIES
jekyll (~> 2.0)
jekyll-redirect-from
json
rake
rb-fsevent
sanitize (~> 2.0)
BUNDLED WITH
1.10.1

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,69 +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 "build into ../../react-gh-pages"
task :release => [:update_version, :js, :fetch_remotes] do
system "jekyll build -d ../../react-gh-pages"
end
task :default => [:js]

View File

@@ -1,48 +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/"
relative_permalinks: true
paginate: 5
timezone: America/Los_Angeles
highlighter: pygments
defaults:
- scope:
path: ''
type: post
values:
layout: post
- scope:
path: docs
type: page
values:
layout: 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
react_version: 0.14.7
react_hashes:
dev: xQae1pUPdAKUe0u0KUTNt09zzdwheX4VSUsV8vatqM+t6X7rta01qOzessL808ox
prod: zTm/dblzLXQNp3CgY+hfaC/WJ6h4XtNrePh2CW2+rO9GPuNiPb9jmthvAL+oI/dQ
addons_dev: I5TF2q2QDmB31aN5lcClArdUo+WJH/Yi3hcH3PBVXFe5DYtYCFh7Jx/dmpba12zn
addons_prod: KPHTQfiYMhtsIRbZcY4ri1lBYZQbj4ePsSdzODR2Bu5L5ts3APVyqwKPBThO5Hgc
dom_dev: A1t0GCrR06cTHvMjaxeSE8XOiz6j7NvWdmxhN/9z748wEvJTVk13Rr8gMzTUnd8G
dom_prod: ntqCsHbLdMxT352UbhPbT7fqjE8xi4jLmQYQa8mYR+ylAapbXRfdsDweueDObf7m
dom_server_dev: 3I5+eGB/ILYa6pQQX+rM9O0SyDltamM40RiZ5JvIijSYEfVGZU0vY4Iwx9a1eYyD
dom_server_prod: Kt9dEqXzv00orFPW2o3H+kxQtSiNO8EqXsXJT3i99rCcp74N/Km98V0kUxAzy44k

View File

@@ -1,173 +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: #268bd2;
}
.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: #637c84;
}
.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: #cb4b16;
}
.cm-s-solarized-light span.cm-tag {
color: #657b83;
}
.cm-s-solarized-light span.cm-attribute {
color: #586e75;
font-weight: bold;
}
.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;
font-weight: bold;
}
.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
);
}
}

Some files were not shown because too many files have changed in this diff Show More