Commit Graph

579 Commits

Author SHA1 Message Date
Ben Newman c7d6a5ae4d Merge pull request #237 from yungsters/master
Fix Test Failures
2013-07-28 07:02:17 -07:00
yungsters d5e970b93f Fix Danger test failures.
The original tests were flawed because the `Danger` module exploits the fact that all React-generated markup has at least one attribute. This allows the module to extract node names from markup strings faster.

However, the tests were passing in strings of markup with no attributes.

Also, this fixes a test failure due to the test trying to set text content into a `<tr>` which is typically disallowed by browsers (and PhantomJS). This changes it to use `<td>` instead.
2013-07-28 01:05:13 -07:00
yungsters 4cb49f5561 Change ReactMultiChild test to check for innerHTML descriptor.
Not all testing environments will support setting the `innerHTML` descriptor. For example, PhantomJS initializes the `innerHTML` property as not configurable.
2013-07-28 01:04:24 -07:00
Paul O’Shannessy c347b720a9 Updated Readme for 0.4.1 2013-07-26 15:57:37 -07:00
Paul O’Shannessy 27a1729f6d Blog post for v0.4.1 2013-07-26 15:56:52 -07:00
Paul O’Shannessy a1f5c1dee7 Updated Changelog for 0.4.1 2013-07-26 15:56:22 -07:00
Paul O’Shannessy 20179b7991 Send branch info from travis for continuous builds 2013-07-26 14:28:33 -07:00
Tim Yung adffa9b0f4 Batch Child Markup Generation
Setting `innerHTML` is slow: http://jsperf.com/react-child-creation/2

This reduces the number of times we set `innerHTML` by batching markup generation in a component tree.

As usual, I cleaned up the `ReactMultiChild` module significantly.

== Children Reconciliation ==

When a `ReactNativeComponent` reconciles, it compares currently rendered children, `prevChildren`, with the new children, `nextChildren`. It figures out the shortest series of updates required to render `nextChildren` where each update is one of:

 - Create nodes for a new child and insert it at an index.
 - Update an existing node and, if necessary, move it to an index.
 - Remove an existing node.

This serializable series of updates is sent to `ReactDOMIDOperations` where the actions are actually acted on.

== Problem ==

There are two problems:

 # When a `ReactNativeComponent` renders new children, it sets `innerHTML` once for each contiguous set of children.
 # Each `ReactNativeComponent` renders its children in isolation, so two components that both render new children will do so separately.

For example, consider the following update:

  React.renderComponent(<div><p><span /></p><p><span /></p></div>, ...);
  React.renderComponent(<div><p><img /><span /><img /></p><p><img /><span /><img /></p></div>, ...);

This will trigger setting `innerHTML` four times.

== Solution ==

Instead of enqueuing the series of updates per component, this diff changes `ReactMultiChild` to enqueue updates per component tree (which works by counting recursive calls to `updateChildren`). Once all updates in the tree are accounted for, we render all markup using a single `innerHTML` set.
2013-07-26 12:48:07 -07:00
Tim Yung 2e37f65bdc Delete throwIf
Deletes `throwIf()` in favor of having one way to throw errors: `invariant()`
2013-07-26 12:48:07 -07:00
Paul O'Shannessy 2e43de20cc Cleanup 2nd param to ReactEventEmitter.ensureListening
It was removed, so these callsites aren't actually doing anything.
2013-07-26 12:25:03 -07:00
Paul O’Shannessy a41aa76ef3 Merge pull request #224 from spicyj/cb-context
Call callbacks from setState in component context
2013-07-25 09:04:17 -07:00
Tim Yung bdf2a9bb12 Use invariant in react/utils
Just some therapeutic cleanup.
2013-07-24 17:41:54 -07:00
Tim Yung 8d48610b7e Typecheck ImmutableObject
Just some therapeutic cleanup.
2013-07-24 17:41:37 -07:00
Tim Yung 759425fc90 Use invariant in OrderedMap
Just some therapeutic cleanup.
2013-07-24 17:41:22 -07:00
Jordan Walke 2ee66262db Remove circular dependencies in React Core.
There is a circular dependency between `ReactID`, `ReactMount` and
`ReactInstanceHandles`. Ben and I talked about this today. It seems like the
simplest solution is to consolidate a lot of the code that Ben recently wrote
into `ReactMount`. We can later find ways to trim code out of this module
without causing circular deps.
2013-07-24 17:40:57 -07:00
Pete Hunt 260d90ba02 Warn when server-rendered markup is not what we expect on the client
As @leebyron and balpert pointed out, if the markup on the server is differnet than what the client expects undefined behavior and chaos may ensue. A good fallback
is for us to just inject the client-side markup (as it is the source of truth) and warn the user in __DEV__ that something is wrong. In order to do a fast
browser-independent check of the DOM I use an adler32 checksum of the generated markup. I believe this is better than a simple innerHTML compare because different
browsers massage innerHTML differently.
2013-07-24 17:39:59 -07:00
Jordan Walke 492407bcc9 Fix OrderedMap.
Tim caught a bug. Squashing it so he can rebase on top of it.
2013-07-24 17:39:37 -07:00
Paul O’Shannessy ddb0ef98f7 Fix "Suppport" type in docs 2013-07-24 13:13:27 -07:00
Paul O’Shannessy 8dd4428c55 Merge pull request #217 from jakubmal/non-browser-env
Allow to execute JSXTransformer outside of browser environment
2013-07-23 17:29:14 -07:00
Jakub Malinowski 795a84d60f Do not export load in JSXTransformer unless in a browser environment 2013-07-23 23:01:38 +02:00
Jakub Malinowski 947e17154a Merge remote branch 'upstream/master' into non-browser-env 2013-07-23 22:31:48 +02:00
Cheng Lou 7f8b2885d9 fix jquery-bootstrap example bugs
Old one had some bugs:
- 'x' on modal wasn't showing.
- trying to close modal in unmount, but modal had a closing animation.
2013-07-23 11:01:42 -07:00
Paul O’Shannessy d1c5cda93f Use the right home page for react-source gem 2013-07-23 10:55:41 -07:00
Vjeux 975b5d978f Community Round-up #5
http://fooo.fr:4000/react/blog/2013/07/20/community-roundup-5.html
2013-07-23 09:23:50 -07:00
Ben Alpert f1231e60b0 Call callbacks from setState in component context
This is way more useful than the alternative.
2013-07-22 23:47:07 -05:00
Tim Yung 4deb0d619c Fix Clicks in Mobile Safari
This works around a bug with listening to clicks using event delegation on Mobile Safari using an event plugin.

