Commit Graph

6934 Commits

Author SHA1 Message Date
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