Commit Graph

568 Commits

Author SHA1 Message Date
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
Flarnie Marchan
49c8d717a0 16.0.0-rc.1 (#10630) 2017-09-06 15:43:22 -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
Nikita Lebedev
a8845587a3 Fix typo in script function name (#10611) 2017-09-05 10:28:34 -07:00
Dan Abramov
9f772abdc6 Update sizes 2017-08-31 22:35:42 -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
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
Andrew Clark
b9c8e4e9df Remove UMD builds from fixture directory (#10547) 2017-08-25 17:17:31 -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
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
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
Brian Vaughn
e464cf2def Removed ReactNativeFeatureFlag shim from RN bundle (#10472) 2017-08-18 08:26:11 -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
Brandon Dail
5ff5700625 Add explicit invariant when ReactDOM is loaded w/o React (#10449) 2017-08-13 13:16:13 -05: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
b9e92c6747 Moved around package dependencies fixes #10335 (#10424) 2017-08-09 18:47:52 +01:00
Mateusz Burzyński
9166cf9b8d Add test for duplicate events with nested dispatch 2017-08-09 09:30:08 -05:00
Brian Vaughn
c3718c48f0 16 beta 5 version bump and results JSON 2017-08-08 10:25:25 -07:00
Brian Vaughn
9ebd0c9e9a Updated packages and results JSON for 16 beta 4 2017-08-08 09:08:17 -07: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
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
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
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
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
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
138224f6b3 16.0.0-beta.2 2017-07-27 18:06:26 +01:00
Keyan Zhang
3abbcc48a5 Fix ReactPartialRenderer in production (#10300) 2017-07-27 10:19:05 +01:00
Brian Vaughn
834d2c6954 Updated package versions and Rollup results 2017-07-26 12:55:31 -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
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
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
66065115dc Update sizes 2017-07-26 12:27:29 +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
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
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