Commit Graph

427 Commits

Author SHA1 Message Date
petehunt 4fccaa514b @vjeux comments 2013-07-14 17:07:57 -07:00
petehunt 13ad0c500b antipatterns 2013-07-14 17:07:57 -07:00
petehunt 126a7f5c11 more jsx handholding 2013-07-14 17:07:57 -07:00
petehunt bb3bd76fe9 Reorg docs, write a lot of content, import a lot of stuff from dex 2013-07-14 17:07:57 -07:00
petehunt 4bbdcdb0b8 another comment 2013-07-14 17:07:57 -07:00
petehunt d294a7f30f more scaling up 2013-07-14 17:07:57 -07:00
petehunt de8d0e35a2 more state machiens 2013-07-14 17:07:57 -07:00
petehunt faa84b5b85 further improvements 2013-07-14 17:07:57 -07:00
petehunt e1e5f17b27 link to blog 2013-07-14 17:07:57 -07:00
petehunt 0e63000b5c even better toc 2013-07-14 17:07:57 -07:00
petehunt 151997b1e1 Start on section 04 2013-07-14 17:07:57 -07:00
petehunt a36bcd33c6 more toc 2013-07-14 17:07:57 -07:00
petehunt 9194fea915 Add table of contents info 2013-07-14 17:07:57 -07:00
petehunt 67d9891926 add seconds 02.1 and 03 2013-07-14 17:07:56 -07:00
petehunt 05341fb3b3 Add more jsx docs rather than linking 2013-07-14 17:07:56 -07:00
petehunt c82afd7e54 Some style changes 2013-07-14 17:07:56 -07:00
petehunt ed98f2ca57 Make less facebooky 2013-07-14 17:07:56 -07:00
petehunt 462e450bb3 First two sections of newdocs 2013-07-14 17:07:56 -07:00
Paul O'Shannessy 06e5fcc010 "use strict" for ReactDoNotBindDeprecated 2013-07-12 15:42:46 -07:00
Paul O'Shannessy ac84652e50 Cleanup console.* uses
* Stop doing `global.console && ...`
* Make sure all uses are behind `__DEV__` checks so they get stripped out
2013-07-12 15:42:25 -07:00
Tim Yung eee3980749 Stringify value in ReactDOMInput / ChangeEventPlugin
This fixes two bugs related to string-casting in React:

 # Setting `<input value={0} />` would use an empty `value` because `0` is falsey.
 # Using `onChange` and `setState` with non-strings could lead to an infinite loop.

The latter is possible with controlled inputs when:

 - User changes input value.
 - `onpropertychange` fires.
 - `ChangeEventPlugin` dispatches `onChange`.
 - A handler responds via `this.setState` with a non-string value (e.g. a number).
 - The input re-renders and re-sets `value`.
 - The new `value` is not a string, but the current `value` (read from the element) is cast to a string automatically by the browser.
 - This triggers another `onpropertychange`.
 - `ChangeEventPlugin` dispatches another `onChange`.
 - ...
2013-07-12 15:40:55 -07:00
Paul O'Shannessy cf83fbe397 Remove references to React.autoBind
Cleaned up a comment and removed a useless test.
2013-07-11 23:07:01 -07:00
Paul O’Shannessy e221ff7cd4 Add exports to globals for jshint
This is a bit unfortunate, but it'll shut lint up for the time being. We
can't just change the modules to use `module.exports = { ... }` due to
how we handle circular dependencies internally (`ReactMount` require
`ReactID` and vice versa).
2013-07-11 17:20:21 -07:00
Paul O’Shannessy 607de16d82 New blog post: Props in v0.4 2013-07-11 15:52:29 -07:00
Paul O'Shannessy d762627312 Rename props to propTypes
This does two things:

 - Rename `props` to `propTypes`.
 - Rename `ReactProps` to `ReactPropTypes` (and `React.Props` to `React.PropTypes`)
2013-07-10 15:06:18 -07:00
Tim Yung 10dab495f2 Stop Unnecessary Purging of Node Cache
When each component unmounts, it already cleans up its respective entry in the node cache. Let's stop blowing away the entire node cache unnecessarily.

This should improve performance because a React component's root will never need to be searched for more than once.
2013-07-10 15:05:18 -07:00
Tim Yung ee1335b6a2 Delete setTextNodeValueAtIndexByParentID
This does not appear to be used anywhere.
2013-07-10 15:05:06 -07:00
Tim Yung 8687645c50 Reduce Lookup for Missing Lifecycle Methods
This is a micro-optimization that reduces the lookup time for missing lifecycle methods. The extra amount of memory is linear to the number of components that exist on a page which I think is a worthwile trade-off.
2013-07-10 15:04:44 -07:00
Tim Yung 7b68fcd408 Short-circuit updatePropertyByID
When `ReactNativeComponent` updates, it calls `updatePropertyByID` in `ReactDOMIDOperations` which calls `DOMPropertyOperations`. However, in `ReactDOMIDOperations`, we will lookup the node for an ID using `ReactID.getNode`. This wastes time looking for nodes when we may not need to ever update it (e.g. `children`).

This changes `ReactNativeComponent` to bail out sooner.
2013-07-10 15:04:23 -07:00
Pete Hunt 92dab0759c More autobind warnings and invariants
This adds two new warnings and one new invariant:

