Commit Graph

2739 Commits

Author SHA1 Message Date
Brandon Dail 7d9ded56a2 Use hardcoded value for PropType secret (#7194)
Rename secret!
(cherry picked from commit 2c93a41580)
2016-07-13 11:39:40 -07:00
Brandon Dail e75e8dcbeb 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

(cherry picked from commit 95ac239cf3)
2016-07-13 11:39:40 -07:00
Troy DeMonbreun 4a0a534357 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

(cherry picked from commit 6cc037bd0d)
2016-07-13 11:39:40 -07:00
Ben Alpert d441128bf6 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.
(cherry picked from commit abcd567325)
2016-07-13 11:39:40 -07:00
Dan Abramov 891e087926 Fix tests from #6158 to use Jasmine 2 (#7126)
(cherry picked from commit a49b7a2dfb)
2016-07-13 11:39:40 -07:00
Swaroop SM 9d385ef326 Warn if the included mixin is undefined (#6158)
(cherry picked from commit 18bad0669f)
2016-07-13 11:39:40 -07:00
Evan Jacobs 3b80d4dcd7 [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.
(cherry picked from commit 5a20d449f6)
2016-07-13 11:39:39 -07:00
Dan Abramov 343033bf06 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

(cherry picked from commit 83cbc3e5fb)
2016-07-13 11:39:39 -07:00
Jim b688bb301c Warn if people mutate children. (#7001)
(cherry picked from commit 49238b9440)
2016-07-13 11:39:34 -07:00
Paul O’Shannessy 68faf9d1b9 15.2.1 2016-07-08 15:15:02 -07:00
Dan Abramov 9fb898943a 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.

(cherry picked from commit 1a0e3a3215)
2016-07-08 11:01:15 -07:00
Andrey Okonetchnikov 9db68fcf5d Do not render name attribute on INPUT if it is not supplied. Closes #7198. (#7199)
(cherry picked from commit 0d892c03da)
2016-07-08 10:58:37 -07:00
Paul O’Shannessy 219e838070 Don't detach value from defaultValue for submit/reset inputs (#7197)
(cherry picked from commit 5c737b9550)
2016-07-08 10:58:37 -07:00
Dan Abramov 720ce5aa70 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

(cherry picked from commit d2ff462b79)
2016-07-08 10:58:36 -07:00
Sebastian Markbåge a0a8f2a451 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.
(cherry picked from commit 4f7a38c3b7)
2016-07-08 10:56:29 -07:00
Timothy Yung 75e6399261 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.
(cherry picked from commit 2b226f5fa6)
2016-07-08 10:56:29 -07:00
Dan Abramov 25528eacbc Disable DebugTools in production (#7189)
(cherry picked from commit 5d31ebcf5f)
2016-07-08 10:56:23 -07:00
Christopher Chedeau f6b619aab1 [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
(cherry picked from commit 309215fc40)
2016-07-08 10:48:57 -07:00
Dan Abramov 7547d0d8e5 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.

(cherry picked from commit 8fe6b5fb46)
2016-07-08 10:48:57 -07:00
Christopher Chedeau d7a6c95464 [flow] fix flattenChildren type (#7110)
Summary:
Make the debug attribute optional

Test Plan:
npm run flow

Reviewers: @keyanzhang @chicoxyzzy
(cherry picked from commit 07cfba17a9)
2016-07-08 10:48:57 -07:00
Dan Abramov 9687b35d83 Remove Danger.dangerouslyRenderMarkup as it is dead code (#7185)
(cherry picked from commit 7d0801e1a0)
2016-07-08 10:48:57 -07:00
Robin Ricard 173d065a9e 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
(cherry picked from commit dbdddf1c82)
2016-07-08 10:48:56 -07:00
Richard Roncancio 67cbe6d471 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.
(cherry picked from commit 6e5dd8926c)
2016-07-08 10:48:56 -07:00
Sebastian Markbåge c625bc88aa 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.
(cherry picked from commit 4bc1048e0d)
2016-07-08 10:48:56 -07:00
Sebastian Markbåge f1f599d775 Merge pull request #7154 from sebmarkbage/sideeffects
[Fiber] Host Side Effects
(cherry picked from commit cf259a4ff8)
2016-07-08 10:48:56 -07:00
Sebastian Markbåge c4b719d4dc Merge pull request #7034 from sebmarkbage/newreconciler
[Fiber] Host Container Fiber and Priority Levels
(cherry picked from commit 291f8e30a9)
2016-07-08 10:48:56 -07:00
starkch e23690a0dc 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

(cherry picked from commit f94912516f)
2016-07-08 10:48:56 -07:00
Dan Abramov 20d2398ab6 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

(cherry picked from commit 25f9f4563e)
2016-07-08 10:48:56 -07:00
Esteban 32cadeacdb Remove comment about PooledClass destructors being optional (#6560)
They are no longer optional since #4720
(cherry picked from commit 752e1595fc)
2016-07-08 10:48:56 -07:00
Sergey Rubanov a3c0d68af9 [flow] add some typings to utils (#7104)
* add some typings to utils

* add typing of flattenChildren

* more accurate typings for flattenChildren

(cherry picked from commit 3b5c756c7a)
2016-07-08 10:48:56 -07:00
Christopher Chedeau 24cf5c7a5e [flow] type deprecated (#7076)
Summary:

Test Plan:
npm run flow

Reviewers: @zpao @spicyj @gabelevi
(cherry picked from commit 9342c2f02f)
2016-07-08 10:48:56 -07:00
Jim 8ea1ee14d5 Remove dead HAS_SIDE_EFFECTS logic (#6987)
(cherry picked from commit 416b5ef173)
2016-07-08 10:48:56 -07:00
Christopher Chedeau ba6ca7ff71 [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
(cherry picked from commit b0732ef881)
2016-07-08 10:48:55 -07:00
Christopher Chedeau eb9f4efde7 [flow] type adler32 (#7080)
This one is trivial

Test Plan:
npm run flow

Reviewers: @zpao @spicyj
(cherry picked from commit 489caeb2d7)
2016-07-08 10:48:55 -07:00
Christopher Chedeau 8ee93720ce [flow] type KeyEscapeUtils (#7079)
Summary:

The only call site ensures that the value is not null: https://github.com/facebook/react/blob/dc6fc8cc0726458a14f0544a30514af208d0098b/src/shared/utils/traverseAllChildren.js#L44

key is stringified inside of createElement, so we are guaranteed to receive a string right now: https://github.com/facebook/react/blob/dc6fc8cc0726458a14f0544a30514af208d0098b/src/isomorphic/classic/element/ReactElement.js#L142

Test Plan:
npm run flow

Reviewers: @zpao @spicyj
(cherry picked from commit 12a6ad1ef5)
2016-07-08 10:48:55 -07:00
Christopher Chedeau cea00b4b21 Merge pull request #7053 from vjeux/flow_accumulate
[flow] annotate accumulate, accumulateInto and forEachAccumulated
(cherry picked from commit 5b4dad31f8)
2016-07-08 10:48:55 -07:00
Toru Kobayashi 23de673537 Remove setProps and replaceProps from src (#7045)
(cherry picked from commit e8fa464d6f)
2016-07-08 10:48:55 -07:00
Jim 26870ad27b Move null-input-value-prop warning into devtool, add stack trace (#7040)
(cherry picked from commit 97d89fa5bf)
2016-07-08 10:48:55 -07:00
Paul O’Shannessy c650249339 15.2.0 2016-07-01 11:31:05 -07:00
Paul O’Shannessy 33f54bfaa1 15.2.0-rc.2 2016-06-30 23:22:15 -07:00
Griffin Michl 5131a43f96 Group warnings for unknown DOM properties (#7153)
(cherry picked from commit 39265cb892)
2016-06-30 23:13:29 -07:00
Jim 62135da3ba Add autoFocus to list of whitelisted dom element props. (#7098)
(cherry picked from commit b4fc27357c)
2016-06-30 23:13:10 -07:00
Paul O’Shannessy c66f40f749 15.2.0-rc.1 2016-06-14 18:24:12 -07:00
Paul O’Shannessy 2a411dd248 Revert part of createElement validation changes from #6859 2016-06-14 18:16:41 -07:00
Christoph Pojer 243be87c6d Add symbol to identify a ReactTestComponent instance. (#7035)
(cherry picked from commit 6b8db0e111)
2016-06-14 15:50:39 -07:00
Dominic Gannaway eab4ffa721 Performance: setTextContent should attempt to set TextNode nodeValue where possible (#7005)
(cherry picked from commit 40f6d3eaca)
2016-06-14 15:50:39 -07:00
Jim d4aebaa671 Remove console.log from test (#7006)
(cherry picked from commit 2282894d52)
2016-06-14 15:50:39 -07:00
Jim cd5189a63c Fix controlled/uncontrolled validation for radio+checkbox inputs (#7003)
(cherry picked from commit 0bb0fe8d00)
2016-06-14 15:50:39 -07:00
Jim cf50a83b8d Fix IE11 placeholder textContent value bug. (#7002)
(cherry picked from commit f0b140d726)
2016-06-14 15:50:39 -07:00
Brandon Dail 89746fa70f Warn if childContextType is defined on SFC (#6933)
Add console.error message content check

Use appropriate name in warning/test
(cherry picked from commit c47830d12c)
2016-06-14 15:50:39 -07:00