NOTE: We don't enable touch events by default, so I don't know if would want to inject this plugin by default. In fact, I'm not sure what our strategy is at all for when to invoke `React.useTouchEvents(true)`.
2013-07-22 18:31:33 -07:00
Tim Yung cf3ff07f92 Fix TypeError in SyntheticEvent
I suspect that plugins are modifying `Object.prototype` which is causing TypeErrors in `SyntheticEvent`. Let's fix it.
2013-07-22 18:31:08 -07:00
Paul O’Shannessy bbb4a367be Run grunt build with npm test so that we can upload all files 2013-07-22 18:16:44 -07:00
Paul O’Shannessy 63d6cc013e Push builds from travis to remote host 2013-07-22 18:07:43 -07:00
Paul O'Shannessy d1d2d8d463 Don't set DOM attributes to "undefined" on update
We already skip `null` and `undefined` when building up the stringified html on first render, but if you update a component to the *exact same* conditions, React will leave the DOM in a different state. We shouldn't do that.
2013-07-22 10:28:21 -07:00
Jordan Walke 74cfc9c274 Remove unused dependency on ReactMount
We don't really use these, and this will make our lives easier.
2013-07-22 10:28:12 -07:00
Ben Newman add809be21 Add comment explaining internalGetID 2013-07-22 10:28:09 -07:00
Paul O’Shannessy 579d86f024 Merge pull request #218 from chenglou/patch-2
upgrade example to 0.4
2013-07-20 16:33:05 -07:00
Cheng Lou 73ceb5a401 upgrade example to 0.4
manually tested
2013-07-20 16:05:25 -04:00
Jakub Malinowski 2b9dd04f4d Allow to execute JSXTransformer outside of browser environment 2013-07-20 15:10:36 +02:00
Paul O’Shannessy 4f53fbf1a2 Merge pull request #216 from phleet/patch-1
Docs Typo Fix: s/pased/passed
2013-07-19 16:47:44 -07:00
Cheng Lou 64d72f8c4b fix typos 2013-07-19 16:40:09 -07:00
Jamie Wong 50a00662cf s/pased/passed 2013-07-19 18:48:46 -04:00
Paul O’Shannessy d7fcbe0f96 Merge pull request #213 from benjamn/remove-stray-nodes-after-each-test
After each test, remove any stray nodes added to the document
2013-07-19 11:26:50 -07:00
Ben Newman 0441d4c7f5 Rename removeSiblings to removeNextSiblings. 2013-07-19 14:18:44 -04:00
Paul O’Shannessy d9aa2bd12c Merge pull request #212 from spicyj/docfix
One-character typo fix
2013-07-19 11:02:40 -07:00
Ben Alpert 222faf4544 One-character typo fix 2013-07-19 10:55:31 -07:00
Ben Newman 36fbd8d941 After each test, remove any stray nodes added to the document.
This was not necessary when we were running each test in its own
`<iframe>`, and it doesn't seem to affect any test behavior currently, but
it seems wise for the sake of test isolation and hygiene.
2013-07-19 13:53:15 -04:00
Paul O’Shannessy 547079763e Merge pull request #211 from phleet/patch-1
Docs Typo Fix: s/distinciton/distinction
2013-07-19 10:36:25 -07:00
Paul O’Shannessy a7dfe04406 Merge pull request #210 from benjamn/rewrite-Function.prototype.bind-polyfill
Pull in my rewritten Function.prototype.bind polyfill from upstream
2013-07-19 10:23:17 -07:00
Jamie Wong bf275a9097 Docs Typo Fix: s/distinciton/distinction 2013-07-19 12:33:54 -04:00
Ben Newman 507e58ed96 Pull in my rewritten Function.prototype.bind polyfill from upstream.
We don't sync upstream polyfills (because we don't have a story for how
they would be used), so this needs to be updated manually.

Sacrificed some negligible performance optimizations to reduce the number
of different cases from four to one.

It's important to test this implementation in PhantomJS, since that's the
only browser that I know of where built-in functions sometimes do not have
a `.prototype`.
2013-07-19 12:28:44 -04:00
Paul O’Shannessy d9c0be408b Merge pull request #209 from benjamn/speed-up-tests
Abandon <iframe> test isolation hack now that dumpCache works
2013-07-19 09:10:52 -07:00
Ben Newman 5beb481145 Abandon <iframe> test isolation hack now that we have dumpCache.
This cuts the running time of `grunt phantom:run` from 4.4s to 3.1s on my
machine, because we no longer have to load/execute a separate instance of
`react-test.js` in a separate `<iframe>` for each test.
2013-07-19 11:10:02 -04:00
Ben Newman 7ef5172d80 Don't call require("mock-modules").register("test/all", ...).
The "test/all" module will never be mocked, nor should it ever need to be
reset by `dumpCache`.
2013-07-19 11:10:02 -04:00