Commit Graph
2888 Commits
Author SHA1 Message Date
Keyan ZhangandDan Abramov fb97197805 improved warning in ReactUpdateQueue (#7326) 2016-07-21 12:41:31 +01:00
Alex ZherdevandDan Abramov 4c96bc4cf8 Mention actual prop type in element type checker (#7319) 2016-07-20 19:16:55 +01:00
Sassan HaradjiandDan Abramov a989fb06a4 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 AbramovandGitHub 573ad5d3e4 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 AbramovandGitHub 92fe0fe12d 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
Troy DeMonbreunandPaul O’Shannessy d75f8535b1 Fix #7099 (#7251)
* Set step prop before value prop

* Embed comments on .step sequence behavior
2016-07-13 13:28:14 -07:00
Mert KahyaoğluandPaul O’Shannessy 54d7a20b8a Renaming: ReactDOM (#7265)
Rename React with ReactDOM
2016-07-13 12:59:02 -07:00
Brandon DailandPaul O’Shannessy fb76e1a62c Add referrerPolicy to HTMLDOMPropertyConfig (#7274) 2016-07-13 11:56:57 -07:00
Keyan ZhangandGitHub 10ac032b9b warn for using maps as children with owner info (#7260) 2016-07-13 08:29:42 -07:00
Ben AlpertandGitHub 7f9eba20e3 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
UsmanandPaul O’Shannessy 3991ee0db3 Fixed all eslint warnings (#7230) 2016-07-11 17:47:41 -07:00
Samy Al ZahraniandDan Abramov d58691e130 Add xmlns and xmlns:xlink attributes (#6471) 2016-07-09 13:32:53 +01:00
Dan AbramovandGitHub 53dfa7d692 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 DailandDan Abramov cf106a263a Inject default batching after pending transactions (#7033) 2016-07-08 18:52:14 +01:00
Dan AbramovandGitHub 48b308356d 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
Ben AlpertandGitHub 2c92188366 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 OkonetchnikovandPaul O’Shannessy 29a9bcf7bb 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’ShannessyandGitHub 02bae08ff1 Don't detach value from defaultValue for submit/reset inputs (#7197) 2016-07-05 16:39:43 -07:00
Dan AbramovandGitHub befc4808e4 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 DailandDan Abramov d693f1c453 Use hardcoded value for PropType secret (#7194)
Rename secret!
2016-07-06 00:22:01 +01:00
Sebastian MarkbågeandGitHub eafd80df16 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
Timothy YungandGitHub 104737e70e 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 DailandDan Abramov 4b4652c9e6 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 AbramovandGitHub 0c1585528f Disable DebugTools in production (#7189) 2016-07-05 19:41:45 +01:00
Christopher ChedeauandGitHub 9282bbdd3e [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 AbramovandGitHub 9d3f4cb849 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 ChedeauandGitHub 677097445b [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 AbramovandGitHub f208b8d741 Remove Danger.dangerouslyRenderMarkup as it is dead code (#7185) 2016-07-05 03:25:06 +01:00
Dan AbramovandGitHub a6b15d03c6 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 RicardandDan Abramov 27ea2610bc 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 RoncancioandDan Abramov 1345d72733 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
Sebastian MarkbågeandGitHub a2a922f110 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
Sebastian MarkbågeandGitHub 0bbb6245ac Merge pull request #7154 from sebmarkbage/sideeffects
[Fiber] Host Side Effects
2016-06-30 16:35:38 -07:00
Griffin MichlandDan Abramov 26c27d7dfe Group warnings for unknown DOM properties (#7153) 2016-07-01 00:13:32 +01:00
Sebastian Markbage 45536275f4 Nits 2016-06-30 15:55:09 -07:00
Sebastian Markbage dc17ed968d Rudimentary DOM Renderer with Example 2016-06-30 14:30:16 -07:00
Sebastian Markbage 3ebbf9409b 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 55fc5b3744 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 9f283ee521 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 465322ce4f 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 c86053656f 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 Markbage b98eba6daa Remove unreachable code
This should've been caught above.
2016-06-30 12:55:55 -07:00
Sebastian Markbage 29e9de2db9 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 6478b2a16f Feedback on style 2016-06-30 12:55:55 -07:00
Sebastian Markbage b88b68f89c 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 0cb3e05f5a 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 ce99d40397 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 07ea8ac44c 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 50a93e41c1 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 39d05d8746 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