Commit Graph

345 Commits

Author SHA1 Message Date
Sebastian Markbage
27669c09ca Move flattenChildren into MultiChild 2013-10-07 15:06:44 -07:00
Tim Yung
0c59c57d66 Speed Key Validation (by over 9000)
Use a valid identifier (and non-string) to reduce chance of de-optimizing in V8 and Nitro.
2013-10-07 15:05:56 -07:00
Christopher Chedeau
26d7c4275a Add warning when using componentShouldUpdate 2013-10-07 15:05:44 -07:00
Josh Duck
2b7a7599bb Add select event plugin
Polyfill 'onSelect' behavior for React.

Use non-standard 'selectionchange' event rather than 'select' event.
This allows us to fire the event when user moves the cursor via arrow
keys, and not just when they select multiple chars.

Add methods to ReactDOMSelection to make getting current selection
easier, so we can do a fast check for change without having to
calculate char offsets for selection start and end.
2013-10-07 15:02:57 -07:00
Sebastian Markbage
ed9c0ca87c Expose bound function, context and arguments
Exposes the bound context, original method and bound arguments for any
auto-bound methods, for debugging purposes.
2013-10-07 15:02:47 -07:00
Sebastian Markbage
68abbacc39 Expose the rendered children before they're actually mounted
Exposing the _renderedChildren property before all the children are fully
mounted. This allows us to debug a partially mounted tree when the debugger
has a breakpoint in the one of the mounting children.

This only has a functional difference in the case where mounting throws. This
will end up not mounting the component anyway. Any remounting shouldn't be
affected by this change.
2013-10-07 15:02:27 -07:00
Ben Newman
0a02b55d95 Use nodeContains where appropriate. 2013-10-01 17:55:13 -07:00
Tim Yung
20af6a7ce8 Speed Owner Access (by over 9000)
Use a valid identifier (and non-string) to reduce chance of de-optimizing in V8 and Nitro.
2013-10-01 16:32:06 -07:00
Ben Newman
7c0f5c3237 Fix isEventSupported in recent versions of jsdom.
Setting the `eventName` attribute of an element to the empty string is not
enough to cause `typeof element[eventName] === 'function'` in jsdom. The
attribute value actually has to look like a function body.
2013-10-01 16:31:46 -07:00
Paul O'Shannessy
f43449d333 ReactNativeComponent -> ReactDOMComponent
In an effort to break the DOMy parts of React away from the non-DOMy parts, I'm renaming this.
2013-10-01 16:31:32 -07:00
Ben Newman
e66287f92e Copy the nodeContains module from static_upstream. 2013-10-01 19:18:09 -04:00
Paul O’Shannessy
f20626f17a Merge pull request #378 from spicyj/html-reconciliation
Fix reconciling when switching to/from innerHTML
2013-10-01 13:38:08 -07:00
Andrew Zich
ab00f8d15c Removed "ajaxify" from DefaultDOMPropertyConfig
The `"ajaxify"` attribute is Facebook-specific and does not belong in this repo.
2013-10-01 13:34:26 -07:00
Pete Hunt
58de758a32 Sort batched updates by owner depth
If we reconcile components higher in the hierarchy they will likely reconcile components lower in the
hierarchy. If we sort by depth then when we reach those components there will be no more pending state or
props and it will no op.
2013-10-01 13:33:12 -07:00
Paul O’Shannessy
15c1358aaf Merge pull request #386 from chenglou/unitless-line-height
add line-height to unitless css props, test cases
2013-10-01 10:35:21 -07:00
Cheng Lou
27ee9c6eb0 add line-height to unitless css props, test cases 2013-09-30 13:56:56 -04:00
Ben Alpert
3ca507d73f Fix reconciling when switching to/from innerHTML
There's no way that this can work if _updateDOMChildren doesn't know about dangerouslySetInnerHTML, so tell it.

