Commit Graph

1335 Commits

Author SHA1 Message Date
Sebastian Markbåge 7354a699ff Revert "Monitoring code use of cloneWithProps" 2014-12-18 12:13:09 -08:00
Paul O’Shannessy 50a0d69961 Protect better against createElement(null/undefined)
This adds a warning to React.createElement in __DEV__ about using null
or undefined. This is technically valid since element creation can be
considered safe and usable in multiple rendering environments. But
rendering in a DOM environment with an element with null/undefined type
is not safe.
2014-12-17 10:38:02 -08:00
Paul O’Shannessy 63d8e0c144 Fix lint 2014-12-14 15:22:24 -08:00
Paul O’Shannessy 0b0fa760cc Merge pull request #2647 from zpao/text-component-expect
Add toBeTextComponentWithValue to reactComponentExpect
2014-12-14 14:33:37 -08:00
Paul O’Shannessy c46dadea55 Remove deprecated methods since 0.12 shipped 2014-12-14 14:19:44 -08:00
Paul O’Shannessy c9fb5b258e Add toBeTextComponentWithValue to reactComponentExpect
This was previously possible by looking at renderedChildren and props
but this feels better.
2014-12-14 14:12:29 -08:00
Sebastian Markbage 801e953334 Move ReactClass, ReactElement and ReactPropTypes into "traditional"
This moves ReactClass, ReactElement and ReactPropTypes into a legacy folder
but since it's not quite legacy yet, I call it "classic".

These are "classic" because they are decoupled and can be replaced by
ES6 classes, JSX and Flow respectively.

This also extracts unit tests from ReactCompositeComponent, which was
terribly overloaded, into the new corresponding test suites.

There is one weird case for ReactContextValidator. This actually happens in
core, and technically belongs to ReactCompositeComponent. I'm not sure
we will be able to statically validate contexts so this might be a case
for dynamic checks even in the future. Leaving the unit tests in classic
until we can figure out what to do with them.
2014-12-12 17:54:35 -08:00
Paul O’Shannessy 80ed4d870a Merge pull request #2690 from salier/before-input
Combine BeforeInput and Composition event plugins
2014-12-11 17:08:26 -08:00
Jim 74f5b21758 Fixed ReactTestUtils scry for TextComponents. Fixes issue #2654. 2014-12-11 13:12:35 -08:00
Isaac Salier-Hellendag 9ad0e1d846 Update BeforeInputEventPlugin.js 2014-12-10 11:36:39 -05:00
Isaac Salier-Hellendag ddaf215b03 Combine BeforeInput and Composition event plugins
In order to improve support for Chinese and Japanese IME input in
Internet Explorer, use a fallback composition state to determine
inserted text. IE composition events are mostly okay, except for
certain punctuation characters that are ignored. Using the fallback, we
can detect these characters.

The fallback is also useful for emitting `beforeInput` events, so it
makes sense to simply combine these plugins.

