Commit Graph

312 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
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
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
Ben Alpert
9d07ea7105 Remove reactComponentExpect (#9856)
Legacy.
2017-06-05 16:42:56 -07: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
Edvin Erikson
b9ddd206f9 Fiber SSR tests (#9846) 2017-06-04 15:44:24 -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
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
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
fedb2ff8ec Remove createClass, PropTypes, DOM factories, and createMixin from React object (#9788) 2017-05-30 15:35:30 +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
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
Ben Alpert
f0a0999c3b Add test for key warning at top level (#9473) 2017-05-21 15:39:25 -07: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
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
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
Ben Alpert
542dac4a23 Fix return value of ReactDOMFiber.unmountComponentAtNode (#9619) 2017-05-05 17:54:53 -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
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
Dan Abramov
45dbcfb67d Add missing passing test 2017-05-02 14:22:09 +01:00
Ben Alpert
f677bfc964 Fix __proto__ bug in ReactDOMSelect (#9536)
https://twitter.com/rauschma/status/857307345231249409
2017-04-29 08:23:00 -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
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
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
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
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
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
864973c544 Run Fiber test script 2017-04-20 11:37:18 -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
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