Fixes #377.
2013-09-27 16:22:46 -07:00
Ben Alpert
94d2bbb221 Fix lint errors including use of global 2013-09-26 16:55:26 -07:00
Pete Hunt
84dea7e971 Fix server rendering 2013-09-26 15:49:19 -07:00
Daniel Miladinov
b0ae800d64 Change spec policy for getDefaultProps to SpecPolicy.DEFINE_MANY_MERGED
This will allow multiple mixins for a component to define
getDefaultProps and their values will be merged.

See also:
https://groups.google.com/d/msg/reactjs/UzSiXw2Vo5s/FxK7AHWOzLMJ
2013-09-25 23:52:29 -04:00
Pete Hunt
fc73bf0a0a ReactLink: two-way binding for React
This introduces `ReactLink` which is a super lightweight way to do two-way binding for React.

If you want to use a controlled form input today, it's a lot of lines of code:

http://jsfiddle.net/T3z3v/

Look how many times `name` is repeated in there. And you have to remember to wire up event handles and pass the right state and
right event handler for *each* form field. It's really annoying.

With ReactLink, you can "link" a form value to a state field. It's just some simple sugar around the value prop/onChange
convention:

https://gist.github.com/petehunt/6689857

Ah, much nicer! And requires very little core changes or extra bytes. `ReactLink` just wraps the current value and "request
change" handler into a little object and provides some sugar to create some from composite component state.
2013-09-24 12:14:25 -07:00
Marshall Roch
458836abd3 Fix use of 'window' in CompositionEventPlugin
access to `window` needs to be guarded by `ExecutionEnvironment.canUseDOM`.
2013-09-23 23:01:14 -07:00
Josh Duck
5d7633d74c Move composition event to plugin with polyfill
Move compositionstart/compositionend to a new event plugin.

Add a polyfill that listens to key and mouse events and uses selection to
determine which text has changed.
2013-09-23 16:27:01 -07:00
Josh Duck
8f15eea910 Add ReactDOMSelection module
Add a DOM based selection module. This can both be used on its own and
in ReactInputSelection where our current implementation is lacking.

There is still some inconsistency with how IE and modern browsers
handle block nodes. Should be OK if we are just getting and setting
and not trying to set selection based on character offsets.
2013-09-23 16:23:35 -07:00
Pete Hunt
832d9de037 Rename unmountAndReleaseReactRootNode() -> unmountComponentAtNode()
This is just a better name; we may revisit the name later.
2013-09-19 14:46:49 -07:00
Josh Duck
578863881f Add composition events to React.
Composition events make it possible to detect IME entry/exit.
https://developer.mozilla.org/en-US/docs/Web/API/CompositionEvent
2013-09-19 14:30:21 -07:00
Ben Newman
adda400602 Make constant propagation smarter about pruning if statements. 2013-09-18 13:33:45 -04:00
Pete Hunt
a9d53dae72 Merge pull request #351 from spicyj/api-docs
Flesh out reference documentation, more API info
2013-09-17 16:12:16 -07:00
Tim Yung
ea0cde2cf4 Fix PropTypes Documentation 2013-09-17 16:09:23 -07:00
Sebastian Markbage
e5ba82a44b Fix DOM node warning
bdf2a9bb12 broke the warning that children aren't suppose to be real DOM nodes.
2013-09-17 16:04:44 -07:00
Ben Alpert
364d6029b6 Flesh out reference documentation, more API info 2013-09-17 16:01:57 -07:00
Josh Duck
ed7fa0ed22 Stop ReactInputSelection breaking in IE8
In the IE code path the method assumed that the input.value property
was non-null. A quick fix is to use either value or innerText; which means
the same code can be shared for textarea and contentEditable components.

The code is slightly buggy because the range.parentElement() !== input check
will fail for contentEditable components when the focus within a deep DOM tree.
2013-09-14 06:18:03 -07:00
Tim Yung
3e4302e6ae Fix lint errors in tests 2013-09-14 06:17:50 -07:00
Josh Duck
1a38cb9e07 Ensure selection range exists
The selection object doesn't always have ranges. In Chrome the
selection is not updated before 'focus' event handlers are fired. See
http://jsfiddle.net/t4DYA/ for example.