This change also incorporates a recent change to the Google Input Tools
browser extension that exposes a `data` field via the `detail` object
on the custom composition events it emits.
2014-12-10 11:32:53 -05:00
Paul O’Shannessy 739baa9092 Fix new lint errors
We'll get to lint parity soon and then not need to do this.
2014-12-08 12:18:41 -08:00
Paul O’Shannessy 5c1589b81e Merge pull request #2658 from ianobermiller/margin-attrs
Support marginHeight and marginWidth attributes
2014-12-04 19:02:34 -08:00
Paul O’Shannessy dd844bffc0 Merge pull request #2489 from cody/form
Add Attributes formAction, formEncType, formMethod and formTarget
2014-12-04 19:01:32 -08:00
Ian Obermiller 9d7467e225 Don't need MUST_USE_ATTRIBUTE for margin(Width|Height) 2014-12-04 11:02:35 -08:00
Ian Obermiller 96bd155cbd Support marginHeight and marginWidth attributes
marginHeight and marginWidth are used on iframes to set the default body margin inside the iframe.
2014-12-04 07:35:17 -08:00
Isaac Salier-Hellendag 6b46e80bb9 Use getSelection in IE where available
IE9+ has support for window.getSelection, but we’re still using
document.selection for IE9/10. Only use the old IE selection API if the
modern one is unavailable.
2014-12-03 14:03:26 -08:00
Árni Hermann Reynisson fdffec73c3 Use String.charAt for character by index lookup
Using object property accessor for string character lookup breaks in
non-modern browsers.
2014-12-03 14:49:55 +00:00
Paul O’Shannessy bd6b10887a Remove unused require from ReactDOM-test
This happened internally in a codemod
2014-12-02 14:39:19 -08:00
Árni Hermann Reynisson a352b94f57 Give context aware message if markup reuse fails
The context is an extra message with comparison of where server and
client markup started to differ.
2014-12-01 10:15:07 +00:00
Jim d42b285b0c Monitoring code use of cloneWithProps 2014-11-26 16:29:09 -08:00
Paul O’Shannessy 45a19a290c Merge pull request #2553 from mhuggins/headers-attribute
Permit th `headers` attribute
2014-11-26 11:15:21 -08:00
Paul O’Shannessy c48b877253 Merge pull request #2596 from sebmarkbage/rce
reactComponentExpect expects itself
2014-11-26 11:10:00 -08:00
Jim 90d75ab099 Warn if context values differ, related to issue #2112 2014-11-25 16:44:09 -08:00
Jim 3a8fb5fc1e Merge pull request #2597 from jsfb/render-into-document
Replaced document.createElement with ReactTestUtil
2014-11-25 15:35:26 -08:00
Paul O’Shannessy b7b74b7efe Fix lint warnings, style fixups
Followup work for recent PRs
2014-11-25 15:06:30 -08:00
Jim 89fafad255 Replaced document.createElement with ReactTestUtils.renderIntoDocument where container was not subsequently utilized.
Fixes #1250
2014-11-25 12:06:22 -08:00
Sebastian Markbage a530f1c379 reactComponentExpect expects itself
This was a bug when reactComponentExpectInternal was separated from
the normal reactComponentExpect flow.
2014-11-24 18:48:41 -08:00
Sebastian Markbåge 47e18c3ce6 Merge pull request #2593 from sebmarkbage/mountImage
Add additional field for ART reconciler
2014-11-24 17:08:13 -08:00
Sebastian Markbage 61349eb5a6 Add additional field for ART reconciler
ART, just like MultiChild adds an expando property to manage it's diffing
state. This is ugly and bad. We should be moving this state outside the
component for use by the diffing algorithm. This state is not needed by
components nested in composites, and varies by diffing algorithm.

It sucks that I have to add it to every component just to support ART,
but that's the quickest solution, other than disabling preventExtensions.

At least now we know that it sucks.
2014-11-24 17:02:11 -08:00
Jim 9f7901fe1d Use warning module for context warning instead of invoking console.warn and monitorCodeUse directly. Depends on https://phabricator.fb.com/D1695279 2014-11-24 13:24:56 -08:00
Ben Alpert 582bc932e5 Merge pull request #2583 from spicyj/style-example
Add example for how to use `style` properly
2014-11-21 14:27:32 -08:00
Ben Alpert 1c5443175c Add example for how to use `style` properly
Test Plan: jest
2014-11-21 12:10:59 -08:00
Ben Alpert c6ed9df7f3 Merge pull request #2582 from spicyj/rendercomponent
Finish renaming renderComponent -> render
2014-11-21 11:54:36 -08:00
Ben Alpert d4e32a7b2c Finish renaming renderComponent -> render
Test Plan: jest
2014-11-20 23:07:58 -08:00
Ben Alpert c4b9b938cf Update variable name and doc type to be accurate
Test Plan: Crossed fingers.
2014-11-20 23:03:03 -08:00
Sebastian Markbåge 68ba3b6d18 Merge pull request #2567 from sebmarkbage/childrenreconciler
Separate Child Reconciliation Step from Diffing
2014-11-20 11:48:54 -08:00
Sebastian Markbage 26ea341870 Separate Child Reconciliation Step from Diffing
This separates the reconciliation step of children into a separate module.
This is the first step towards prerendering.