- Warn when using React.autoBind() that it is deprecated.
- Throw when calling bind() on an autobound method with the wrong value of "this". Today we'll silently ignore the provided value, which is confusing.
- Warn when calling bind() on an autobound method with the *right* value of "this" and no other arguments. This is already done for you by React.
2013-07-10 15:03:50 -07:00
Ben Newman 5c6e59f53c Don't ignore children of non-ancestor ID nodes in findComponentRoot. 2013-07-10 14:58:57 -07:00
Tim Yung 067fe27699 Fix Clowny Validation Code
ಠ_ಠ
2013-07-10 14:58:47 -07:00
Paul O’Shannessy 8db2ba9130 Upgrade other dependencies
Nothing groundbreaking. `semver` was likely already installed at 2.0.x
anyway (since >=) and `grunt-contrib-jshint` just gives us `jshint`
@ 2.1.3
2013-07-09 10:55:56 -07:00
Paul O’Shannessy 1500e9810c Upgrade browserify.
There are other changes I'm sure but the most important is that module
sorting results in deterministic builds.

The biggest win here comes for releases. Previously we had to jump
through hoops to make sure the files we put in bower were the same files
we put on the CDN, were the same files packaged in the Ruby gem, were
the same files we packaged into a zip file, were the same file we used
when create PRs to CDNJS. Rebuilding docs also resulted in conflicting
versions so we had to be careful when committing. This takes away all of
that pain. We can build from the same revision and get the same files.
2013-07-09 09:20:57 -07:00
Paul O’Shannessy a3b21b10e4 Merge pull request #178 from paulshen/master
Add __benchmarks__ to .gitignore
2013-07-08 18:27:39 -07:00
Paul Shen fa03e98426 Add __benchmarks__ to .gitignore 2013-07-08 16:40:21 -07:00
Paul O'Shannessy 203dba271b Add some missing attributes
Mostly this was to better support some HTML5 stuff. This was not a complete pass through though, and we should probably add more.
2013-07-08 13:58:42 -07:00
Paul O’Shannessy 91562ba934 Sync JSX tags from upstream
This is the other part of fc5f7e0e85. This
file isn't part of our sync process so needs to be done separately.
2013-07-08 12:51:11 -07:00
Paul O'Shannessy fc5f7e0e85 Add support for missing html elements
We're missing a bunch of elements. So I scraped them from https://developer.mozilla.org/en-US/docs/Web/HTML/Element. Here's the script I used (run from Firefox scratchpad):

```
Array.prototype.slice.call(document.querySelectorAll('div.index.widgeted li'))
  .filter(function(li) {
    return !/deprecatedElement|obsoleteElement|nonStdElement/.test(li.firstChild.className)
  })
  .map(function(li) {
    // <tag> -> tag
    return li.querySelector('code').textContent.replace(/<(.+)>/,'$1');
  })
  .join(': false,\n  ');
```

I had to filter a couple more out (because there's some malformed content), but then it was simply merge with what we had and check to see if the new ones needed to omit the close tag.
2013-07-08 11:51:47 -07:00
Ben Newman a4123a069e Continue over ID-less children in ReactMount.findComponentRoot.
This fixes our perf test by coping with edge cases like the
injection of `<tbody>` between `<table>` and `<tr>` nodes, which occurs
automatically in some browsers when we set `.innerHTML`.

Introducing more search branches would be risky if not for my previous
commit that made `findComponentRoot` breadth-first instead of depth-first.
2013-07-08 11:50:55 -07:00
Ben Newman a5ddb07cb3 Make ReactMount.findComponentRoot breadth-first & non-recursive.
This function needs to be as fast as possible for those cases when
`ReactID.getNode` can't rely on the `nodeCache`.

Breadth-first search prevents us from diving too deeply down the wrong
branches when the sought-after node can be found at a shallower level.

The queue required for breadth-first search is implemented by a single
array indexed by `childIndex`. To save space, only the `.firstChild` nodes
are stored, and we use `.nextSibling` to iterate over the other siblings
in a `while` loop.
2013-07-08 11:50:34 -07:00
Ben Newman 917e101c2c Try harder to find container in ReactMount.findReactContainerForID.
When we render a new component into a container, we now record a reference to the rendered DOM node as `rootElementsByReactRootID[reactRootID]`, so that we can determine the actual container later on, in case `containersByReactRootID[reactRootID]` is no longer the true container.
2013-07-08 11:50:13 -07:00
Pete Hunt 5c624021ea Tweaks to make the Closure parser happy
This doesn't make it actually run with Closure, but passes its parser.
2013-07-08 11:50:02 -07:00
Pete Hunt 5676a486cf Allow nested ReactUpdates 2013-07-08 11:49:42 -07:00
Pete Hunt 1658feade8 Remove the check for console.warn
We already polyfill this at FB and we should recommend https://github.com/paulmillr/console-polyfill for open source.
2013-07-08 11:49:28 -07:00
Pete Hunt 5f1eceb1ee Merge pull request #176 from andreypopp/master
Add datetime to the list of known DOM attributes
2013-07-08 00:44:33 -07:00
Andrey Popp fc3491e0d0 dateTime attr: camelCase and MUST_USE_ATTRIBUTE 2013-07-08 11:23:43 +04:00
Andrey Popp 9f94244994 add datetime to the list of known attributes
as per http://www.whatwg.org/specs/web-apps/current-work/multipage/text-level-semantics.html#attr-time-datetime
2013-07-08 00:09:38 +04:00
Pete Hunt 6ebdd0cfd2 Merge pull request #173 from chenglou/patch-4
Emphasis on single child.
2013-07-06 23:20:20 -07:00
Cheng Lou 858377946f Emphasis on single child. 2013-07-06 16:10:34 -04:00