The selection will have rangeCount of 0 and calling getRangeAt(0) will
throw error "Uncaught IndexSizeError: Index or size was negative, or greater
than the allowed value."
2013-09-14 06:16:15 -07:00
Paul O’Shannessy
8a7c977942 Merge pull request #338 from spicyj/fullpage-tests
Fix ReactRenderDocument tests
2013-09-11 16:54:48 -07:00
Paul O’Shannessy
63bacfacfd Merge pull request #339 from spicyj/doc-rendering
Fix full-page rendering
2013-09-11 16:54:31 -07:00
Paul O’Shannessy
7ff11c3c88 Merge pull request #332 from spicyj/radio-test
Fix radio input test in Chrome
2013-09-11 13:45:47 -07:00
Paul O’Shannessy
5ab68d9a0d Hard code version instead of doing constant replacement
This isn't really ideal, but it makes it so that people managing to
build with @providesModule still get a consistent experience (since this
is what gets packed client-side with react-page-middleware anyway).
2013-09-11 09:51:43 -07:00
Ben Alpert
58fae896fe Fix full-page rendering
Closes #337.

Test Plan:
Opened react-page sample without any JS errors. Also ran grunt test after cherry-picking this changeset on top of #338.
2013-09-11 01:26:49 -07:00
Ben Alpert
fea4fec0bc Fix ReactRenderDocument tests
I am unsure how this was ever supposed to work, as testDocument is guaranteed to be undefined at that point since beforeEach doesn't run synchronously. (I don't think there's any way to have beforeEach halt the tests.)
2013-09-10 22:42:05 -07:00
Paul O’Shannessy
d853bbcf77 Merge pull request #205 from spicyj/version
Add React.version
2013-09-10 18:35:12 -07:00
Paul O’Shannessy
f82f2a0fe2 Merge pull request #274 from chenglou/textarea-patch
fix textarea `value` of number 0
2013-09-10 18:01:33 -07:00
Paul O’Shannessy
6d77ad4be3 Merge pull request #330 from spicyj/warn-class-for
Warn for 'class' and 'for' property names
2013-09-10 16:21:33 -07:00
Jeff Morrison
7a6a508066 Merge pull request #328 from zpao/no-transform-class
Stop transforming class -> className
2013-09-10 08:23:08 -07:00
Cheng Lou
cd019871e3 Fix input/textarea value of number 0 and false
Previously, setting textarea `value` to number 0 is treated as if `value` wasn't set at all (thus the textarea is cleared from 0 to '' upon `onChange`). `false` also renders as `"false"` instead of `""` for both `defaultValue` and `value`, on textarea _and_ input.
2013-09-10 10:40:53 -04:00
Ben Alpert
3bbd966a82 Fix radio input test in Chrome
It seems like the `form="pluto"` was throwing it off and making the input live outside the form it should have been contained in, causing it to uncheck A. I added it intending to test the form attribute but ended up not needing it so removing it should be fine. (The tests were passing in phantomjs since it doesn't support the `form` attribute and simply ignored it.)

Test Plan:
grunt test; grunt test --debug
2013-09-09 23:38:05 -07:00
Isaac Salier-Hellendag
5388d70bb1 Add cut, copy, paste
Add clipboard events to React.

For forms, these shouldn't really be necessary -- the onChange event should handle deletions and insertions. For contenteditables, however, we need to be able to access clipboard data.
2013-09-09 23:33:05 -07:00
Ben Alpert
5fd4467bf7 Add React.version
getConfig needs to be a function because grunt.config.data.pkg.version isn't available at the time that grunt/config/jsx/jsx.js is required.

Test Plan:
grunt build, grunt lint, grunt test all work. After building, both react.js and react.min.js contain the version number.
2013-09-09 17:01:06 -07:00
Timothy Yung
aa765e8fa3 Merge pull request #287 from spicyj/noglobal
Remove all uses of ExecutionEnvironment.global
2013-09-09 16:23:20 -07:00
Ben Alpert
232b61044c Warn for 'class' and 'for' property names
Also stroke-linecap, stroke-width, stop-color, stop-opacity.

Test Plan:
grunt test
2013-09-09 15:59:42 -07:00