The stateful instances are reconciled and put into a "rendered children"
set. Updates creates a new of these sets. These two sets are then diffed
to create insert/move/remove operations on the set.

The next step is to move the ReactChildReconciler step to before the
native DOM component. That way it's possible to rely on child
reconciliation without relying on diffing.
2014-11-20 11:45:02 -08:00
Jim 7768d91363 Removed context paremeter to renderToString/renderToStaticMarkup. 2014-11-19 15:16:23 -08:00
yungsters fc7cf2ff63 Replace `mountDepth` with `isTopLevel`
Summary:
After #2570, `mountDepth` is only used to enforce that `setProps` and `replaceProps` is only invoked on the top-level component. This replaces `mountDepth` with a simpler `isTopLevel` boolean set by `ReactMount` which reduces the surface area of the internal API and removes the need to thread `mountDepth` throughout React core.

Reviewers: @sebmarkbage @zpao

Test Plan:
Ran unit tests successfully:

```
npm run jest
```
2014-11-19 13:13:08 -08:00
yungsters c7fd626b1f Summary:
Currently, `ReactUpdates` updates dirty components in increasing order of mount depth. However, mount depth is only relative to the component passed into `React.render`. This breaks down for components that invoke `React.render` as an implementation detail because the child components will be updated before the parent component.

This fixes the problem by using the order in which components are mounted (instead of their depth). The mount order transcends component trees (rooted at `React.render` calls).

Reviewers: @sebmarkbage @zpao

Test Plan:
Ran unit tests successfully:

```
npm run jest
```
2014-11-19 12:51:55 -08:00
Sebastian Markbage 13ed0317fa Remove some invariants and deadcode
These are not necessary if we enable type checks. Static or dynamic.

They're distracting my greppability.

Also, some dead code in shallow rendering.
2014-11-18 13:04:56 -08:00
Timothy Yung df87ea1fa6 Merge pull request #2465 from yungsters/perf
Preserve Implicit Method Names
2014-11-18 12:51:08 -08:00
yungsters bda199de04 Preserve Implicit Method Names
Summary:
Changes the way we instrument methods for `ReactPerf` so that developer tools can assign implicit method names to measured functions.

Reviewers: @zpao @sebmarkbage
2014-11-18 12:48:58 -08:00
yungsters 8e15046283 Stop Mutating Merged Lifecycle Results
Summary:
Currently, `ReactClass` mutates values returned by `getDefaultProps`, `getInitialState`, and `getChildContext`. This is bad because the objects may, for example, be cached and re-used across instances of a React component.

This changes `ReactClass` to instead create a new object. In return for allocating a new object, I've replaced `mapObject` with a `for ... in` so that we are no longer allocating an unused object.

Fair trade, IMO.

Test Plan:
Ran unit tests successfully:

```
npm run jest
```

Conflicts:
	src/core/ReactCompositeComponent.js

Conflicts:
	src/class/ReactClass.js
2014-11-18 10:00:22 -08:00
Matt Huggins 9a472ca8f1 Permit th attribute 2014-11-18 07:52:25 -07:00
Sebastian Markbåge e3e0bf5de2 Merge pull request #2550 from sebmarkbage/cleanupinternals
Move ComponentEnvironment out of ReactComponent
2014-11-17 17:41:32 -08:00
Sebastian Markbage 5951a131db Move ComponentEnvironment out of ReactComponent
We currently have three DOM specific hooks that get injected. I move those
out to ReactComponentEnvironment. The idea is to eventually remove this
injection as the reconciler gets refactored.

There is also a BackendIDOperation which is specific to the DOM component
itself so I move this injection to be more specific to the DOMComponent.

E.g. it makes sense for it to be injectable for cross-worker DOM operations
but it doesn't make sense for ART components.
2014-11-17 17:21:41 -08:00
Jim 46bff98a3f Fixed 'imports' to resolve merge conflict 2014-11-17 17:14:00 -08:00
Jim 081feeb2dd Added warning if owner-based and parent-based contexts differ. 2014-11-17 17:02:20 -08:00