Compare commits

..

817 Commits

Author SHA1 Message Date
Paul O’Shannessy
f3db0006e8 Update everything for v0.5.1 2013-10-29 11:46:46 -07:00
Paul O’Shannessy
ef4d7a37f0 npm shrinkwrap
We should be doing this in the stable branch to ensure fuzzy
dependencies are met identically on subsequent releases.

In this case, browserify had a change in 2.34.3 which resulted in
JSXTransformer to be a different size. While it was a change for the
better, it was unexpected and not a change we were calling out in the
release.

This shrinkwraps to the same versions of packages we had when we shipped
0.5.0.
2013-10-29 11:46:46 -07:00
Laurence Rowe
64016811d3 Make 'disabled' MUST_USE_ATTRIBUTE for compatibility with CSS [disabled] selectors.
When a ReactDOMComponent is created with the property `disabled: true` subsequently setting the property to `disabled: false` the HTML attribute `disabled="true"` was being left in the DOM.
2013-10-29 10:16:04 -07:00
Andrey Popp
7b957c880c Fix unmounting components mounted into doc element
If we are to unmount a component mounted into a document element we should
unmount it from document.documentElement and not from document.firstChild which
is a doctype element in this specific case.
2013-10-29 10:16:04 -07:00
Ian Obermiller
1b835fb5cf Fix ReactTransitionEvents detectEvents 2013-10-29 10:16:04 -07:00
Cat Chen
9f0bbce797 fixed %d in invariant call 2013-10-29 10:16:04 -07:00
Josh Duck
c9d20e56d3 Don't reset mouseDown in focus handlers
Focus fires after mouse down on initial click, so we lost the
flag when the user initially began dragging on the input.
2013-10-29 10:16:04 -07:00
Ben Alpert
ce612904ef Make SelectEventPlugin not throw for range inputs
Accessing .selectionStart on a non-text input will throw (see http://www.w3.org/TR/2009/WD-html5-20090423/editing.html#textFieldSelection), so check that the input has selection capabilities before accessing the property.

Fixes #437.
2013-10-29 10:16:04 -07:00
Paul O’Shannessy
ea1ab5501d Update API docs for unmountAndReleaseReactRootNode 2013-10-26 17:45:03 -07:00
Brian Rue
2c35ed8068 ReactTransitionGroup example: fix typo and logic bug in handleRemove 2013-10-25 18:25:14 -07:00
Keito Uchiyama
c994cc24c3 docs: Delete Mutation Events (onCharacterDOMModified) 2013-10-25 18:24:37 -07:00
Paul O’Shannessy
24da1c0023 docs: remove OUTLINE 2013-10-21 15:20:46 -07:00
Cheng Lou
d82181e4b9 Add clickable anchors to docs headers
Closes #434
2013-10-21 14:38:57 -07:00
Paul O’Shannessy
ba166b9652 Fix live editor examples on home page.
Remember that one time I wrote release notes and said:

> This is a breaking change - if you were using class, you must change
> this to className or your components will be visually broken.

Good thing I didn't listen to myself!
2013-10-16 18:11:10 -07:00
Paul O’Shannessy
f756cb3d9c 0.5.0 release
Updated README, CHANGELOG, blog post
2013-10-16 11:44:37 -07:00
Paul O’Shannessy
cadf8b786c Fix grunt npm:test 2013-10-16 11:44:37 -07:00
Paul O’Shannessy
953947a617 bump version for 0.5 2013-10-15 22:32:20 -07:00
Paul O’Shannessy
d8c949e4d8 Update browserify 2013-10-15 21:27:26 -07:00
JeffMo
243a2b816e bump baseline jstransform and esprima dependency versions 2013-10-15 18:54:01 -07:00
Paul O’Shannessy
451176665c Update docs with supported tags and attributes 2013-10-15 18:15:24 -07:00
Paul O’Shannessy
cff62f8d72 Enable linting for bitwise operators 2013-10-15 18:02:28 -07:00
Paul O'Shannessy
3f2ba221ef Use getActiveElement module
We had something that did the same sort of protection. The module
differs slightly (returns document.body instead of undefined) but
looking at the callers, that should be ok.
2013-10-15 18:00:05 -07:00
Paul O'Shannessy
46713c3d7d Fix Lint
Enabling bitwise linting caught another user. Also fixed a semicolon
misuse.
2013-10-15 17:59:14 -07:00
Paul O’Shannessy
b015204938 Updated AUTHORS for 0.5
closes #414
2013-10-15 15:01:14 -07:00
petehunt
24f6bed855 new addons docs
closes #403
2013-10-15 14:09:21 -07:00
Paul O’Shannessy
5325e944e9 Merge pull request #426 from SanderSpies/sspi-fix-jsx-doc-link
In-browser JSX warning linked to wrong anchor (should be lowercase)
2013-10-15 12:04:59 -07:00
Paul O’Shannessy
b488cb3d4b Merge branch 'SanderSpies-sspi-dom-attribute-process' 2013-10-15 12:00:52 -07:00
Paul O’Shannessy
087c2afed1 Make sure DOM components work in JSDOM 2013-10-15 11:38:26 -07:00
Paul O’Shannessy
b0645bd5d3 Be consistent with object naming in tests
This also fixes line length issues our linter was complaining about.
2013-10-15 11:38:26 -07:00
SanderSpies
5a13dd090d Standardize prop -> DOM attribute process
Allow more than strings and numbers to be used as attributes for DOM
nodes. This removes the special casing for `0` and `false` that was
being used in ReactDOMInput and ReactDOMTextarea.

Now we will just `toString` any object we try to insert into a DOM.

Closes #422, #372, #302
2013-10-15 11:38:25 -07:00
Paul O'Shannessy
b0455f4670 Ensure attribute values are strings
`jsdom` behavers differently than browsers here and we should ensure
that we are consistent. Browsers should be (and are) converting to
a string first, while `jsdom` doesn't.
2013-10-15 10:39:51 -07:00
Tim Yung
287f5b578c Add bitwise lint escape to DefaultDOMPropertyConfig 2013-10-15 10:38:31 -07:00
SanderSpies
6839704c4b #JSX => #jsx 2013-10-15 19:11:19 +02:00
Martin Konicek
5332422239 [docs] Fix a broken link to JSX syntax in README. 2013-10-14 17:10:26 -07:00
Ben Alpert
7909c3e71b Forcibly wrap SVG nodes with <svg> on creation
Forcing wrapping seems necessary here: I compared a <circle> created within a <div> with a <circle> created inside an <svg> and they appear to have exactly the same properties with the exception of .parentNode (and .parentElement), yet the former refuses to show up when appended to an <svg> element. As such, I can't find any useful way to write a unit test (testing getMarkupWrap's output doesn't seem particularly useful to me).

Fixes #311.

Test Plan:
With a component that adds a <circle> after mounting (such as http://jsfiddle.net/spicyj/hxFVe/), verify that the circle appears in both Chrome and IE9.
2013-10-14 13:44:36 -07:00
Paul O’Shannessy
b45c82c256 Merge pull request #419 from piranha/svg-attrs
svg properties -> attributes

Fixes #190
2013-10-14 11:24:36 -07:00
Alexander Solovyov
3a5a82fd18 DefaultDOMPropertyConfig: sort properties alphabetically 2013-10-14 20:45:00 +03:00
Josh Duck
1238f5f23a Remove DOM mutation listeners
Mutation listeners are known to be slow. Rough benchmarks show text
changes are now 50% faster.
2013-10-11 17:33:47 -07:00
Owen Coutts
ac9f5e9da4 Better click behavior for ff
Firefox created onClick events for right mouse clicks. This diff brings behavior on firefox inline with other browsers.
2013-10-11 15:42:22 -07:00
Josh Duck
58c392ae3b Check for null selection
getRangeAt(0) will throw on null selection. Add guard in
ReactDOMSelection and DocumentSelection.
2013-10-11 12:52:19 -07:00
Alexander Solovyov
aa38ffc22d svg attributes properly cased when assigned by react 2013-10-11 15:48:17 +03:00
Alexander Solovyov
6d300527c8 svg: rx/ry for rounded corners 2013-10-11 13:42:10 +03:00
Alexander Solovyov
a601c5cc81 svg properties -> attributes 2013-10-11 13:32:22 +03:00
Alexander Solovyov
4549fd7510 fix namesToPlugins for gcc advanced mode 2013-10-09 22:08:03 +03:00
Keito Uchiyama
ef60eee57a Make transferPropsTo() message easier to debug
Summary:
Made the transferPropsTo() error introduced in
325322898c easier to use to debug.
2013-10-09 11:28:35 -07:00
Sebastian Markbage
7a9c13dee8 Set _renderedComponent before it's fully mounted
For debugging so that we can inspect the currently rendering tree. I think this
should be safe and makes sense since it tried to mount.
2013-10-09 11:28:22 -07:00
Tim Yung
d652dd928a Add displayName for DOM Components 2013-10-09 11:28:12 -07:00
Jan Kassens
c99d6a8013 Make the injection of ReactPerf work
The injection was only evaluated when ReactCompositeComponent was first loaded.
This made it impossible to inject a custom measure and the injection pointless.
2013-10-09 11:27:40 -07:00
Ben Newman
f8c5752472 Merge pull request #374 from spicyj/workers
Test that React loads properly in a web worker.

Most of this code is open source-only, so I think it's safe to merge without figuring out how to translate it upstream first.
2013-10-09 08:50:41 -07:00
Paul O’Shannessy
44352a2861 Merge pull request #370 from zpao/addons
react-with-addons build
2013-10-08 16:54:31 -07:00
Paul O’Shannessy
7da874d835 Add TransitionGroup example 2013-10-08 16:49:11 -07:00
Paul O’Shannessy
de9e94de5f Make sure react-with-addons ends up in react-source gem 2013-10-08 16:49:11 -07:00
Paul O’Shannessy
a151133161 Make sure react-with-addons ends up in bower 2013-10-08 16:49:11 -07:00
Paul O’Shannessy
042a2723ff Make sure addons builds are sent to build server 2013-10-08 16:49:11 -07:00
Paul O’Shannessy
2e6092b217 react-with-addons build
This creates a new standalone build which should have everything the
default build has, plus a little extra. This is not a sustainable long
term solution (we shouldn't make people choose like this) but it fixes
the problem we have in the short term.

This also removes the terrible react-transitions build. This is better
anway.

Fixes #369
2013-10-08 16:49:11 -07:00
Ben Alpert
f658c32df1 Tweak verbiage about required polyfills
I found it weird how the es5-shim comment came after the list of functions; now it's before.
2013-10-08 16:25:29 -07:00
Paul O’Shannessy
b16874c5a8 Merge pull request #407 from Samangan/master
renamed ReactOnDOMReady module to ReactMountReady
2013-10-08 15:12:29 -07:00
Connor McSheffrey
b9a657db2c fixed broken link on Community Round-up #9 blog post
closes #409
2013-10-08 11:09:33 -07:00
Josh Duck
dbc613199b Fix SelectEventPlugin
There were 2 issues:

I was reusing event outside the original event handler (activeNativeEvent).
This is a bad idea. I've changed deferred dispatch to have an empty object
as the nativeEvent.

I didn't handle inputs without .selectionStart (e.g. file inputs). I extracted
a input type check from ChangeEventPlugin and reuse it here.
2013-10-08 10:28:43 -07:00
Paul O’Shannessy
920c4206f4 Sync getActiveElement module from FB. 2013-10-07 15:32:47 -07:00
Paul O’Shannessy
fdb10c0679 React.__internals
We need access to internal modules in order to provide a single way for some
projects to work internally with @providesModule and externally.
2013-10-07 15:07:20 -07:00
Pete Hunt
325322898c Throw when calling transferPropsTo() on a component you don't own
This is dangerous because it means that data is flowing into the component from two components, only one of which is the actual "owner". While we may be able to figure out how to
support this someday, let's be strict and prevent it for now.
2013-10-07 15:07:04 -07:00
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
Samangan
84d8e1841a renamed ReactOnDOMReady module to ReactMountReady
fix

renamed ReactOnDOMReady module to ReactMountReady
2013-10-05 01:35:56 -05:00
Vjeux
a9b3139ff8 Community round-up #9
http://fooo.fr:4000/react/blog/2013/10/03/community-roundup-9.html
2013-10-03 15:18:21 -07:00
Vjeux
582b720183 Add app id for comments moderation
This way we can be notified when any new comment appear in the docs/blog and add moderators
2013-10-03 22:32:20 +02: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
8beaa211fb Merge pull request #387 from spicyj/exec-fix
Actually make exec work
2013-10-01 13:14:56 -07:00
Paul O’Shannessy
7c217324a6 Merge pull request #384 from chenglou/doc-link
Add doc link to DOM differences from JSX gotchas
2013-10-01 11:25:34 -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
Ben Alpert
0a45325621 Actually make exec work
The spec for eval (http://es5.github.io/x15.1.html#x15.1.2.1) says "If Type(x) is not String, return x." and that's exactly what's happening here -- it gets {code: ...} and does nothing.
2013-09-30 18:51:39 -07:00
Cheng Lou
607eeaed4b Add doc link to DOM differences from JSX gotchas 2013-09-30 20:46:41 -04:00
Paul O’Shannessy
c764adc256 Merge pull request #376 from spicyj/noglobal
Fix lint errors including use of `global`
2013-09-30 14:21:12 -07:00
Cheng Lou
27ee9c6eb0 add line-height to unitless css props, test cases 2013-09-30 13:56:56 -04:00
Pete Hunt
8835e9d99f Update README.md 2013-09-28 19:57:18 -07: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
3dc1074908 Test that React loads properly in a web worker
This should catch top-level uses of `window` and `document`, while lint rules catch `global`.
2013-09-27 14:38:11 -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
Pete Hunt
781bbe2916 Merge pull request #375 from danielmiladinov/master
Change spec policy for getDefaultProps to SpecPolicy.DEFINE_MANY_MERGED
2013-09-26 13:45:34 -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
Paul O’Shannessy
848a8e1180 Remove animation "example"
It was never a real example and shouldn't have been checked in.
2013-09-25 11:08:24 -07:00
Paul O’Shannessy
fc0b68af28 Fix 404s to non-existent API docs 2013-09-24 16:00:52 -07:00
Paul O’Shannessy
c6f831e85f Redirect docs/reference.html 2013-09-24 15:47:17 -07:00
Vjeux
58173edb16 Community round-up #8 2013-09-24 14:18:11 -07: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
Paul O’Shannessy
d27746ee0b Docs: Give headers ids for easy linking
This gives markdown headers an id so that we can link directly to
sections of our docs. This is better than the alternative of adding them
all ourselves.
2013-09-23 10:30:51 -07:00
Keito Uchiyama
d13ce702a8 Fix typo in doc 2013-09-22 15:09:36 -07:00
Keito Uchiyama
d262285827 Fix use of "it's" in docs 2013-09-22 13:24:25 -07:00
Jeff Morrison
b5a11a431e Merge pull request #336 from spicyj/jsx-spacing
JSX: Respect original spacing and newlines better
2013-09-20 10:59:21 -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
Paul O’Shannessy
8875e1dc3b Merge pull request #359 from SanderSpies/master
Give the user a warning when using unoptimized JSX code
2013-09-19 13:14:12 -07:00
SanderSpies
cd79ed32cb - removed creation of the id within the tooling integration doc (expect this to be done by @zpao's pull request)
- removed the if statement and now always provide a warning message (as proposed by @spicyj)
- improved the warning message
2013-09-19 06:48:38 +02:00
SanderSpies
1924b7c945 Correcting the markdown anchor 2013-09-19 00:58:37 +02:00
SanderSpies
d2bf50c63d Give the user a warning when using unoptimized JSX code and send the user to the correct location in the documentation to optimize. 2013-09-19 00:55:10 +02:00
Ben Newman
b1dd4149a0 Merge pull request #343 from benjamn/fix-if-statement-pruning
Make constant propagation smarter about pruning if statements
2013-09-18 11:10:56 -07:00
Paul O’Shannessy
208ebd35b7 Don't update the docs version by default
This was leading to a lot of unnecessary churn in the config file since
different YAML versions were serializing differently.
2013-09-18 10:40:12 -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
Pete Hunt
735223fc9f Merge pull request #356 from yungsters/master
Add link to third-party `JavaScript (JSX).tmLanguage` in docs.
2013-09-17 13:35:59 -07:00
yungsters
be9ac236fd Add link to third-party JavaScript (JSX).tmLanguage in docs. 2013-09-17 13:30:53 -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
71ad5cb37a Update wording 2013-09-14 13:48:17 +02: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
c8ec4595bb Merge pull request #344 from benjamn/fix-silent-test-failure-due-to-requiring-React
Use a regular expression to parse out React.version
2013-09-11 16:03:59 -07:00
Ben Newman
133ea3df09 Use a regular expression to parse out React.version.
This fixes a silent failure of the test suite that appears to be due to
the call require('./build/modules/React').
2013-09-11 18:41:56 -04:00
Paul O’Shannessy
f729a28f3c Delete version.js
This file is an artifact of a build process long abandoned.
2013-09-11 14:20:26 -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
Ben Alpert
f69112cb3f JSX: Respect original spacing and newlines better
Fixes #335.

Now this JSX:

```
/** @jsx React.DOM */
var HelloMessage = React.createClass({
  render: function() {
    return <div>
      Look!
      <a href=
        "http://www.facebook.com/">Facebook
      </a>
    </div>;
  }
});
```

produces

```
/** @jsx React.DOM */
var HelloMessage = React.createClass({displayName: 'HelloMessage',
  render: function() {
    return React.DOM.div(null,
      " Look! ",
      React.DOM.a( {href:
        "http://www.facebook.com/"}, "Facebook "
      )
    );
  }
});
```

rather than the less-desirable

```
/** @jsx React.DOM */
var HelloMessage = React.createClass({displayName: 'HelloMessage',
  render: function() {
    return React.DOM.div(null,
" Look! ",      React.DOM.a( {href:"http://www.facebook.com/"}, "Facebook "      ),
    );
  }
});
```
2013-09-10 17:14:36 -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
Paul O’Shannessy
63b58cf6b5 AUTHORS
Created a .mailmap file with all of the associations, then used
git + perl to create the AUTHORS file. In theory these should all get
picked up by npm.

I used ABC order so it would remain unbiased and automatable. I wish we
could go back and fill out the history or at least fix the commits we
have from CommitSyncScript, but oh well.

This also includes the script I used to automate this process in the
future.
2013-09-09 23:42:54 -07: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
Ben Alpert
426cdbb3ae Remove all uses of ExecutionEnvironment.global
Closes #271.

All three of these files are DOM-specific so it should be fine to use window. (ReactEventTopLevelCallback isn't obviously DOM-specific but it calls getEventTarget which is so I think we're fine here.)

Test Plan:
grunt test, tried events in a real browser and they seemed to work still.
2013-09-09 15:51:06 -07:00
Paul O’Shannessy
d83fe785c5 Stop transforming class -> className
Update the broken examples too (`git grep class=`)
2013-09-09 15:37:43 -07:00
Ben Newman
888cc309e0 Stop using comments as boundary markers in dangerouslyRenderMarkup.
Jordan warned (and StackOverflow confirmed) that IE8 doesn't respect HTML
comment nodes when setting `.innerHTML`:
http://stackoverflow.com/questions/15006001/inserting-a-comment-in-innerhtml

The virtue of the comment strategy was that the parser did all the work of
maintaining the boundaries between markup chunks, using comments as the
boundary markers.  The new strategy (of tagging the first node with a
special attribute) has a similar virtue, since the parser should preserve
that attribute only for the nodes we care about, and any rendered nodes
that do not have the attribute can be ignored (and complained about by
`console.error`).
2013-09-09 14:59:55 -07:00
Paul O'Shannessy
4ed7b85ed8 Log unknown props only when we have a match
Logging every unknown property got very noisy when combined with use of `transferPropsTo`. I knew this would be a potential issue initially but decided it was worth it. Others disagreed and it's resulting in some confusion.

This changes the logging to ensure that we have a potential correction, so only DOMish properties should result in warnings.
2013-09-09 14:57:56 -07:00
Pete Hunt
647731e399 Supporting mounting into iframes
Sencha says that separating big components into their own iframes was important for performance:
http://www.sencha.com/blog/the-making-of-fastbook-an-html5-love-story.

Today the only thing stopping us is that events don't bubble to our events system from an iframe. This diff
looks at the owning document of the container and adds top-level listeners to it. It should not change
existing behavior and should improve our support for this.
2013-09-09 14:57:33 -07:00
Ben Newman
cd7d863f20 Avoid unnecessary array allocations in dangerouslyRenderMarkup. 2013-09-09 14:56:27 -07:00
Paul O'Shannessy
9d0f3623c3 Cache length of NodeList when updating radios 2013-09-09 11:53:13 -07:00
Pete Hunt
e010a2d90b Fix bugs with CSS3 animation event in webkit
We were incorrectly sniffing the animationend event.
2013-09-09 11:52:59 -07:00
Paul O’Shannessy
d704bc24f4 Initial build of ReactTransitionGroup
This builds `ReactTransitionGroup` with it's own copy of `React`, which
it total clownshoes. This should be technically usable, but definitely
should not be used in any production environment.
2013-09-07 16:18:14 -07:00
Paul O’Shannessy
ff2fc586d5 Merge pull request #324 from chenglou/backbone-todo-ex
Fix backbone todo example bugs.
2013-09-07 14:53:01 -07:00
Cheng Lou
78d305eb16 Fix backbone todo example bugs.
Fixed:
- New todo not submitting correctly (page refreshes. `preventDefault`
wasn't there.
- Old checked todo being removed will leave the checkmark on the next
todo replacing its position.
- Cannot change todo (`value`'s now a controlled field).
- `autofocus` (should be `autoFocus`, how ironic given the current
situation) on new todo input isn't working. Switched to manual
`focus()` in `componentDidMount` for now.
- More consistent breathing space between lines.
- Gutter at 80.

Added:
- Use todomvc-common base.css. The old one had to change ids to
classes. No longer necessary.
- Give `cx` a better name and move it in `Utils`.
- Trim input upon finishing edit.
- Remove todo if the new edited value is empty.
- Submit edited todo value on input blur.
- README to explain the existence of this example. Being able to
maintain a non-compilant version allows nice deviations from the
todomvc specs, such as animations, in the future.
2013-09-07 17:44:05 -04:00
Paul O’Shannessy
6b5c1810c0 Merge pull request #323 from benjamn/simplify-bin/jsx
Simplify bin/jsx to perform just the JSX transform
2013-09-07 14:41:55 -07:00
Paul O’Shannessy
e41912d6d4 Merge pull request #325 from spicyj/elseifdev
Move else if (__DEV__) into two statements
2013-09-07 14:08:03 -07:00
Ben Alpert
97e0926696 Move else if (__DEV__) into two statements
The minification stage doesn't like `else if (__DEV__)`.
2013-09-07 14:03:48 -07:00
Paul O’Shannessy
8df407deb8 Merge pull request #281 from spicyj/radio
Fix controlled radio button behavior
2013-09-07 13:54:57 -07:00
Paul O’Shannessy
2ba405d5f8 Merge pull request #267 from spicyj/warn-props
Warn about unknown property values
2013-09-07 13:06:41 -07:00
Ben Newman
658f41cb30 Simplify bin/jsx to perform just the JSX transform.
We will continue using `bin/jsx-internal`, well, internally.

Note that this version no longer respects `@providesModule`, and it
doesn't do anything special with constants like `__DEV__`, so we can no
longer get to claim that `bin/jsx` can be used to build the core.

I'm happy about this, personally, because it demonstrates the flexibility
of Commoner.
2013-09-06 16:20:25 -04:00
Ben Newman
ebc0d09595 Merge pull request #322 from petehunt/build-animations
Add ReactTransitionGroup to the build
2013-09-06 10:49:30 -07:00
petehunt
f7ea031dac Add ReactTransitionGroup to the build 2013-09-06 10:47:18 -07:00
Ben Alpert
b56b5885d0 Fix controlled radio button behavior
Fixes #242.
2013-09-06 00:57:51 -07:00
Ben Alpert
a4c23d328c Warn about unknown property values
Fixes #255.
2013-09-06 00:33:01 -07:00
Paul O'Shannessy
3cf14e8f9b Remove ReactChildren methods from React object
These are not terribly useful on this object and the naming of
`React.forEachChildren` sucked anyway.
2013-09-05 18:35:59 -07:00
Pete Hunt
c8886a0424 Make mounting on the root of the page work correctly
This was apparently only partially supported. We had issues initially mounting if there was no HTML present and
also had issues if we had to update HTML that was already there. This diff fixes all of these cases and has
tests to prove it. NOTE: I removed a test that was actually erroneous. My bad.
2013-09-05 13:50:18 -07:00
Paul O’Shannessy
4f0dea3e7e Merge pull request #294 from clayallsopp/better_update_msg
More helpful message if you update an unrendered component
2013-09-05 11:54:07 -07:00
Clay Allsopp
9dd8ef4777 fix formatting and test for correct error 2013-09-04 18:13:33 -07:00
Paul O’Shannessy
65c4ef91c7 Sync CSSCore from upstream 2013-09-04 16:47:16 -07:00
Pete Hunt
32d3d7774a Use dumpCache() rather than manual reset
I forgot this module existed until @benjamn reminded we had a way to do it.
2013-09-04 15:54:27 -07:00
Pete Hunt
8664c8ac57 Test cases covering rendering onto document
There were some bug reports here, I couldn't reproduce but wrote tests anyway. We should definitely have these.
2013-09-04 15:54:11 -07:00
Ben Newman
dea0cc01cf Improve error behavior of Danger.dangerouslyRenderMarkup.
HTML comment nodes are now interspersed in the original markup list so
that we can tell which chunks of markup rendered as more or less than one
node, and give a more helpful error message in that case.

Regardless of how many nodes were rendered, we only take the first one. If
zero nodes were rendered, then `resultList` will contain `null` at the
corresponding position.

If we decide to revisit the idea of using document fragments, it will be
very easy to handle the `!== 1` case by returning a document fragment.
2013-09-04 15:54:09 -07:00
Pete Hunt
80f1590265 Add ReactTransitionGroup
This introduces <ReactTransitionGroup>, a component that works a lot
like Angular's ng-animate.

The problem we're currently facing is twofold:
1. We don't really have a great convention surrounding CSS transitions
   in React
2. (harder) we can't animate nodes that are leaving the DOM, as their
   nodes are instantly destroyed.

To solve the first issue I've adopted Angular's convention. It's
implemented in ReactTransitionableChild.

The second part is what's tricky. To do this I've implemented three modules:
- ReactTransitionableChild, which can keep its old children around if they
  change to null
- ReactTransitionKeySet, which can look at a prev and next set of child
  keys and merge them in a reasonable way
- ReactTransitionGroup, which combines ReactTransitionableChild and
  ReactTransitionKeySet to keep nodes that are leaving the DOM in the
  DOM until their animations are complete
2013-09-04 15:54:06 -07:00
Paul O’Shannessy
c25c5b543b Update wording 2013-09-04 15:26:31 -07:00
Cheng Lou
8852b86ad8 Add Stack Overflow link for doc support page. 2013-09-04 16:01:48 -04:00
Paul O'Shannessy
a42fd30fc2 Remove React.autoBind for real
This has been deprecated for a long while now, we should actually remove it.
2013-09-03 14:27:00 -07:00
Pete Hunt
406dcbd8da Fix a few GC leaks in events system
Summary:
    - Weren't pooling the Transaction in the batching strategy
    - Creating a new closure for every event tick due to batchedUpdates()
    - EnterLeaveEventPlugin creates a new array on each event.

I wonder if there is more optimization opportunity in accumulate(). Squinting at the fps graph this seems to be faster and waste less memory but it's hard to conclusively tell. I did verify that these were all hotspots though.
2013-09-03 14:27:00 -07:00
Paul O’Shannessy
de61f9fd81 Merge pull request #298 from vjeux/pagination
Add pagination to blog
2013-09-03 13:35:12 -07:00
Paul O’Shannessy
57fe412619 Merge pull request #305 from brianr/tutorial-explain-showdown
Tutorial: show how to add showdown.js
2013-09-03 13:33:05 -07:00
Pete Hunt
b4ff29ac78 Merge pull request #312 from zpao/docs-redirect
Redirect /docs to the right page
2013-09-03 13:30:16 -07:00
Paul O’Shannessy
ba460de7ed Redirect /docs to the right page
I've hit this a few times where I want to get to docs so I take whatever
my urlbar gives me and strip out the actual page so I can get to the
root, however that's a 404.

This introduces a super easy way to redirect, which could be handy in
the future as docs get rewritten.

I would much rather do this with a real htaccess file or even just
handle 404s gracefully, but that's not currently an option with GitHub
pages (since we generate our own and don't use a custom domain).
2013-09-03 13:25:23 -07:00
Pete Hunt
c7768fde5d Merge pull request #307 from chenglou/todomvc-director
sync with tastejs todomvc
2013-09-02 10:22:58 -07:00
Clay Allsopp
15f84a391d move lifecycle check into replaceProps instead of updateComponent 2013-09-01 18:42:01 -07:00
Cheng Lou
2b9c34b5c7 sync with tastejs todomvc 2013-08-31 21:54:37 -04:00
Brian Rue
403b087e97 Tutorial: show how to add showdown.js 2013-08-30 16:29:01 -07:00
Sebastian Markbage
75aee1714b Expose the instance cache
We need access to the instance cache for debugging tools. Ideally we want to
expose a more stable and supported interface but this seems like a quick win,
for now.
2013-08-30 13:21:04 -07:00
Pete Hunt
c41e86c990 Make ReactDefaultPerf work server-side
We were reading from window which was throwing when ReactDefaultPerf was injected.
2013-08-30 13:20:53 -07:00
Paul O'Shannessy
4d8f0449d9 React.isValidClass
Sometimes you may need to detect if a value is a valid React class constructor. This enables that and prevents future consumers from getting caught in the trap of depending on an internal implementation detail we might change.

Currently this works for classes created with `React.createClass` as well as `React.DOM.*`.
2013-08-30 13:20:51 -07:00
Pete Hunt
0db4077c3a Make React batching strategy injectable 2013-08-30 13:20:48 -07:00
Tim Yung
f88aa35187 Change vendored module isDOMNode -> isNode 2013-08-30 13:20:45 -07:00
Andrew Zich
7d34c09e17 Don't trigger mouse events on native button elements that are disabled
This adds a `ReactDOMButton` module that shims the native `<button>` React component so it doesn't receive mouseup, mousemove, mousedown, click, or double-click events when its disabled property is truthy.
2013-08-30 13:20:40 -07:00
Paul O’Shannessy
e11c4ecbaf [docs] Small tweaks as reported in comments
* highlight `</form>`
* use correct id in `getElementById` call
2013-08-28 14:42:07 -07:00
Paul O’Shannessy
553ed1416c Update package dependencies
Sometimes I look at https://david-dm.org/facebook/react
2013-08-27 14:46:06 -07:00
Paul O’Shannessy
688f5051e6 Sync objMap from upstream 2013-08-27 14:43:46 -07:00
Pete Hunt
adb666e67f Allow getInitialState() for mixins
Today mixins can't easily be stateful because they can't provide getInitialState(). This allows multiple getInitialState() methods as long as they don't return objects that have conflicting keys. In that case, we throw.
2013-08-27 14:17:26 -07:00
Paul O’Shannessy
07e2072692 Support props for <meta> elements.
`content`, `httpEquiv`, `charSet` are all needed. We're currently
working around this in `react-page`.

`content` is the risky one here since we previously supporting using
`content` to set the text content. We removed support for that in
e998041229 so the risk is minimal, there
just might be some lingering old code.

Fixes #292

Test Plan: Visit `data:text/html,<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" charset="utf-8"></head>`

```
var m = document.querySelector('meta');
m.httpEquiv; // Content-Type
m.httpEquiv = 'foo';
m.httpEquiv; // foo

m.charset; // undefined
m.charSet; // undefined
m.getAttribute('charset'); // utf-8
m.setAttribute('charset', 'bar');
m.getAttribute('charset'); // bar

m.content; // text/html; charset=utf-8
m.content = 'baz';
m.content; // baz
```
2013-08-27 11:45:59 -07:00
Vjeux
1c14cd6c8b Add pagination to blog
- Add pagination
- Display full content in /blog
- Truncate Recent posts
- Add permalink that lists all the blog posts
- Add spacing and bullet around recent posts to make it more readable
2013-08-27 02:14:17 +02:00
Paul O’Shannessy
744b54a829 Fix capitalization of Tooling Integration page 2013-08-26 14:53:56 -07:00
Vjeux
a90c463abe Update the tooling page to include pyReact, react-rails and react-page 2013-08-26 14:49:31 -07:00
Vjeux
6bf21f1610 Community round-up #7
http://fooo.fr:4000/react/blog/2013/08/26/community-roundup-7.html
2013-08-26 14:22:16 -07:00
Ben Alpert
364ee1ffae Add missing "use strict" statement to pass lint
Test Plan:
grunt lint; grunt test
2013-08-26 13:46:11 -07:00
Clay Allsopp
88faef3ba9 Add more helpful invariant if you're updating an unrendered component 2013-08-26 10:42:53 -07:00
Eric Clemmons
bcc6b524fb Add rowSpan DOM property 2013-08-25 13:32:38 -05:00
Sebastian Markbage
61b38b9f05 Explicit and Implicit Keys Need Separate Namespaces
There are certain cases where you can end up with a collision with an implicit
key (array index) if your explicit key prop is a number. They should use
different namespaces. Therefore I wrap explicit keys in curlies and implicit
array indices in brackets.

I added a simple test case, but another case came up on the mailing list. Where
undefined entries in an array actually results in an entry and therefore an
implicit key.
2013-08-23 14:05:18 -07:00
Danny Ben-David
fce57abeca Benchmarking tool for React application performance
ReactAppPerf wraps core methods and logs info from them; there's no real
UI at this point
2013-08-23 14:05:11 -07:00
Paul O’Shannessy
946e9b0c80 Merge pull request #289 from jordwalke/ServerRenderingFixes3
Server rendering: rendering of entire document using React.
2013-08-23 13:14:06 -07:00
Jordan Walke
748ed6cd81 adding better test - moving execution env module. 2013-08-23 12:32:35 -07:00
Jordan Walke
49f174cdad Server rendering: rendering of entire document using React.
Summary: Allows rendering of React into the "document" as opposed to into a
particular node. To recap some basics:

document: One level above the <html> tag - like the browser.
document.documentElement: <body>

To support full-page server side rendering, we need to be able to render
*everything* including the HTML/BODY tags. This allows that.
2013-08-23 02:04:07 -07:00
Paul O’Shannessy
6ca8d31c83 [react-tools] Add src/ to files
This is so it's possible to use the original @providesModule source
files in a toolchain that understands those.
2013-08-22 22:35:50 -07:00
Paul O’Shannessy
aa1fa7468b Merge pull request #280 from jeffmo/jstransform_npm
Move to using `jstransform` and `esprima-fb` npm modules
2013-08-22 15:43:59 -07:00
JeffMo
2d048f1f34 Move to using jstransform and esprima-fb npm modules 2013-08-22 15:28:41 -07:00
Clay Allsopp
3d1cc16a9b Add CDNJS to docs. Fixes #244 2013-08-22 11:07:50 -07:00
Paul O’Shannessy
cbe86e04b3 Docs: fix header 2013-08-22 11:02:09 -07:00
Paul O’Shannessy
a558e560bd Use script to find remaining 404s. Fix them. 2013-08-22 10:59:22 -07:00
Clay Allsopp
cfe4152b1d Fix broken tutorial link and change wording 2013-08-21 22:38:44 -07:00
Kunal Mehta
91c2a8d90b Added PyReact blog post. 2013-08-19 14:48:28 -07:00
Christopher Chedeau
2c8f907b2c Merge pull request #277 from stoyan/patch-1
typo fix
2013-08-19 11:45:51 -07:00
Tim Yung
669f4b867f Allow DOM Nodes in ImmutableObject
Currently, `ImmutableObject` will stack overflow while it tries to recurse and deep freeze all the properties of a DOM node.
2013-08-19 11:37:08 -07:00
Stoyan
5fae286cf4 typo fix 2013-08-19 11:35:46 -07:00
Timothy Yung
a2c90aad86 Merge pull request #275 from spicyj/input-private
Make getChecked, getValue, handleChange private
2013-08-19 11:20:52 -07:00
Ben Alpert
898621d0a1 Make getChecked, getValue, handleChange private
Test Plan: grunt test, enter text in ballmer-peak example without any JS errors.
2013-08-17 22:29:41 -07:00
Timothy Yung
e1c1d869de Merge pull request #251 from spicyj/select-value
Fix behavior of ReactDOMSelect with `defaultValue`
2013-08-17 21:50:13 -07:00
Ben Alpert
25e2cd0db6 Fix behavior of ReactDOMSelect
Closes #250.

Test Plan:
With multiple and not, verified: With defaultValue, the correct option is picked initially, user changes change the selection, and changes to defaultValue have no effect. With value, the correct option is picked initially, user changes do nothing, and changes to value change the selection.

Also ran the tests.
2013-08-17 16:57:49 -07:00
Paul O’Shannessy
1f8ef4c903 Sync modules to vendor/core
We haven't done this recently. Nothing has changed significantly, though
this does remove some files we weren't using.
2013-08-16 15:40:23 -07:00
James Ide
d9511d817a Move utils out of React that aren't being used
Many of React's util functions are non-redundant with Facebook's core
libraries, so move them out of React into a central location (out of
this repo).

These files were not getting used by any part of React core, so didn't
actually belong here anyway.
2013-08-16 15:40:11 -07:00
Cheng Lou
2fda70fb4a fix test case for rendering text node number 0 2013-08-16 13:51:17 -07:00
Sebastian Markbåge
02f618d52c Merge pull request #268 from spicyj/bind-null
Make .bind(null, ...) work on autobound methods
2013-08-16 12:06:49 -07:00
Jordan Walke
61c47e4cae Refactor ReactComponent to have no dependency on the DOM.
React is more than just a DOM app library, it is a component
abstraction library. This enforces that.
2013-08-15 10:56:39 -07:00
Jordan Walke
e6b216bdbb Extract out core ReactEmitter functionality.
Other environments can make use of some of the logic in ReactEventEmitter.
2013-08-15 10:56:30 -07:00
Ben Alpert
192727e152 Make .bind(null, ...) work on autobound methods
Fixes #266.
2013-08-15 09:58:38 -07:00
Paul O’Shannessy
cb00d3e66c Upgrade phantomjs to 1.9.1-4
This fixes the install and permissions issues we've been seeing with
other 1.9.1-x versions.
2013-08-13 15:37:26 -07:00
Paul O’Shannessy
987e5e8f13 Merge pull request #258 from chenglou/patch-3
defaultValue of 0 now displayed
2013-08-12 18:20:32 -07:00
Paul O’Shannessy
df0bc8c3af Merge pull request #261 from benjamn/phantomjs-1.9.0-1
Hold PhantomJS version at 1.9.0-1.
2013-08-12 15:21:50 -07:00
Ben Newman
983120102c Hold PhantomJS version at 1.9.0-1.
And don't attempt any chmod magic, either.
2013-08-12 17:47:31 -04:00
Cheng Lou
86c0b69390 separate new tests into respective file 2013-08-12 17:03:10 -04:00
Cheng Lou
d5989a0de4 tests for displaying defaultValue of 0 2013-08-12 16:08:16 -04:00
Cheng Lou
1b747c526c defaultValue of 0 now displayed
previously treated as empty string when passed to input text/textarea
2013-08-09 23:13:44 -04:00
Paul O'Shannessy
5cbabdf4c9 Support autocapitalize DOM Property
It's non-standard, but potentially useful on mobile.

See some discussion in google group: https://groups.google.com/forum/#!topic/reactjs/MBcCFohHHHA

Closes #247
2013-08-06 14:19:49 -07:00
Paul Shen
9ef4e74ba2 ReactChildren
Instead of changing `traverseAllChildren`, keep that around for perf
reasons (for the hot code path `flattenChildren`)

Introduce `ReactChildren.map` and `ReactChildren.forEach`
which mirrors `Array.prototype.map` and `Array.prototype.forEach`. This
involves a rename of `mapAllChildren`
2013-08-06 14:17:33 -07:00
Vjeux
0321171113 Community Round-up #6 2013-08-06 01:31:23 +02:00
Christopher Chedeau
d542621155 Fix 404 in Getting Started 2013-08-04 21:09:15 -07:00
Pete Hunt
4bbf8acc9b Merge pull request #249 from pcottle/fixLinks
Fix Github links in examples
2013-08-04 17:40:00 -07:00
Peter Cottle
a21556314d Fix Github links in examples
Looks like we link to github.com/facebook/react/ instead of react-js. This just fixes the links

`grep -r "facebook/react.js" .` comes up clean now
2013-08-04 16:40:12 -07:00
Paul O'Shannessy
99d3d7f914 Get rid of remaining ReactID references
It's gone. Also compacted a bit of code to match the other usage.
2013-08-01 13:58:28 -07:00
Paul O’Shannessy
86d9e0a97a Merge pull request #245 from chenglou/patch-3
Change ref from ReactID to ReactInstanceHandles
2013-08-01 13:41:10 -07:00
Cheng Lou
db0ff96200 Change ref from ReactID to ReactInstanceHandles 2013-08-01 14:52:08 -04:00
Tim Yung
808e625d9d Use createNodesFromMarkup
Pulled out markup rendering logic for better reuse.
2013-07-31 21:21:06 -07:00
Paul O’Shannessy
dc06704ec7 react-rails blog post 2013-07-30 15:25:44 -07:00
Tim Yung
5ef3c1b09b Fix Reconciling Components to Content
This fixes a reconciliation bug introduced by adffa9b0f4.

The new unit test case exhibits the bug. When a component that has rendered child components is updated to render inline text, we usually:

 # Unmount and remove all child components.
 # Set the new inline text content.

However, with batched child operations, we do not **remove all child components** until later. The current implementation will set the inline text content and blow away those nodes, causing a fatal when `ReactMultiChild` later tries to find and remove those nodes.

This fixes the bug by ensuring that text content changes are also enqueued.
2013-07-29 16:15:30 -07:00
Paul O’Shannessy
fe451c30f8 Merge pull request #241 from gasi/master
Fix incorrect port of standard Python server
2013-07-29 11:09:37 -07:00
Daniel Gasienica
6f2848f4a6 Fix incorrect port of standard Python server
/ht @zpao
2013-07-29 10:59:43 -07:00
Paul O’Shannessy
d63ce62916 Merge pull request #207 from thisishugo/patch-1
update dead jsx link to point to an extant page
2013-07-29 09:11:37 -07:00
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
Hugo Jobling
4ab62a6bd2 remove dead link
the event handling doc page no longer exists
2013-07-18 11:05:39 +01:00
Hugo Jobling
07427ae9d0 put closing paren in correct place 2013-07-18 10:44:22 +01:00
Hugo Jobling
8f55d94d40 update dead jsx link to point to an extant page
syntax.html no longer exists, so point people at the in depth article instead.
2013-07-18 10:36:54 +01:00
Pete Hunt
e6812d7e36 Add iframe attributes to React
These are pretty useful for building apps and stuff.
2013-07-17 20:39:19 -07:00
Ben Newman
75ce576d3d Avoid some innocuous test warnings.
This reduces some console.warning spew from `grunt test` output.
2013-07-17 20:38:32 -07:00
Ben Newman
fa7cc57a6d Merge pull request #206 from benjamn/getAttribute-instead-of-getAttributeNode
Use getAttribute instead of getAttributeNode in ReactID.rawGetID
2013-07-17 18:24:27 -07:00
Ben Newman
fd2125ee94 Use getAttribute instead of getAttributeNode in ReactID.rawGetID.
Also known as internalGetID, internally.
2013-07-17 21:14:04 -04:00
Paul O’Shannessy
52e622f1db Version bump for 0.5.0 development 2013-07-17 16:45:38 -07:00
Paul O’Shannessy
3d7ac69c39 Merge pull request #203 from spicyj/homepage
Fix all errors and warnings on homepage
2013-07-17 13:32:52 -07:00
Ben Alpert
e379f8ec03 Fix all errors and warnings on homepage
Also onChange instead of onInput in two places!
2013-07-17 13:31:52 -07:00
Paul O’Shannessy
dbdf1cc296 Merge branch 'chenglou-master'
Conflicts:
	docs/_js/examples/markdown.js
2013-07-17 13:30:22 -07:00
Cheng Lou
dd14fdfdc5 todo fix 2013-07-17 16:28:04 -04:00
Cheng Lou
fc6a567e0e jsx 2013-07-17 16:25:25 -04:00
Paul O’Shannessy
96bd63cc4b Fix typo in blogpost
I fixed this in the changelog, but missed this one.
2013-07-17 13:23:18 -07:00
Cheng Lou
169b172ffc textarea format 2013-07-17 16:22:30 -04:00
Paul O’Shannessy
ec67076090 Update readme for 0.4.0 2013-07-17 11:52:29 -07:00
Paul O’Shannessy
9221b15bff Typo in changelog, update blog leading sentence. 2013-07-17 11:51:27 -07:00
Paul O’Shannessy
a54333842f Bump version for v0.4.0 2013-07-17 11:33:31 -07:00
Paul O’Shannessy
0c1f2720b3 Remove React.autoBind from examples 2013-07-17 11:33:31 -07:00
Paul O’Shannessy
75f7f1e9ba remove likebutton from docs for now
it has some facebook-ism in there and it's probably shouldn't be on the
site.
2013-07-17 11:21:33 -07:00
Paul O’Shannessy
09fbf8e0ca Blog post for 0.4 2013-07-17 11:20:21 -07:00
Paul O’Shannessy
d17d0d5f50 Changelog for 0.4.0 2013-07-17 11:19:58 -07:00
Paul O’Shannessy
1a7a8486ca [docs] Make sure JSX comments code is in block 2013-07-17 11:18:17 -07:00
Paul O’Shannessy
65548db916 Re-order entries in changelog
React is more important than react-tools so put it first!
2013-07-17 10:04:27 -07:00
Paul O’Shannessy
894bb03b23 Add CHANGELOG at the root, remove from downloads page 2013-07-17 10:01:16 -07:00
Paul O’Shannessy
94573545f3 [docs] Prop validation + cleanup default props 2013-07-17 09:47:09 -07:00
Paul O’Shannessy
7734429b89 [docs] Remove @benjamn's TODO for testing 2013-07-17 09:12:26 -07:00
Paul O’Shannessy
35f092afef Write Default Props section 2013-07-17 09:12:02 -07:00
Paul O’Shannessy
b837bb7bdd [docs] fix typo
"L" is not ":"
2013-07-17 08:45:27 -07:00
Paul O’Shannessy
c629a0c5ad Revert "Merge pull request #200 from spicyj/version"
This reverts commit d889322827, reversing
changes made to 156dffb961.
2013-07-17 08:26:59 -07:00
Ben Newman
d889322827 Merge pull request #200 from spicyj/version
Add React.version
2013-07-17 06:13:49 -07:00
Paul O’Shannessy
156dffb961 [docs] Fix broken links 2013-07-17 01:37:52 -07:00
Pete Hunt
e5befc0a73 Update DOM differences docs to include a note about the style attribute. 2013-07-17 01:00:01 -07:00
Paul O’Shannessy
e3f6a6d916 Merge pull request #188 from facebook/docs-refactor
Look ma, new docs!
2013-07-17 00:56:07 -07:00
Paul O’Shannessy
58fecc8cbe Merge branch 'master' into docs-refactor 2013-07-17 00:26:05 -07:00
Paul O’Shannessy
b5aad9479e re-bold some text so it stands out better 2013-07-17 00:25:23 -07:00
Paul O’Shannessy
5db3a0e481 Remove React.autoBind from examples 2013-07-16 23:44:09 -07:00
Paul O’Shannessy
0300f2aa22 em dashes 2013-07-16 23:38:15 -07:00
Paul O’Shannessy
17d36a4cc3 Standardized Markdown lists 2013-07-16 23:35:54 -07:00
Paul O’Shannessy
c222f57b00 Cleanup "Reference"
(unlinked likebutton tutorial - not updated enough for public)
2013-07-16 23:31:32 -07:00
Paul O’Shannessy
1b64508aab Cleanup "Tooling Integration" 2013-07-16 23:31:03 -07:00
Paul O’Shannessy
f2b92d4c7b Cleanup "More About Refs" 2013-07-16 23:30:41 -07:00
Paul O’Shannessy
82f82c7543 Cleanup "Working With the Browser" 2013-07-16 23:30:18 -07:00
Paul O’Shannessy
602623661a Cleanup "Forms" 2013-07-16 23:29:39 -07:00
Paul O’Shannessy
ca3564898d Cleanup "Reusable Components" 2013-07-16 23:29:14 -07:00
Paul O’Shannessy
5b662b43a0 Cleanup "Multiple Components" 2013-07-16 23:28:51 -07:00
Paul O’Shannessy
6ba6fc149a Cleanup "Interactivity and Dynamic UIs" 2013-07-16 23:28:25 -07:00
Paul O’Shannessy
5a3a39aba4 Cleanup "JSX Gotchas" 2013-07-16 23:27:36 -07:00
Paul O’Shannessy
b9b300fcbd Cleanup "JSX in Depth" 2013-07-16 23:24:56 -07:00
Paul O’Shannessy
59f52bce04 Cleanup "Displaying Data" 2013-07-16 23:24:22 -07:00
Paul O’Shannessy
8d3465060d Merge remote-tracking branch 'upstream/docs-refactor' into HEAD 2013-07-16 23:23:32 -07:00
Paul O’Shannessy
d0af08190e Merge pull request #199 from chenglou/patch-1
Tweaked the intro page
2013-07-16 23:01:45 -07:00
Cheng Lou
b343fcaba3 grammar error 2013-07-17 00:15:49 -04:00
Cheng Lou
526099c928 changing back to 'give it five minutes', tweak that sentence 2013-07-17 00:12:21 -04:00
Paul O’Shannessy
f0984cf789 Don't hard code React version anywhere 2013-07-16 21:08:10 -07:00
Ben Alpert
7be14d8155 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-07-16 20:38:40 -07:00
Cheng Lou
28f6f034ff Tweaked the intro page
Here are some ideas that I think work better:
- 15 repetitions of "React". Removed a few.
- The "two main ideas" weren't clearly separated. I put them under different headers and simplified the wording.
- The "Give it Five Minutes section didn't sound as reassuring. Made it sound more certain.
2013-07-16 21:39:20 -04:00
Paul O’Shannessy
3be6083ea4 Autogen the docs nav
This is still the same amount of duplication, except way easier to
parse. Docs nav now lives in `_config.yml` and you must restart jekyll
to see changes to that list (since config is only read at jekyll launch)
2013-07-16 17:24:41 -07:00
Paul O’Shannessy
f367d0e707 Remove numbers from URLs.
This will let us keep docs in order on the filesystem but have
reasonable permalinks. If we add something at 02- it doesn't result in
lots of broken links.
2013-07-16 17:09:43 -07:00
Paul O’Shannessy
9694a0f7ea Fix title casing and heading levels 2013-07-16 14:52:57 -07:00
Paul O’Shannessy
04bfa545f7 Remove "Scaling Up" 2013-07-16 13:55:42 -07:00
Ben Newman
1971ae8cac Merge pull request #196 from zpao/fix-test-warnings
Fix tests to silence some warnings due to autobinding
2013-07-16 13:15:35 -07:00
Paul O’Shannessy
fd3d16d379 Fix tests to silence some warnings due to autobinding 2013-07-16 13:08:46 -07:00
Paul O’Shannessy
dfd406fe4c Merge pull request #195 from benjamn/force-upgrade-graceful-fs
Upgrade Commoner and Populist to force upgrade to graceful-fs v2.0.0
2013-07-16 12:53:46 -07:00
Ben Newman
301c571405 Upgrade Commoner and Populist to force upgrade to graceful-fs v2.0.0.
A silent upgrade from graceful-fs v1.2.2 to v1.2.3 (a dependency for both
Commoner and Populist) broke the build process, even though tests were
still passing. The 2.0.0 version fixes whatever was broken, though I won't
pretend to know exactly what the root cause was.
2013-07-16 15:42:17 -04:00
Paul O’Shannessy
3376d27915 Merge pull request #194 from benjamn/build-jasmine-bundle-with-populist
Use populist for building jasmine test harness bundle
2013-07-16 11:51:22 -07:00
Ben Newman
0827646695 Use populist for building jasmine test harness package.
We're using populist for building the bundle of test modules and their
dependencies, so it seems worthwhile for consistency to do the same for
the test harness.
2013-07-16 14:48:31 -04:00
Ben Newman
03578e66b5 Fix rootElementsByReactRootID bookkeeping in ReactMount.js.
It's not always possible to update `rootElementsByReactRootID` when the
contents of the container are re-rendered; for instance, when we call
`dangerouslyReplaceNodeWithMarkup` or `dangerouslySetInnerHTML`. Since
this bookkeeping is just trying to warn about potentially problematic
manipulations of the root element, and we can be relatively sure that a
new element with the same ID is logically the same element, this diff
avoids warning in such cases.
2013-07-16 11:43:43 -07:00
Jan Kassens
71e24455a3 add missing argument to invariant in ReactDOMSelect 2013-07-16 11:38:35 -07:00
Tim Yung
83a840656c Fix Markup Rendering in IE
This fixes known browser bugs with rendering markup using `innerHTML` in IE ([[http://support.microsoft.com/kb/276228 | here is an example of one]]).

This is a subset of what `HTML` (and jQuery) does, and we should eventually consider pulling it out into a separate module to reduce code duplication. For now, this is the minimal set of changes needed to unbreak React in production.

We can afford to use a subset of what `HTML` does because we have the luxury of knowing that the markup is generated sanely with proper closing tags, etc.
2013-07-16 11:37:26 -07:00
Tim Yung
ed54fff204 Controlled <select> and <option> Components
This implements a `<select>` component that supports `value` and `defaultValue`. It also changes `<option>` to warn when the `selected` prop is supplied.
2013-07-16 11:37:04 -07:00
Jordan Walke
5d4f903482 [React Children] Step Three: New test case for traverseChildren.
If we're going to build utilities off of this, we should have good test
coverage.
2013-07-16 11:36:53 -07:00
Jordan Walke
946029c921 [React Children] Step Two: Use traverseChildren to perform mapChildren
Use the new `traverseChildren` utility to perform `mapChildren`.
The goal is to get as close to the bavior of the semantics of
`Array.prototype.map`, but also in a way that understands deeply nested arrays
and objects.
2013-07-16 11:36:11 -07:00
Jordan Walke
f4321f8624 [React Children] Step One: Refactor flattenChildren
Refactoring `flattenChildren` so that the traversal code is reusable
for other purposes.
2013-07-16 11:35:43 -07:00
Paul O’Shannessy
46d05b1191 Sync vendor modules from FB.
Biggest win here is that we'll strip out the console.error from
EventListener and we won't need to suggest people use a console
polyfill with the minified build.
2013-07-15 21:04:43 -07:00
Ben Newman
558e8ca312 Merge pull request #193 from benjamn/use-populist-for-testing
Fix tests
2013-07-15 16:42:57 -07:00
Ben Newman
b763d7d029 Use a separate grunt/config/jsx config file for tests.
No longer injecting __MOCK__ as a global constant (it's just a config
property now).

Turns out the `grunt jsx:debug` task was never necessary for tests.
2013-07-15 19:41:40 -04:00
Ben Newman
2d61639f90 Store dirtyMocks array globally so it can survive dumpCache().
When require("mock-modules").dumpCache() is called, all mock functions
previously created continue to refer to the old dirtyMocks array.

If we replace that array with a new one, those mock functions will never
have their .mockClear() methods called again.

The upstream version of mocks.js pulls a similar global trick, and I never
understood why until now.
2013-07-15 19:41:40 -04:00
Ben Newman
204796868d Enable module.exports mocking in react-test.js.
We don't currently attempt to mock modules automatically, but we do
respect require("mock-modules").mock, .dontMock, and .dumpCache.

I'm going to keep investigating auto-mocking, since that would move us
much closer to the behavior used within Facebook.

Closes #154.
Closes #155.
2013-07-15 19:41:40 -04:00
Ben Newman
37014e1002 Call require("mock-modules").register in every mockable module.
Mocking happens only when config.constants.__MOCK__ is true.
2013-07-15 18:10:49 -04:00
Ben Newman
c6c4657f83 Use populist v0.1.2 to bundle test modules instead of browserify.
This will allow full support for mocking, dumpCache, and correct line
numbers in error messages.
2013-07-15 18:10:49 -04:00
Ben Newman
f457394362 Remove remaining calls to ReactCompositeComponent.autoBind.
This is causing console.warning spew in the open source tests.
2013-07-15 15:09:01 -07:00
Tim Yung
2b97c608f8 Normalize DefaultDOMPropertyConfig
For consistency, use lowerCamelCase for all props in `DefaultDOMPropertyConfig`.
2013-07-15 15:08:46 -07:00
Paul O’Shannessy
15493530f1 Revert "Update LICENSE"
This reverts commit dd1d49b360.

The license is actually supposed to look like that. That section is
boilerplate for others to apply the license to their own work. See
immediately above...

> To apply the Apache License to your work, attach the following
> boilerplate notice, with the fields enclosed by brackets "[]"
> replaced with your own identifying information. (Don't include
> the brackets!)
2013-07-15 10:40:27 -07:00
Pete Hunt
dd1d49b360 Update LICENSE 2013-07-15 00:28:36 -07:00
petehunt
e9e8934577 fix markup bugs 2013-07-14 18:46:50 -07:00
petehunt
2397e35cdd switch to guides 2013-07-14 18:43:33 -07:00
petehunt
0e585d8102 put it all together 2013-07-14 18:42:39 -07:00
petehunt
6009934176 cleanup some files, move tutorial 2013-07-14 18:35:59 -07:00
petehunt
b20c2641d4 move docs around, add likebutton 2013-07-14 18:31:46 -07:00
petehunt
445a0dac37 tweak the source 2013-07-14 18:25:51 -07:00
petehunt
33abe80b59 scaling up fix 2013-07-14 18:00:17 -07:00
petehunt
d7cf1c509b delete old docs 2013-07-14 17:57:39 -07:00
petehunt
7d97f26870 add more examples 2013-07-14 17:52:25 -07:00
petehunt
b2107ba80b update and move tutorial 2013-07-14 17:49:07 -07:00
petehunt
d0c431a2a3 Fix comma 2013-07-14 17:15:28 -07:00
Pete Hunt
ab7ef4ed3b Update 08-working-with-your-environment.md 2013-07-14 17:07:58 -07:00
petehunt
204edb4a27 fix some links 2013-07-14 17:07:57 -07:00
Pete Hunt
3c742d50b6 Update 03-interactivity-and-dynamic-uis.md 2013-07-14 17:07:57 -07:00
Pete Hunt
1c51cc34cd Update 02.1-jsx-in-depth.md 2013-07-14 17:07:57 -07:00
Pete Hunt
64b9b55a0d Update 02.2-jsx-gotchas.md 2013-07-14 17:07:57 -07:00
Pete Hunt
f9741b0728 Update 01-motivation.md 2013-07-14 17:07:57 -07:00
petehunt
3085254a91 reorg 2013-07-14 17:07:57 -07:00
petehunt
0de35588c1 jsx gotchas, reference 2013-07-14 17:07:57 -07:00
petehunt
21ea1ac61e add working with your environment section 2013-07-14 17:07:57 -07:00
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
Ben Newman
826d603b05 Merge pull request #167 from benjamn/issue-166-fix-phantomjs-executability
Ensure that the phantomjs binary has appropriate UNIX mode
2013-07-05 16:18:05 -07:00
Ben Newman
da4b761c45 Don't require tmp module unless we're going to use it. 2013-07-05 19:17:20 -04:00
Ben Newman
70a2f8046c Ensure that the phantomjs binary has appropriate UNIX mode.
The 755 mode corresponds to a UNIX mode string of -rwxr-xr-x.

Closes #166.
2013-07-05 19:06:49 -04:00
Christopher Chedeau
51bf95f6d1 Merge pull request #157 from vjeux/communit_4
Community Round-up #4
2013-07-03 18:32:36 -07:00
Vjeux
2246f530af Community Round-up #4 2013-07-04 03:25:35 +02:00
Paul O’Shannessy
4e04ef0769 Merge pull request #153 from lrowe/patch-2
Add `hidden` attribute to DOM properties.
2013-07-03 15:48:19 -07:00
Laurence Rowe
b2bbdf8cbf Add hidden attribute to DOM properties. 2013-07-03 14:05:44 -07:00
petehunt
9178208ba8 update docs 2013-07-03 13:09:10 -07:00
Pete Hunt
7d3db0e5ed Add finally block for clearing ReactUpdates state
If any component throws during reconciliation any subsequent reconciliation will break badly because ReactUpdates will be in an inconsistent state.
Add a finally block to prevent this.
2013-07-03 11:38:50 -07:00
Tim Yung
2869e5b4df Inject ReactDOMInput
Changes `<input>` in React to use `ReactDOMInput` which supports `value` and `defaultValue` instead of the current, arguably broken `value` behavior.
2013-07-03 11:38:45 -07:00
Tim Yung
510146eb6d Faster Listener Deletion
Whenever a component is unmounted, we delete all listeners that might have been attached. This sucks because most applications, Facebook included, do not use every listener. There's a lot of wasted computation, especially if many components are mounted and unmounted.

This changes `deleteAllListeners` to more delete listeners more efficiently.
2013-07-03 11:38:34 -07:00
Tim Yung
c692d9e844 Fix ChangeEventPlugin for IE8 and IE9
This fixes a bug with `ChangeEventPlugin` in IE8 and IE9. The extend of this bug includes:

 - On IE8, not firing `onChange` immediately after `value` of an input is changed.
 - On IE9, not firing `onChange` when backspacing.
2013-07-03 11:38:31 -07:00
Pete Hunt
32423a83fc Injectable DOMProperty configs, and add back ID attribute
https://github.com/facebook/react/pull/141
2013-07-02 18:30:04 -07:00
Sebastian Markbage
d50148591b Introduce a supported way to slice children
Introduces a counterpart to mapChildren. It excludes empty children just as
mapChildren for compatibility. With might introduce something like
sliceChildrenIncludingEmptyValues at some point.
2013-07-02 18:30:04 -07:00
Pete Hunt
b6451be582 Update syntax.md
Some inconsistencies pointed out in FB comments
2013-07-02 18:27:15 -07:00
Paul O’Shannessy
5e296d7af8 Merge pull request #150 from benjamn/commoner-dir-watcher
Upgrade Commoner to --watch directories instead of individual files
2013-07-02 17:21:39 -07:00
Pete Hunt
3093a476b1 Merge pull request #115 from spicyj/async-state
Batch together calls to setState, setProps, etc
2013-07-02 17:16:07 -07:00
Paul O’Shannessy
00e56c5155 Merge pull request #151 from spicyj/bq
Add blockquote tag (already in JSX)
2013-07-02 17:14:34 -07:00
Pete Hunt
8b9891aa8a Remove autobinding warning
I think this warns on many legitimate use cases. We should get rid of it I think.
2013-07-02 16:53:39 -07:00
Ben Alpert
f7901a2380 Add blockquote tag (already in JSX) 2013-07-02 16:19:41 -07:00
Ben Newman
5c4352b57b Upgrade Commoner to --watch directories instead of individual files.
This behavior is new in Commoner v0.8.3, following the incorporation of
@jeffreylin's `DirWatcher` implementation:
https://github.com/jeffreylin/jsx_transformer_fun/blob/master/dirWatcher.js

Watching directories instead of files reduces the total number of open
files, and copes better with editors that save files by deleting and then
immediately recreating them.

Closes #60.
Closes #71.
2013-07-02 17:47:52 -04:00
Paul O’Shannessy
9ca7c9631a Blog: Autobind by Default
Kicking off the series of posts previewing v0.4
2013-07-02 13:04:14 -07:00
Ben Alpert
d9e99d4688 Batch together calls to setState, setProps, etc
The end of ReactUpdates-test.js is probably most illuminating for seeing how this works.
2013-07-02 00:04:50 -07:00
Pete Hunt
3fd56b4038 Merge pull request #147 from lrowe/patch-1
Add figure and figcaption elements to React.DOM (already supported by jsx)
2013-07-01 17:51:42 -07:00
Laurence Rowe
44659df598 Add figure and figcaption elements to React.DOM (already supported by jsx.) 2013-07-01 17:03:54 -07:00
Ben Alpert
0e9ee239a9 Merge branch 'master' into async-state 2013-07-01 16:08:57 -07:00
Paul O’Shannessy
ce0704a491 Merge pull request #145 from benjamn/no-jsx-dependency-scanning-by-default
Bump Commoner version to disable dependency scanning by default
2013-07-01 13:57:12 -07:00
Paul O’Shannessy
0acc1d8c78 Merge pull request #144 from benjamn/fix-EMFILE-jsx-errors
Bump Commoner version to fix EMFILE errors
2013-07-01 13:54:09 -07:00
Ben Newman
18ef8962f1 Bump Commoner version to disable dependency scanning by default.
If you are using bin/jsx independently, you may need to pass
--follow-requires to it if you rely on its dependency scanning.

Dependency scanning is still a good idea, but it's difficult to make it
work perfectly for everyone the first time they try bin/jsx.

Closes #131.
2013-07-01 16:50:35 -04:00
Ben Newman
e748be32da Bump Commoner version to fix EMFILE errors.
Finally found a more robust solution for the "too many open files"
problem: https://github.com/benjamn/commoner/commit/ad72ba42db.

Closes #137.
Closes #138.
2013-07-01 16:31:56 -04:00
Paul O’Shannessy
0ad14fc038 Merge pull request #143 from spicyj/ie8-fixes-2
Use proper names for scroll metric properties
2013-07-01 13:12:14 -07:00
CommitSyncScript
dd61439061 Revert Flattening of Children
I still think the semantics of flattening children is valid but we'll
want to revert the flattening implementation while we solidify the
semantics and try another approach.

This reverts flattening so that this.props.children can once again be
either a single child, flat array or nested array.

mapChildren calls flattenChildren before doing anything else. This is
not the most efficient approach but I wanted to keep this inital diff
simple. It also ignores empty values for backwards compatibility.

We may want to try another approach where empty values are included
in the map.

Validation of keys is still done inside ReactComponent. Ideally I'd
like to extract that into a separate module but to avoid cyclic
dependencies, I'm keeping it in ReactComponent for now.
2013-07-01 13:01:52 -07:00
CommitSyncScript
40bebf0c86 Fix ReactDOMInput and ReactDOMTextarea Race Condition
This fixes a race condition if the `onClick` tries to update the input or textarea (e.g. by calling `setState`):

  <input
    onClick={function(event) {
      this.setState({somethingElse: true}); // Triggers an update.
      // event.target.value is now equal to the old value, fail...
      this.props.onChange(event);
    })
  />
2013-07-01 13:00:41 -07:00
Ben Alpert
2aa5631e2e Use proper names for scroll metric properties 2013-07-01 11:54:13 -07:00
Paul O’Shannessy
f39a0f8e40 Merge branch 'no-content' of git://github.com/spicyj/react into spicyj-no-content
Conflicts:
	src/core/ReactNativeComponent.js
2013-06-28 16:42:59 -07:00
CommitSyncScript
ca19ffb083 use .apply instead of .call in ReactCompositeComponent
This was a bit ridiculous.. let's just use arguments as it's supposed to
be used.
2013-06-28 16:36:54 -07:00
CommitSyncScript
15272f30f4 Don't keep the HTML escaped ID internally, only in HTML generation
A dynamic value can be provided as a key to a child. Either as part of an object
or key property. This becomes part of the component's ID.

We have to be careful to escape this key before inserting it into the DOM since
it could become a vulnerability. We fixed this by escaping just the keys.

However, the current implementation breaks when you used escaped keys. The
internal value is escaped and the value used by getAttributeNode and
getElementById are both unescaped.

This fixes that by keeping the unescaped value internally but escaping it right
before the HTML is generated (like any other attribute).

This is important since business logic IDs (that should be used as keys)
contains characters that need to be escaped.
2013-06-28 16:35:45 -07:00
CommitSyncScript
55176116a2 Implement ReactDOMTextarea
This changes `ReactDOMTextarea` to accept `defaultValue` and `value`. It will warn people about using children (but allow it and treat it as `defaultValue`, which is the current behavior).
2013-06-28 16:35:04 -07:00
CommitSyncScript
738de8cfa8 Improve findComponentRoot Error Message
Instead of simply logging the React ID of the `ancestorNode` when `findComponentRoot` fails, use a `try ... finally` to `console.error` the `ancestorNode`. This allows modern web inspectors to actually log a reference to the node (which may not have a React ID).

This means when people run into the problem, they will not have to execute:

  require('ReactID').getNode(<copy+paste>);

NOTE: Admittedly, this will not log anything in IE8. That's fine, since IE8 has shitty console logging anyway.
2013-06-28 16:34:27 -07:00
Paul O’Shannessy
bd150ec658 Clean up unused variables for lint 2013-06-28 16:34:19 -07:00
Paul O’Shannessy
ee21a604f3 Delete files that accidentally got merged in
ಠ_ಠ
2013-06-28 14:54:07 -07:00
yungsters
43358157cf Merge branch 'textarea-update-value' of git://github.com/spicyj/react
Conflicts:
	src/core/ReactDefaultInjection.js
2013-06-28 14:30:47 -07:00
Paul O’Shannessy
0b65d7555e Merge pull request #136 from jeffmo/empty_expressions
Add support for empty XJS expressions
2013-06-28 14:16:23 -07:00
CommitSyncScript
8bc2abd367 .reactRoot[base10] -> .r[base36]
Just a bit of byte savings for server rendering. Props to @benjamn for the base36 idea (and for making this diff easy).

With a little work we could probably get rid of the .r as well.
2013-06-28 13:48:08 -07:00
CommitSyncScript
6556881417 Throw on Missing Elements
This changes React to throw when `ReactID.getNode()` fails to find a node. This method is used by two call sites:

 - Implements `ReactComponent#getDOMNode`. This method already throws if a component is not mounted, and //all mounted components should be able to find their rendered root nodes//.
 - Used by `ReactDOMIDOperations`. These call sites aleady assume that `getNode` returns a non-null. Currently, if the node is not found, this is the site that fatals (and the stack trace is much harder to debug).

The error message should make it //a lot// easier to debug unexpected DOM trees. In particular, this will help track down all the places where the browser inserts `<tbody>` unexpectedly.
2013-06-28 13:47:31 -07:00
CommitSyncScript
c54900f63e Fix Composition Level of Components w/o Owners
This fixes a bug with components constructed with no owners, for example:

  // Both the <div> and <span> have no owners.
  React.renderComponent(<div><span /></div>, node);

They should have a composition level of 1 and their keys should be prefixed with 0 to indicate they were created without owners. However, they currently incorrectly get a composition level of 0 (which means that //their// children will have keys prefixed with 0, which is wrong).
2013-06-28 13:47:05 -07:00
JeffMo
9c35189ad1 Add support for empty XJS expressions 2013-06-28 13:10:20 -07:00
Ben Alpert
e998041229 Remove content property
Fixes #119.
2013-06-28 11:14:59 -07:00
Christopher Chedeau
431e1d5608 Merge pull request #135 from vjeux/bugbuster
Add link roundup
2013-06-28 09:36:45 -07:00
Vjeux
d4c7991aee Add link roundup 2013-06-28 18:35:52 +02:00
Christopher Chedeau
811df48756 Merge pull request #123 from vjeux/patch-2
Add @jsx common parser issues in the docs
2013-06-27 17:17:59 -07:00
CommitSyncScript
dbd9d99bcd Fix findComponentRoot w/ Unidentified Nodes
The current `ReactInstanceHandles` has a bug where `findComponentRoot` barfs if it comes across a node that was not identified by React (via `ReactID`). This fixes that.

This was always a bug, but it became more apparent once we switched to `data-reactid` because arbitrary `document.createElement`'d nodes are much more likely to have an `id` than they are to have a `data-reactid`.
2013-06-27 16:44:08 -07:00
Paul O’Shannessy
c032743b93 Bump version to 0.4.0a
This should have happened a while ago, but better late than never.
2013-06-27 13:30:09 -07:00
Christopher Chedeau
418c1fc427 Add @jsx common parser issues in the docs
Update getting-started.md
2013-06-27 22:27:54 +02:00
petehunt
fe30279ed0 Merge pull request #126 from vjeux/community_3
Community Roundup #3
2013-06-27 13:19:48 -07:00
Vjeux
b4f096364f Community Roundup #3 2013-06-27 22:18:26 +02:00
Paul O’Shannessy
9e6a581f68 Merge pull request #132 from petehunt/engines
Recommend Node v0.10.0 due to https://github.com/isaacs/npm/issues/2907
2013-06-27 13:14:28 -07:00
petehunt
f7e49f3b25 Recommend Node v0.10.0 due to https://github.com/isaacs/npm/issues/2907 2013-06-27 13:09:29 -07:00
Paul O’Shannessy
2fd5efd92b Merge pull request #128 from mathieumg/master
Double quotes for strings in JSON data
2013-06-26 15:52:44 -07:00
CommitSyncScript
67cf44e7c1 Change ReactID.ATTR_NAME to "data-reactid"
This final change is what we've all been waiting for.

Note that it no longer makes sense to use `document.getElementById` in
`getNode`, because that only ever worked with "id" attributes.
2013-06-26 14:31:50 -07:00
CommitSyncScript
9ceaff7318 Refactor of ChangeEventPlugin
some refactoring and also handle if `blur` doesn't fire on the form
input in IE8 (by always cleaning up on focus). per discussions with
@balpert
2013-06-26 14:31:33 -07:00
Mathieu M-Gosselin
703c825196 Changed JSON data in the tutorial to use double quotes for strings. 2013-06-26 16:24:51 -04:00
Ben Newman
86adcd6766 Merge pull request #124 from zpao/keep-compare-size-cache
The compare_size cache gets wiped out with `grunt clean`
2013-06-26 11:57:03 -07:00
CommitSyncScript
5a85c5e535 Don't pass a null context to Function.prototype.call.
This prevents PhantomJS tests from hanging in the open-source React repo.

Until the advent of `"use strict"`, passing `null` as the context object
to `.call` or `.apply` resulted in `this` taking on the value of the
global object inside the invoked function.

Technically the `"use strict"` directive is supposed to make it possible
that `this === null`, but strict mode is not respected by all browsers,
including (unfortunately) PhantomJS.

Since these `expect`-ations are just testing binding behavior, let's not
make them also test strict mode `this` handling.
2013-06-26 11:23:25 -07:00
CommitSyncScript
cf926338bf Fix onChange for File Input
Makes sure that `onChange` fires for file inputs.
2013-06-26 11:23:13 -07:00
CommitSyncScript
43930455de Cache Default Props
The `getDefaultProps` return value should not be dependent on any external data (including `this.props` and `this.state`), so the return value should be consistent everytime we call it.

This caches the return value so we do not do work and allocate memory unnecessarily.
2013-06-26 11:22:39 -07:00
Paul O’Shannessy
6f04bd9410 Merge pull request #112 from spicyj/check-dom-nodetype
Check that `container` is a valid DOM element
2013-06-25 14:22:21 -07:00
CommitSyncScript
59212a538e Remove deleted files again
These accidentally got re-added in a rebase
2013-06-25 14:15:35 -07:00
CommitSyncScript
a9b024330c Make @typechecks static-only 2013-06-25 14:01:15 -07:00
CommitSyncScript
d93761af62 Enforce nodeCache validity
A node is considered valid if it

  1. has the expected ID (more of a sanity check than something that is
     ever likely to go wrong), and

  2. is contained by a currently mounted container.

When these requirements are met, we can be confident that
`ReactMount.findReactRenderedDOMNodeSlow(node.id) === node`, which is
important for cache consistency because `findReactRenderedDOMNodeSlow` is
what we fall back to when we don't find a node in the cache.

Point 2 is a subtle requirement, because it allows nodes to be valid even
if they are not currently contained by a document. Rendering into a
detached node is okay, in other words (which is something that
`document.getElementById` never properly accounted for).

Containment testing takes linear time in the depth of the DOM, which
sounds unfortunate until you realize that virtually all browsers support a
native `ancestor.contains(descendant)` method, and in practice the vast
majority of nodes are either orphaned with `.parentNode === null` or not
very deep relative to their container.
2013-06-25 14:00:31 -07:00
CommitSyncScript
fb6381fb35 Upgrade TextChangeEventPlugin to ChangeEventPlugin and support more form elements
Upgrade `TextChangeEventPlugin` to be the `onChange` event that React
fires. In React, `onChange` will now fire when `input` fires for form elements in
modern browsers.

Handle this for:

  input[type=text]
  input[type=password]
  input[type=checkbox]
  input[type=radio]
  textarea
  select

Support:

- OSX Chrome
- OSX Safari
- OSX Firefox
- Win 7 / IE8
- Win 7 / IE9
- Win 7 / IE10

Everything works but caret selection / placement differs from browser to
browser.

For <select> elements, the event is fired with `change`. This is a
conscious decision, even though in some browsers (OSX firefox, IE), it
can be argued that the event should fire more due to how the UI looks.

Builds on https://github.com/facebook/react/pull/75, which handled only
text inputs.
2013-06-25 13:58:59 -07:00
CommitSyncScript
1d65f81b16 Remove ReactDOMNodeCache and getDOMNodeID.
These modules have been superseded by `ReactID`. Since they were only used
internally, and I have updated all client code that previously assumed
their existence, I believe they can be dropped for good.
2013-06-25 13:58:43 -07:00
CommitSyncScript
1c40dde782 Remove ReactID.primeTree in favor of priming in ReactID.getID.
Although it would have been nice to prime the entire tree and achieve a
cache hit rate of 100%, that cost would have to be paid up front, during
page rendering.

This patch avoids priming up front in favor of making the most of the work
done by `ReactMount.findReactRenderedDOMNodeSlow`, which calls
`ReactID.getID` while traversing the rendered DOM. The insight is this: if
`getID` simply primes the cache whenever it finds a new ID, then
`findReactRenderedDOMNodeSlow` will end up priming quite a few more nodes
that are actually involved in `ReactID.getNode` lookups, and we won't need
`primeTree` at all.
2013-06-25 13:57:54 -07:00
Ben Alpert
f6c4d2d161 Check that container is a valid DOM element 2013-06-25 10:54:28 -07:00
Paul O’Shannessy
b282a0f4f1 The compare_size cache gets wiped out with grunt clean
`.grunt/` is the directory that is suggested for storing task related
files, and this file is not useful if it gets wiped out often. So I'm
moving the compare_size cache into `.grunt/` so we keep it around
longer.
2013-06-24 21:35:00 -07:00
CommitSyncScript
c1886c6513 Use ReactID.ATTR_NAME as the React-specific ID attribute name.
Another step in the plan towards making `ReactID.ATTR_NAME` the central
source of truth regarding the React-specific ID attribute name.
2013-06-24 18:28:29 -07:00
CommitSyncScript
bd8ecc1caa Restore @spicyj's lifecycle tests
These got lost in a rebase.
2013-06-24 18:28:18 -07:00
CommitSyncScript
6bbcbc08cf Rename BrowserEnv to ViewportMetrics
Becuase that's what it is.
2013-06-24 18:28:16 -07:00
CommitSyncScript
f0a4ca5f69 Remove React.autoBind entirely 2013-06-24 18:28:12 -07:00
CommitSyncScript
de40842597 Use @return, not @returns 2013-06-24 16:16:46 -07:00
CommitSyncScript
76ec746341 Require Statement Nits 2013-06-24 16:16:38 -07:00
CommitSyncScript
14102e8a48 Fix isMounted() for composite components
This behavior seemed incorrect for composite components.

- isComponentMounted() represents ReactComponent's lifecycle of mounting
- isMounted() represents ReactCompositeComponent's lifecycle of isMounted()

Therefore, ReactComponents no longer have isMounted(). I think this is fine since it was not supposed to be public anyway.
2013-06-24 16:15:49 -07:00
CommitSyncScript
4f2d8dfe72 Dynamic Input Component
Summary:
This is a proposal based loosely on the discussions I've had with @paulshen and @jwalke. It implements a shim for `React.DOM.input` (used as `<input>`) that supports two different use cases depending on whether `value` is provided or not.

If a `value` is //not// provided, the input will be initialized with the empty string (or `defaultValue`) and anytime the user changes the input, the `onChange` (or `onTextChange`) handler will be fired and the DOM will reflect the new changes.

  React.renderComponent(
    <input type="text" defaultValue="Untitled" onTextChange={handleChange} />,
    container
  );

If a `value` is provided, the input will be initialized to that value. Anytime the user changes the input, the `onChange` (or `onTextChange`) handler will be fired. However, the DOM will //not// reflect the new changes. If a `value` is provided, it is the responsibility of the owner to update the `value` prop passed in.

  var value = "Untitled";
  var input = React.renderComponent(
    <input type="text" value={value} onTextChange={handleChange} />,
    container
  );
  function handleChange(event) {
    // Do something cool like strip out non-numbers.
    var value = event.target.value.replace(/\D/g, '');
    input.setProps({value: value});
  }

This is just a start and we should build similar components for `textarea` and `select`. Also, this does not inject the new components because the changes are not backward compatible. Once we change all `<input>` uses to use `ReactDOMInput`, then we can inject.
2013-06-24 16:13:14 -07:00
CommitSyncScript
7c60bb3e54 Add unit test to prevent regression
The original autobinding diff made some assumptions about how methods were called on components that had to be reverted. This diff
enforces those assumptions in a test
2013-06-24 16:12:06 -07:00
CommitSyncScript
a62686622b Clean up naming
Fix a small style nit
2013-06-24 16:11:55 -07:00
CommitSyncScript
a61f4df0b9 Fix a bunch of problems with implicit autobinding 2013-06-24 16:11:24 -07:00
CommitSyncScript
3266818b42 fix bad caching in ReactID.getID 2013-06-24 16:11:00 -07:00
CommitSyncScript
c9ecbaccb3 Use React.autoBind by default.
Per our discussion - this is the general approach we'd like to take for
the public facing API.

    var MyComponent = React.createClass({
      render: function() {
        return <div onClick={this.myCallback} />;
      },
      myCallback: function() {
      }
    });
2013-06-24 16:10:33 -07:00
Ben Newman
336a0facc1 Merge pull request #99 from petehunt/invariants
Remove second argument to invariant()
2013-06-24 15:38:22 -07:00
petehunt
7053f59ad1 Remove second argument to invariant() 2013-06-23 21:58:59 -07:00
CommitSyncScript
3373572e15 Use ReactID.{get,set}ID instead of manipulating .id property directly.
Another step in the plan to centralize control of React-specific identifers.
2013-06-21 16:08:07 -07:00
CommitSyncScript
1839bcf109 Replace uses of ReactDOMNodeCache and getDOMNodeID with ReactID.
Also removed some unnecessary calls to `document.getElementById`, which
will eventually cease to work for React-specific IDs.

This clears the way for the deprecation of `ReactDOMNodeCache` and
`getDOMNodeID`.
2013-06-21 16:07:51 -07:00
CommitSyncScript
191c0dec32 Consolidate ReactDOMNodeCache and getDOMNodeID into ReactID.
When we move away from using the "id" attribute to identify
React-generated elements, we will need the cache (formerly
ReactDOMNodeCache) to be tied much more closely to the code that looks
elements up by ID (getDOMNodeID) and sets element IDs, since the magic of
document.getElementById will no longer be available.

The priming functions are going to come in handy when we create new DOM
fragments in mountComponent.

For backwards compatibility, the ReactDOMNodeCache and getDOMNodeID
modules still exist, but they are implemented entirely in terms of
functions exported from ReactID.
2013-06-21 16:07:22 -07:00
CommitSyncScript
2bc2b52eaa Allow accessing siblings by ref
This makes it possible to write a wider range of components without
depending on internal implementations.
2013-06-21 16:02:57 -07:00
CommitSyncScript
36a724feca Add reactComponentExpect#toBeComponentOfType
This adds a `toBeComponentOfType` method to `reactComponentExpect`. Now that we are injecting composite native components, `toBeDOMComponentWithTag` will not suffice and should be deprecated.
2013-06-21 16:02:55 -07:00
Paul O’Shannessy
18352090e7 Blogpost & changelog for v0.3.3 2013-06-21 10:57:41 -07:00
Paul O’Shannessy
4c97ffee34 Bring in Facebook's requestAnimationFrame module 2013-06-20 16:51:21 -07:00
Ben Alpert
ac5320e887 Remove textContent tests; they break in phantomjs 2013-06-19 17:26:29 -07:00
Ben Newman
91b10bd37c Merge pull request #109 from zpao/esprima-dep-as-tarball
Use github tarball link for esprima dependency
2013-06-19 15:59:56 -07:00
petehunt
79a2734068 Merge pull request #113 from vjeux/community_2
Community Roundup #2
2013-06-19 12:19:40 -07:00
Vjeux
32030687ba Community Roundup #2 2013-06-19 21:18:28 +02:00
Paul O’Shannessy
cb01363260 Cleanup lint warnings 2013-06-19 11:06:04 -07:00
Ben Alpert
0493b27222 Don't update value or textContent unnecessarily
_updateDOMChildren was already updating textContent so we don't need to
do it in _updateDOMProperties. Additionally, don't update .value if
it'll be a noop because it has side-effects (like moving the cursor) in
some browsers (like IE 9).

Refactor tests to be a bit more robust and a bit cleaner too.
2013-06-18 23:31:15 -07:00
Ben Alpert
44d6b94752 Merge remote-tracking branch 'origin/master' into textarea-update-value 2013-06-18 23:31:08 -07:00
petehunt
a2bc7387e4 Merge pull request #110 from vjeux/patch-1
Fix dangerouslySetInnerHTML
2013-06-18 23:13:58 -07:00
Christopher Chedeau
ea5e13893e Fix dangerouslySetInnerHTML 2013-06-19 00:09:02 -06:00
Paul O’Shannessy
bd044fc919 Use github tarball link for esprima dependency
It turns out that (at least for local development) npm has a long
standing bug where it doesn't recognize changing dependencies stored as
git urls (see https://github.com/isaacs/npm/issues/1727). Luckily npm
understand tarballs and GitHub provides tarballs for every commit, so
the workaround is easy, though unfortunate.
2013-06-18 15:29:37 -07:00
Paul O’Shannessy
870a29d9b0 Use absolute URLs for FB comments box 2013-06-18 10:20:34 -07:00
CommitSyncScript
0e91febb9c Better warnings for missing keys on arrays
We have less dynamic arrays in the code base now so let's start warning for all
the cases where we pass dynamic arrays without keys.

I use the displayName to point out which component's render method was
responsible. I only warn once per component. If the child was created in a
different component (and passed as a property) I also show the owner of the
child. Maybe it should've attached the key at a higher level.

This does give false positives for arrays that are truly static. Those should
probably be refactored to use the XML syntax if possible.
2013-06-18 09:36:24 -07:00
CommitSyncScript
37ddfa0521 Don't transfer children in transferPropsTo
06cff60bc1 made it so that `this.props.children` was no longer set when
none were provided.

  var x = <div />;

This caused an issue if the code was relying on the following not
transferring children.

  return this.transferPropsTo(<div />);
  // this now transfer children
2013-06-18 09:32:23 -07:00
Paul O’Shannessy
5bd449c157 Ignore .module-cache directories 2013-06-17 17:14:14 -07:00
Paul O’Shannessy
b69d7f0d2a Merge pull request #107 from remixz/package-json-fix
Fix package.json's reference to vendor/constants.js
2013-06-17 16:31:24 -07:00
Zach Bruggeman
a0475b3c29 Fix package.json's reference to vendor/constants.js 2013-06-17 16:27:07 -07:00
CommitSyncScript
3156458041 Fix most lint warnings/errors 2013-06-17 16:26:56 -07:00
CommitSyncScript
48333acba6 Remove reactKeys
It wasn't being used and it wasn't conforming to the @providesModule === file name rule.
2013-06-17 16:26:45 -07:00
CommitSyncScript
4a0456fb8e Fix lint warning about mismatched file & module name
@providesModule should match the file name. In this case we'll be consistent and suffix mixins with Mixin.
2013-06-17 16:26:07 -07:00
petehunt
405be0f966 Merge pull request #106 from benjamn/rename-woodchipper
Rename Woodchipper to ConstantVisitor, and simplify the vendor/constants.js interface
2013-06-17 15:55:25 -07:00
Ben Newman
000928f9dc Use recast.parse and .print for require("vendor/constants").propagate.
This removes the need to pass a callback, which is a nice improvement.
2013-06-17 16:30:32 -04:00
Ben Newman
0f87e8ee87 Rename Woodchipper-related stuff.
No functional changes introduced by this commit.

Renamed:

    woodchipper.js -> constants.js
    Woodchipper -> ConstantVisitor
    debranch -> propagate
2013-06-17 16:21:51 -04:00
Paul O’Shannessy
2195a479a8 Merge pull request #105 from benjamn/fix-options.writeback-bug
Upgrade Recast to 0.4.8 to fix options.writeback bug
2013-06-17 13:07:43 -07:00
Ben Newman
2383fd8813 Upgrade Recast to 0.4.8 to fix options.writeback bug.
Bug introduced by: https://github.com/benjamn/recast/commit/e913b22f8f
Bug fixed by: https://github.com/benjamn/recast/commit/170e18091e
2013-06-17 15:57:33 -04:00
CommitSyncScript
d8b6d260c9 Add missing license header 2013-06-17 12:50:55 -07:00
CommitSyncScript
6a41ede2d4 Fixing known keying problems
This fixes the last known parts of the flattening experiment. This has grown to
be somewhat complex and potentially fragile because of it. We may end up
reverting flattening in the future or address it slightly differently.

The purpose of this diff is to test if we've finally understood the real world
edge cases that flattening can lead to and how we have to key components to
cover those cases.

With this commit we never rekey the internal _key property. The semantics is
that once a component passes through a composite component, it's identity is
frozen.

props.key should accept numeric values and booleans which includes 0 and false.
This fixes the truthiness check.

We should never warn about missing key properties if a component is passed as a
static child. The _key acts as a flag to determine whether this component
was checked already.
2013-06-17 12:50:29 -07:00
CommitSyncScript
c04081bc56 Add missing license header. 2013-06-17 12:50:15 -07:00
CommitSyncScript
0b1ecd8872 Add Back DOMCharacterDataModified
Accidentally lost `DOMCharacterDataModified`.
2013-06-17 12:49:58 -07:00
CommitSyncScript
88e90d5601 Use Synthetic Events
Swaps out usage of `AbstractEvent` with `SyntheticEvent` (and subclasses).
2013-06-17 12:49:45 -07:00
CommitSyncScript
03464dc148 Fix EventPluginRegistry Unit Tests in GitHub
Dumping the mock cache isn't dirying the modules in the open source version, so we have to unit test a different way. If we can fix the unit test framework, we should revert this.

Also, I added strict mode to `EventPluginRegistry.js`.

See: https://github.com/facebook/react/pull/91
2013-06-17 12:49:22 -07:00
CommitSyncScript
1112f1a003 React onlyChild utility.
Small utility that extracts and validates that there is only a single
child passed to a React composite component. The benefit here is that we
abstract away *how* the children are actually stored while we iterate on
different approaches. This way we won't break callsites as we try different
ideas. When we settle on a final approach, all of these callsites will still
work.
2013-06-17 12:48:47 -07:00
Paul O’Shannessy
c1576fcf97 Remove trailing whitespace 2013-06-17 12:48:43 -07:00
CommitSyncScript
8592eacbf9 Use Node Cache in ReactComponent
There are currently two places where we lookup and cache nodes: `ReactDOMNodeCache` and `ReactComponent`. Instead, we should just consolidate caches and make `ReactComponent` use `ReactDOMNodeCache`.
2013-06-17 12:48:26 -07:00
petehunt
888cb824d7 Merge pull request #103 from benjamn/fix-maxBuffer-exceeded
Use grunt.util.spawn for jsx:* tasks instead of exec
2013-06-17 11:10:07 -07:00
petehunt
061527df6c Merge pull request #102 from zpao/fix-transformer
Improve JSXTransformer
2013-06-17 11:08:35 -07:00
Ben Newman
96b0a0253f Use grunt.util.spawn for jsx:* tasks instead of exec.
This should prevent "Warning: stdout maxBuffer exceeded" errors.

Also piping child process stdout and stderr to the parent process, so
you can see more of what's happening during the build process.
2013-06-17 13:56:58 -04:00
Paul O’Shannessy
c79a59b599 Improve JSXTransformer
The biggest improvement is that we'll now insert each parsed JSX script
back into a `<script>` tag with the body set. This allows the browser to
execute these scripts normally. Using `Function(functionBody)` or
`eval(functionBody)` both execute in window scope, but `var` assignments
don't actually get set on window (unlike everywhere else).

I also did some cleanup to make the code a little bit more readable.
In my minimal test cases this didn't break anything (scripts loaded in
the right order).
2013-06-17 10:52:16 -07:00
petehunt
fad7d58fc9 Update jsx-is-not-html.md 2013-06-17 03:11:57 -06:00
petehunt
97efa84676 Merge pull request #88 from vjeux/jsx_pitfall
Adding JSX pitfalls section in the docs
2013-06-17 02:05:55 -07:00
petehunt
22347ea54d Merge pull request #95 from groodt/patch-1
Small correction to tutorial.md
2013-06-17 01:36:51 -07:00
petehunt
46513c6d78 Merge pull request #96 from groodt/master
Very minor corrections to documentation
2013-06-17 01:26:31 -07:00
petehunt
1c7d01c2f4 Merge pull request #97 from spicyj/patch-1
Link to my own blog instead of Quora
2013-06-17 01:25:31 -07:00
ngavalas
7a0f2d71bb Add callbacks to all public-facing state/props methods
All public facing {set,replace,force}{props,state} methods now support
callbacks.
2013-06-16 22:45:36 -07:00
Ben Alpert
4104beadbb Link to my own blog 2013-06-15 18:59:45 -06:00
Greg Roodt
87f4b8be67 Minor grammar. 2013-06-15 11:08:06 +03:00
Greg Roodt
8d729d7da2 Minor typo. 2013-06-15 11:07:20 +03:00
Greg Roodt
f016479289 Update tutorial.md
The ajax call happens every 5 seconds, not every 60 seconds.
2013-06-15 10:15:42 +03:00
ngavalas
c81cc2e6d5 markdown syntax
Small problem with markdown syntax in syntax-highlighted block.
2013-06-14 16:41:02 -07:00
ngavalas
f3aac85d01 Updated docs and check for truthiness
Change api docs to reflect presence of the new argument.  In addition,
callback was change to require only a "truthy" value.
2013-06-14 16:37:20 -07:00
ngavalas
c6665e3460 Adds optional callback to setState
This commit adds an optional callback as a second argument to
`setState`, to be called after `setState` runs.

We never guarantee synchronous execution of `setState`, and as per
@phunt, we don't want to make that guarantee because we may eventually
batch calls to `setState`.  @jwalke agrees with him.
2013-06-14 16:23:06 -07:00
Timothy Yung
c7295b9e09 Merge pull request #61 from spicyj/getdomnodeid
getDOMNodeID: Don't return .id on random objects
2013-06-14 11:27:44 -07:00
Ben Newman
9fd9f712bf Merge pull request #91 from yungsters/master
Fix `EventPluginRegistry` Unit Tests
2013-06-14 06:45:57 -07:00
Ben Alpert
a9c70bcc1c getDOMNodeID: Don't return .id on random objects
If you defined a global named `id` (a horrible name, I know) then
getDOMNodeID(window) would return that object. Since only DOM nodes can
have IDs, this should be a noop change otherwise.

Test Plan:
Verified that document.documentElement and document.body both support
getAttributeNode properly in latest Chrome and in IE8.
2013-06-14 00:21:15 -07:00
Timothy Yung
80edd6ca87 Merge pull request #89 from vjeux/patch-4
Exposing ReactProps as React.Props
2013-06-13 21:08:10 -07:00
Timothy Yung
48f46b568d Merge pull request #92 from spicyj/fix-textchange
Fix textchange event enqueueing
2013-06-13 20:53:47 -07:00
yungsters
279792f891 Fix EventPluginRegistry Unit Tests
Dumping the mock cache isn't dirying the modules, so we have to unit test a different way. If we can fix our unit test framework, we should revert this.

Also, I added strict mode to `EventPluginRegistry.js`.
2013-06-13 20:38:23 -07:00
Ben Alpert
792b69ba11 Fix textchange event enqueueing
(Was broken by e1535fbd71d8c89c82cd9d9073c1ee97ee6a3b00.)
2013-06-13 20:34:14 -07:00
Paul O’Shannessy
06cff60bc1 Sync latest JSX transform - all children passed as separate arguments
This was a part of e1fe13d0cb upstream.
2013-06-13 18:18:54 -07:00
CommitSyncScript
770ec5946a Unbreaking falsy check on style values
Style values can be the number zero which is an actual value. So we check for
null instead. The empty string case falls through.
2013-06-13 17:49:04 -07:00
CommitSyncScript
b525a0c061 Unnecessary this._rootNodeID Invariant
Summary: This invariant is unnecessary because `ReactComponent.Mixin.receiveProps` already asserts that this component is mounted. (Being mounted guarantees you have a DOM ID, look at `ReactComponent` and see when `this._rootNodeID` is mutated.)
2013-06-13 17:48:09 -07:00
CommitSyncScript
34970fd785 Fix tht typos 2013-06-13 17:47:59 -07:00
Paul O’Shannessy
ceb5303581 Merge pull 75 upstream
Needed to make some small changes since we weren't synced when it was
merged.
2013-06-13 17:47:51 -07:00
CommitSyncScript
f456f8fa8d Remove isStatic
This can be replicated with a custom component that always returns false`
from `shouldComponentUpdate`. A generic implementation might look like:

```
var StaticContainer = React.createClass({
  shouldComponentUpdate: function() {
    return false;
  },

  render: function() {
    return this.transferPropsTo(this.props.children[0]);
  }
});
```

And then used in JSX as
`<StaticContainer><div>Hello!</div></StaticContainer>`, resulting in
only `<div>Hello!</div>` being inserted into the DOM.
2013-06-13 17:40:52 -07:00
CommitSyncScript
e1fe13d0cb Pass multiple children in JSX as additional arguments
This is an alternative to D809298. In normal usage you'd end up with a single
flat array in props.children.
2013-06-13 17:40:05 -07:00
CommitSyncScript
01511ea557 Remove Unnecessary DOM Mutations
This fixes an edge case that can cause unnecessary mutations in the DOM. Namely, if a prop is falsey, it will get touched on every update by reconciliation. See unit test.
2013-06-13 17:39:47 -07:00
CommitSyncScript
802241a660 Cleanup style Prop Reconciliation
This cleans up the reconcilation path when adding a `style` prop (going from a falsey or no `style` to having one) by reducing the need for an object allocation and for-loop.
2013-06-13 17:39:23 -07:00
CommitSyncScript
e1535fbd71 Create EventPluginRegistry
The `EventPluginHub` module was getting huge and scary. This pulls out all of the logic required to inject plugins and publish their event registration names into a new `EventPluginRegistry` module.

Functionally, nothing should have changed. I added many error checks to cover edge cases that we were not yet running into, but they are all in `EventPluginRegistry` and unit tested.
2013-06-13 17:38:49 -07:00
CommitSyncScript
aea8e16b4a Add ReactComponent#isMounted
There is currently no way for components to know whether or not they are mounted. This means there's no way for callbacks to figure out if they can make certain assumptions (e.g. can `getDOMNode()` or `setState()` be safely invoked).

This adds an `isMounted` protected method that lets components properly handle callback behavior when unmounted.
2013-06-13 17:38:20 -07:00
CommitSyncScript
0d6bb650cb Add HTML5 Drag/Drop events to React 2013-06-13 17:37:58 -07:00
Ben Alpert
ddc4ffffa0 Don't let textarea value change via textContent
Turns out my tests before weren't particularly useful because
receiveProps doesn't end up running componentDidUpdate since the
transaction never finishes. Now they use replaceProps instead (and I
verified that commenting out the "rootNode.value = ..." line makes the
tests fail, which wasn't true before).
2013-06-12 19:12:52 -07:00
Vjeux
d7a5f137ff Adding JSX pitfalls section in the docs 2013-06-13 03:08:50 +02:00
Christopher Chedeau
34173638d4 Exposing ReactProps as React.Props
Right now, even though ReactProps is committed, there is no way to use it as it is not exposed.
2013-06-12 18:28:25 -06:00
Timothy Yung
c9618587ef Merge pull request #67 from vjeux/fb_comments
Facebook comments integration on Docs and Blog
2013-06-12 16:13:05 -07:00
Vjeux
101bfa3112 Facebook comments integration on Docs and Blog 2013-06-13 01:08:31 +02:00
Vjeux
523bde4dc5 Community round-up blog post 2013-06-12 13:55:51 -07:00
Jordan W
483350905b Merge pull request #86 from petehunt/fixed-width-height
Fixed width/height on React logo
2013-06-12 12:35:33 -07:00
petehunt
5b72334852 Fixed width/height on React logo 2013-06-12 12:33:38 -07:00
Ben Alpert
d13a37ce22 Don't set value if it'll be a noop 2013-06-12 01:55:26 -07:00
Ben Alpert
0c6f4b3bcc Set textarea value when changing content
At http://jsfiddle.net/spicyj/W4QLq/, typing into the textbox would cause
clicking the button to do nothing; now it should work.
2013-06-12 00:14:58 -07:00
Timothy Yung
0e6fca4a38 Merge pull request #68 from vjeux/twitter
Integrate twitter in the support page
2013-06-11 22:34:44 -07:00
Timothy Yung
dfd76be568 Merge pull request #75 from spicyj/textchange
Add new textChange event: input + IE shim
2013-06-11 22:00:19 -07:00
Ben Alpert
0dc08c2115 Missing semicolon 2013-06-11 21:54:50 -07:00
Ben Alpert
6b572b3f25 Refactor based on review feedback 2013-06-11 21:51:47 -07:00
Timothy Yung
c6c40a5fb3 Merge pull request #84 from spicyj/remove-props
Correctly remove attributes when deleting props
2013-06-11 19:54:36 -07:00
Ben Alpert
fdc6beed1a Fix nit and comment 2013-06-11 19:53:24 -07:00
Ben Alpert
731aa8ead1 internalPropNames isn't necessary, so remove it
Perhaps we'll bring it back as a future perf optimization if that
appears useful.
2013-06-11 19:02:35 -07:00
Ben Alpert
8762634cf1 Remove unused require 2013-06-11 17:28:06 -07:00
Ben Alpert
735a91c9d5 Fix relative require copy pasta 2013-06-11 17:24:35 -07:00
Ben Alpert
705ce56694 Correctly remove attributes when deleting props
The most obvious manifestation of this bug is visible here:
http://jsfiddle.net/spicyj/zzGas/. In short, when props are removed from a
component, the underlying HTML element doesn't have the attribute
removed.

This change should fix it, but unfortunately it (presumably) makes
_updateDOMProperties a bit slower.
2013-06-11 16:46:10 -07:00
petehunt
94fdf2cf5d Merge pull request #81 from benjamn/issue-80-commoner-no-longer-rewrites-require
Upgrade Commoner and Recast to latest versions
2013-06-11 16:22:17 -07:00
Paul O’Shannessy
758c21fb9c Merge pull request #77 from spicyj/componentdidmount-order
Run inner componentDidMount method first
2013-06-11 13:10:03 -07:00
Ben Newman
15360056bd Upgrade Commoner and Recast to latest versions.
The Commoner upgrade is a big one because it makes bin/jsx no longer
rewrite module identifiers to be relative by default, which should
reduce confusion for people trying to use it as a standalone
transformer.

Closes #80.
2013-06-11 15:24:50 -04:00
Ben Alpert
932c45a7ab Check canUseDOM before calling isEventSupported 2013-06-10 18:27:22 -07:00
Ben Alpert
e39743f2f8 Removed unused variable 2013-06-10 17:19:45 -07:00
Paul O’Shannessy
cff4d53a9e Add missing license headers 2013-06-10 16:25:37 -07:00
CommitSyncScript
c2ce1d00cd Fix Event Normalization in IE<9
IE<9 relied on the `target` property being overriden. This adds back a hack that only applies in IE<9. I'll be able to revert this hack once I check in synthetic events.
2013-06-10 16:19:25 -07:00
CommitSyncScript
b3e0dc47a8 Rename "Delegate" to "Synthetic"
This is just a simple rename of the event classes to `SyntheticEvent`. I've also updated the constructor arguments to be more correct:

 - `dispatchConfig`: Data used by the plugin system for dispatching the event, for example: `{registrationName: 'onClick'}`
 - `dispatchMarker`: An identifying marker used to describe where the event is occuring, for example: `.reactRoot[0]`
2013-06-10 16:19:03 -07:00
CommitSyncScript
93f979ae18 Use isAncestorIDOf in ReactInstanceHandles
This is both a functional fix and performance fix for `ReactInstanceHandles`.

 - `getFirstReactDOM` uses `indexOf` but should be checking ancestry (via `isMarker()`).
 - Added `isAncestorIDOf`, checking ancestry can be way faster than getting a common ancestor: http://jsperf.com/react-ancestor-id-check
2013-06-10 16:18:40 -07:00
CommitSyncScript
ca3f871646 Reduce ReactInstanceHandles API Surface Area
Change `ReactInstanceHandles` so that `getFirstCommonAncestorID` and `nextDescendantID` are now private (and documented to be only exposed for unit testing). Also:

 - Renamed `nextDescendantID` to `getNextDescendantID`.
 - Renamed `parentID` to `getParentID`.

I also organized `ReactInstanceHandles-test` by method names.

Functionally, this diff should not change anything.
2013-06-10 16:18:13 -07:00
CommitSyncScript
1be6c592a6 Fix typechecks for isRenderedByReact() 2013-06-10 16:17:52 -07:00
CommitSyncScript
37cde3d864 Stabilize minimal server rendering API
This is a pretty killer feature and the API is simple. I know it's another API method on React, but I think it's
the only way.
2013-06-10 16:17:26 -07:00
Ben Alpert
2afd7186ae Run inner componentDidMount method first
Fixes #76.
2013-06-09 17:21:22 -07:00
Ben Alpert
c19bf9cffe Add new textChange event: input + IE shim
IE8 doesn't support oninput and IE9 supports it badly but we can do
almost a perfect shim by listening to a handful of different events
(focus, blur, propertychange, selectionchange, keyup, keydown).

This always triggers event handlers during the browser's event loop (not
later in a setTimeout) and after the value property has been updated.

The only case I know of where this doesn't fire the event immediately is
if (in IE8) you modify the input value using JS and then the user does a
key repeat, in which case we fire the event on the second keydown.

Test Plan:
Modify ballmer-peak example to add es5-shim and to use onTextChange
instead of onInput. In IE8, IE9, and latest Chrome, make sure that the
event is fired upon:

* typing normally,
* backspacing,
* forward-deleting,
* cutting,
* pasting,
* context-menu deleting,
* dragging text to reorder characters.

After modifying the example to change .value, make sure that the event
is not fired as a result of the changes from JS (even when the input box
is focused).
2013-06-09 04:18:15 -07:00
CommitSyncScript
7e7579e1ba Assign the same keys if it's a single nested array or not
If you specify a single array, we didn't prefix the keys with 0.

If you later add children, the first array won't have the same key.
2013-06-07 22:10:20 -07:00
CommitSyncScript
582359aeea Remove React.createComponentRenderer
Remove ReactMount.createComponentRenderer because it does not function
correctly.

  var f = React.createComponentRenderer(<div />);

  var container1 = document.createElement('div');
  var container2 = document.createElement('div');
  f(container1);
  f(container2); // error because mounting same instance into new root
2013-06-07 22:10:06 -07:00
CommitSyncScript
6c3c643c8e Fix typo in OrderedMap
Unique was spelled wrong. This fixes it.
2013-06-07 22:09:49 -07:00
CommitSyncScript
3eaed5a122 Delegate Event Classes
React's top-level event delegation dispatches `AbstractEvent` objects that contain:

 - `nativeEvent`, the original browser event.
 - `data`, an object with custom normalized properties.

This diff creates a set of `DelegateEvent` classes that will replace `AbstractEvent`. The goal is two-fold:

 # Provide a cross-browser implementation that conforms to the DOM Level 3 Events API so people don't have to use `nativeEvent`.
 # Generalize the event object API so that it can be shared by `DOMEventManager`, a top-level event delegation WIP.

This simply implements the classes. I will follow-up by replacing `AbstractEvent` with them.
2013-06-07 22:08:32 -07:00
CommitSyncScript
4bb966a7f0 Bugfixes to key assignment
Type coersion bug and ID breaking assumption.

Names need to be wrapped in something unique since otherwise two unique siblings
can end up having IDs that are subsets of eachother.
2013-06-07 22:08:14 -07:00
CommitSyncScript
0e9e64c550 Replace persistentCloneOf with persist
There are to reasons to prefer a `persist` method on the event rather than a static method:

 - In open source, people do not have access to `AbstractEvent`.
 - This will allow people to persist events without requiring another module.
 - This will make refactors easier and more flexible.
2013-06-07 22:07:43 -07:00
Jeffrey Lin
c5998fb483 Merge pull request #72 from benjamn/module-cache
Cache modules for jsx grunt tasks in react-tools/.module-cache
2013-06-07 18:11:05 -07:00
Ben Newman
880ada0a1c Cache modules for jsx grunt tasks in react-tools/.module-cache.
As of Commoner v0.6.11, the default is to put the cache files in
output/.module-cache, which used to be build/modules/.module-cache
before this commit. That still happens when you run bin/jsx directly,
just not for grunt tasks anymore.

The module cache needs to be cleared much less often than
build/modules, so it doesn't make sense to throw away all that work.
2013-06-07 18:02:43 -04:00
Jordan W
a5e5f53494 Merge pull request #69 from jordow/SimplifyExample
Make todo example shorter and not rely on the DOM.
2013-06-07 13:16:17 -07:00
jordow
81f3a5c6cd Make todo example shorter and not rely on the DOM. 2013-06-07 13:11:40 -07:00
Paul O’Shannessy
59bee8df21 Remove clowny diff.diff
An artifact of our sync process.
2013-06-06 15:09:11 -07:00
Paul O’Shannessy
796837b8c7 Merge pull request #66 from zpao/sync-latest
Sync latest from Facebook
2013-06-06 15:03:09 -07:00
CommitSyncScript
2dc24fc234 Add typecheck, cleanup
Followup with some additional comments for https://github.com/facebook/react/pull/58
2013-06-06 14:50:54 -07:00
CommitSyncScript
88923f61a7 Improve Browser Support for wheel Event
This improved browser support for the `wheel` event.

 - Try to use `wheel` event (DOM Level 3 Specification).
 - Fallback to `mousewheel` event.
 - Fallback to `DOMMouseWheel` (older Firefox).

Also, since `wheel` is the standard event name, let's use that in React.

NOTE: The tricky part was detecting if `wheel` is supported for IE9+ because `onwheel` does not exist.

Test Plan:
Execute the following in the console on a page with React:

  var React = require('React');
  React.renderComponent(React.DOM.div({
    style: {
      width: 10000,
      height: 10000
    },
    onWheel: function() {
      console.log('wheel');
    }
  }, null), document.body);

Verified that mousewheel events are logged to the console.
Verified in IE8-10, Firefox, Chrome, and Safari.
2013-06-06 14:48:25 -07:00
CommitSyncScript
ba6fea1bf5 Simplify Event Core
Summary:
This makes a few changes to React Core, most notably `ReactEventEmitter` and `ReactEventTopLevelCallback`.

 - Changed `ReactEventEmitter` to use `EventListener` (instead of `NormalizedEventListener`).
 - Deleted `NormalizedEventListener` (which was previously broken).
 - Created `getEventTarget` which is used to get a normalized `target` from a native event.
 - Changed `ReactEventTopLevelCallback` to use `getEventTarget`.
 - Renamed `abstractEventType` to `reactEventType` in `AbstractEvent`.
 - Reanmed `abstractTargetID` to `reactTargetID` in `AbstractEvent`.
 - Removed `originatingTopLevelEventType` from `AbstractEvent` (unused and violates encapsulation).
 - Removed `nativeEvent.target === window` check when refreshing authoritative scroll values (unnecessary).

This actually fixes React because `NormalizedEventListener` does not currently do what it promises to do (which is normalizing `target` on the native event). The `target` event is read-only on native events.

This also revises documentation and adds `@typechecks` to a few modules.

NOTE: Most importantly, this sets the stage for replacing `AbstractEvent` with `ReactEvent` and subclasses, piecemeal.
2013-06-06 14:48:12 -07:00
CommitSyncScript
36d8ce8fab [React] remove deprecated Component.update()
Summary: Since grepping for `update` and `updateAll` is pretty hard, I had these these functions call through but complain loudly. This noisy call through has been in prod for over a week and I haven't heard any complains, so let's take it out altogether.
2013-06-06 14:46:53 -07:00
CommitSyncScript
153fd9246e [React] Don't use autoMockOff 2013-06-06 14:29:45 -07:00
CommitSyncScript
fac24d462f React: Add @typechecks to CallbackRegistry 2013-06-06 14:29:45 -07:00
Paul O’Shannessy
83101b878e Add license headers to new files 2013-06-06 14:29:45 -07:00
CommitSyncScript
9d1055b3d2 Rename ReactEvent to ReactEventEmitter
ReactEvent should be reserved for the actual object created when an
event fires. The current ReactEvent is more like EventEmitter than
anything (e.g. it sets up delegation, provides methods to attach and
remove listeners).
2013-06-06 14:29:45 -07:00
CommitSyncScript
0614d30654 Move test utils internally, update for consistency 2013-06-06 14:29:44 -07:00
CommitSyncScript
9965b6b9dd Fix Listener Cleanup on Unmount
We need to make sure that deleteAllListeners() is invoked before we call
the superclass's unmountComponent() method or else we will lose
this._rootNodeID.

I also added an invariant and unit test to make sure we do not break
this in the future.
2013-06-06 14:29:44 -07:00
CommitSyncScript
a06de4bc4f Cleanup ReactCurrentOwner on Fatal
If a React component's render() fatals, it may contaminate
ReactCurrentOwner. This will cause the owner to be set improperly for
the next React.renderComponent() invocation (which causes an owner to be
set when there shouldn't be one).
2013-06-06 14:29:44 -07:00
CommitSyncScript
11a7cb5b73 Only Allow forceUpdate on Mounted Components 2013-06-06 14:29:44 -07:00
CommitSyncScript
bae6100ae8 Make ReactIdentity-test less fragile with respect to root IDs. 2013-06-06 14:29:44 -07:00
CommitSyncScript
3ffbb4d096 Re-add invariant
Bring back the invariant() that disallows setProps() and replaceProps()
on owned components.
2013-06-06 14:29:44 -07:00
CommitSyncScript
ca5d7bc683 Add getDefaultProps()
As it turns out, default values are very useful. This implements
getDefaultProps(), a hook for components to provide prop values when
a prop is not specified by the user.
2013-06-06 14:29:44 -07:00
CommitSyncScript
1457850b72 Rename domUtils to dom 2013-06-06 14:29:44 -07:00
CommitSyncScript
100af48f53 Support rendering different components into same node
var container = ...; // some DOM node
React.renderComponent(<div />, container);
React.renderComponent(<span />, container);

This should replace the rendered <div> with a <span>, effectively
reconciling at the root level.
2013-06-06 14:29:44 -07:00
CommitSyncScript
3e211bf662 [React] Removing invariant warning about updating owner state
It seems like it's possible to render a component that ends up having an
owner. Because you can end up rendering inside a render somehow.
2013-06-06 14:29:44 -07:00
CommitSyncScript
606d6b8fd4 Revert Object.create in NormalizedEventListener
It seems that the use of Object.create (to comply with strict mode) in
NormalizedEventListener is not happy in IE8.
2013-06-06 14:29:44 -07:00
CommitSyncScript
b581c8cfc7 Always reassign _key for every pass
Currently we're mutating _key. Mutation here is fine, but it needs to
be idempotent - which it's not. This is causing some issues.

Instead I reassign the _key every time it passes through a flattening.
This means that it's unique and stable for a single pass through a composite
component. When it's repassed another level, it loses it previous
identity and is rekeyed by it's new location.

For auto-generated keys by index, this actually means it has the same
semantics as before flattening.

For explicit keys, it has the effect that keys need to be unique at
every level. Regardless of how the key got there. Every component needs to ensure
that it doesn't combine keys from two different sources that may collide. This
is also inline with the old semantics but less intuitive in the new model.
2013-06-06 14:29:44 -07:00
CommitSyncScript
54d3134da2 Add ReactProps.func
This adds ReactProps.func so people don't need to write the
slightly-more-cryptic ReactProps.instanceOf(Function). We should have
had this all along.
2013-06-06 14:29:44 -07:00
CommitSyncScript
259392035d mapChildren
mapChilden() is similar to Array.map() and objMap() but handles deep
nested structures and follows similar rules to flattenChildren()
2013-06-06 14:29:44 -07:00
CommitSyncScript
4b81de93d3 use key="foo" for all components
flattenChildren was only using key when child.mountInContainerNode
exists, which is defined on ReactCompositeComponent, and not
ReactNativeComponent.

This uses the isValidComponent() fn to see if we should use this key.
2013-06-06 14:29:44 -07:00
CommitSyncScript
93fc188afb style prop improvements
Some improvements to how style={{x:y}} is handled in React:
* ignores null styles, rather than setting them.

Codez:

    var highlighted = false;
    <div style={{color: highlighted ? 'red' : null}} />

Before:

    <div style="color:;"></div>

After:

    <div></div>

Respects that 0 has no units.
2013-06-06 14:29:44 -07:00
CommitSyncScript
007b75f78a Flatten Children A Single Level
This expects static children as additional arguments to the constructor
and flattens any array arguments one level deep.

Component(props, child1, child2, arrayOfChildren, child3) ->
.props.children = [child1, child2, ...arrayOfChildren, child3]

This can avoid an additional heap allocation for the unflat array.

It allows you to pass nested arrays and objects like you used to. Those
aren't immediately flattened. That makes this a fairly safe change.

Passing a dynamic array without key properties will yield a warning
(once). Might consider throwing later.

Once we change the transpiler to use the new syntax, you'll end up with
a single flat array in normal usage.

This doesn't actually update the JSX transform.
2013-06-06 14:29:43 -07:00
Vjeux
0435216eb6 Using markdown instead of html 2013-06-06 08:40:24 +02:00
Vjeux
7061d2b25b Integrate twitter in the support page 2013-06-06 08:38:09 +02:00
Paul O’Shannessy
31cdb4c8a7 Merge pull request #58 from spicyj/unmount-nothrow
Make unmountAndReleaseReactRootNode not throw
2013-06-05 15:00:00 -07:00
Paul O’Shannessy
1e76d84569 Merge pull request #32 from spicyj/input
Add new onInput event
2013-06-05 14:57:25 -07:00
petehunt
3204135a46 Update 2013-06-05-why-react.md 2013-06-05 12:51:17 -06:00
Paul O’Shannessy
a64faf7bf7 Fix broken link in Why React post 2013-06-05 10:02:11 -07:00
petehunt
4a79a718a3 Rename and fix typo 2013-06-05 08:46:51 -07:00
petehunt
e293f998a1 Update 2013-06-04-why-react.md 2013-06-04 18:03:32 -06:00
Paul O’Shannessy
dbfaa81ee0 Update links in readme to 0.3.2 2013-06-04 16:58:01 -06:00
Ben Alpert
6012e94e50 Make unmountAndReleaseReactRootNode not throw
When there isn't any React node in the DOM, unmountAndReleaseReactRootNode
threw an exception because component was undefined. Instead, return whether we
were able to unmount the component.
2013-06-04 14:36:16 -07:00
petehunt
0f67f7a782 Merge pull request #56 from petehunt/blogpost
Bring in the last few edits
2013-06-04 13:55:01 -07:00
petehunt
4201ddaf4e Bring in the last few edits 2013-06-04 13:09:20 -07:00
petehunt
14f1f8f53a edits from the committee 2013-06-04 14:00:18 -06:00
petehunt
61b5bd81d8 update date 2013-06-04 01:54:15 -07:00
Ben Alpert
35306fa7f5 Revert "Simulate input event" for now
This reverts commit 580e8f0dbb.
2013-06-04 01:29:12 -07:00
petehunt
b441dcd6f0 Merge pull request #55 from spicyj/docs-fix-2
"nuts and bolts" isn't hyphenated
2013-06-04 00:57:09 -07:00
Ben Alpert
17d368910f "nuts and bolts" isn't hyphenated 2013-06-04 00:54:49 -07:00
petehunt
321e7e1175 Merge pull request #53 from yungsters/master
Revise "Why React" content.
2013-06-03 21:12:50 -07:00
yungsters
bef3dd6760 Another pass over "Why React". 2013-06-03 15:54:26 -07:00
yungsters
3ded55f9f7 Revise "Why React" content. 2013-06-03 15:00:08 -07:00
Paul O’Shannessy
962cebf7c5 Merge pull request #43 from vjeux/jsfiddle
Add JSFiddle to the getting started section
2013-06-03 14:26:31 -07:00
Paul O’Shannessy
4081678f2e Merge pull request #49 from paulshen/jekyllrss
[docs] Add RSS feed.xml for blog posts
2013-06-03 14:12:54 -07:00
petehunt
b202569c83 Merge pull request #52 from zpao/blog-tweaks
Improve blog setup
2013-06-03 13:59:29 -07:00
Paul O’Shannessy
55a8339781 Improve blog setup
* All posts under blog/
* Index @ blog/index.html
* Only show excerpt on index with "continue reading" link
* Date, name formatting improvements (better for humans)

It could probably still use some style tweaks but I feel better about
it.

Moving forward, we'll use the "excerpt" feature of Jekyll with the
default separator, which is just 2 newlines. So the first paragraph will
be special. Alternatively you can specify excerpt, but we'll want to fix
the layout so that gets added in.
2013-06-03 13:51:44 -07:00
petehunt
a6707f158b Merge pull request #41 from divad12/homepage-examples-autobind
Consistently use autoBind on homepage examples
2013-06-03 12:53:26 -07:00
petehunt
96a5fe9e15 Merge pull request #51 from dschafer/patch-1
Highlight additional change in tutorial12.js
2013-06-03 12:51:12 -07:00
dschafer
24f523a351 Highlight additional change in tutorial12.js
tutorial12.js switches from using this.props to this.state. Let's highlight the change on line 10 as well to make that clear.
2013-06-03 13:48:14 -06:00
petehunt
065f8abfe3 Merge pull request #48 from petehunt/add-blog
Add "Why React"
2013-06-03 12:46:48 -07:00
petehunt
7b5602d00a @jeffreylin 2013-06-03 12:09:14 -07:00
Paul Shen
2bb7e15773 [docs] RSS: Pass title through xml_escape 2013-06-03 11:36:04 -07:00
Paul Shen
cb9cc5de5c [docs] Use date_to_xmlschema in feed.xml 2013-06-03 11:34:42 -07:00
petehunt
0244123a52 Break lines 2013-06-03 11:19:51 -07:00
petehunt
1897bb3d2e @vjeux @benjamn 2013-06-03 11:16:38 -07:00
Paul Shen
b353e8a807 [docs] Add RSS feed.xml for blog posts
uses `feed.xml` from https://github.com/snaptortoise/jekyll-rss-feeds
(slightly modified for `site.url` + `site.baseurl`)
2013-06-03 11:02:14 -07:00
petehunt
b3e2aca13a Add why-react 2013-06-03 11:01:08 -07:00
Ben Newman
e829f8f71f Merge pull request #1 from benjamn/run-tests-in-iframes
Run each test in its own <iframe>
2013-06-03 10:58:01 -07:00
Paul Shen
9425e58591 Merge pull request #42 from vjeux/blog
Blog article for JSFiddle Integration
2013-06-03 10:44:23 -07:00
Ben Newman
603c9ef6a8 Implement constructor-aware binding per @zpao's request.
When the function to be bound does not have a prototype, ignore the constructor case.
2013-06-03 13:20:13 -04:00
Ben Newman
906b8f3f95 Create testing <iframe>s dynamically, according to grunt config. 2013-06-03 13:20:13 -04:00
Ben Newman
6cfa71a3c2 Run each test in an <iframe>. 2013-06-03 13:20:13 -04:00
Ben Newman
42f8d155f8 Silence tests unsupported in PhantomJS.
These tests can still be run in the browser using `grunt test --debug`.
2013-06-03 13:20:13 -04:00
Ben Newman
009c0b9200 Expose test modules for requirement. 2013-06-03 13:20:13 -04:00
Ben Newman
c740373b31 Fix some silly uses of Function.prototype.bind in jasmine-support.js. 2013-06-03 13:20:13 -04:00
Ben Newman
03f92bb155 Polyfill Function.prototype.bind during tests. 2013-06-03 13:20:13 -04:00
Ben Newman
f8af93237a Use bin/jsx and browserify to build a jasmine bundle. 2013-06-03 13:20:13 -04:00
Ben Newman
83029eb756 Make the bin/jsx source and output directories configurable. 2013-06-03 13:20:13 -04:00
Paul O’Shannessy
99c577e210 Merge pull request #38 from camspiers/range-attributes
Add attributes used in input[type=range]
2013-06-03 10:19:19 -07:00
petehunt
dd92335dc4 Merge pull request #46 from jordow/ChromeInstructions
Adding instructions for chrome. (No server needed! Just execute a single...
2013-06-03 03:22:19 -07:00
jordow
8c37499af8 Adding instructions for chrome. (No server needed! Just execute a single command
line to load in Chrome).
2013-06-03 02:43:48 -07:00
petehunt
a32276e400 Fix bug in todomvc 2013-06-03 00:44:20 -07:00
petehunt
83b8ad7a31 Add TODOMVC features 2013-06-03 00:34:23 -07:00
Paul O’Shannessy
dfdf1f82ae Merge pull request #44 from vjeux/script_download
Add <script> tags in the download page for easy embed
2013-06-02 17:25:49 -07:00
Vjeux
cbda00c415 Add <script> tags in the download page for easy embed 2013-06-03 02:17:26 +02:00
Vjeux
21dab3d7d8 Add JSFiddle to the getting started section 2013-06-03 01:59:06 +02:00
Vjeux
9b399968eb Add a base link without JSX 2013-06-03 01:28:22 +02:00
Vjeux
df361e9dd6 Adding \n at the end of the files 2013-06-03 01:06:05 +02:00
Vjeux
245f501120 Adding a left menu navigation 2013-06-03 01:04:19 +02:00
Vjeux
1902eafa8d Initial version of the blog 2013-06-03 00:48:15 +02:00
David Hu
7795968382 Consistently use autoBind on homepage examples
Except for todo.js, all the other examples on the homepage use React.autoBind
when defining event handler methods.

Test Plan: Added todo items successfully
2013-06-02 12:04:16 -07:00
Cam Spiers
415192c001 Add attributes used in input[type=range] 2013-06-02 13:32:12 +12:00
Ben Alpert
580e8f0dbb Simulate input event instead of relying on native
Test Plan:
With the ballmer-peak example (modified to use input), tested that the
percentage updates when adding or deleting text in the field on Chrome
and IE9. After adding es5-shim and es5-sham to the ballmer-peak page,
IE8 works properly too.
2013-06-01 16:55:19 -07:00
petehunt
095fccb974 ReactDOM->React.DOM 2013-06-01 13:01:52 -07:00
Ben Newman
ebff2bc7a3 Merge pull request #36 from jeffreylin/master
Fix live_editor.js usage of class=
2013-06-01 06:37:55 -07:00
Jeffrey Lin
a78f752143 Fix live_editor.js usage of class= 2013-05-31 20:50:21 -07:00
Paul O’Shannessy
a70d567ec6 v0.3.2
Also some tweaks to package.json details.
2013-05-31 17:10:08 -07:00
petehunt
8d259093bf Merge pull request #34 from zpao/npm-ship-modules
Ship CJS modules instead of browserified build
2013-05-31 15:41:59 -07:00
Paul O’Shannessy
0c6bbf275b Ship CJS modules instead of browserified build
It turns out that if you try to browserify a file requiring react-tools,
it doesn't work. This is because browserify just visits the require
statements in the file and looks for files in that path.
./ReactCompositeComponent doesn't exist and that's the point that fails.
So the fix is to actually ship each of our CJS modules as individual
files like browserify expects. This should have no negative side effects
- we still only export React (though the rest of our modules are now
actually accessible, which might make it easier to do more with the
module).

The other change here is to move source-map to dependencies since it's
required in the transform code.

Test Plan:

```
$ npm pack .
$ cd /tmp
$ npm install path/to/react-tools-0.3.1.tgz
$ echo "require('react-tools')" > test.js
$ browserify test.js
```
2013-05-31 10:57:40 -07:00
petehunt
824a2e0630 Merge pull request #33 from spicyj/docs-fix
Update stale event docs in tutorial
2013-05-31 09:52:20 -07:00
Ben Newman
70a99cd1ee Merge pull request #20 from benjamn/issue-12-test-install-package
Provide `grunt npm:test` for verifying NPM package functionality
2013-05-31 07:39:42 -07:00
Ben Newman
60a6665bbd Provide grunt npm:test for verifying NPM package functionality.
This basically calls `npm pack`, installs the resulting package in a temporary directory, then requires it and attempts to use the .transform method.

Closes #12.
2013-05-31 10:35:39 -04:00
Ben Alpert
2e5dae0c25 Add return false; to onSubmit handlers 2013-05-31 01:46:55 -07:00
Jeff Morrison
2d253fe1dc Merge pull request #27 from seiffert/master
JSX Transformer / DisplayName Visitor: Multiple declarations with one `var` statement
2013-05-30 22:25:51 -07:00
petehunt
bb4788e997 Merge pull request #31 from spicyj/immutable-state
Change TodoMVC to not modify state in place
2013-05-30 22:19:59 -07:00
Paul Seiffert
510ced1d13 Removed duplicate object type check 2013-05-31 07:13:49 +02:00
Ben Alpert
767391c26e Wording tweaks 2013-05-30 20:21:44 -07:00
Ben Alpert
6e805dda24 Change TodoMVC to not modify state in place
Instead, use .concat and make a new todos array.

Test Plan:
Added todo items successfully.
2013-05-30 20:19:19 -07:00
Ben Alpert
ea82dba555 Update stale event docs in tutorial
The example uses onSubmit but the docs were still referring to onKeyUp.
2013-05-30 18:24:48 -07:00
Ben Alpert
2467c0e651 Update examples to use onInput instead of onKeyUp
onInput has the advantage that it responds to repeated key events before
onKeyUp and is called when modifying the input without the keyboard
(such as pasting with the mouse).

Test Plan:
Opened the ballmer-peak example and docs homepage in Chrome and checked
that both examples update whenever the text is changed.
2013-05-30 18:20:34 -07:00
Ben Alpert
292dd238e7 Add new onInput event
'input' is supported in IE9+ and all other browsers according to
https://developer.mozilla.org/en-US/docs/Web/API/window.oninput

Test Plan:
Modified ballmer-peak example to use onInput instead of onKeyUp and
tested that it works properly on latest Chrome.
2013-05-30 18:20:34 -07:00
Paul O’Shannessy
b20a7c2beb Bump docs version to v0.3.1 2013-05-30 15:06:46 -07:00
Paul O’Shannessy
de2832c0c0 Only re-write docs _config on version bumps
Doesn't fix, but mostly addresses the concerns in #24. Some churn at
version bumps is far better than what we have right now.
2013-05-30 14:57:32 -07:00
Paul O’Shannessy
d40704ab85 Bump to 0.3.1 2013-05-30 14:57:32 -07:00
Timothy Yung
2cde6ff60f Merge pull request #29 from petehunt/mixin-docs
[docs] Return of mixin docs
2013-05-30 14:52:43 -07:00
petehunt
f586c58f96 @yungsters 2013-05-30 14:45:22 -07:00
petehunt
84d4bbb13d bla 2013-05-30 14:23:53 -07:00
petehunt
071201e84b fixes 2013-05-30 14:22:05 -07:00
petehunt
15d8200b13 oops 2013-05-30 14:20:50 -07:00
petehunt
d73c2b23e0 Return of mixin docs 2013-05-30 14:20:50 -07:00
petehunt
a808d48169 add localstorage, oops 2013-05-30 14:19:33 -07:00
Paul O’Shannessy
6ed829ff95 Merge branch 'master' of github.com:facebook/react 2013-05-30 11:54:14 -07:00
petehunt
a52512863e Clean up todomvc examples: autoBind(), onSubmit 2013-05-30 11:53:23 -07:00
petehunt
4297b1ad55 remove unused const 2013-05-30 11:53:23 -07:00
Paul Seiffert
b03f04ff24 Fixing Bug in JSX transformer
The bug fixed by this commit prevented the correct parsing of
`var` statements with multiple variables being declared. Instead
of trying to parse a whole 'variable declarations' (a `var`
statement with all its declarations), this visitor now only
parses single 'variable declarators'.
2013-05-30 20:51:15 +02:00
Paul O’Shannessy
86eeef1ccd Update bower install command
Fixes #21
2013-05-30 11:49:57 -07:00
Timothy Yung
ce2d7991c9 Merge pull request #23 from yungsters/jsx-compiler
Add a JSX Compiler tool.
2013-05-30 11:41:24 -07:00
yungsters
5d812949a1 Ignore "docs/js/jsx-compiler.js" from Git. 2013-05-30 11:37:56 -07:00
yungsters
855c82e224 Revise 'live_editor.js' using JSX. 2013-05-30 11:31:21 -07:00
yungsters
955b472f8b Add a JSX Compiler tool. 2013-05-30 11:26:36 -07:00
petehunt
c5612b34c9 Merge pull request #19 from seiffert/submit_button
Docs/Tutorial: Introducing a submit button in the comment form
2013-05-30 11:15:40 -07:00
Paul O’Shannessy
9894e7e1fe Merge pull request #22 from yungsters/docs
[docs] Revise marketing copy around JSX.
2013-05-30 11:09:47 -07:00
Paul O’Shannessy
7dd4576ee4 Merge pull request #17 from seiffert/master
Docs/Tutorial: Highlighting the correct line
2013-05-30 10:32:42 -07:00
yungsters
5fc2aad364 [docs] Revise marketing copy around JSX. 2013-05-30 10:05:53 -07:00
Ben Newman
507ad5bac5 Prominently display Travis build status. 2013-05-30 12:57:51 -03:00
Paul Seiffert
cd665be43e Introducing a submit button in the tutorial's comment form 2013-05-30 16:54:30 +02:00
Paul Seiffert
39c4414d5a Highlighting the correct line 2013-05-30 16:22:11 +02:00
Ben Newman
a203bc5da9 Merge pull request #11 from zpao/fix-node-module
Fix react-tools module
2013-05-30 05:14:15 -07:00
petehunt
36b61d2b11 Merge pull request #14 from petehunt/marketing
Docs updates per community response
2013-05-30 04:42:48 -07:00
petehunt
2ce4530d24 make it a little less cynical 2013-05-30 04:42:11 -07:00
petehunt
84a7c2e67c Merge pull request #13 from petehunt/update-docs
add a link to my tutorial repo
2013-05-30 04:39:42 -07:00
petehunt
c7d2760521 Move backbone integration into its own mixin 2013-05-30 04:35:42 -07:00
petehunt
875782cc0a sync more with backbone 2013-05-30 04:18:40 -07:00
petehunt
036e11c9ee more backbone fixes 2013-05-30 04:11:07 -07:00
petehunt
b4c0661dce Make more idiomatic 2013-05-30 03:38:42 -07:00
petehunt
56dbec46db Fix backbone todomvc example 2013-05-30 03:35:45 -07:00
petehunt
cfe3b75cb0 Docs updates per community response 2013-05-30 01:16:15 -07:00
petehunt
9415d839a5 add a link to my tutorial repo 2013-05-29 22:41:28 -07:00
Paul O’Shannessy
4f7380c4d7 Fix react-tools module
I messed this up pretty badly and didn't include react *at all*.

Test Plan: npm pack && npm install <packed.tgz>, then require('react-tools')`
2013-05-29 21:20:04 -07:00
Paul O’Shannessy
fd321cf07d Merge pull request #9 from chroman/master
Fix minor typo error
2013-05-29 16:40:07 -07:00
Paul O’Shannessy
12e1bb1daa Add grunt-cli to devDependencies to make sure it's installed for travisci 2013-05-29 16:17:49 -07:00
Christian Roman
a8866ab824 Fix minor typo error 2013-05-29 18:16:52 -05:00
Paul O’Shannessy
7534bfe2d9 Enable Travis-CI 2013-05-29 15:34:52 -07:00
461 changed files with 58041 additions and 1 deletions

12
.editorconfig Normal file
View File

@@ -0,0 +1,12 @@
# http://editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false

25
.gitignore vendored Normal file
View File

@@ -0,0 +1,25 @@
.DS_STORE
node_modules
*~
*.pyc
static
.grunt
_SpecRunner.html
__benchmarks__
build/
.module-cache
*.gem
docs/code
docs/_site
docs/.sass-cache
docs/css/react.css
docs/js/.module-cache
docs/js/JSXTransformer.js
docs/js/react.min.js
docs/js/docs.js
docs/js/jsx-compiler.js
docs/js/live_editor.js
docs/js/examples
docs/downloads
examples/shared/*.js

20
.jshintrc Normal file
View File

@@ -0,0 +1,20 @@
{
"node": true,
"boss": true,
"curly": true,
"devel": true,
"eqnull": true,
"expr": true,
"funcscope": true,
"globalstrict": true,
"loopfunc": true,
"newcap": false,
"noempty": true,
"nonstandard": true,
"onecase": true,
"regexdash": true,
"trailing": true,
"undef": true,
"unused": "vars"
}

21
.mailmap Normal file
View File

@@ -0,0 +1,21 @@
Ben Newman <bn@cs.stanford.edu> <benjamn@fb.com>
Dan Schafer <dschafer@fb.com>
Harry Hull <harry.hull1@gmail.com>
Jeff Morrison <jeff@anafx.com> <Jeff@anafx.com>
Jeff Morrison <jeff@anafx.com> JeffMo <jeffmo@fb.com>
Jeffrey Lin <lin.jeffrey@gmail.com> <jeffreylin@fb.com>
Jordan Walke <jordojw@gmail.com>
Jordan Walke <jordojw@gmail.com> <jordanjcw@fb.com>
Laurence Rowe <l@lrowe.co.uk> <laurence@lrowe.co.uk>
Nick Gavalas <njg57@cornell.edu>
Paul OShannessy <paul@oshannessy.com> <poshannessy@fb.com>
Paul Shen <paul@mnml0.com> <paulshen@fb.com>
Pete Hunt <floydophone@gmail.com>
Pete Hunt <floydophone@gmail.com> <pete.hunt@fb.com>
Pete Hunt <floydophone@gmail.com> <pete@instagram.com>
Sander Spies <sandermail@gmail.com>
Sebastian Markbåge <sebastian@calyptus.eu> <sema@fb.com>
Stoyan Stefanov <ssttoo@ymail.com>
Timothy Yung <yungsters@gmail.com> <yungsters@fb.com>
Vjeux <vjeuxx@gmail.com>
Vjeux <vjeuxx@gmail.com> <vjeux@fb.com>

15
.travis.yml Normal file
View File

@@ -0,0 +1,15 @@
---
language: node_js
node_js:
- '0.10'
after_script:
- curl -F "react=@build/react.js" -F "react.min=@build/react.min.js" -F "transformer=@build/JSXTransformer.js"
-F "react-with-addons=@build/react-with-addons.js" -F "react-with-addons.min=@build/react-with-addons.min.js"
-F "commit=$TRAVIS_COMMIT" -F "date=`git log --format='%ct' -1`" -F "pull_request=$TRAVIS_PULL_REQUEST"
-F "token=$SECRET_TOKEN" -F "branch=$TRAVIS_BRANCH" $SERVER
env:
global:
# SERVER
- secure: qPvsJ46XzGrdIuPA70b55xQNGF8jcK7N1LN5CCQYYocXLa+fBrl+fTE77QvehOPhqwJXcj6kOxI+sY0KrVwV7gmq2XY2HZGWUSCxTN0SZlNIzqPA80Y7G/yOjA4PUt8LKgP+8tptyhTAY56qf+hgW8BoLiKOdztYF2p+3zXOLuA=
# SECRET_TOKEN
- secure: dkpPW+VnoqC/okhRdV90m36NcyBFhcwEKL3bNFExAwi0dXnFao8RoFlvnwiPlA23h2faROkMIetXlti6Aju08BgUFV+f9aL6vLyU7gUent4Nd3413zf2fwDtXIWIETg6uLnOpSykGKgCAT/hY3Q2oPLqOoY0OxfgnbqwxkxljrE=

50
AUTHORS Normal file
View File

@@ -0,0 +1,50 @@
Alexander Solovyov <alexander@solovyov.net>
Andrew Zich <azich@fb.com>
Andrey Popp <8mayday@gmail.com>
Ben Alpert <spicyjalapeno@gmail.com>
Ben Newman <bn@cs.stanford.edu>
Brian Rue <brian@rollbar.com>
Cam Spiers <camspiers@gmail.com>
Cat Chen <catchen@fb.com>
Cheng Lou <chenglou92@gmail.com>
Christian Roman <chroman16@gmail.com>
Clay Allsopp <clay.allsopp@gmail.com>
Connor McSheffrey <connor.mcsheffrey@gmail.com>
Dan Schafer <dschafer@fb.com>
Daniel Gasienica <dgasienica@zynga.com>
Daniel Miladinov <dmiladinov@wingspan.com>
Danny Ben-David <dannybd@fb.com>
David Hu <davidhu91@gmail.com>
Eric Clemmons <eric@smarterspam.com>
Greg Roodt <groodt@gmail.com>
Harry Hull <harry.hull1@gmail.com>
Hugo Jobling <me@thisishugo.com>
Ian Obermiller <iano@fb.com>
Isaac Salier-Hellendag <isaac@fb.com>
Jakub Malinowski <jakubmal@gmail.com>
James Ide <ide@fb.com>
Jamie Wong <jamie.lf.wong@gmail.com>
Jan Kassens <jkassens@fb.com>
Jeff Morrison <jeff@anafx.com>
Jeffrey Lin <lin.jeffrey@gmail.com>
Jordan Walke <jordojw@gmail.com>
Josh Duck <josh@fb.com>
Keito Uchiyama <keito@fb.com>
Kunal Mehta <k.mehta@berkeley.edu>
Laurence Rowe <l@lrowe.co.uk>
Marshall Roch <mroch@fb.com>
Martin Konicek <mkonicek@fb.com>
Mathieu M-Gosselin <mathieumg@gmail.com>
Nick Gavalas <njg57@cornell.edu>
Owen Coutts <owenc@fb.com>
Paul OShannessy <paul@oshannessy.com>
Paul Seiffert <paul.seiffert@gmail.com>
Paul Shen <paul@mnml0.com>
Pete Hunt <floydophone@gmail.com>
Peter Cottle <pcottle@fb.com>
Sander Spies <sandermail@gmail.com>
Sebastian Markbåge <sebastian@calyptus.eu>
Stoyan Stefanov <ssttoo@ymail.com>
Timothy Yung <yungsters@gmail.com>
Vjeux <vjeuxx@gmail.com>
Zach Bruggeman <zbruggeman@me.com>

131
CHANGELOG.md Normal file
View File

@@ -0,0 +1,131 @@
## 0.5.1 (October 29, 2013)
### React
* Fixed bug with `<input type="range">` and selection events.
* Fixed bug with selection and focus.
* Made it possible to unmount components from the document root.
* Fixed bug for `disabled` attribute handling on non-`<input>` elements.
### React with Addons
* Fixed bug with transition and animation event detection.
## 0.5.0 (October 16, 2013)
### React
* Memory usage improvements - reduced allocations in core which will help with GC pauses
* Performance improvements - in addition to speeding things up, we made some tweaks to stay out of slow path code in V8 and Nitro.
* Standardized prop -> DOM attribute process. This previously resulting in additional type checking and overhead as well as confusing cases for users. Now we will always convert your value to a string before inserting it into the DOM.
* Support for Selection events.
* Support for [Composition events](https://developer.mozilla.org/en-US/docs/Web/API/CompositionEvent).
* Support for additional DOM properties (`charSet`, `content`, `form`, `httpEquiv`, `rowSpan`, `autoCapitalize`).
* Support for additional SVG properties (`rx`, `ry`).
* Support for using `getInitialState` and `getDefaultProps` in mixins.
* Support mounting into iframes.
* Bug fixes for controlled form components.
* Bug fixes for SVG element creation.
* Added `React.version`.
* Added `React.isValidClass` - Used to determine if a value is a valid component constructor.
* Removed `React.autoBind` - This was deprecated in v0.4 and now properly removed.
* Renamed `React.unmountAndReleaseReactRootNode` to `React.unmountComponentAtNode`.
* Began laying down work for refined performance analysis.
* Better support for server-side rendering - [react-page](https://github.com/facebook/react-page) has helped improve the stability for server-side rendering.
* Made it possible to use React in environments enforcing a strict [Content Security Policy](https://developer.mozilla.org/en-US/docs/Security/CSP/Introducing_Content_Security_Policy). This also makes it possible to use React to build Chrome extensions.
### React with Addons (New!)
* Introduced a separate build with several "addons" which we think can help improve the React experience. We plan to deprecate this in the long-term, instead shipping each as standalone pieces. [Read more in the docs](http://facebook.github.io/react/docs/addons.html).
### JSX
* No longer transform `class` to `className` as part of the transform! This is a breaking change - if you were using `class`, you *must* change this to `className` or your components will be visually broken.
* Added warnings to the in-browser transformer to make it clear it is not intended for production use.
* Improved compatibility for Windows
* Improved support for maintaining line numbers when transforming.
## 0.4.1 (July 26, 2013)
### React
* `setState` callbacks are now executed in the scope of your component.
* `click` events now work on Mobile Safari.
* Prevent a potential error in event handling if `Object.prototype` is extended.
* Don't set DOM attributes to the string `"undefined"` on update when previously defined.
* Improved support for `<iframe>` attributes.
* Added checksums to detect and correct cases where server-side rendering markup mismatches what React expects client-side.
### JSXTransformer
* Improved environment detection so it can be run in a non-browser environment.
## 0.4.0 (July 17, 2013)
### React
* Switch from using `id` attribute to `data-reactid` to track DOM nodes. This allows you to integrate with other JS and CSS libraries more easily.
* Support for more DOM elements and attributes (e.g., `<canvas>`)
* Improved server-side rendering APIs. `React.renderComponentToString(<component>, callback)` allows you to use React on the server and generate markup which can be sent down to the browser.
* `prop` improvements: validation and default values. [Read our blog post for details...](http://facebook.github.io/react/blog/2013/07/11/react-v0-4-prop-validation-and-default-values.html)
* Support for the `key` prop, which allows for finer control over reconciliation. [Read the docs for details...](http://facebook.github.io/react/docs/multiple-components.html)
* Removed `React.autoBind`. [Read our blog post for details...](http://facebook.github.io/react/blog/2013/07/02/react-v0-4-autobind-by-default.html)
* Improvements to forms. We've written wrappers around `<input>`, `<textarea>`, `<option>`, and `<select>` in order to standardize many inconsistencies in browser implementations. This includes support for `defaultValue`, and improved implementation of the `onChange` event, and circuit completion. [Read the docs for details...](http://facebook.github.io/react/docs/forms.html)
* We've implemented an improved synthetic event system that conforms to the W3C spec.
* Updates to your component are batched now, which may result in a significantly faster re-render of components. `this.setState` now takes an optional callback as it's second parameter. If you were using `onClick={this.setState.bind(this, state)}` previously, you'll want to make sure you add a third parameter so that the event is not treated as the callback.
### JSX
* Support for comment nodes `<div>{/* this is a comment and won't be rendered */}</div>`
* Children are now transformed directly into arguments instead of being wrapped in an array
E.g. `<div><Component1/><Component2/></div>` is transformed into `React.DOM.div(null, Component1(null), Component2(null))`.
Previously this would be transformed into `React.DOM.div(null, [Component1(null), Component2(null)])`.
If you were using React without JSX previously, your code should still work.
### react-tools
* Fixed a number of bugs when transforming directories
* No longer re-write `require()`s to be relative unless specified
## 0.3.3 (June 20, 2013)
### React
* Allow reusing the same DOM node to render different components. e.g. `React.renderComponent(<div/>, domNode); React.renderComponent(<span/>, domNode);` will work now.
### JSX
* Improved the in-browser transformer so that transformed scripts will execute in the expected scope. The allows components to be defined and used from separate files.
### react-tools
* Upgrade Commoner so `require` statements are no longer relativized when passing through the transformer. This was a feature needed when building React, but doesn't translate well for other consumers of `bin/jsx`.
* Upgraded our dependencies on Commoner and Recast so they use a different directory for their cache.
* Freeze our esprima dependency.
## 0.3.2 (May 31, 2013)
### JSX
* Improved compatability with other coding styles (specifically, multiple assignments with a single `var`).
### react-tools
* Switch from using the browserified build to shipping individual modules. This allows react-tools to be used with [browserify](https://github.com/substack/node-browserify).
## 0.3.1 (May 30, 2013)
### react-tools
* Fix bug in packaging resulting in broken module.
## 0.3.0 (May 29, 2013)
* Initial public release

1
CNAME
View File

@@ -1 +0,0 @@
legacy.reactjs.org

63
CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,63 @@
# Contributing to React
React is one of Facebook's first open source projects that is both under very active development and is also being used to ship code to everybody on facebook.com. We're still working out the kinks to make contributing to this project as easy and transparent as possible, but we're not quite there yet. Hopefully this document makes the process for contributing clear and preempts some questions you may have.
## Our Development Process
Some of the core team will be working directly on GitHub. These changes will be public from the beginning. Other changesets will come via a bridge with Facebook's internal source control. This is a necessity as it allows engineers at Facebook outside of the core team to move fast and contribute from an environment they are comfortable in.
### `master` is unsafe
We will do our best to keep `master` in good shape, with tests passing at all times. But in order to move fast, we will make API changes that your application might not be compatible with. We will do our best to communicate these changes and always version appropriately so you can lock into a specific version if need be.
### Pull Requests
The core team will be monitoring for pull requests. When we get one, we'll run some Facebook-specific integration tests on it first. From here, we'll need to get another person to sign off on the changes and then merge the pull request. For API changes we may need to fix internal uses, which could cause some delay. We'll do our best to provide updates and feedback throughout the process.
*Before* submitting a pull request, please make sure the following is done…
1. Fork the repo and create your branch from `master`.
2. If you've added code that should be tested, add tests!
3. If you've changed APIs, update the documentation.
4. Ensure the test suite passes (`grunt test`).
5. Make sure your code lints (`grunt lint`) - we've done our best to make sure these rules match our internal linting guidelines.
6. If you haven't already, complete the CLA.
### Contributor License Agreement ("CLA")
In order to accept your pull request, we need you to submit a CLA. You only need to do this once, so if you've done this for another Facebook open source project, you're good to go. If you are submitting a pull request for the first time, just let us know that you have completed the CLA and we can cross-check with your GitHub username.
Complete your CLA here: <https://developers.facebook.com/opensource/cla>
## Bugs
### Where to Find Known Issues
We will be using GitHub Issues for our public bugs. We will keep a close eye on this and try to make it clear when we have an internal fix in progress. Before filing a new task, try to make sure your problem doesn't already exist.
### Reporting New Issues
The best way to get your bug fixed is to provide a reduced test case. jsFiddle, jsBin, and other sites provide a way to give live examples. Those are especially helpful though may not work for `JSX`-based code.
### Security Bugs
Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe disclosure of security bugs. With that in mind, please do not file public issues and go through the process outlined on that page.
## How to Get in Touch
* IRC - [#reactjs on freenode](http://webchat.freenode.net/?channels=reactjs)
* Mailing list - [reactjs on Google Groups](http://groups.google.com/group/reactjs)
## Coding Style
* Use semicolons;
* Commas last,
* 2 spaces for indentation (no tabs)
* Prefer `'` over `"`
* `"use strict";`
* 80 character line length
* "Attractive"
## License
By contributing to React, you agree that your contributions will be licensed under the [Apache License Version 2.0 (APLv2)](LICENSE).

130
Gruntfile.js Normal file
View File

@@ -0,0 +1,130 @@
'use strict';
var exec = require('child_process').exec;
var jsxTask = require('./grunt/tasks/jsx');
var browserifyTask = require('./grunt/tasks/browserify');
var wrapupTask = require('./grunt/tasks/wrapup');
var populistTask = require('./grunt/tasks/populist');
var phantomTask = require('./grunt/tasks/phantom');
var npmTask = require('./grunt/tasks/npm');
var releaseTasks = require('./grunt/tasks/release');
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
copy: require('./grunt/config/copy'),
jsx: require('./grunt/config/jsx/jsx'),
browserify: require('./grunt/config/browserify'),
wrapup: require('./grunt/config/wrapup'),
populist: require('./grunt/config/populist'),
phantom: require('./grunt/config/phantom'),
npm: require('./grunt/config/npm'),
clean: ['./build', './*.gem', './docs/_site', './examples/shared/*.js'],
jshint: require('./grunt/config/jshint'),
compare_size: require('./grunt/config/compare_size')
});
grunt.config.set('compress', require('./grunt/config/compress'));
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-compare-size');
grunt.loadNpmTasks('grunt-contrib-compress');
// Alias 'jshint' to 'lint' to better match the workflow we know
grunt.registerTask('lint', ['jshint']);
// Register jsx:debug and :release tasks.
grunt.registerMultiTask('jsx', jsxTask);
// Our own browserify-based tasks to build a single JS file build
grunt.registerMultiTask('browserify', browserifyTask);
// Similar to Browserify, use WrapUp to generate single JS file that
// defines global variables instead of using require.
grunt.registerMultiTask('wrapup', wrapupTask);
grunt.registerMultiTask('populist', populistTask);
grunt.registerMultiTask('phantom', phantomTask);
grunt.registerMultiTask('npm', npmTask);
// Check that the version we're exporting is the same one we expect in the
// package. This is not an ideal way to do this, but makes sure that we keep
// them in sync.
var reactVersionExp = /\bReact\.version\s*=\s*['"]([^'"]+)['"];/;
grunt.registerTask('version-check', function() {
var version = reactVersionExp.exec(
grunt.file.read('./build/modules/React.js')
)[1];
var expectedVersion = grunt.config.data.pkg.version;
if (version !== expectedVersion) {
grunt.log.error('Versions do not match. Expected %s, saw %s', expectedVersion, version);
return false;
}
});
grunt.registerTask('build:basic', ['jsx:debug', 'version-check', 'browserify:basic']);
grunt.registerTask('build:addons', ['jsx:debug', 'browserify:addons']);
grunt.registerTask('build:transformer', ['jsx:debug', 'browserify:transformer']);
grunt.registerTask('build:min', ['jsx:release', 'version-check', 'browserify:min']);
grunt.registerTask('build:addons-min', ['jsx:debug', 'browserify:addonsMin']);
grunt.registerTask('build:test', [
'jsx:jasmine',
'jsx:test',
'version-check',
'populist:jasmine',
'populist:test'
]);
grunt.registerTask('test', ['build:test', 'build:basic', 'phantom:run']);
grunt.registerTask('npm:test', ['build', 'npm:pack']);
// Optimized build task that does all of our builds. The subtasks will be run
// in order so we can take advantage of that and only run jsx:debug once.
grunt.registerTask('build', [
'jsx:debug',
'version-check',
'browserify:basic',
'browserify:transformer',
'browserify:addons',
'jsx:release',
'browserify:min',
'browserify:addonsMin',
'copy:react_docs',
'compare_size'
]);
// Automate the release!
grunt.registerTask('release:setup', releaseTasks.setup);
grunt.registerTask('release:bower', releaseTasks.bower);
grunt.registerTask('release:docs', releaseTasks.docs);
grunt.registerTask('release:msg', releaseTasks.msg);
grunt.registerTask('release:starter', releaseTasks.starter);
grunt.registerTask('release', [
'release:setup',
'clean',
'build',
'gem:only',
'release:bower',
'release:starter',
'compress',
'release:docs',
'release:msg'
]);
// `gem` task to build the react-source gem
grunt.registerTask('gem', ['build', 'gem:only']);
grunt.registerTask('gem:only', function() {
var done = this.async();
exec('gem build react-source.gemspec', done);
});
// The default task - build - to keep setup easy
grunt.registerTask('default', ['build']);
};

201
LICENSE Normal file
View File

@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

96
README.md Normal file
View File

@@ -0,0 +1,96 @@
# [React](http://facebook.github.io/react) [![Build Status](https://travis-ci.org/facebook/react.png?branch=master)](https://travis-ci.org/facebook/react)
React is a JavaScript library for building user interfaces.
* **Declarative:** React uses a declarative paradigm that makes it easier to reason about your application.
* **Efficient:** React computes the minimal set of changes necessary to keep your DOM up-to-date.
* **Flexible:** React works with the libraries and frameworks that you already know.
[Learn how to use React in your own project.](http://facebook.github.io/react/docs/getting-started.html)
## Examples
We have several examples [on the website](http://facebook.github.io/react). Here is the first one to get you started:
```js
/** @jsx React.DOM */
var HelloMessage = React.createClass({
render: function() {
return <div>{'Hello ' + this.props.name}</div>;
}
});
React.renderComponent(
<HelloMessage name="John" />,
document.getElementById('container')
);
```
This example will render "Hello John" into a container on the page.
You'll notice that we used an XML-like syntax; [we call it JSX](http://facebook.github.io/react/docs/jsx-in-depth.html). JSX is not required to use React, but it makes code more readable, and writing it feels like writing HTML. A simple transform is included with React that allows converting JSX into native JavaScript for browsers to digest.
## Installation
The fastest way to get started is to serve JavaScript from the CDN (also available on [CDNJS](http://cdnjs.com/#react)):
```html
<!-- The core React library -->
<script src="http://fb.me/react-0.5.1.js"></script>
<!-- In-browser JSX transformer, remove when pre-compiling JSX. -->
<script src="http://fb.me/JSXTransformer-0.5.1.js"></script>
```
We've also built a [starter kit](http://facebook.github.io/react/downloads/react-0.5.1.zip) which might be useful if this is your first time using React. It includes a webpage with an example of using React with live code.
If you'd like to use [bower](http://bower.io), it's as easy as:
```sh
bower install --save react
```
## Contribute
The main purpose of this repository is to continue to evolve React core, making it faster and easier to use. If you're interested in helping with that, then keep reading. If you're not interested in helping right now that's ok too :) Any feedback you have about using React would be greatly appreciated.
### Building Your Copy of React
The process to build `react.js` is built entirely on top of node.js, using many libraries you may already be familiar with.
#### Prerequisites
* You have `node` installed at v0.10.0+ (it might work at lower versions, we just haven't tested).
* You are familiar with `npm` and know whether or not you need to use `sudo` when installing packages globally.
* You are familiar with `git`.
#### Build
Once you have the repository cloned, building a copy of `react.js` is really easy.
```sh
# grunt-cli is needed by grunt; you might have this installed already
npm install -g grunt-cli
npm install
grunt build
```
At this point, you should now have a `build/` directory populated with everything you need to use React. The examples should all work.
### Grunt
We use grunt to automate many tasks. Run `grunt -h` to see a mostly complete listing. The important ones to know:
```sh
# Create test build & run tests with PhantomJS
grunt test
# Lint the core library code with JSHint
grunt lint
# Lint package code
grunt lint:package
# Wipe out build directory
grunt clean
```
### More…
There's only so much we can cram in here. To read more about the community and guidelines for submitting pull requests, please read the [Contributing document](CONTRIBUTING.md).

12
bin/jsx Executable file
View File

@@ -0,0 +1,12 @@
#!/usr/bin/env node
"use strict";
var visitors = require('../vendor/fbtransform/visitors').transformVisitors;
var transform = require('jstransform').transform;
require("commoner").resolve(function(id) {
return this.readModuleP(id);
}).process(function(id, source) {
// This is where JSX, ES6, etc. desugaring happens.
return transform(visitors.react, source).code;
});

55
bin/jsx-internal Executable file
View File

@@ -0,0 +1,55 @@
#!/usr/bin/env node
"use strict";
var visitors = require('../vendor/fbtransform/visitors').transformVisitors;
var transform = require('jstransform').transform;
var propagate = require("../vendor/constants").propagate;
require("commoner").resolve(function(id) {
var context = this;
// Note that the result of context.getProvidedP() is cached for the
// duration of the build, so it is both consistent and cheap to
// evaluate multiple times.
return context.getProvidedP().then(function(idToPath) {
// If a module declares its own identifier using @providesModule
// then that identifier will be a key in the idToPath object.
if (idToPath.hasOwnProperty(id)) {
return context.readFileP(idToPath[id]);
}
// Otherwise assume the identifier maps directly to a path in the
// filesystem.
return context.readModuleP(id);
});
}).process(function(id, source) {
var context = this;
var constants = context.config.constants || {};
// This is where JSX, ES6, etc. desugaring happens.
source = transform(visitors.react, source).code;
// Constant propagation means removing any obviously dead code after
// replacing constant expressions with literal (boolean) values.
source = propagate(constants, source);
if (context.config.mocking) {
// Make sure there is exactly one newline at the end of the module.
source = source.replace(/\s+$/m, "\n");
return context.getProvidedP().then(function(idToPath) {
if (id !== "mock-modules" &&
id !== "mocks" &&
id !== "test/all" &&
idToPath.hasOwnProperty("mock-modules")) {
return source + '\nrequire("mock-modules").register(' +
JSON.stringify(id) + ', module);\n';
}
return source;
});
}
return source;
});

21
docs/Gemfile Normal file
View File

@@ -0,0 +1,21 @@
source 'https://rubygems.org'
gem 'rake'
# jekyll, which builds it all
gem 'jekyll', '~>1.0'
# JSON
gem 'json'
# SASS for CSS
gem 'sass'
# For `rake watch`
gem 'rb-fsevent'
# Redcarpet for Markdown
gem 'redcarpet'
# For markdown header cleanup
gem 'sanitize'

54
docs/Gemfile.lock Normal file
View File

@@ -0,0 +1,54 @@
GEM
remote: https://rubygems.org/
specs:
classifier (1.3.3)
fast-stemmer (>= 1.0.0)
colorator (0.1)
commander (4.1.3)
highline (~> 1.6.11)
directory_watcher (1.4.1)
fast-stemmer (1.0.2)
highline (1.6.19)
jekyll (1.0.2)
classifier (~> 1.3)
colorator (~> 0.1)
commander (~> 4.1.3)
directory_watcher (~> 1.4.1)
kramdown (~> 1.0.2)
liquid (~> 2.3)
maruku (~> 0.5)
pygments.rb (~> 0.5.0)
safe_yaml (~> 0.7.0)
json (1.8.0)
kramdown (1.0.2)
liquid (2.5.0)
maruku (0.6.1)
syntax (>= 1.0.0)
mini_portile (0.5.1)
nokogiri (1.6.0)
mini_portile (~> 0.5.0)
posix-spawn (0.3.6)
pygments.rb (0.5.0)
posix-spawn (~> 0.3.6)
yajl-ruby (~> 1.1.0)
rake (10.0.4)
rb-fsevent (0.9.3)
redcarpet (2.2.2)
safe_yaml (0.7.1)
sanitize (2.0.6)
nokogiri (>= 1.4.4)
sass (3.2.9)
syntax (1.0.0)
yajl-ruby (1.1.0)
PLATFORMS
ruby
DEPENDENCIES
jekyll (~> 1.0)
json
rake
rb-fsevent
redcarpet
sanitize
sass

61
docs/README.md Normal file
View File

@@ -0,0 +1,61 @@
# React Documentation & Website
We use [Jekyll](http://jekyllrb.com/) to build the site using ([mostly](http://zpao.com/posts/adding-line-highlights-to-markdown-code-fences/)) Markdown, and we host it by pushing HTML to [GitHub Pages](http://pages.github.com/).
## Installation
If you are working on the site, you will want to install and run a local copy of it.
### Dependencies
In order to use Jekyll, you will need to have Ruby installed.
- [Ruby](http://www.ruby-lang.org/) (version >= 1.8.7)
- [RubyGems](http://rubygems.org/) (version >= 1.3.7)
- [Bundler](http://gembundler.com/)
Mac OS X comes pre-installed with Ruby, but you may need to update RubyGems (via `gem update --system`).
Otherwise, [RVM](https://rvm.io/) and [rbenv](https://github.com/sstephenson/rbenv) are popular ways to install Ruby.
Once you have RubyGems and installed Bundler (via `gem install bundler`), use it to install the dependencies:
```sh
$ cd react/docs
$ bundle install # Might need sudo.
```
### Instructions
The site requires React, so first make sure you've built the project (via `grunt`).
Use Jekyll to serve the website locally (by default, at `http://localhost:4000`):
```sh
$ cd react/docs
$ rake
$ jekyll serve -w
$ open http://localhost:4000/react/
```
We use [SASS](http://sass-lang.com/) (with [Bourbon](http://bourbon.io/)) for our CSS, and we use JSX to transform some of our JS.
If you only want to modify the HTML or Markdown, you do not have to do anything because we package pre-compiled copies of the CSS and JS.
If you want to modify the CSS or JS, use [Rake](http://rake.rubyforge.org/) to compile them:
```sh
$ cd react/docs
$ rake watch # Automatically compiles as needed.
# rake Manually compile CSS and JS.
# rake css Manually compile CSS, only.
# rake js Manually compile JS, only.
```
## Afterthoughts
### Updating `facebook.github.io/react`
The easiest way to do this is to have a separate clone of this repository, checked out to the `gh-pages` branch. We have a build step that expects this to be in a directory named `react-gh-pages` at the same depth as `react`. Then it's just a matter of running `grunt docs`, which will compile the site and copy it out to this repository. From there you can check it in.
**Note:** This should only be done for new releases. You should create a tag corresponding to the relase tag in the main repository.
### Removing the Jekyll / Ruby Dependency
In an ideal world, we would not be adding a Ruby dependency on part of our project. We would like to move towards a point where we are using React to render the website.

37
docs/Rakefile Normal file
View File

@@ -0,0 +1,37 @@
require('rubygems')
require('json')
require('yaml')
desc "generate css from sass"
task :css do
system "sass --style=compressed _css/react.scss css/react.css"
end
desc "generate js from jsx"
task :js do
system "../bin/jsx _js js"
end
desc "watch css & js"
task :watch do
Process.spawn "sass --style=compressed --watch _css/react.scss:css/react.css"
Process.spawn "../bin/jsx --watch _js js"
Process.waitall
end
desc "update version to match ../package.json"
task :update_version do
react_version = JSON.parse(File.read('../package.json'))['version']
site_config = YAML.load_file('_config.yml')
if site_config['react_version'] != react_version
site_config['react_version'] = react_version
File.open('_config.yml', 'w+') { |f| f.write(site_config.to_yaml) }
end
end
desc "build into ../../react-gh-pages"
task :release => [:update_version, :default] do
system "jekyll build -d ../../react-gh-pages"
end
task :default => [:css, :js]

71
docs/_config.yml Normal file
View File

@@ -0,0 +1,71 @@
---
baseurl: /react
url: http://facebook.github.io
permalink: /blog/:year/:month/:day/:title.html
exclude:
- Gemfile
- Gemfile.lock
- README.md
- Rakefile
redcarpet:
extensions:
- fenced_code_blocks
pygments: true
name: React
markdown: redcarpet
react_version: 0.5.1
description: A JavaScript library for building user interfaces
relative_permalinks: true
paginate: 5
paginate_path: /blog/page:num
nav_docs_sections:
- title: Quick Start
items:
- id: getting-started
title: Getting Started
- id: tutorial
title: Tutorial
- title: Guides
items:
- id: why-react
title: Why React?
- id: displaying-data
title: Displaying Data
subitems:
- id: jsx-in-depth
title: JSX in Depth
- id: jsx-gotchas
title: JSX Gotchas
- id: interactivity-and-dynamic-uis
title: Interactivity and Dynamic UIs
- id: multiple-components
title: Multiple Components
- id: reusable-components
title: Reusable Components
- id: forms
title: Forms
- id: working-with-the-browser
title: Working With the Browser
subitems:
- id: more-about-refs
title: More About Refs
- id: tooling-integration
title: Tooling Integration
- id: addons
title: Add-ons
- id: examples
title: Examples
- title: Reference
items:
- id: top-level-api
title: Top-Level API
- id: component-api
title: Component API
- id: component-specs
title: Component Specs and Lifecycle
- id: tags-and-attributes
title: Supported Tags and Attributes
- id: events
title: Event System
- id: dom-differences
title: DOM Differences

173
docs/_css/_solarized.scss Normal file
View File

@@ -0,0 +1,173 @@
html * {
color-profile: sRGB;
rendering-intent: auto;
}
.cm-s-solarized-light {
background-color: #f8f5ec;
color: #637c84;
}
.cm-s-solarized-light .emphasis {
font-weight: bold;
}
.cm-s-solarized-light .dotted {
border-bottom: 1px dotted #cb4b16;
}
.cm-s-solarized-light .CodeMirror-gutter {
background-color: #eee8d5;
border-right: 3px solid #eee8d5;
}
.cm-s-solarized-light .CodeMirror-gutter .CodeMirror-gutter-text {
color: #93a1a1;
}
.cm-s-solarized-light .CodeMirror-cursor {
border-left-color: #002b36 !important;
}
.cm-s-solarized-light .CodeMirror-matchingbracket {
color: #002b36;
background-color: #eee8d5;
box-shadow: 0 0 10px #eee8d5;
font-weight: bold;
}
.cm-s-solarized-light .CodeMirror-nonmatchingbracket {
color: #002b36;
background-color: #eee8d5;
box-shadow: 0 0 10px #eee8d5;
font-weight: bold;
color: #dc322f;
border-bottom: 1px dotted #cb4b16;
}
.cm-s-solarized-light span.cm-keyword {
color: #268bd2;
}
.cm-s-solarized-light span.cm-atom {
color: #2aa198;
}
.cm-s-solarized-light span.cm-number {
color: #586e75;
}
.cm-s-solarized-light span.cm-def {
color: #637c84;
}
.cm-s-solarized-light span.cm-variable {
color: #637c84;
}
.cm-s-solarized-light span.cm-variable-2 {
color: #b58900;
}
.cm-s-solarized-light span.cm-variable-3 {
color: #cb4b16;
}
.cm-s-solarized-light span.cm-comment {
color: #93a1a1;
}
.cm-s-solarized-light span.cm-property {
color: #637c84;
}
.cm-s-solarized-light span.cm-operator {
color: #657b83;
}
.cm-s-solarized-light span.cm-string {
color: #36958e;
}
.cm-s-solarized-light span.cm-error {
font-weight: bold;
border-bottom: 1px dotted #cb4b16;
}
.cm-s-solarized-light span.cm-bracket {
color: #cb4b16;
}
.cm-s-solarized-light span.cm-tag {
color: #657b83;
}
.cm-s-solarized-light span.cm-attribute {
color: #586e75;
font-weight: bold;
}
.cm-s-solarized-light span.cm-meta {
color: #268bd2;
}
.cm-s-solarized-dark {
background-color: #002b36;
color: #839496;
}
.cm-s-solarized-dark .emphasis {
font-weight: bold;
}
.cm-s-solarized-dark .dotted {
border-bottom: 1px dotted #cb4b16;
}
.cm-s-solarized-dark .CodeMirror-gutter {
background-color: #073642;
border-right: 3px solid #073642;
}
.cm-s-solarized-dark .CodeMirror-gutter .CodeMirror-gutter-text {
color: #586e75;
}
.cm-s-solarized-dark .CodeMirror-cursor {
border-left-color: #fdf6e3 !important;
}
.cm-s-solarized-dark .CodeMirror-matchingbracket {
color: #fdf6e3;
background-color: #073642;
box-shadow: 0 0 10px #073642;
font-weight: bold;
}
.cm-s-solarized-dark .CodeMirror-nonmatchingbracket {
color: #fdf6e3;
background-color: #073642;
box-shadow: 0 0 10px #073642;
font-weight: bold;
color: #dc322f;
border-bottom: 1px dotted #cb4b16;
}
.cm-s-solarized-dark span.cm-keyword {
color: #839496;
font-weight: bold;
}
.cm-s-solarized-dark span.cm-atom {
color: #2aa198;
}
.cm-s-solarized-dark span.cm-number {
color: #93a1a1;
}
.cm-s-solarized-dark span.cm-def {
color: #268bd2;
}
.cm-s-solarized-dark span.cm-variable {
color: #cb4b16;
}
.cm-s-solarized-dark span.cm-variable-2 {
color: #cb4b16;
}
.cm-s-solarized-dark span.cm-variable-3 {
color: #cb4b16;
}
.cm-s-solarized-dark span.cm-comment {
color: #586e75;
}
.cm-s-solarized-dark span.cm-property {
color: #b58900;
}
.cm-s-solarized-dark span.cm-operator {
color: #839496;
}
.cm-s-solarized-dark span.cm-string {
color: #6c71c4;
}
.cm-s-solarized-dark span.cm-error {
font-weight: bold;
border-bottom: 1px dotted #cb4b16;
}
.cm-s-solarized-dark span.cm-bracket {
color: #cb4b16;
}
.cm-s-solarized-dark span.cm-tag {
color: #839496;
}
.cm-s-solarized-dark span.cm-attribute {
color: #93a1a1;
font-weight: bold;
}
.cm-s-solarized-dark span.cm-meta {
color: #268bd2;
}

136
docs/_css/_typography.scss Normal file
View File

@@ -0,0 +1,136 @@
@import 'variables.scss';
$textColor: $mediumColor;
$textColorLight: lighten($textColor, 20%);
html {
font-family: $helvetica;
font-family: proxima-nova, $helvetica;
font-weight: 300;
color: $textColor;
line-height: 1.28;
}
p {
margin: 0 0 10px;
}
.subHeader {
font-size: 21px;
font-weight: 200;
line-height: 30px;
margin-bottom: 10px;
}
em {
font-style: italic;
}
h1,
h2,
h3,
h4,
h5,
h6 {
margin: 10px 0;
font-family: inherit;
font-weight: bold;
line-height: 20px;
color: inherit;
text-rendering: optimizelegibility;
}
h1 small,
h2 small,
h3 small,
h4 small,
h5 small,
h6 small {
font-weight: normal;
color: $textColorLight
}
h1,
h2,
h3 {
line-height: 40px;
}
h1 {
font-size: 39px;
}
h2 {
font-size: 31px;
}
h3 {
font-size: 23px;
}
h4 {
font-size: 17px;
}
h5 {
font-size: 14px;
}
h6 {
font-size: 11px;
}
h1 small {
font-size: 24px;
}
h2 small {
font-size: 18px;
}
h3 small {
font-size: 16px;
}
h4 small {
font-size: 14px;
}
ul,
ol {
margin: 0 0 10px 25px;
padding: 0;
}
ul ul,
ul ol,
ol ol,
ol ul {
margin-bottom: 0;
}
li {
line-height: 20px;
}
a {
color: $linkColor;
text-decoration: none;
&:hover,
&:focus {
color: $linkInteract;
text-decoration: underline;
}
&:focus {
outline: thin dotted #333;
outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px;
}
}
.center {
text-align: center;
}

22
docs/_css/_variables.scss Normal file
View File

@@ -0,0 +1,22 @@
$primary: #cc7a6f;
$linkColor: darken($primary, 9%);
$linkInteract: darken($linkColor, 9%);
$pageBg: #f9f9f9;
$lightColor: #e9e9e9;
$mediumestColor: #666;
$mediumColor: #484848;
$darkColor: #2d2d2d;
$darkestColor: #222222;
$blueColor: #61dafb;
$orangeColor: complement($blueColor);
$lightTextColor: #fafafa;
$mediumTextColor: #aaa;
$darkTextColor: $mediumColor;
$buttonBlueTop: #77a3d2;
$buttonBlueBottom: #4783c2;
$buttonGreyTop: #9a9a9a;
$buttonGreyBottom: #646464;

View File

@@ -0,0 +1,13 @@
//************************************************************************//
// These mixins/functions are deprecated
// They will be removed in the next MAJOR version release
//************************************************************************//
@mixin box-shadow ($shadows...) {
@include prefixer(box-shadow, $shadows, spec);
@warn "box-shadow is deprecated and will be removed in the next major version release";
}
@mixin background-size ($lengths...) {
@include prefixer(background-size, $lengths, spec);
@warn "background-size is deprecated and will be removed in the next major version release";
}

59
docs/_css/bourbon/_bourbon.scss vendored Normal file
View File

@@ -0,0 +1,59 @@
// Custom Helpers
@import "helpers/deprecated-webkit-gradient";
@import "helpers/gradient-positions-parser";
@import "helpers/linear-positions-parser";
@import "helpers/radial-arg-parser";
@import "helpers/radial-positions-parser";
@import "helpers/render-gradients";
@import "helpers/shape-size-stripper";
// Custom Functions
@import "functions/compact";
@import "functions/flex-grid";
@import "functions/grid-width";
@import "functions/linear-gradient";
@import "functions/modular-scale";
@import "functions/px-to-em";
@import "functions/radial-gradient";
@import "functions/tint-shade";
@import "functions/transition-property-name";
// CSS3 Mixins
@import "css3/animation";
@import "css3/appearance";
@import "css3/backface-visibility";
@import "css3/background";
@import "css3/background-image";
@import "css3/border-image";
@import "css3/border-radius";
@import "css3/box-sizing";
@import "css3/columns";
@import "css3/flex-box";
@import "css3/font-face";
@import "css3/hidpi-media-query";
@import "css3/image-rendering";
@import "css3/inline-block";
@import "css3/keyframes";
@import "css3/linear-gradient";
@import "css3/perspective";
@import "css3/radial-gradient";
@import "css3/transform";
@import "css3/transition";
@import "css3/user-select";
@import "css3/placeholder";
// Addons & other mixins
@import "addons/button";
@import "addons/clearfix";
@import "addons/font-family";
@import "addons/hide-text";
@import "addons/html5-input-types";
@import "addons/position";
@import "addons/prefixer";
@import "addons/retina-image";
@import "addons/size";
@import "addons/timing-functions";
@import "addons/triangle";
// Soon to be deprecated Mixins
@import "bourbon-deprecated-upcoming";

273
docs/_css/bourbon/addons/_button.scss vendored Normal file
View File

@@ -0,0 +1,273 @@
@mixin button ($style: simple, $base-color: #4294f0) {
@if type-of($style) == color {
$base-color: $style;
$style: simple;
}
// Grayscale button
@if $base-color == grayscale($base-color) {
@if $style == simple {
@include simple($base-color, $grayscale: true);
}
@else if $style == shiny {
@include shiny($base-color, $grayscale: true);
}
@else if $style == pill {
@include pill($base-color, $grayscale: true);
}
}
// Colored button
@else {
@if $style == simple {
@include simple($base-color);
}
@else if $style == shiny {
@include shiny($base-color);
}
@else if $style == pill {
@include pill($base-color);
}
}
&:disabled {
opacity: 0.5;
cursor: not-allowed;
}
}
// Simple Button
//************************************************************************//
@mixin simple($base-color, $grayscale: false) {
$color: hsl(0, 0, 100%);
$border: adjust-color($base-color, $saturation: 9%, $lightness: -14%);
$inset-shadow: adjust-color($base-color, $saturation: -8%, $lightness: 15%);
$stop-gradient: adjust-color($base-color, $saturation: 9%, $lightness: -11%);
$text-shadow: adjust-color($base-color, $saturation: 15%, $lightness: -18%);
@if lightness($base-color) > 70% {
$color: hsl(0, 0, 20%);
$text-shadow: adjust-color($base-color, $saturation: 10%, $lightness: 4%);
}
@if $grayscale == true {
$border: grayscale($border);
$inset-shadow: grayscale($inset-shadow);
$stop-gradient: grayscale($stop-gradient);
$text-shadow: grayscale($text-shadow);
}
border: 1px solid $border;
border-radius: 3px;
box-shadow: inset 0 1px 0 0 $inset-shadow;
color: $color;
display: inline-block;
font-size: 11px;
font-weight: bold;
@include linear-gradient ($base-color, $stop-gradient);
padding: 7px 18px;
text-decoration: none;
text-shadow: 0 1px 0 $text-shadow;
background-clip: padding-box;
&:hover:not(:disabled) {
$base-color-hover: adjust-color($base-color, $saturation: -4%, $lightness: -5%);
$inset-shadow-hover: adjust-color($base-color, $saturation: -7%, $lightness: 5%);
$stop-gradient-hover: adjust-color($base-color, $saturation: 8%, $lightness: -14%);
@if $grayscale == true {
$base-color-hover: grayscale($base-color-hover);
$inset-shadow-hover: grayscale($inset-shadow-hover);
$stop-gradient-hover: grayscale($stop-gradient-hover);
}
box-shadow: inset 0 1px 0 0 $inset-shadow-hover;
cursor: pointer;
@include linear-gradient ($base-color-hover, $stop-gradient-hover);
}
&:active:not(:disabled) {
$border-active: adjust-color($base-color, $saturation: 9%, $lightness: -14%);
$inset-shadow-active: adjust-color($base-color, $saturation: 7%, $lightness: -17%);
@if $grayscale == true {
$border-active: grayscale($border-active);
$inset-shadow-active: grayscale($inset-shadow-active);
}
border: 1px solid $border-active;
box-shadow: inset 0 0 8px 4px $inset-shadow-active, inset 0 0 8px 4px $inset-shadow-active, 0 1px 1px 0 #eee;
}
}
// Shiny Button
//************************************************************************//
@mixin shiny($base-color, $grayscale: false) {
$color: hsl(0, 0, 100%);
$border: adjust-color($base-color, $red: -117, $green: -111, $blue: -81);
$border-bottom: adjust-color($base-color, $red: -126, $green: -127, $blue: -122);
$fourth-stop: adjust-color($base-color, $red: -79, $green: -70, $blue: -46);
$inset-shadow: adjust-color($base-color, $red: 37, $green: 29, $blue: 12);
$second-stop: adjust-color($base-color, $red: -56, $green: -50, $blue: -33);
$text-shadow: adjust-color($base-color, $red: -140, $green: -141, $blue: -114);
$third-stop: adjust-color($base-color, $red: -86, $green: -75, $blue: -48);
@if lightness($base-color) > 70% {
$color: hsl(0, 0, 20%);
$text-shadow: adjust-color($base-color, $saturation: 10%, $lightness: 4%);
}
@if $grayscale == true {
$border: grayscale($border);
$border-bottom: grayscale($border-bottom);
$fourth-stop: grayscale($fourth-stop);
$inset-shadow: grayscale($inset-shadow);
$second-stop: grayscale($second-stop);
$text-shadow: grayscale($text-shadow);
$third-stop: grayscale($third-stop);
}
border: 1px solid $border;
border-bottom: 1px solid $border-bottom;
border-radius: 5px;
box-shadow: inset 0 1px 0 0 $inset-shadow;
color: $color;
display: inline-block;
font-size: 14px;
font-weight: bold;
@include linear-gradient(top, $base-color 0%, $second-stop 50%, $third-stop 50%, $fourth-stop 100%);
padding: 8px 20px;
text-align: center;
text-decoration: none;
text-shadow: 0 -1px 1px $text-shadow;
&:hover:not(:disabled) {
$first-stop-hover: adjust-color($base-color, $red: -13, $green: -15, $blue: -18);
$second-stop-hover: adjust-color($base-color, $red: -66, $green: -62, $blue: -51);
$third-stop-hover: adjust-color($base-color, $red: -93, $green: -85, $blue: -66);
$fourth-stop-hover: adjust-color($base-color, $red: -86, $green: -80, $blue: -63);
@if $grayscale == true {
$first-stop-hover: grayscale($first-stop-hover);
$second-stop-hover: grayscale($second-stop-hover);
$third-stop-hover: grayscale($third-stop-hover);
$fourth-stop-hover: grayscale($fourth-stop-hover);
}
cursor: pointer;
@include linear-gradient(top, $first-stop-hover 0%,
$second-stop-hover 50%,
$third-stop-hover 50%,
$fourth-stop-hover 100%);
}
&:active:not(:disabled) {
$inset-shadow-active: adjust-color($base-color, $red: -111, $green: -116, $blue: -122);
@if $grayscale == true {
$inset-shadow-active: grayscale($inset-shadow-active);
}
box-shadow: inset 0 0 20px 0 $inset-shadow-active, 0 1px 0 #fff;
}
}
// Pill Button
//************************************************************************//
@mixin pill($base-color, $grayscale: false) {
$color: hsl(0, 0, 100%);
$border-bottom: adjust-color($base-color, $hue: 8, $saturation: -11%, $lightness: -26%);
$border-sides: adjust-color($base-color, $hue: 4, $saturation: -21%, $lightness: -21%);
$border-top: adjust-color($base-color, $hue: -1, $saturation: -30%, $lightness: -15%);
$inset-shadow: adjust-color($base-color, $hue: -1, $saturation: -1%, $lightness: 7%);
$stop-gradient: adjust-color($base-color, $hue: 8, $saturation: 14%, $lightness: -10%);
$text-shadow: adjust-color($base-color, $hue: 5, $saturation: -19%, $lightness: -15%);
@if lightness($base-color) > 70% {
$color: hsl(0, 0, 20%);
$text-shadow: adjust-color($base-color, $saturation: 10%, $lightness: 4%);
}
@if $grayscale == true {
$border-bottom: grayscale($border-bottom);
$border-sides: grayscale($border-sides);
$border-top: grayscale($border-top);
$inset-shadow: grayscale($inset-shadow);
$stop-gradient: grayscale($stop-gradient);
$text-shadow: grayscale($text-shadow);
}
border: 1px solid $border-top;
border-color: $border-top $border-sides $border-bottom;
border-radius: 16px;
box-shadow: inset 0 1px 0 0 $inset-shadow, 0 1px 2px 0 #b3b3b3;
color: $color;
display: inline-block;
font-size: 11px;
font-weight: normal;
line-height: 1;
@include linear-gradient ($base-color, $stop-gradient);
padding: 5px 16px;
text-align: center;
text-decoration: none;
text-shadow: 0 -1px 1px $text-shadow;
background-clip: padding-box;
&:hover:not(:disabled) {
$base-color-hover: adjust-color($base-color, $lightness: -4.5%);
$border-bottom: adjust-color($base-color, $hue: 8, $saturation: 13.5%, $lightness: -32%);
$border-sides: adjust-color($base-color, $hue: 4, $saturation: -2%, $lightness: -27%);
$border-top: adjust-color($base-color, $hue: -1, $saturation: -17%, $lightness: -21%);
$inset-shadow-hover: adjust-color($base-color, $saturation: -1%, $lightness: 3%);
$stop-gradient-hover: adjust-color($base-color, $hue: 8, $saturation: -4%, $lightness: -15.5%);
$text-shadow-hover: adjust-color($base-color, $hue: 5, $saturation: -5%, $lightness: -22%);
@if $grayscale == true {
$base-color-hover: grayscale($base-color-hover);
$border-bottom: grayscale($border-bottom);
$border-sides: grayscale($border-sides);
$border-top: grayscale($border-top);
$inset-shadow-hover: grayscale($inset-shadow-hover);
$stop-gradient-hover: grayscale($stop-gradient-hover);
$text-shadow-hover: grayscale($text-shadow-hover);
}
border: 1px solid $border-top;
border-color: $border-top $border-sides $border-bottom;
box-shadow: inset 0 1px 0 0 $inset-shadow-hover;
cursor: pointer;
@include linear-gradient ($base-color-hover, $stop-gradient-hover);
text-shadow: 0 -1px 1px $text-shadow-hover;
background-clip: padding-box;
}
&:active:not(:disabled) {
$active-color: adjust-color($base-color, $hue: 4, $saturation: -12%, $lightness: -10%);
$border-active: adjust-color($base-color, $hue: 6, $saturation: -2.5%, $lightness: -30%);
$border-bottom-active: adjust-color($base-color, $hue: 11, $saturation: 6%, $lightness: -31%);
$inset-shadow-active: adjust-color($base-color, $hue: 9, $saturation: 2%, $lightness: -21.5%);
$text-shadow-active: adjust-color($base-color, $hue: 5, $saturation: -12%, $lightness: -21.5%);
@if $grayscale == true {
$active-color: grayscale($active-color);
$border-active: grayscale($border-active);
$border-bottom-active: grayscale($border-bottom-active);
$inset-shadow-active: grayscale($inset-shadow-active);
$text-shadow-active: grayscale($text-shadow-active);
}
background: $active-color;
border: 1px solid $border-active;
border-bottom: 1px solid $border-bottom-active;
box-shadow: inset 0 0 6px 3px $inset-shadow-active, 0 1px 0 0 #fff;
text-shadow: 0 -1px 1px $text-shadow-active;
}
}

29
docs/_css/bourbon/addons/_clearfix.scss vendored Normal file
View File

@@ -0,0 +1,29 @@
// Micro clearfix provides an easy way to contain floats without adding additional markup
//
// Example usage:
//
// // Contain all floats within .wrapper
// .wrapper {
// @include clearfix;
// .content,
// .sidebar {
// float : left;
// }
// }
@mixin clearfix {
*zoom: 1;
&:before,
&:after {
content: " ";
display: table;
}
&:after {
clear: both;
}
}
// Acknowledgements
// Micro clearfix: [Nicolas Gallagher](http://nicolasgallagher.com/micro-clearfix-hack/)

View File

@@ -0,0 +1,5 @@
$georgia: Georgia, Cambria, "Times New Roman", Times, serif;
$helvetica: "Helvetica Neue", Helvetica, Arial, sans-serif;
$lucida-grande: "Lucida Grande", Tahoma, Verdana, Arial, sans-serif;
$monospace: "Bitstream Vera Sans Mono", Consolas, Courier, monospace;
$verdana: Verdana, Geneva, sans-serif;

View File

@@ -0,0 +1,5 @@
@mixin hide-text {
color: transparent;
font: 0/0 a;
text-shadow: none;
}

View File

@@ -0,0 +1,56 @@
//************************************************************************//
// Generate a variable ($all-text-inputs) with a list of all html5
// input types that have a text-based input, excluding textarea.
// http://diveintohtml5.org/forms.html
//************************************************************************//
$inputs-list: 'input[type="email"]',
'input[type="number"]',
'input[type="password"]',
'input[type="search"]',
'input[type="tel"]',
'input[type="text"]',
'input[type="url"]',
// Webkit & Gecko may change the display of these in the future
'input[type="color"]',
'input[type="date"]',
'input[type="datetime"]',
'input[type="datetime-local"]',
'input[type="month"]',
'input[type="time"]',
'input[type="week"]';
$unquoted-inputs-list: ();
@each $input-type in $inputs-list {
$unquoted-inputs-list: append($unquoted-inputs-list, unquote($input-type), comma);
}
$all-text-inputs: $unquoted-inputs-list;
// Hover Pseudo-class
//************************************************************************//
$all-text-inputs-hover: ();
@each $input-type in $unquoted-inputs-list {
$input-type-hover: $input-type + ":hover";
$all-text-inputs-hover: append($all-text-inputs-hover, $input-type-hover, comma);
}
// Focus Pseudo-class
//************************************************************************//
$all-text-inputs-focus: ();
@each $input-type in $unquoted-inputs-list {
$input-type-focus: $input-type + ":focus";
$all-text-inputs-focus: append($all-text-inputs-focus, $input-type-focus, comma);
}
// You must use interpolation on the variable:
// #{$all-text-inputs}
// #{$all-text-inputs-hover}
// #{$all-text-inputs-focus}
// Example
//************************************************************************//
// #{$all-text-inputs}, textarea {
// border: 1px solid red;
// }

42
docs/_css/bourbon/addons/_position.scss vendored Normal file
View File

@@ -0,0 +1,42 @@
@mixin position ($position: relative, $coordinates: 0 0 0 0) {
@if type-of($position) == list {
$coordinates: $position;
$position: relative;
}
$top: nth($coordinates, 1);
$right: nth($coordinates, 2);
$bottom: nth($coordinates, 3);
$left: nth($coordinates, 4);
position: $position;
@if $top == auto {
top: $top;
}
@else if not(unitless($top)) {
top: $top;
}
@if $right == auto {
right: $right;
}
@else if not(unitless($right)) {
right: $right;
}
@if $bottom == auto {
bottom: $bottom;
}
@else if not(unitless($bottom)) {
bottom: $bottom;
}
@if $left == auto {
left: $left;
}
@else if not(unitless($left)) {
left: $left;
}
}

49
docs/_css/bourbon/addons/_prefixer.scss vendored Normal file
View File

@@ -0,0 +1,49 @@
//************************************************************************//
// Example: @include prefixer(border-radius, $radii, webkit ms spec);
//************************************************************************//
$prefix-for-webkit: true !default;
$prefix-for-mozilla: true !default;
$prefix-for-microsoft: true !default;
$prefix-for-opera: true !default;
$prefix-for-spec: true !default; // required for keyframe mixin
@mixin prefixer ($property, $value, $prefixes) {
@each $prefix in $prefixes {
@if $prefix == webkit {
@if $prefix-for-webkit {
-webkit-#{$property}: $value;
}
}
@else if $prefix == moz {
@if $prefix-for-mozilla {
-moz-#{$property}: $value;
}
}
@else if $prefix == ms {
@if $prefix-for-microsoft {
-ms-#{$property}: $value;
}
}
@else if $prefix == o {
@if $prefix-for-opera {
-o-#{$property}: $value;
}
}
@else if $prefix == spec {
@if $prefix-for-spec {
#{$property}: $value;
}
}
@else {
@warn "Unrecognized prefix: #{$prefix}";
}
}
}
@mixin disable-prefix-for-all() {
$prefix-for-webkit: false;
$prefix-for-mozilla: false;
$prefix-for-microsoft: false;
$prefix-for-opera: false;
$prefix-for-spec: false;
}

View File

@@ -0,0 +1,32 @@
@mixin retina-image($filename, $background-size, $extension: png, $retina-filename: null, $asset-pipeline: false) {
@if $asset-pipeline {
background-image: image_url($filename + "." + $extension);
}
@else {
background-image: url($filename + "." + $extension);
}
@include hidpi {
@if $asset-pipeline {
@if $retina-filename {
background-image: image_url($retina-filename + "." + $extension);
}
@else {
background-image: image_url($filename + "@2x" + "." + $extension);
}
}
@else {
@if $retina-filename {
background-image: url($retina-filename + "." + $extension);
}
@else {
background-image: url($filename + "@2x" + "." + $extension);
}
}
background-size: $background-size;
}
}

44
docs/_css/bourbon/addons/_size.scss vendored Normal file
View File

@@ -0,0 +1,44 @@
@mixin size($size) {
@if length($size) == 1 {
@if $size == auto {
width: $size;
height: $size;
}
@else if unitless($size) {
width: $size + px;
height: $size + px;
}
@else if not(unitless($size)) {
width: $size;
height: $size;
}
}
// Width x Height
@if length($size) == 2 {
$width: nth($size, 1);
$height: nth($size, 2);
@if $width == auto {
width: $width;
}
@else if not(unitless($width)) {
width: $width;
}
@else if unitless($width) {
width: $width + px;
}
@if $height == auto {
height: $height;
}
@else if not(unitless($height)) {
height: $height;
}
@else if unitless($height) {
height: $height + px;
}
}
}

View File

@@ -0,0 +1,32 @@
// CSS cubic-bezier timing functions. Timing functions courtesy of jquery.easie (github.com/jaukia/easie)
// Timing functions are the same as demo'ed here: http://jqueryui.com/demos/effect/easing.html
// EASE IN
$ease-in-quad: cubic-bezier(0.550, 0.085, 0.680, 0.530);
$ease-in-cubic: cubic-bezier(0.550, 0.055, 0.675, 0.190);
$ease-in-quart: cubic-bezier(0.895, 0.030, 0.685, 0.220);
$ease-in-quint: cubic-bezier(0.755, 0.050, 0.855, 0.060);
$ease-in-sine: cubic-bezier(0.470, 0.000, 0.745, 0.715);
$ease-in-expo: cubic-bezier(0.950, 0.050, 0.795, 0.035);
$ease-in-circ: cubic-bezier(0.600, 0.040, 0.980, 0.335);
$ease-in-back: cubic-bezier(0.600, -0.280, 0.735, 0.045);
// EASE OUT
$ease-out-quad: cubic-bezier(0.250, 0.460, 0.450, 0.940);
$ease-out-cubic: cubic-bezier(0.215, 0.610, 0.355, 1.000);
$ease-out-quart: cubic-bezier(0.165, 0.840, 0.440, 1.000);
$ease-out-quint: cubic-bezier(0.230, 1.000, 0.320, 1.000);
$ease-out-sine: cubic-bezier(0.390, 0.575, 0.565, 1.000);
$ease-out-expo: cubic-bezier(0.190, 1.000, 0.220, 1.000);
$ease-out-circ: cubic-bezier(0.075, 0.820, 0.165, 1.000);
$ease-out-back: cubic-bezier(0.175, 0.885, 0.320, 1.275);
// EASE IN OUT
$ease-in-out-quad: cubic-bezier(0.455, 0.030, 0.515, 0.955);
$ease-in-out-cubic: cubic-bezier(0.645, 0.045, 0.355, 1.000);
$ease-in-out-quart: cubic-bezier(0.770, 0.000, 0.175, 1.000);
$ease-in-out-quint: cubic-bezier(0.860, 0.000, 0.070, 1.000);
$ease-in-out-sine: cubic-bezier(0.445, 0.050, 0.550, 0.950);
$ease-in-out-expo: cubic-bezier(1.000, 0.000, 0.000, 1.000);
$ease-in-out-circ: cubic-bezier(0.785, 0.135, 0.150, 0.860);
$ease-in-out-back: cubic-bezier(0.680, -0.550, 0.265, 1.550);

45
docs/_css/bourbon/addons/_triangle.scss vendored Normal file
View File

@@ -0,0 +1,45 @@
@mixin triangle ($size, $color, $direction) {
height: 0;
width: 0;
@if ($direction == up) or ($direction == down) or ($direction == right) or ($direction == left) {
border-color: transparent;
border-style: solid;
border-width: $size / 2;
@if $direction == up {
border-bottom-color: $color;
} @else if $direction == right {
border-left-color: $color;
} @else if $direction == down {
border-top-color: $color;
} @else if $direction == left {
border-right-color: $color;
}
}
@else if ($direction == up-right) or ($direction == up-left) {
border-top: $size solid $color;
@if $direction == up-right {
border-left: $size solid transparent;
} @else if $direction == up-left {
border-right: $size solid transparent;
}
}
@else if ($direction == down-right) or ($direction == down-left) {
border-bottom: $size solid $color;
@if $direction == down-right {
border-left: $size solid transparent;
} @else if $direction == down-left {
border-right: $size solid transparent;
}
}
}

52
docs/_css/bourbon/css3/_animation.scss vendored Normal file
View File

@@ -0,0 +1,52 @@
// http://www.w3.org/TR/css3-animations/#the-animation-name-property-
// Each of these mixins support comma separated lists of values, which allows different transitions for individual properties to be described in a single style rule. Each value in the list corresponds to the value at that same position in the other properties.
// Official animation shorthand property.
@mixin animation ($animations...) {
@include prefixer(animation, $animations, webkit moz spec);
}
// Individual Animation Properties
@mixin animation-name ($names...) {
@include prefixer(animation-name, $names, webkit moz spec);
}
@mixin animation-duration ($times...) {
@include prefixer(animation-duration, $times, webkit moz spec);
}
@mixin animation-timing-function ($motions...) {
// ease | linear | ease-in | ease-out | ease-in-out
@include prefixer(animation-timing-function, $motions, webkit moz spec);
}
@mixin animation-iteration-count ($values...) {
// infinite | <number>
@include prefixer(animation-iteration-count, $values, webkit moz spec);
}
@mixin animation-direction ($directions...) {
// normal | alternate
@include prefixer(animation-direction, $directions, webkit moz spec);
}
@mixin animation-play-state ($states...) {
// running | paused
@include prefixer(animation-play-state, $states, webkit moz spec);
}
@mixin animation-delay ($times...) {
@include prefixer(animation-delay, $times, webkit moz spec);
}
@mixin animation-fill-mode ($modes...) {
// none | forwards | backwards | both
@include prefixer(animation-fill-mode, $modes, webkit moz spec);
}

View File

@@ -0,0 +1,3 @@
@mixin appearance ($value) {
@include prefixer(appearance, $value, webkit moz ms o spec);
}

View File

@@ -0,0 +1,6 @@
//************************************************************************//
// Backface-visibility mixin
//************************************************************************//
@mixin backface-visibility($visibility) {
@include prefixer(backface-visibility, $visibility, webkit spec);
}

View File

@@ -0,0 +1,48 @@
//************************************************************************//
// Background-image property for adding multiple background images with
// gradients, or for stringing multiple gradients together.
//************************************************************************//
@mixin background-image($images...) {
background-image: _add-prefix($images, webkit);
background-image: _add-prefix($images);
}
@function _add-prefix($images, $vendor: false) {
$images-prefixed: ();
$gradient-positions: false;
@for $i from 1 through length($images) {
$type: type-of(nth($images, $i)); // Get type of variable - List or String
// If variable is a list - Gradient
@if $type == list {
$gradient-type: nth(nth($images, $i), 1); // linear or radial
$gradient-pos: null;
$gradient-args: null;
@if ($gradient-type == linear) or ($gradient-type == radial) {
$gradient-pos: nth(nth($images, $i), 2); // Get gradient position
$gradient-args: nth(nth($images, $i), 3); // Get actual gradient (red, blue)
}
@else {
$gradient-args: nth(nth($images, $i), 2); // Get actual gradient (red, blue)
}
$gradient-positions: _gradient-positions-parser($gradient-type, $gradient-pos);
$gradient: _render-gradients($gradient-positions, $gradient-args, $gradient-type, $vendor);
$images-prefixed: append($images-prefixed, $gradient, comma);
}
// If variable is a string - Image
@else if $type == string {
$images-prefixed: join($images-prefixed, nth($images, $i), comma);
}
}
@return $images-prefixed;
}
//Examples:
//@include background-image(linear-gradient(top, orange, red));
//@include background-image(radial-gradient(50% 50%, cover circle, orange, red));
//@include background-image(url("/images/a.png"), linear-gradient(orange, red));
//@include background-image(url("image.png"), linear-gradient(orange, red), url("image.png"));
//@include background-image(linear-gradient(hsla(0, 100%, 100%, 0.25) 0%, hsla(0, 100%, 100%, 0.08) 50%, transparent 50%), linear-gradient(orange, red));

103
docs/_css/bourbon/css3/_background.scss vendored Normal file
View File

@@ -0,0 +1,103 @@
//************************************************************************//
// Background property for adding multiple backgrounds using shorthand
// notation.
//************************************************************************//
@mixin background(
$background-1 , $background-2: false,
$background-3: false, $background-4: false,
$background-5: false, $background-6: false,
$background-7: false, $background-8: false,
$background-9: false, $background-10: false,
$fallback: false
) {
$backgrounds: compact($background-1, $background-2,
$background-3, $background-4,
$background-5, $background-6,
$background-7, $background-8,
$background-9, $background-10);
$fallback-color: false;
@if (type-of($fallback) == color) or ($fallback == "transparent") {
$fallback-color: $fallback;
}
@else {
$fallback-color: _extract-background-color($backgrounds);
}
@if $fallback-color {
background-color: $fallback-color;
}
background: _background-add-prefix($backgrounds, webkit);
background: _background-add-prefix($backgrounds);
}
@function _extract-background-color($backgrounds) {
$final-bg-layer: nth($backgrounds, length($backgrounds));
@if type-of($final-bg-layer) == list {
@for $i from 1 through length($final-bg-layer) {
$value: nth($final-bg-layer, $i);
@if type-of($value) == color {
@return $value;
}
}
}
@return false;
}
@function _background-add-prefix($backgrounds, $vendor: false) {
$backgrounds-prefixed: ();
@for $i from 1 through length($backgrounds) {
$shorthand: nth($backgrounds, $i); // Get member for current index
$type: type-of($shorthand); // Get type of variable - List (gradient) or String (image)
// If shorthand is a list (gradient)
@if $type == list {
$first-member: nth($shorthand, 1); // Get first member of shorthand
// Linear Gradient
@if index(linear radial, nth($first-member, 1)) {
$gradient-type: nth($first-member, 1); // linear || radial
$gradient-args: false;
$gradient-positions: false;
$shorthand-start: false;
@if type-of($first-member) == list { // Linear gradient plus additional shorthand values - lg(red,orange)repeat,...
$gradient-positions: nth($first-member, 2);
$gradient-args: nth($first-member, 3);
$shorthand-start: 2;
}
@else { // Linear gradient only - lg(red,orange),...
$gradient-positions: nth($shorthand, 2);
$gradient-args: nth($shorthand, 3); // Get gradient (red, blue)
}
$gradient-positions: _gradient-positions-parser($gradient-type, $gradient-positions);
$gradient: _render-gradients($gradient-positions, $gradient-args, $gradient-type, $vendor);
// Append any additional shorthand args to gradient
@if $shorthand-start {
@for $j from $shorthand-start through length($shorthand) {
$gradient: join($gradient, nth($shorthand, $j), space);
}
}
$backgrounds-prefixed: append($backgrounds-prefixed, $gradient, comma);
}
// Image with additional properties
@else {
$backgrounds-prefixed: append($backgrounds-prefixed, $shorthand, comma);
}
}
// If shorthand is a simple string (color or image)
@else if $type == string {
$backgrounds-prefixed: join($backgrounds-prefixed, $shorthand, comma);
}
}
@return $backgrounds-prefixed;
}
//Examples:
//@include background(linear-gradient(top, orange, red));
//@include background(radial-gradient(circle at 40% 40%, orange, red));
//@include background(url("/images/a.png") no-repeat, linear-gradient(orange, red));
//@include background(url("image.png") center center, linear-gradient(orange, red), url("image.png"));

View File

@@ -0,0 +1,55 @@
@mixin border-image($images) {
-webkit-border-image: _border-add-prefix($images, webkit);
-moz-border-image: _border-add-prefix($images, moz);
-o-border-image: _border-add-prefix($images, o);
border-image: _border-add-prefix($images);
}
@function _border-add-prefix($images, $vendor: false) {
$border-image: null;
$images-type: type-of(nth($images, 1));
$first-var: nth(nth($images, 1), 1); // Get type of Gradient (Linear || radial)
// If input is a gradient
@if $images-type == string {
@if ($first-var == "linear") or ($first-var == "radial") {
$gradient-type: nth($images, 1); // Get type of gradient (linear || radial)
$gradient-pos: nth($images, 2); // Get gradient position
$gradient-args: nth($images, 3); // Get actual gradient (red, blue)
$gradient-positions: _gradient-positions-parser($gradient-type, $gradient-pos);
$border-image: _render-gradients($gradient-positions, $gradient-args, $gradient-type, $vendor);
}
// If input is a URL
@else {
$border-image: $images;
}
}
// If input is gradient or url + additional args
@else if $images-type == list {
$type: type-of(nth($images, 1)); // Get type of variable - List or String
// If variable is a list - Gradient
@if $type == list {
$gradient: nth($images, 1);
$gradient-type: nth($gradient, 1); // Get type of gradient (linear || radial)
$gradient-pos: nth($gradient, 2); // Get gradient position
$gradient-args: nth($gradient, 3); // Get actual gradient (red, blue)
$gradient-positions: _gradient-positions-parser($gradient-type, $gradient-pos);
$border-image: _render-gradients($gradient-positions, $gradient-args, $gradient-type, $vendor);
@for $i from 2 through length($images) {
$border-image: append($border-image, nth($images, $i));
}
}
}
@return $border-image;
}
//Examples:
// @include border-image(url("image.png"));
// @include border-image(url("image.png") 20 stretch);
// @include border-image(linear-gradient(45deg, orange, yellow));
// @include border-image(linear-gradient(45deg, orange, yellow) stretch);
// @include border-image(linear-gradient(45deg, orange, yellow) 20 30 40 50 stretch round);
// @include border-image(radial-gradient(top, cover, orange, yellow, orange));

View File

@@ -0,0 +1,22 @@
//************************************************************************//
// Shorthand Border-radius mixins
//************************************************************************//
@mixin border-top-radius($radii) {
@include prefixer(border-top-left-radius, $radii, spec);
@include prefixer(border-top-right-radius, $radii, spec);
}
@mixin border-bottom-radius($radii) {
@include prefixer(border-bottom-left-radius, $radii, spec);
@include prefixer(border-bottom-right-radius, $radii, spec);
}
@mixin border-left-radius($radii) {
@include prefixer(border-top-left-radius, $radii, spec);
@include prefixer(border-bottom-left-radius, $radii, spec);
}
@mixin border-right-radius($radii) {
@include prefixer(border-top-right-radius, $radii, spec);
@include prefixer(border-bottom-right-radius, $radii, spec);
}

View File

@@ -0,0 +1,4 @@
@mixin box-sizing ($box) {
// content-box | border-box | inherit
@include prefixer(box-sizing, $box, webkit moz spec);
}

47
docs/_css/bourbon/css3/_columns.scss vendored Normal file
View File

@@ -0,0 +1,47 @@
@mixin columns($arg: auto) {
// <column-count> || <column-width>
@include prefixer(columns, $arg, webkit moz spec);
}
@mixin column-count($int: auto) {
// auto || integer
@include prefixer(column-count, $int, webkit moz spec);
}
@mixin column-gap($length: normal) {
// normal || length
@include prefixer(column-gap, $length, webkit moz spec);
}
@mixin column-fill($arg: auto) {
// auto || length
@include prefixer(columns-fill, $arg, webkit moz spec);
}
@mixin column-rule($arg) {
// <border-width> || <border-style> || <color>
@include prefixer(column-rule, $arg, webkit moz spec);
}
@mixin column-rule-color($color) {
@include prefixer(column-rule-color, $color, webkit moz spec);
}
@mixin column-rule-style($style: none) {
// none | hidden | dashed | dotted | double | groove | inset | inset | outset | ridge | solid
@include prefixer(column-rule-style, $style, webkit moz spec);
}
@mixin column-rule-width ($width: none) {
@include prefixer(column-rule-width, $width, webkit moz spec);
}
@mixin column-span($arg: none) {
// none || all
@include prefixer(column-span, $arg, webkit moz spec);
}
@mixin column-width($length: auto) {
// auto || length
@include prefixer(column-width, $length, webkit moz spec);
}

52
docs/_css/bourbon/css3/_flex-box.scss vendored Normal file
View File

@@ -0,0 +1,52 @@
// CSS3 Flexible Box Model and property defaults
// Custom shorthand notation for flexbox
@mixin box($orient: inline-axis, $pack: start, $align: stretch) {
@include display-box;
@include box-orient($orient);
@include box-pack($pack);
@include box-align($align);
}
@mixin display-box {
display: -webkit-box;
display: -moz-box;
display: box;
}
@mixin box-orient($orient: inline-axis) {
// horizontal|vertical|inline-axis|block-axis|inherit
@include prefixer(box-orient, $orient, webkit moz spec);
}
@mixin box-pack($pack: start) {
// start|end|center|justify
@include prefixer(box-pack, $pack, webkit moz spec);
}
@mixin box-align($align: stretch) {
// start|end|center|baseline|stretch
@include prefixer(box-align, $align, webkit moz spec);
}
@mixin box-direction($direction: normal) {
// normal|reverse|inherit
@include prefixer(box-direction, $direction, webkit moz spec);
}
@mixin box-lines($lines: single) {
// single|multiple
@include prefixer(box-lines, $lines, webkit moz spec);
}
@mixin box-ordinal-group($int: 1) {
@include prefixer(box-ordinal-group, $int, webkit moz spec);
}
@mixin box-flex($value: 0.0) {
@include prefixer(box-flex, $value, webkit moz spec);
}
@mixin box-flex-group($int: 1) {
@include prefixer(box-flex-group, $int, webkit moz spec);
}

23
docs/_css/bourbon/css3/_font-face.scss vendored Normal file
View File

@@ -0,0 +1,23 @@
// Order of the includes matters, and it is: normal, bold, italic, bold+italic.
@mixin font-face($font-family, $file-path, $weight: normal, $style: normal, $asset-pipeline: false ) {
@font-face {
font-family: $font-family;
font-weight: $weight;
font-style: $style;
@if $asset-pipeline == true {
src: font-url('#{$file-path}.eot');
src: font-url('#{$file-path}.eot?#iefix') format('embedded-opentype'),
font-url('#{$file-path}.woff') format('woff'),
font-url('#{$file-path}.ttf') format('truetype'),
font-url('#{$file-path}.svg##{$font-family}') format('svg');
} @else {
src: url('#{$file-path}.eot');
src: url('#{$file-path}.eot?#iefix') format('embedded-opentype'),
url('#{$file-path}.woff') format('woff'),
url('#{$file-path}.ttf') format('truetype'),
url('#{$file-path}.svg##{$font-family}') format('svg');
}
}
}

View File

@@ -0,0 +1,10 @@
// HiDPI mixin. Default value set to 1.3 to target Google Nexus 7 (http://bjango.com/articles/min-device-pixel-ratio/)
@mixin hidpi($ratio: 1.3) {
@media only screen and (-webkit-min-device-pixel-ratio: $ratio),
only screen and (min--moz-device-pixel-ratio: $ratio),
only screen and (-o-min-device-pixel-ratio: #{$ratio}/1),
only screen and (min-resolution: #{round($ratio*96)}dpi),
only screen and (min-resolution: #{$ratio}dppx) {
@content;
}
}

View File

@@ -0,0 +1,13 @@
@mixin image-rendering ($mode:optimizeQuality) {
@if ($mode == optimize-contrast) {
image-rendering: -moz-crisp-edges;
image-rendering: -o-crisp-edges;
image-rendering: -webkit-optimize-contrast;
image-rendering: optimize-contrast;
}
@else {
image-rendering: $mode;
}
}

View File

@@ -0,0 +1,8 @@
// Legacy support for inline-block in IE7 (maybe IE6)
@mixin inline-block {
display: inline-block;
vertical-align: baseline;
zoom: 1;
*display: inline;
*vertical-align: auto;
}

43
docs/_css/bourbon/css3/_keyframes.scss vendored Normal file
View File

@@ -0,0 +1,43 @@
// Adds keyframes blocks for supported prefixes, removing redundant prefixes in the block's content
@mixin keyframes($name) {
$original-prefix-for-webkit: $prefix-for-webkit;
$original-prefix-for-mozilla: $prefix-for-mozilla;
$original-prefix-for-microsoft: $prefix-for-microsoft;
$original-prefix-for-opera: $prefix-for-opera;
$original-prefix-for-spec: $prefix-for-spec;
@if $original-prefix-for-webkit {
@include disable-prefix-for-all();
$prefix-for-webkit: true;
@-webkit-keyframes #{$name} {
@content;
}
}
@if $original-prefix-for-mozilla {
@include disable-prefix-for-all();
$prefix-for-mozilla: true;
@-moz-keyframes #{$name} {
@content;
}
}
@if $original-prefix-for-opera {
@include disable-prefix-for-all();
$prefix-for-opera: true;
@-o-keyframes #{$name} {
@content;
}
}
@if $original-prefix-for-spec {
@include disable-prefix-for-all();
$prefix-for-spec: true;
@keyframes #{$name} {
@content;
}
}
$prefix-for-webkit: $original-prefix-for-webkit;
$prefix-for-mozilla: $original-prefix-for-mozilla;
$prefix-for-microsoft: $original-prefix-for-microsoft;
$prefix-for-opera: $original-prefix-for-opera;
$prefix-for-spec: $original-prefix-for-spec;
}

View File

@@ -0,0 +1,41 @@
@mixin linear-gradient($pos, $G1, $G2: false,
$G3: false, $G4: false,
$G5: false, $G6: false,
$G7: false, $G8: false,
$G9: false, $G10: false,
$deprecated-pos1: left top,
$deprecated-pos2: left bottom,
$fallback: false) {
// Detect what type of value exists in $pos
$pos-type: type-of(nth($pos, 1));
$pos-spec: null;
$pos-degree: null;
// If $pos is missing from mixin, reassign vars and add default position
@if ($pos-type == color) or (nth($pos, 1) == "transparent") {
$G10: $G9; $G9: $G8; $G8: $G7; $G7: $G6; $G6: $G5;
$G5: $G4; $G4: $G3; $G3: $G2; $G2: $G1; $G1: $pos;
$pos: null;
}
@if $pos {
$positions: _linear-positions-parser($pos);
$pos-degree: nth($positions, 1);
$pos-spec: nth($positions, 2);
}
$full: compact($G1, $G2, $G3, $G4, $G5, $G6, $G7, $G8, $G9, $G10);
// Set $G1 as the default fallback color
$fallback-color: nth($G1, 1);
// If $fallback is a color use that color as the fallback color
@if (type-of($fallback) == color) or ($fallback == "transparent") {
$fallback-color: $fallback;
}
background-color: $fallback-color;
background-image: _deprecated-webkit-gradient(linear, $deprecated-pos1, $deprecated-pos2, $full); // Safari <= 5.0
background-image: -webkit-linear-gradient($pos-degree $full); // Safari 5.1+, Chrome
background-image: unquote("linear-gradient(#{$pos-spec}#{$full})");
}

View File

@@ -0,0 +1,8 @@
@mixin perspective($depth: none) {
// none | <length>
@include prefixer(perspective, $depth, webkit moz spec);
}
@mixin perspective-origin($value: 50% 50%) {
@include prefixer(perspective-origin, $value, webkit moz spec);
}

View File

@@ -0,0 +1,29 @@
$placeholders: '-webkit-input-placeholder',
'-moz-placeholder',
'-ms-input-placeholder';
@mixin placeholder {
@each $placeholder in $placeholders {
@if $placeholder == "-webkit-input-placeholder" {
&::#{$placeholder} {
@content;
}
}
@else if $placeholder == "-moz-placeholder" {
// FF 18-
&:#{$placeholder} {
@content;
}
// FF 19+
&::#{$placeholder} {
@content;
}
}
@else {
&:#{$placeholder} {
@content;
}
}
}
}

View File

@@ -0,0 +1,44 @@
// Requires Sass 3.1+
@mixin radial-gradient($G1, $G2,
$G3: false, $G4: false,
$G5: false, $G6: false,
$G7: false, $G8: false,
$G9: false, $G10: false,
$pos: null,
$shape-size: null,
$deprecated-pos1: center center,
$deprecated-pos2: center center,
$deprecated-radius1: 0,
$deprecated-radius2: 460,
$fallback: false) {
$data: _radial-arg-parser($G1, $G2, $pos, $shape-size);
$G1: nth($data, 1);
$G2: nth($data, 2);
$pos: nth($data, 3);
$shape-size: nth($data, 4);
$full: compact($G1, $G2, $G3, $G4, $G5, $G6, $G7, $G8, $G9, $G10);
// Strip deprecated cover/contain for spec
$shape-size-spec: _shape-size-stripper($shape-size);
// Set $G1 as the default fallback color
$first-color: nth($full, 1);
$fallback-color: nth($first-color, 1);
@if (type-of($fallback) == color) or ($fallback == "transparent") {
$fallback-color: $fallback;
}
// Add Commas and spaces
$shape-size: if($shape-size, '#{$shape-size}, ', null);
$pos: if($pos, '#{$pos}, ', null);
$pos-spec: if($pos, 'at #{$pos}', null);
$shape-size-spec: if(($shape-size-spec != ' ') and ($pos == null), '#{$shape-size-spec}, ', '#{$shape-size-spec} ');
background-color: $fallback-color;
background-image: _deprecated-webkit-gradient(radial, $deprecated-pos1, $deprecated-pos2, $full, $deprecated-radius1, $deprecated-radius2); // Safari <= 5.0 && IOS 4
background-image: -webkit-radial-gradient(unquote(#{$pos}#{$shape-size}#{$full}));
background-image: unquote("radial-gradient(#{$shape-size-spec}#{$pos-spec}#{$full})");
}

15
docs/_css/bourbon/css3/_transform.scss vendored Normal file
View File

@@ -0,0 +1,15 @@
@mixin transform($property: none) {
// none | <transform-function>
@include prefixer(transform, $property, webkit moz ms o spec);
}
@mixin transform-origin($axes: 50%) {
// x-axis - left | center | right | length | %
// y-axis - top | center | bottom | length | %
// z-axis - length
@include prefixer(transform-origin, $axes, webkit moz ms o spec);
}
@mixin transform-style ($style: flat) {
@include prefixer(transform-style, $style, webkit moz ms o spec);
}

34
docs/_css/bourbon/css3/_transition.scss vendored Normal file
View File

@@ -0,0 +1,34 @@
// Shorthand mixin. Supports multiple parentheses-deliminated values for each variable.
// Example: @include transition (all, 2.0s, ease-in-out);
// @include transition ((opacity, width), (1.0s, 2.0s), ease-in, (0, 2s));
// @include transition ($property:(opacity, width), $delay: (1.5s, 2.5s));
@mixin transition ($properties...) {
@if length($properties) >= 1 {
@include prefixer(transition, $properties, webkit moz spec);
}
@else {
$properties: all 0.15s ease-out 0;
@include prefixer(transition, $properties, webkit moz spec);
}
}
@mixin transition-property ($properties...) {
-webkit-transition-property: transition-property-names($properties, 'webkit');
-moz-transition-property: transition-property-names($properties, 'moz');
transition-property: transition-property-names($properties, false);
}
@mixin transition-duration ($times...) {
@include prefixer(transition-duration, $times, webkit moz spec);
}
@mixin transition-timing-function ($motions...) {
// ease | linear | ease-in | ease-out | ease-in-out | cubic-bezier()
@include prefixer(transition-timing-function, $motions, webkit moz spec);
}
@mixin transition-delay ($times...) {
@include prefixer(transition-delay, $times, webkit moz spec);
}

View File

@@ -0,0 +1,3 @@
@mixin user-select($arg: none) {
@include prefixer(user-select, $arg, webkit moz ms spec);
}

View File

@@ -0,0 +1,11 @@
// Remove `false` values from a list
@function compact($vars...) {
$list: ();
@each $var in $vars {
@if $var {
$list: append($list, $var, comma);
}
}
@return $list;
}

View File

@@ -0,0 +1,39 @@
// Flexible grid
@function flex-grid($columns, $container-columns: $fg-max-columns) {
$width: $columns * $fg-column + ($columns - 1) * $fg-gutter;
$container-width: $container-columns * $fg-column + ($container-columns - 1) * $fg-gutter;
@return percentage($width / $container-width);
}
// Flexible gutter
@function flex-gutter($container-columns: $fg-max-columns, $gutter: $fg-gutter) {
$container-width: $container-columns * $fg-column + ($container-columns - 1) * $fg-gutter;
@return percentage($gutter / $container-width);
}
// The $fg-column, $fg-gutter and $fg-max-columns variables must be defined in your base stylesheet to properly use the flex-grid function.
// This function takes the fluid grid equation (target / context = result) and uses columns to help define each.
//
// The calculation presumes that your column structure will be missing the last gutter:
//
// -- column -- gutter -- column -- gutter -- column
//
// $fg-column: 60px; // Column Width
// $fg-gutter: 25px; // Gutter Width
// $fg-max-columns: 12; // Total Columns For Main Container
//
// div {
// width: flex-grid(4); // returns (315px / 995px) = 31.65829%;
// margin-left: flex-gutter(); // returns (25px / 995px) = 2.51256%;
//
// p {
// width: flex-grid(2, 4); // returns (145px / 315px) = 46.031746%;
// float: left;
// margin: flex-gutter(4); // returns (25px / 315px) = 7.936508%;
// }
//
// blockquote {
// float: left;
// width: flex-grid(2, 4); // returns (145px / 315px) = 46.031746%;
// }
// }

View File

@@ -0,0 +1,13 @@
@function grid-width($n) {
@return $n * $gw-column + ($n - 1) * $gw-gutter;
}
// The $gw-column and $gw-gutter variables must be defined in your base stylesheet to properly use the grid-width function.
//
// $gw-column: 100px; // Column Width
// $gw-gutter: 40px; // Gutter Width
//
// div {
// width: grid-width(4); // returns 520px;
// margin-left: $gw-gutter; // returns 40px;
// }

View File

@@ -0,0 +1,13 @@
@function linear-gradient($pos, $gradients...) {
$type: linear;
$pos-type: type-of(nth($pos, 1));
// if $pos doesn't exist, fix $gradient
@if ($pos-type == color) or (nth($pos, 1) == "transparent") {
$gradients: zip($pos $gradients);
$pos: false;
}
$type-gradient: $type, $pos, $gradients;
@return $type-gradient;
}

View File

@@ -0,0 +1,40 @@
@function modular-scale($value, $increment, $ratio) {
@if $increment > 0 {
@for $i from 1 through $increment {
$value: ($value * $ratio);
}
}
@if $increment < 0 {
$increment: abs($increment);
@for $i from 1 through $increment {
$value: ($value / $ratio);
}
}
@return $value;
}
// div {
// Increment Up GR with positive value
// font-size: modular-scale(14px, 1, 1.618); // returns: 22.652px
//
// Increment Down GR with negative value
// font-size: modular-scale(14px, -1, 1.618); // returns: 8.653px
//
// Can be used with ceil(round up) or floor(round down)
// font-size: floor( modular-scale(14px, 1, 1.618) ); // returns: 22px
// font-size: ceil( modular-scale(14px, 1, 1.618) ); // returns: 23px
// }
//
// modularscale.com
@function golden-ratio($value, $increment) {
@return modular-scale($value, $increment, 1.618)
}
// div {
// font-size: golden-ratio(14px, 1); // returns: 22.652px
// }
//
// goldenratiocalculator.com

View File

@@ -0,0 +1,8 @@
// Convert pixels to ems
// eg. for a relational value of 12px write em(12) when the parent is 16px
// if the parent is another value say 24px write em(12, 24)
@function em($pxval, $base: 16) {
@return ($pxval / $base) * 1em;
}

View File

@@ -0,0 +1,23 @@
// This function is required and used by the background-image mixin.
@function radial-gradient($G1, $G2,
$G3: false, $G4: false,
$G5: false, $G6: false,
$G7: false, $G8: false,
$G9: false, $G10: false,
$pos: null,
$shape-size: null) {
$data: _radial-arg-parser($G1, $G2, $pos, $shape-size);
$G1: nth($data, 1);
$G2: nth($data, 2);
$pos: nth($data, 3);
$shape-size: nth($data, 4);
$type: radial;
$gradient: compact($G1, $G2, $G3, $G4, $G5, $G6, $G7, $G8, $G9, $G10);
$type-gradient: $type, $shape-size $pos, $gradient;
@return $type-gradient;
}

View File

@@ -0,0 +1,9 @@
// Add percentage of white to a color
@function tint($color, $percent){
@return mix(white, $color, $percent);
}
// Add percentage of black to a color
@function shade($color, $percent){
@return mix(black, $color, $percent);
}

View File

@@ -0,0 +1,22 @@
// Return vendor-prefixed property names if appropriate
// Example: transition-property-names((transform, color, background), moz) -> -moz-transform, color, background
//************************************************************************//
@function transition-property-names($props, $vendor: false) {
$new-props: ();
@each $prop in $props {
$new-props: append($new-props, transition-property-name($prop, $vendor), comma);
}
@return $new-props;
}
@function transition-property-name($prop, $vendor: false) {
// put other properties that need to be prefixed here aswell
@if $vendor and $prop == transform {
@return unquote('-'+$vendor+'-'+$prop);
}
@else {
@return $prop;
}
}

View File

@@ -0,0 +1,39 @@
// Render Deprecated Webkit Gradient - Linear || Radial
//************************************************************************//
@function _deprecated-webkit-gradient($type,
$deprecated-pos1, $deprecated-pos2,
$full,
$deprecated-radius1: false, $deprecated-radius2: false) {
$gradient-list: ();
$gradient: false;
$full-length: length($full);
$percentage: false;
$gradient-type: $type;
@for $i from 1 through $full-length {
$gradient: nth($full, $i);
@if length($gradient) == 2 {
$color-stop: color-stop(nth($gradient, 2), nth($gradient, 1));
$gradient-list: join($gradient-list, $color-stop, comma);
}
@else if $gradient != null {
@if $i == $full-length {
$percentage: 100%;
}
@else {
$percentage: ($i - 1) * (100 / ($full-length - 1)) + "%";
}
$color-stop: color-stop(unquote($percentage), $gradient);
$gradient-list: join($gradient-list, $color-stop, comma);
}
}
@if $type == radial {
$gradient: -webkit-gradient(radial, $deprecated-pos1, $deprecated-radius1, $deprecated-pos2, $deprecated-radius2, $gradient-list);
}
@else if $type == linear {
$gradient: -webkit-gradient(linear, $deprecated-pos1, $deprecated-pos2, $gradient-list);
}
@return $gradient;
}

View File

@@ -0,0 +1,13 @@
@function _gradient-positions-parser($gradient-type, $gradient-positions) {
@if $gradient-positions
and ($gradient-type == linear)
and (type-of($gradient-positions) != color) {
$gradient-positions: _linear-positions-parser($gradient-positions);
}
@else if $gradient-positions
and ($gradient-type == radial)
and (type-of($gradient-positions) != color) {
$gradient-positions: _radial-positions-parser($gradient-positions);
}
@return $gradient-positions;
}

View File

@@ -0,0 +1,61 @@
@function _linear-positions-parser($pos) {
$type: type-of(nth($pos, 1));
$spec: null;
$degree: null;
$side: null;
$corner: null;
$length: length($pos);
// Parse Side and corner positions
@if ($length > 1) {
@if nth($pos, 1) == "to" { // Newer syntax
$side: nth($pos, 2);
@if $length == 2 { // eg. to top
// Swap for backwards compatability
$degree: _position-flipper(nth($pos, 2));
}
@else if $length == 3 { // eg. to top left
$corner: nth($pos, 3);
}
}
@else if $length == 2 { // Older syntax ("top left")
$side: _position-flipper(nth($pos, 1));
$corner: _position-flipper(nth($pos, 2));
}
@if ("#{$side} #{$corner}" == "left top") or ("#{$side} #{$corner}" == "top left") {
$degree: _position-flipper(#{$side}) _position-flipper(#{$corner});
}
@else if ("#{$side} #{$corner}" == "right top") or ("#{$side} #{$corner}" == "top right") {
$degree: _position-flipper(#{$side}) _position-flipper(#{$corner});
}
@else if ("#{$side} #{$corner}" == "right bottom") or ("#{$side} #{$corner}" == "bottom right") {
$degree: _position-flipper(#{$side}) _position-flipper(#{$corner});
}
@else if ("#{$side} #{$corner}" == "left bottom") or ("#{$side} #{$corner}" == "bottom left") {
$degree: _position-flipper(#{$side}) _position-flipper(#{$corner});
}
$spec: to $side $corner;
}
@else if $length == 1 {
// Swap for backwards compatability
@if $type == string {
$degree: $pos;
$spec: to _position-flipper($pos);
}
@else {
$degree: -270 - $pos; //rotate the gradient opposite from spec
$spec: $pos;
}
}
$degree: unquote($degree + ",");
$spec: unquote($spec + ",");
@return $degree $spec;
}
@function _position-flipper($pos) {
@return if($pos == left, right, null)
if($pos == right, left, null)
if($pos == top, bottom, null)
if($pos == bottom, top, null);
}

View File

@@ -0,0 +1,69 @@
@function _radial-arg-parser($G1, $G2, $pos, $shape-size) {
@each $value in $G1, $G2 {
$first-val: nth($value, 1);
$pos-type: type-of($first-val);
$spec-at-index: null;
// Determine if spec was passed to mixin
@if type-of($value) == list {
$spec-at-index: if(index($value, at), index($value, at), false);
}
@if $spec-at-index {
@if $spec-at-index > 1 {
@for $i from 1 through ($spec-at-index - 1) {
$shape-size: $shape-size nth($value, $i);
}
@for $i from ($spec-at-index + 1) through length($value) {
$pos: $pos nth($value, $i);
}
}
@else if $spec-at-index == 1 {
@for $i from ($spec-at-index + 1) through length($value) {
$pos: $pos nth($value, $i);
}
}
$G1: false;
}
// If not spec calculate correct values
@else {
@if ($pos-type != color) or ($first-val != "transparent") {
@if ($pos-type == number)
or ($first-val == "center")
or ($first-val == "top")
or ($first-val == "right")
or ($first-val == "bottom")
or ($first-val == "left") {
$pos: $value;
@if $pos == $G1 {
$G1: false;
}
}
@else if
($first-val == "ellipse")
or ($first-val == "circle")
or ($first-val == "closest-side")
or ($first-val == "closest-corner")
or ($first-val == "farthest-side")
or ($first-val == "farthest-corner")
or ($first-val == "contain")
or ($first-val == "cover") {
$shape-size: $value;
@if $value == $G1 {
$G1: false;
}
@else if $value == $G2 {
$G2: false;
}
}
}
}
}
@return $G1, $G2, $pos, $shape-size;
}

View File

@@ -0,0 +1,18 @@
@function _radial-positions-parser($gradient-pos) {
$shape-size: nth($gradient-pos, 1);
$pos: nth($gradient-pos, 2);
$shape-size-spec: _shape-size-stripper($shape-size);
$pre-spec: unquote(if($pos, "#{$pos}, ", null))
unquote(if($shape-size, "#{$shape-size},", null));
$pos-spec: if($pos, "at #{$pos}", null);
$spec: "#{$shape-size-spec} #{$pos-spec}";
// Add comma
@if ($spec != ' ') {
$spec: "#{$spec},"
}
@return $pre-spec $spec;
}

View File

@@ -0,0 +1,26 @@
// User for linear and radial gradients within background-image or border-image properties
@function _render-gradients($gradient-positions, $gradients, $gradient-type, $vendor: false) {
$pre-spec: null;
$spec: null;
$vendor-gradients: null;
@if $gradient-type == linear {
@if $gradient-positions {
$pre-spec: nth($gradient-positions, 1);
$spec: nth($gradient-positions, 2);
}
}
@else if $gradient-type == radial {
$pre-spec: nth($gradient-positions, 1);
$spec: nth($gradient-positions, 2);
}
@if $vendor {
$vendor-gradients: -#{$vendor}-#{$gradient-type}-gradient(#{$pre-spec} $gradients);
}
@else if $vendor == false {
$vendor-gradients: "#{$gradient-type}-gradient(#{$spec} #{$gradients})";
$vendor-gradients: unquote($vendor-gradients);
}
@return $vendor-gradients;
}

View File

@@ -0,0 +1,10 @@
@function _shape-size-stripper($shape-size) {
$shape-size-spec: null;
@each $value in $shape-size {
@if ($value == "cover") or ($value == "contain") {
$value: null;
}
$shape-size-spec: "#{$shape-size-spec} #{$value}";
}
@return $shape-size-spec;
}

714
docs/_css/react.scss Normal file
View File

@@ -0,0 +1,714 @@
@import 'bourbon/bourbon';
@import '_variables';
@import '_typography';
@import '_solarized';
@mixin code-typography {
font-family: 'source-code-pro', Menlo, 'Courier New', Consolas, monospace;
font-size: 13px;
line-height: 20px;
}
$skinnyContentWidth: 650px;
$contentWidth: 920px;
$contentPadding: 20px;
$columnWidth: 280px;
$columnGutter: 40px;
$twoColumnWidth: 2 * $columnWidth + $columnGutter;
// basic reset
* {
@include box-sizing(border-box);
border: none;
margin: 0;
padding: 0;
}
html {
background: $pageBg;
}
.left {
float: left;
}
.right {
float: right;
}
.container {
padding-top: 50px;
min-width: $contentWidth + (2 * $contentPadding);
}
.wrap {
width: $contentWidth + (2 * $contentPadding);
margin-left: auto;
margin-right: auto;
padding-left: 20px;
padding-right: 20px;
}
.skinnyWrap {
width: $skinnyContentWidth + (2 * $contentPadding);
margin-left: auto;
margin-right: auto;
padding-left: 20px;
padding-right: 20px;
}
hr {
height: 0;
border-top: 1px solid #ccc;
border-bottom: 1px solid #eee;
}
ul,
li {
margin-left: 20px;
}
// Main Nav
.nav-main {
@include clearfix;
background: $darkestColor;
color: $lightTextColor;
position: fixed;
top: 0;
height: 50px;
box-shadow: 0 0 5px rgba(0, 0, 0, .5);
width: 100%;
z-index: 100;
a {
color: $lightColor;
text-decoration: none;
}
.nav-site {
float: right;
margin: 0;
li {
margin: 0;
}
a {
padding: 0 8px;
text-transform: uppercase;
letter-spacing: 1px;
line-height: 50px;
display: inline-block;
height: 50px;
color: $mediumTextColor;
&:hover {
color: $lightTextColor;
}
&.active {
color: $lightTextColor;
border-bottom: 3px solid $primary;
background: #333;
}
}
}
.nav-home {
color: #00d8ff;
font-size: 24px;
line-height: 50px;
}
.nav-logo {
@include retina-image('../img/logo_small', 38px 38px);
vertical-align: middle;
}
ul {
display: inline;
}
li {
display: inline;
}
}
// Hero!
.hero {
height: 300px;
// background: $darkColor url(../img/header.png) no-repeat center;
background: $darkColor;
padding-top: 50px;
color: $lightColor;
font-weight: 300;
.text {
font-size: 64px;
text-align: center;
}
.minitext {
font-size: 16px;
text-align: center;
text-transform: uppercase;
}
strong {
color: $blueColor;
font-weight: 400;
}
}
.buttons-unit {
margin-top: 60px;
text-align: center;
a {
color: $blueColor;
}
.button {
font-size: 24px;
background: $primary;
color: $lightTextColor;
&:active {
background: darken($primary, 5%);
}
}
}
// Downloads
.buttons-unit.downloads {
margin: 30px 0;
}
// Docs Nav
.nav-docs {
color: $darkColor;
font-size: 14px;
// position: fixed;
float: left;
width: 210px;
ul {
list-style: none;
margin: 0;
}
ul ul {
margin-left: 20px;
}
li {
margin: 0;
}
h3 {
text-transform: uppercase;
font-size: 14px;
}
a {
color: $mediumestColor;
display: block;
&:hover {
text-decoration: none;
color: $primary;
}
&.active {
color: $primary;
}
}
.nav-docs-section {
border-bottom: 1px solid #ccc;
border-top: 1px solid #eee;
padding: 12px 0;
&:first-child {
padding-top: 0;
border-top: 0;
}
&:last-child {
padding-bottom: 0;
border-bottom: 0;
}
}
}
.nav-blog {
li {
margin-bottom: 5px;
}
}
// Home Page specifics
.home-section {
margin: 50px 0;
}
.home-divider {
border-top-color: #bbb;
margin: 0 auto;
width: 400px;
}
.marketing-row {
@include clearfix;
margin: 50px 0;
}
.marketing-col {
float: left;
margin-right: 40px;
width: $columnWidth;
h3 {
color: $darkColor;
font-size: 24px;
font-weight: normal;
text-transform: uppercase;
}
p {
font-size: 16px;
}
}
.marketing-col:last-child {
margin-right: 0;
}
#examples h3, .home-presentation h3 {
color: $darkColor;
font-size: 24px;
font-weight: normal;
margin-bottom: 5px;
}
#examples {
p {
margin: 0 0 25px 0;
max-width: $twoColumnWidth;
}
.example {
margin-top: 60px;
}
#todoExample {
font-size: 14px;
ul {
list-style-type: square;
margin: 0 0 10px 0;
}
input {
border: 1px solid #ccc;
font: 14px proxima-nova, $helvetica;
padding: 3px;
width: 150px;
}
button {
font: 14px proxima-nova, $helvetica;
margin-left: 5px;
padding: 4px 10px;
}
}
#markdownExample {
textarea {
border: 1px solid #ccc;
font: 14px proxima-nova, $helvetica;
margin-bottom: 10px;
padding: 5px;
}
}
}
.home-bottom-section {
margin-bottom: 100px;
}
.docs-nextprev {
@include clearfix;
}
.docs-prev {
float: left;
}
.docs-next {
float: right;
}
footer {
font-size: 13px;
font-weight: 600;
margin-top: 36px;
margin-bottom: 18px;
overflow: auto;
}
section.black content {
padding-bottom: 18px;
}
/**
* Blog
*/
.blogContent {
padding-top: 20px;
blockquote {
padding: 5px 15px;
margin: 20px 0;
background-color: #f8f5ec;
border-left: 5px solid #f7ebc6;
}
}
/**
* Docs
*/
.documentationContent {
@include clearfix;
.subHeader {
font-size: 24px;
}
h1, h2, h3, h4, h5, h6 {
a {
color: $darkTextColor;
&:hover {
text-decoration: underline;
}
}
}
// H2s form documentation topic dividers. Extra space helps.
h2 {
margin-top: 30px;
}
padding-top: 20px;
// Make a notice box out of blockquotes in the documetation:
blockquote {
padding: 15px 30px 15px 15px;
margin: 20px 0;
background-color: rgba(204, 122, 111, 0.09999999999999998);
border-left: 5px solid rgba(191, 87, 73, 0.19999999999999996);
h4 {
margin-top: 0;
}
p:last-child {
margin-bottom: 0;
}
// Treat first child as the title - promote to H4.
p:first-child {
font-weight: bold;
font-size: 17.5px;
line-height: 20px;
margin-top: 0;
text-rendering: optimizelegibility;
}
}
}
.docs-prevnext {
padding-top: 40px;
padding-bottom: 40px;
}
/* JSX Compiler */
.jsxCompiler {
margin: 0 auto;
padding-top: 20px;
width: 1220px;
#jsxCompiler {
margin-top: 20px;
}
.playgroundPreview {
padding: 14px;
width: 600px;
pre {
@include code-typography;
}
}
}
/* Button */
.button {
@include background(linear-gradient($buttonGreyTop, $buttonGreyBottom));
// border: 1px solid $darkestColor;
border-radius: 4px;
padding: 8px 16px;
font-size: 18px;
font-weight: 400;
margin: 0 12px;
// word-spacing: -2px;
// letter-spacing: 1px;
display: inline-block;
color: $lightTextColor;
text-decoration: none;
text-shadow: 0 1px 3px rgba(0, 0, 0, .3);
box-shadow: 0 1px 1px rgba(0, 0, 0, .2);
text-decoration: none;
&:hover {
text-decoration: none;
}
&:active {
box-shadow: none;
}
}
.hero {
.button {
box-shadow: 1px 3px 3px rgba(0, 0, 0, .3);
}
}
.button.blue {
@include background(linear-gradient($buttonBlueTop, $buttonBlueBottom));
}
/* Row */
.row {
padding-bottom: 4px;
}
.row .span4 {
width: 33.33%;
display: table-cell;
}
.row .span8 {
width: 66.66%;
display: table-cell;
}
.row .span6 {
width: 50%;
display: table-cell;
}
/* Content */
p {
margin: 10px 0;
}
.highlight {
padding: 10px;
margin-bottom: 20px;
}
figure {
text-align: center;
}
.inner-content {
float: right;
width: $skinnyContentWidth;
}
.nosidebar .inner-content {
float: none;
margin: 0 auto;
}
/* Blog */
.post-list-item + .post-list-item {
margin-top: 60px;
}
/* Code Mirror */
div.CodeMirror pre, div.CodeMirror-linenumber, code {
@include code-typography;
}
div.CodeMirror-linenumber:after {
content: '.';
}
.CodeMirror, div.CodeMirror-gutters, div.highlight {
border: none;
}
small code,
li code,
p code {
color: #555;
background-color: rgba(0, 0, 0, .04);
padding: 1px 3px;
}
.cm-s-default span.cm-string-2 {
color: inherit;
}
.playground {
@include clearfix;
}
.playground::before {
border-bottom: none !important;
border-radius: 3px 3px 0 0;
padding: 3px 7px;
font-size: 12px;
font-weight: bold;
color: #c2c0bc;
background-color: #f1ede4;
content: 'Live editor';
}
.playground::before,
.playgroundCode,
.playgroundPreview {
border: 1px solid rgba(16,16,16,0.1);
}
.playgroundCode {
border-radius: 0 3px 3px 3px;
float: left;
overflow: hidden;
width: $twoColumnWidth;
}
.playgroundPreview {
background-color: white;
border-radius: 3px;
float: right;
padding: 15px 20px;
width: $columnWidth;
}
.MarkdownEditor textarea {
width: 100%;
height: 100px
}
.hll {
background-color: #f7ebc6;
border-left: 5px solid #f7d87c;
display: block;
margin-left: -14px;
margin-right: -14px;
padding-left: 9px;
}
/* Codemirror doesn't support <jsx> syntax. Instead of highlighting it
as error, just ignore it */
.highlight .javascript .err {
background-color: transparent;
color: inherit;
}
.highlight {
position: relative;
margin-bottom: 14px;
padding: 30px 14px 14px;
border: none;
border-radius: 0;
overflow: auto;
}
.highlight pre {
padding: 0;
margin-top: 0;
margin-bottom: 0;
background-color: transparent;
border: 0;
}
.highlight pre code {
font-size: inherit;
}
.highlight pre .lineno {
display: inline-block;
width: 22px;
padding-right: 5px;
margin-right: 10px;
color: #bebec5;
text-align: right;
}
/* Echo out a label for the example */
.highlight:after {
position: absolute;
top: 0;
right: 0;
left: 0;
padding: 3px 7px;
font-size: 12px;
font-weight: bold;
color: #c2c0bc;
background-color: #f1ede4;
content: "Code";
}
.downloadCenter {
text-align: center;
margin-top: 20px;
margin-bottom: 25px;
}
.downloadSection:hover {
text-decoration: none !important;
}
@media screen and (max-width: 960px) {
.nav-main {
position: static;
}
.container {
padding-top: 0;
}
}
.post {
margin-bottom: 30px;
}
.pagination {
margin-bottom: 30px;
/* Trick to get the wrapper to expand to fit floating elements */
width: 100%;
overflow: hidden;
.next {
float: right;
}
}

View File

@@ -0,0 +1,10 @@
<h1><a href="/react{{ page.url }}">{{ page.title }}</a></h1>
<p class="meta">{{ page.date | date_to_string }} by {{ page.author }}</p>
<div id="post">
{% if content != '' %}
{{ page.excerpt }}
{% else %}
{{ page.content }}
{% endif %}
</div>

View File

@@ -0,0 +1,11 @@
<div class="nav-docs nav-blog">
<div class="nav-docs-section">
<h3>Recent posts</h3>
<ul>
{% for post in site.posts limit:10 %}
<li><a href="/react{{ post.url }}"{% if page.title == post.title %} class="active"{% endif %}>{{ post.title }}</a></li>
{% endfor %}
<li><a href="/react/blog/all.html">All posts ...</a></li>
</ul>
</div>
</div>

View File

@@ -0,0 +1,27 @@
<div class="nav-docs">
{% for section in site.nav_docs_sections %}
<div class="nav-docs-section">
<h3>{{ section.title }}</h3>
<ul>
{% for item in section.items %}
<li>
<a href="/react/docs/{{ item.id }}.html"{% if page.id == item.id %} class="active"{% endif %}>
{{ item.title }}
</a>
{% if item.subitems %}
<ul>
{% for subitem in item.subitems %}
<li>
<a href="/react/docs/{{ subitem.id }}.html"{% if page.id == subitem.id %} class="active"{% endif %}>
{{ subitem.title }}
</a>
</li>
{% endfor %}
</ul>
{% endif %}
</li>
{% endfor %}
</ul>
</div>
{% endfor %}
</div>

View File

@@ -0,0 +1,19 @@
/**
* @jsx React.DOM
*/
var HELLO_COMPONENT = "\
/** @jsx React.DOM */\n\
var HelloMessage = React.createClass({\n\
render: function() {\n\
return <div>{'Hello ' + this.props.name}</div>;\n\
}\n\
});\n\
\n\
React.renderComponent(<HelloMessage name=\"John\" />, mountNode);\
";
React.renderComponent(
<ReactPlayground codeText={HELLO_COMPONENT} />,
document.getElementById('helloExample')
);

View File

@@ -0,0 +1,43 @@
/**
* @jsx React.DOM
*/
var MARKDOWN_COMPONENT = "\
/** @jsx React.DOM */\n\
\n\
var converter = new Showdown.converter();\n\
\n\
var MarkdownEditor = React.createClass({\n\
getInitialState: function() {\n\
return {value: 'Type some *markdown* here!'};\n\
},\n\
handleChange: function() {\n\
this.setState({value: this.refs.textarea.getDOMNode().value});\n\
},\n\
render: function() {\n\
return (\n\
<div className=\"MarkdownEditor\">\n\
<h3>Input</h3>\n\
<textarea\n\
onChange={this.handleChange}\n\
ref=\"textarea\"\n\
defaultValue={this.state.value} />\n\
<h3>Output</h3>\n\
<div\n\
className=\"content\"\n\
dangerouslySetInnerHTML={{\n\
__html: converter.makeHtml(this.state.value)\n\
}}\n\
/>\n\
</div>\n\
);\n\
}\n\
});\n\
\n\
React.renderComponent(<MarkdownEditor />, mountNode);\
";
React.renderComponent(
<ReactPlayground codeText={MARKDOWN_COMPONENT} />,
document.getElementById('markdownExample')
);

View File

@@ -0,0 +1,32 @@
/**
* @jsx React.DOM
*/
var TIMER_COMPONENT = "\
var Timer = React.createClass({\n\
getInitialState: function() {\n\
return {secondsElapsed: 0};\n\
},\n\
tick: function() {\n\
this.setState({secondsElapsed: this.state.secondsElapsed + 1});\n\
},\n\
componentDidMount: function() {\n\
this.interval = setInterval(this.tick, 1000);\n\
},\n\
componentWillUnmount: function() {\n\
clearInterval(this.interval);\n\
},\n\
render: function() {\n\
return React.DOM.div({},\n\
'Seconds Elapsed: ' + this.state.secondsElapsed\n\
);\n\
}\n\
});\n\
\n\
React.renderComponent(Timer({}), mountNode);\
";
React.renderComponent(
<ReactPlayground codeText={TIMER_COMPONENT} />,
document.getElementById('timerExample')
);

47
docs/_js/examples/todo.js Normal file
View File

@@ -0,0 +1,47 @@
/**
* @jsx React.DOM
*/
var TODO_COMPONENT = "\
/** @jsx React.DOM */\n\
var TodoList = React.createClass({\n\
render: function() {\n\
var createItem = function(itemText) {\n\
return <li>{itemText}</li>;\n\
};\n\
return <ul>{this.props.items.map(createItem)}</ul>;\n\
}\n\
});\n\
var TodoApp = React.createClass({\n\
getInitialState: function() {\n\
return {items: [], text: ''};\n\
},\n\
onChange: function(e) {\n\
this.setState({text: e.target.value});\n\
},\n\
handleSubmit: function(e) {\n\
e.preventDefault();\n\
var nextItems = this.state.items.concat([this.state.text]);\n\
var nextText = '';\n\
this.setState({items: nextItems, text: nextText});\n\
},\n\
render: function() {\n\
return (\n\
<div>\n\
<h3>TODO</h3>\n\
<TodoList items={this.state.items} />\n\
<form onSubmit={this.handleSubmit}>\n\
<input onChange={this.onChange} value={this.state.text} />\n\
<button>{'Add #' + (this.state.items.length + 1)}</button>\n\
</form>\n\
</div>\n\
);\n\
}\n\
});\n\
React.renderComponent(<TodoApp />, mountNode);\
";
React.renderComponent(
<ReactPlayground codeText={TODO_COMPONENT} />,
document.getElementById('todoExample')
);

19
docs/_js/jsx-compiler.js Normal file
View File

@@ -0,0 +1,19 @@
/**
* @jsx React.DOM
*/
var HELLO_COMPONENT = "\
/** @jsx React.DOM */\n\
var HelloMessage = React.createClass({\n\
render: function() {\n\
return <div>{'Hello ' + this.props.name}</div>;\n\
}\n\
});\n\
\n\
React.renderComponent(<HelloMessage name=\"John\" />, mountNode);\
";
React.renderComponent(
<ReactPlayground codeText={HELLO_COMPONENT} renderCode={true} />,
document.getElementById('jsxCompiler')
);

130
docs/_js/live_editor.js Normal file
View File

@@ -0,0 +1,130 @@
/**
* @jsx React.DOM
*/
var IS_MOBILE = (
navigator.userAgent.match(/Android/i)
|| navigator.userAgent.match(/webOS/i)
|| navigator.userAgent.match(/iPhone/i)
|| navigator.userAgent.match(/iPad/i)
|| navigator.userAgent.match(/iPod/i)
|| navigator.userAgent.match(/BlackBerry/i)
|| navigator.userAgent.match(/Windows Phone/i)
);
var CodeMirrorEditor = React.createClass({
componentDidMount: function(root) {
if (IS_MOBILE) {
return;
}
this.editor = CodeMirror.fromTextArea(this.refs.editor.getDOMNode(), {
mode: 'javascript',
lineNumbers: false,
matchBrackets: true,
theme: 'solarized-light'
});
this.editor.on('change', this.onChange);
this.onChange();
},
onChange: function() {
if (this.props.onChange) {
var content = this.editor.getValue();
this.props.onChange(content);
}
},
render: function() {
// wrap in a div to fully contain CodeMirror
var editor;
if (IS_MOBILE) {
editor = <pre style={{overflow: 'scroll'}}>{this.props.codeText}</pre>;
} else {
editor = <textarea ref="editor" defaultValue={this.props.codeText} />;
}
return (
<div className={this.props.className}>
{editor}
</div>
);
}
});
var ReactPlayground = React.createClass({
MODES: {XJS: 'XJS', JS: 'JS'}, //keyMirror({XJS: true, JS: true}),
getInitialState: function() {
return {mode: this.MODES.XJS, code: this.props.codeText};
},
bindState: function(name) {
return function(value) {
var newState = {};
newState[name] = value;
this.setState(newState);
}.bind(this);
},
getDesugaredCode: function() {
return JSXTransformer.transform(this.state.code).code;
},
render: function() {
var content;
if (this.state.mode === this.MODES.XJS) {
content =
<CodeMirrorEditor
onChange={this.bindState('code')}
className="playgroundStage"
codeText={this.state.code}
/>;
} else if (this.state.mode === this.MODES.JS) {
content =
<div className="playgroundJS playgroundStage">
{this.getDesugaredCode()}
</div>;
}
return (
<div className="playground">
<div className="playgroundCode">
{content}
</div>
<div className="playgroundPreview">
<div ref="mount" />
</div>
</div>
);
},
componentDidMount: function() {
this.executeCode();
},
componentDidUpdate: function() {
this.executeCode();
},
executeCode: function() {
var mountNode = this.refs.mount.getDOMNode();
try {
React.unmountAndReleaseReactRootNode(mountNode);
} catch (e) { }
try {
if (this.props.renderCode) {
React.renderComponent(
<pre>{this.getDesugaredCode()}</pre>,
mountNode
);
} else {
eval(this.getDesugaredCode());
}
} catch (e) {
React.renderComponent(
<div content={e.toString()} className="playgroundError" />,
mountNode
);
}
}
});

View File

@@ -0,0 +1,96 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>React | {{ page.title }}</title>
<meta name="viewport" content="width=device-width">
<meta property="og:title" content="React | {{ page.title }}" />
<meta property="og:type" content="website" />
<meta property="og:url" content="http://facebook.github.io/react{{ page.url }}" />
<meta property="og:image" content="http://facebook.github.io/react/img/logo_og.png" />
<meta property="og:description" content="A JavaScript library for building user interfaces" />
<meta property="fb:app_id" content="623268441017527" />
<link rel="shortcut icon" href="/react/favicon.ico">
<link rel="alternate" type="application/rss+xml" title="{{ site.name }}" href="{{ site.url }}{{ site.baseurl }}/feed.xml">
<link rel="stylesheet" href="/react/css/react.css">
<link rel="stylesheet" href="/react/css/syntax.css">
<link rel="stylesheet" href="/react/css/codemirror.css">
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
<script type="text/javascript" src="/react/js/codemirror.js"></script>
<script type="text/javascript" src="/react/js/javascript.js"></script>
<script type="text/javascript" src="/react/js/react.min.js"></script>
<script type="text/javascript" src="/react/js/JSXTransformer.js"></script>
<script type="text/javascript" src="/react/js/live_editor.js"></script>
<script type="text/javascript" src="/react/js/showdown.js"></script>
</head>
<body>
<div class="container">
<div class="nav-main">
<div class="wrap">
<a class="nav-home" href="/react/index.html">
<img class="nav-logo" alt="" src="/react/img/logo_small.png" width="38" height="38">
React
</a>
<ul class="nav-site">
<li><a href="/react/docs/getting-started.html"{% if page.sectionid == 'docs' %} class="active"{% endif %}>docs</a></li>
<li><a href="/react/support.html"{% if page.id == 'support' %} class="active"{% endif %}>support</a></li>
<li><a href="/react/downloads.html"{% if page.id == 'downloads' %} class="active"{% endif %}>download</a></li>
<li><a href="/react/blog/"{% if page.sectionid == 'blog' %} class="active"{% endif %}>blog</a></li>
<li><a href="http://github.com/facebook/react">github</a>
</ul>
<!-- <iframe src="http://ghbtns.com/github&#45;btn.html?user=facebook&#38;repo=react.js&#38;type=fork"allowtransparency="true" frameborder="0" scrolling="0" width="62" height="20"></iframe> -->
</div>
</div>
{% if page.id == 'home' %}
<div class="hero">
<div class="wrap">
<div class="text"><strong>React</strong></div>
<div class="minitext">
A JavaScript library for building user interfaces
</div>
<div class="buttons-unit">
<a href="/react/docs/getting-started.html" class="button">Get Started</a>
<a href="/react/downloads.html" class="button">Download React v{{site.react_version}}</a>
</div>
</div>
</div>
{% endif %}
{{ content }}
<footer class="wrap">
<div class="left">A Facebook &amp; Instagram collaboration.</div>
<div class="right">&copy; 2013 Facebook Inc.</div>
</footer>
</div>
<div id="fb-root"></div>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-41298772-1', 'facebook.github.io');
ga('send', 'pageview');
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="https://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=623268441017527";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
</body>
</html>

25
docs/_layouts/docs.html Normal file
View File

@@ -0,0 +1,25 @@
---
layout: default
sectionid: docs
---
<section class="content wrap documentationContent">
{% include nav_docs.html %}
<div class="inner-content">
<h1>{{ page.title }}</h1>
<div class="subHeader">{{ page.description }}</div>
{{ content }}
<div class="docs-prevnext">
{% if page.prev %}
<a class="docs-prev" href="/react/docs/{{ page.prev }}">&larr; Prev</a>
{% endif %}
{% if page.next %}
<a class="docs-next" href="/react/docs/{{ page.next }}">Next &rarr;</a>
{% endif %}
</div>
<div class="fb-comments" data-width="650" data-num-posts="10" data-href="{{ site.url }}{{ site.baseurl }}{{ page.url }}"></div>
</div>
</section>

7
docs/_layouts/page.html Normal file
View File

@@ -0,0 +1,7 @@
---
layout: default
---
<section class="content wrap">
{{ content }}
</section>

21
docs/_layouts/post.html Normal file
View File

@@ -0,0 +1,21 @@
---
layout: default
sectionid: blog
---
<section class="content wrap blogContent">
{% include nav_blog.html %}
<div class="inner-content">
<h1>{{ page.title }}</h1>
<p class="meta">{{ page.date | date: "%B %e, %Y" }} by {{ page.author }}</p>
<hr>
<div class="post">
{{ content }}
</div>
<div class="fb-like" data-send="true" data-width="650" data-show-faces="false"></div>
<div class="fb-comments" data-width="650" data-num-posts="10" data-href="{{ site.url }}{{ site.baseurl }}{{ page.url }}"></div>
</div>
</section>

View File

@@ -0,0 +1,6 @@
<html>
<head>
<meta http-equiv="refresh" content="0; {{ page.destination }}">
</head>
<body></body>
</html>

20
docs/_layouts/single.html Normal file
View File

@@ -0,0 +1,20 @@
---
layout: default
---
<section class="content wrap documentationContent nosidebar">
<div class="inner-content">
<h1>{{ page.title }}</h1>
<div class="subHeader">{{ page.description }}</div>
{{ content }}
<div class="docs-prevnext">
{% if page.prev %}
<a class="docs-prev" href="/react/docs/{{ page.prev }}">&larr; Prev</a>
{% endif %}
{% if page.next %}
<a class="docs-next" href="/react/docs/{{ page.next }}">Next &rarr;</a>
{% endif %}
</div>
</div>
</section>

View File

@@ -0,0 +1,17 @@
require 'redcarpet'
require 'sanitize'
# Simple converter that is probably better than RedCarpet's built in TOC id
# generator (which ends up with things lik id="toc_1"... terrible).
class Redcarpet::Render::HTML
def header(title, level)
clean_title = Sanitize.clean(title)
.downcase
.gsub(/\s+/, "-")
.gsub(/[^A-Za-z0-9\-_.]/, "")
return "<h#{level} id=\"#{clean_title}\"><a href=\"##{clean_title}\">#{title}</a></h#{level}>"
end
end

View File

@@ -0,0 +1,39 @@
# Replace Jekyll's handling of the Redcarpet code_block (which already adds
# support for highlighting, but needs support for the very non-standard
# "code fences with line highlights" extension).
# Since this is currently depending on Redcarpet to cooperate, we are going to
# be naive, and only allow line highlighting when a language is specified. If
# you don't want any syntax highlighting but want to highlight lines, then you
# need to specify text as your language, like:
# ```text{4}
module Jekyll
module Converters
class Markdown
class RedcarpetParser
module WithPygments
def block_code(code, lang)
require 'pygments'
lang_parts = lang && lang.split('{')
lang = lang_parts && !lang_parts[0].empty? && lang_parts[0] || 'text'
hl_lines = ''
if lang_parts && lang_parts.size >= 2
hl_lines = lang_parts[1].gsub(/[{}]/, '').split(',').map do |ln|
if matches = /(\d+)-(\d+)/.match(ln)
ln = Range.new(matches[1], matches[2]).to_a.join(' ')
end
ln
end.join(' ')
end
output = add_code_tags(
Pygments.highlight(code, :lexer => lang,
:options => { :encoding => 'utf-8', :hl_lines => hl_lines }),
lang
)
end
end
end
end
end
end

View File

@@ -0,0 +1,11 @@
---
title: JSFiddle Integration
layout: post
author: Christopher Chedeau
---
[JSFiddle](http://jsfiddle.net) just announced support for React. This is an exciting news as it makes collaboration on snippets of code a lot easier. You can play around this **[base React JSFiddle](http://jsfiddle.net/vjeux/kb3gN/)**, fork it and share it! A [fiddle without JSX](http://jsfiddle.net/vjeux/VkebS/) is also available.
<blockquote class="twitter-tweet" align="center"><p>React (by Facebook) is now available on JSFiddle. <a href="http://t.co/wNQf9JPv5u" title="http://facebook.github.io/react/">facebook.github.io/react/</a></p>&mdash; JSFiddle (@jsfiddle) <a href="https://twitter.com/jsfiddle/status/341114115781177344">June 2, 2013</a></blockquote>
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>

View File

@@ -0,0 +1,91 @@
---
title: Why did we build React?
layout: post
author: Pete Hunt
---
There are a lot of JavaScript MVC frameworks out there. Why did we build React
and why would you want to use it?
## React isn't an MVC framework.
React is a library for building composable user interfaces. It encourages
the creation of reusable UI components which present data that changes over
time.
## React doesn't use templates.
Traditionally, web application UIs are built using templates or HTML directives.
These templates dictate the full set of abstractions that you are allowed to use
to build your UI.
React approaches building user interfaces differently by breaking them into
**components**. This means React uses a real, full featured programming language
to render views, which we see as an advantage over templates for a few reasons:
- **JavaScript is a flexible, powerful programming language** with the ability
to build abstractions. This is incredibly important in large applications.
- By unifying your markup with its corresponding view logic, React can actually
make views **easier to extend and maintain**.
- By baking an understanding of markup and content into JavaScript, there's
**no manual string concatenation** and therefore less surface area for XSS
vulnerabilities.
We've also created [JSX](http://facebook.github.io/react/docs/syntax.html), an optional
syntax extension, in case you prefer the readability of HTML to raw JavaScript.
## Reactive updates are dead simple.
React really shines when your data changes over time.
In a traditional JavaScript application, you need to look at what data changed
and imperatively make changes to the DOM to keep it up-to-date. Even AngularJS,
which provides a declarative interface via directives and data binding [requires
a linking function to manually update DOM nodes](http://docs.angularjs.org/guide/directive#reasonsbehindthecompilelinkseparation).
React takes a different approach.
When your component is first initialized, the `render` method is called,
generating a lightweight representation of your view. From that representation,
a string of markup is produced, and injected into the document. When your data
changes, the `render` method is called again. In order to perform updates as
efficiently as possible, we diff the return value from the previous call to
`render` with the new one, and generate a minimal set of changes to be applied
to the DOM.
> The data returned from `render` is neither a string nor a DOM node -- it's a
> lightweight description of what the DOM should look like.
We call this process **reconciliation**. Check out
[this jsFiddle](http://jsfiddle.net/fv6RD/3/) to see an example of
reconciliation in action.
Because this re-render is so fast (around 1ms for TodoMVC), the developer
doesn't need to explicitly specify data bindings. We've found this approach
makes it easier to build apps.
## HTML is just the beginning.
Because React has its own lightweight representation of the document, we can do
some pretty cool things with it:
- Facebook has dynamic charts that render to `<canvas>` instead of HTML.
- Instagram is a "single page" web app built entirely with React and
`Backbone.Router`. Designers regularly contribute React code with JSX.
- We've built internal prototypes that run React apps in a web worker and use
React to drive **native iOS views** via an Objective-C bridge.
- You can run React
[on the server](http://github.com/petehunt/react-server-rendering)
for SEO, performance, code sharing and overall flexibility.
- Events behave in a consistent, standards-compliant way in all browsers
(including IE8) and automatically use
[event delegation](http://davidwalsh.name/event-delegate).
Head on over to
[facebook.github.io/react](http://facebook.github.io/react) to check
out what we have built. Our documentation is geared towards building
apps with the framework, but if you are interested in the
nuts and bolts
[get in touch](http://facebook.github.io/react/support.html) with us!
Thanks for reading!

View File

@@ -0,0 +1,48 @@
---
title: "Community Round-up #1"
layout: post
author: Vjeux
---
React was open sourced two weeks ago and it's time for a little round-up of what has been going on.
## Khan Academy Question Editor
It looks like [Ben Alpert](http://benalpert.com/) is the first person outside of Facebook and Instagram to push React code to production. We are very grateful for his contributions in form of pull requests, bug reports and presence on IRC ([#reactjs on Freenode](irc://chat.freenode.net/reactjs)). Ben wrote about his experience using React:
> I just rewrote a 2000-line project in React and have now made a handful of pull requests to React. Everything about React I've seen so far seems really well thought-out and I'm proud to be the first non-FB/IG production user of React.
>
> The project that I rewrote in React (and am continuing to improve) is the Khan Academy question editor which content creators can use to enter questions and hints that will be presented to students:
> <figure>[![](/react/img/blog/khan-academy-editor.png)](http://benalpert.com/2013/06/09/using-react-to-speed-up-khan-academy.html)</figure>
>
> [Read the full post...](http://benalpert.com/2013/06/09/using-react-to-speed-up-khan-academy.html)
## Pimp my Backbone.View (by replacing it with React)
[Paul Seiffert](https://blog.mayflower.de/) wrote a blog post that explains how to integrate React into Backbone applications.
> React has some interesting concepts for JavaScript view objects that can be used to eliminate this one big problem I have with Backbone.js.
>
> As in most MVC implementations (although React is probably just a VC implementation), a view is one portion of the screen that is managed by a controlling object. This object is responsible for deciding when to re-render the view and how to react to user input. With React, these view-controllers objects are called components. A component knows how to render its view and how to handle to the user's interaction with it.
>
> The interesting thing is that React is figuring out by itself when to re-render a view and how to do this in the most efficient way.
>
> [Read the full post...](https://blog.mayflower.de/3937-Backbone-React.html)
## Using facebook's React with require.js
[Mario Mueller](http://blog.xenji.com/) wrote a menu component in React and was able to easily integrate it with require.js, EventEmitter2 and bower.
> I recently stumbled upon facebook's React library, which is a Javascript library for building reusable frontend components. Even if this lib is only at version 0.3.x it behaves very stable, it is fast and is fun to code. I'm a big fan of require.js, so I tried to use React within the require.js eco system. It was not as hard as expected and here are some examples and some thoughts about it.
>
> [Read the full post...](http://blog.xenji.com/2013/06/facebooks-react-require-js.html)
## Origins of React
[Pete Hunt](http://www.petehunt.net/blog/) explained what differentiates React from other JavaScript libraries in [a previous blog post](http://facebook.github.io/react/blog/2013/06/05/why-react.html). [Lee Byron](http://leebyron.com/) gives another perspective on Quora:
> React isn't quite like any other popular Javascript libraries, and it solves a very specific problem: complex UI rendering. It's also intended to be used along side many other popular libraries. For example, React works well with Backbone.js, amongst many others.
>
> React was born out of frustrations with the common pattern of writing two-way data bindings in complex MVC apps. React is an implementation of one-way data bindings.
>
> [Read the full post...](http://www.quora.com/React-JS-Library/How-is-Facebooks-React-JavaScript-library/answer/Lee-Byron?srid=3DcX)

View File

@@ -0,0 +1,71 @@
---
title: "Community Round-up #2"
layout: post
author: Vjeux
---
Since the launch we have received a lot of feedback and are actively working on React 0.4. In the meantime, here are the highlights of this week.
## Some quick thoughts on React
[Andrew Greig](http://www.andrewgreig.com/) made a blog post that gives a high level description of what React is.
> I have been using Facebooks recently released Javascript framework called React.js for the last few days and have managed to obtain a rather high level understanding of how it works and formed a good perspective on how it fits in to the entire javascript framework ecosystem.
>
> Basically, React is not an MVC framework. It is not a replacement for Backbone or Knockout or Angular, instead it is designed to work with existing frameworks and help extend their functionality.
>
> It is designed for building big UIs. The type where you have lots of reusable components that are handling events and presenting and changing some backend data. In a traditional MVC app, React fulfils the role of the View. So you would still need to handle the Model and Controller on your own.
>
> I found the best way to utilise React was to pair it with Backbone, with React replacing the Backbone View, or to write your own Model/Data object and have React communicate with that.
>
> [Read the full post...](http://www.andrewgreig.com/637/)
## React and Socket.IO Chat Application
[Danial Khosravi](http://danialk.github.io/) made a real-time chat application that interacts with the back-end using Socket.IO.
> A week ago I was playing with AngularJS and [this little chat application](https://github.com/btford/angular-socket-io-im) which uses socket.io and nodejs for realtime communication. Yesterday I saw a post about ReactJS in [EchoJS](http://www.echojs.com/) and started playing with this UI library. After playing a bit with React, I decided to write and chat application using React and I used Bran Ford's Backend for server side of this little app.
> <figure>[![](/react/img/blog/chatapp.png)](http://danialk.github.io/blog/2013/06/16/reactjs-and-socket-dot-io-chat-application/)</figure>
>
> [Read the full post...](http://danialk.github.io/blog/2013/06/16/reactjs-and-socket-dot-io-chat-application/)
## React and Other Frameworks
[Pete Hunt](http://www.petehunt.net/blog/) wrote an answer on Quora comparing React and Angular directives. At the end, he explains how you can make an Angular directive that is in fact being rendered with React.
> To set the record straight: React components are far more powerful than Angular templates; they should be compared with Angular's directives instead. So I took the first Google hit for "AngularJS directive tutorial" (AngularJS Directives Tutorial - Fundoo Solutions), rewrote it in React and compared them. [...]
>
> We've designed React from the beginning to work well with other libraries. Angular is no exception. Let's take the original Angular example and use React to implement the fundoo-rating directive.
>
> [Read the full post...](http://www.quora.com/Pete-Hunt/Posts/Facebooks-React-vs-AngularJS-A-Closer-Look)
In the same vein, [Markov Twain](https://twitter.com/markov_twain/status/345702941845499906) re-implemented the examples on the front-page [with Ember](http://jsbin.com/azihiw/2/edit) and [Vlad Yazhbin](https://twitter.com/vla) re-implemented the tutorial [with Angular](http://jsfiddle.net/vla/Cdrse/).
## Web Components: React & x-tags
Mozilla and Google are actively working on Web Components. [Vjeux](http://blog.vjeux.com/) wrote a proof of concept that shows how to implement them using React.
> Using [x-tags](http://www.x-tags.org/) from Mozilla, we can write custom tags within the DOM. This is a great opportunity to be able to write reusable components without being tied to a particular library. I wrote [x-react](https://github.com/vjeux/react-xtags/) to have them being rendered in React.
> <figure>[![](/react/img/blog/xreact.png)](http://blog.vjeux.com/2013/javascript/custom-components-react-x-tags.html)</figure>
>
> [Read the full post...](http://blog.vjeux.com/2013/javascript/custom-components-react-x-tags.html)
## React TodoMVC Example
[TodoMVC.com](http://todomvc.com/) is a website that collects various implementations of the same basic Todo app. [Pete Hunt](http://www.petehunt.net/blog/) wrote an idiomatic React version.
> Developers these days are spoiled with choice when it comes to selecting an MV* framework for structuring and organizing their JavaScript web apps.
>
> To help solve this problem, we created TodoMVC - a project which offers the same Todo application implemented using MV* concepts in most of the popular JavaScript MV* frameworks of today.
> <figure>[![](/react/img/blog/todomvc.png)](http://todomvc.com/labs/architecture-examples/react/)</figure>
>
> [Read the source code...](https://github.com/tastejs/todomvc/tree/gh-pages/labs/architecture-examples/react)
## JSX is not HTML
Many of you pointed out differences between JSX and HTML. In order to clear up some confusion, we have added some documentation that covers the four main differences:
- [Whitespace removal](http://facebook.github.io/react/docs/jsx-is-not-html.html)
- [HTML Entities](http://facebook.github.io/react/docs/jsx-is-not-html.html)
- [Comments](http://facebook.github.io/react/docs/jsx-is-not-html.html)
- [Custom HTML Attributes](http://facebook.github.io/react/docs/jsx-is-not-html.html)

View File

@@ -0,0 +1,24 @@
---
title: "React v0.3.3"
layout: post
author: Paul O'Shannessy
---
We have a ton of great stuff coming in v0.4, but in the meantime we're releasing v0.3.3. This release addresses some small issues people were having and simplifies our tools to make them easier to use.
## react-tools
* Upgrade Commoner so `require` statements are no longer relativized when passing through the transformer. This was a feature needed when building React, but doesn't translate well for other consumers of `bin/jsx`.
* Upgraded our dependencies on Commoner and Recast so they use a different directory for their cache.
* Freeze our esprima dependency.
## React
* Allow reusing the same DOM node to render different components. e.g. `React.renderComponent(<div/>, domNode); React.renderComponent(<span/>, domNode);` will work now.
## JSXTransformer
* Improved the in-browser transformer so that transformed scripts will execute in the expected scope. The allows components to be defined and used from separate files.

View File

@@ -0,0 +1,91 @@
---
title: "Community Round-up #3"
layout: post
author: Vjeux
---
The highlight of this week is that an interaction-heavy app has been ported to React. React components are solving issues they had with nested views.
## Moving From Backbone To React
[Clay Allsopp](http://twitter.com/clayallsopp) successfully ported [Propeller](http://usepropeller.com/blog/posts/from-backbone-to-react/), a fairly big, interaction-heavy JavaScript app, to React.
> [<img style="float: right; margin: 0 0 10px 10px;" src="/react/img/blog/propeller-logo.png" />](http://usepropeller.com/blog/posts/from-backbone-to-react/)Subviews involve a lot of easy-to-forget boilerplate that Backbone (by design) doesn't automate. Libraries like Backbone.Marionette offer more abstractions to make view nesting easier, but they're all limited by the fact that Backbone delegates how and went view-document attachment occurs to the application code.
>
> React, on the other hand, manages the DOM and only exposes real nodes at select points in its API. The "elements" you code in React are actually objects which wrap DOM nodes, not the actual objects which get inserted into the DOM. Internally, React converts those abstractions into actual DOMElements and fills out the document accordingly. [...]
>
> We moved about 20 different Backbone view classes to React over the past few weeks, including the live-preview pane that you see in our little iOS demo. Most importantly, it's allowed us to put energy into making each component work great on its own, instead of spending extra cycles to ensure they function in unison. For that reason, we think React is a more scalable way to build view-intensive apps than Backbone alone, and it doesn't require you to drop-everything-and-refactor like a move to Ember or Angular would demand.
>
> [Read the full post...](http://usepropeller.com/blog/posts/from-backbone-to-react/)
## Grunt Task for JSX
[Eric Clemmons](http://ericclemmons.github.io/) wrote a task for [Grunt](http://gruntjs.com/) that applies the JSX transformation to your Javascript files. It also works with [Browserify](http://browserify.org/) if you want all your files to be concatenated and minified together.
> Grunt task for compiling Facebook React's .jsx templates into .js
>
> ```javascript
grunt.initConfig({
react: {
app: {
options: { extension: 'js' },
files: { 'path/to/output/dir': 'path/to/jsx/templates/dir' }
```
>
> It also works great with `grunt-browserify`!
>
> ```javascript
browserify: {
options: {
transform: [ require('grunt-react').browserify ]
},
app: {
src: 'path/to/source/main.js',
dest: 'path/to/target/output.js'
```
>
> [Check out the project ...](https://github.com/ericclemmons/grunt-react)
## Backbone/Handlebars Nested Views
[Joel Burget](http://joelburget.com/) wrote a blog post talking about the way we would write React-like components in Backbone and Handlebars.
> The problem here is that we're trying to maniplate a tree, but there's a textual layer we have to go through. Our views are represented as a tree - the subviews are children of CommentCollectionView - and they end up as part of a tree in the DOM. But there's a Handlebars layer in the middle (which deals in flat strings), so the hierarchy must be destructed and rebuilt when we render.
>
> What does it take to render a collection view? In the Backbone/Handlebars view of the world you have to render the template (with stubs), render each subview which replaces a stub, and keep a reference to each subview (or anything within the view that could change in the future).
>
> So while our view is conceptually hierarchical, due to the fact that it has to go through a flat textual representation, we need to do a lot of extra work to reassemble that structure after rendering.
>
> [Read the full post...](http://joelburget.com/react/)
## JSRomandie Meetup
[Renault John Lecoultre](https://twitter.com/renajohn/) from [BugBuster](http://www.bugbuster.com) did a React introduction talk at a JS meetup called [JS Romandie](https://twitter.com/jsromandie) last week.
<script async class="speakerdeck-embed" data-id="888a9d50c01b01300df36658d0894ac1" data-ratio="1.33333333333333" src="//speakerdeck.com/assets/embed.js"></script>
## CoffeeScript integration
[Vjeux](http://blog.vjeux.com/) used the fact that JSX is just a syntactic sugar on-top of regular JS to rewrite the React front-page examples in CoffeeScript.
> Multiple people asked what's the story about JSX and CoffeeScript. There is no JSX pre-processor for CoffeeScript and I'm not aware of anyone working on it. Fortunately, CoffeeScript is pretty expressive and we can play around the syntax to come up with something that is usable.
>
> ```javascript
{div, h3, textarea} = React.DOM
(div {className: 'MarkdownEditor'}, [
(h3 {}, 'Input'),
(textarea {onKeyUp: @handleKeyUp, ref: 'textarea'},
@state.value
)
])
```
>
> [Read the full post...](http://blog.vjeux.com/2013/javascript/react-coffeescript.html)
## Tutorial in Plain Javascript
We've seen a lot of people comparing React with various frameworks. [Ricardo Tomasi](http://ricardo.cc/) decided to re-implement the tutorial without any framework, just plain Javascript.
> Facebook & Instagram launched the React framework and an accompanying tutorial. Developer Vlad Yazhbin decided to rewrite that using AngularJS. The end result is pretty neat, but if you're like me you will not actually appreciate the HTML speaking for itself and doing all the hard work. So let's see what that looks like in plain javascript.
>
> [Read the full post...](http://ricardo.cc/2013/06/07/react-tutorial-rewritten-in-plain-javascript.html)

View File

@@ -0,0 +1,52 @@
---
title: "New in React v0.4: Autobind by Default"
layout: post
author: Paul O'Shannessy
---
React v0.4 is very close to completion. As we finish it off, we'd like to share with you some of the major changes we've made since v0.3. This is the first of several posts we'll be making over the next week.
## What is React.autoBind?
If you take a look at most of our current examples, you'll see us using `React.autoBind` for event handlers. This is used in place of `Function.prototype.bind`. Remember that in JS, [function calls are late-bound](http://bonsaiden.github.io/JavaScript-Garden/#function.this). That means that if you simply pass a function around, the `this` used inside won't necessarily be the `this` you expect. `Function.prototype.bind` creates a new, properly bound, function so that when called, `this` is exactly what you expect it to be.
Before we launched React, we would write this:
```js{4}
React.createClass({
onClick: function(event) {/* do something with this */},
render: function() {
return <button onClick={this.onClick.bind(this)} />;
}
});
```
We wrote `React.autoBind` as a way to cache the function creation and save on memory usage. Since `render` can get called multiple times, if you used `this.onClick.bind(this)` you would actually create a new function on each pass. With React v0.3 you were able to write this instead:
```js{2,4}
React.createClass({
onClick: React.autoBind(function(event) {/* do something with this */}),
render: function() {
return <button onClick={this.onClick} />;
}
});
```
## What's Changing in v0.4?
After using `React.autoBind` for a few weeks, we realized that there were very few times that we didn't want that behavior. So we made it the default! Now all methods defined within `React.createClass` will already be bound to the correct instance.
Starting with v0.4 you can just write this:
```js{2,4}
React.createClass({
onClick: function(event) {/* do something with this */},
render: function() {
return <button onClick={this.onClick} />;
}
});
```
For v0.4 we will simply be making `React.autoBind` a no-op — it will just return the function you pass to it. Most likely you won't have to change your code to account for this change, though we encourage you to update. We'll publish a migration guide documenting this and other changes that come along with React v0.4.

View File

@@ -0,0 +1,58 @@
---
title: "Community Round-up #4"
layout: post
author: Vjeux
---
React reconciliation process appears to be very well suited to implement a text editor with a live preview as people at Khan Academy show us.
## Khan Academy
[Ben Kamens](http://bjk5.com/) explains how [Ben Alpert](http://benalpert.com/) and [Joel Burget](http://joelburget.com/) are promoting React inside of [Khan Academy](https://www.khanacademy.org/). They now have three projects in the works using React.
> Recently two Khan Academy devs dropped into our team chat and said they were gonna use React to write a new feature. They even hinted that we may want to adopt it product-wide.
>
> "The library is only a week old. It's a brand new way of thinking about things. We're the first to use it outside of Facebook. Heck, even the React devs were surprised to hear we're using this in production!!!"
>
> [Read the full post...](http://bjk5.com/post/53742233351/getting-your-team-to-adopt-new-technology)
The best part is the demo of how React reconciliation process makes live editing more user-friendly.
> Our renderer, post-React, is on the left. A typical math editor's preview is on the right.
> <figure>[<img src="/react/img/blog/monkeys.gif" width="70%" />](http://bjk5.com/post/53742233351/getting-your-team-to-adopt-new-technology)</figure>
## React Snippets
Over the past several weeks, members of our team, [Pete Hunt](http://www.petehunt.net/) and [Paul O'Shannessy](http://zpao.com/), answered many questions that were asked in the [React group](https://groups.google.com/forum/#!forum/reactjs). They give a good overview of how to integrate React with other libraries and APIs through the use of [Mixins](/react/docs/reusable-components.html) and [Lifecycle Methods](/react/docs/working-with-the-browser.html).
> [Listening Scroll Event](https://groups.google.com/forum/#!topic/reactjs/l6PnP8qbofk)
>
> * [JSFiddle](http://jsfiddle.net/aabeL/1/): Basically I've given you two mixins. The first lets you react to global scroll events. The second is, IMO, much more useful: it gives you scroll start and scroll end events, which you can use with setState() to create components that react based on whether the user is scrolling or not.
>
> [Fade-in Transition](https://groups.google.com/forum/#!topic/reactjs/RVAY_eQmdpo)
>
> * [JSFiddle](http://jsfiddle.net/ufe8k/1/): Creating a new `<FadeInWhenAdded>` component and using jQuery `.fadeIn()` function on the DOM node.
> * [JSFiddle](http://jsfiddle.net/R8f5L/5/): Using CSS transition instead.
>
> [Socket.IO Integration](https://groups.google.com/forum/#!topic/reactjs/pyUZBRWcHB4)
>
> * [Gist](https://gist.github.com/zpao/5686416): The big thing to notice is that my component is pretty dumb (it doesn't have to be but that's how I chose to model it). All it does is render itself based on the props that are passed in. renderOrUpdate is where the "magic" happens.
> * [Gist](https://gist.github.com/petehunt/5687230): This example is doing everything -- including the IO -- inside of a single React component.
> * [Gist](https://gist.github.com/petehunt/5687276): One pattern that we use at Instagram a lot is to employ separation of concerns and consolidate I/O and state into components higher in the hierarchy to keep the rest of the components mostly stateless and purely display.
>
> [Sortable jQuery Plugin Integration](https://groups.google.com/forum/#!topic/reactjs/mHfBGI3Qwz4)
>
> * [JSFiddle](http://jsfiddle.net/LQxy7/): Your React component simply render empty divs, and then in componentDidMount() you call React.renderComponent() on each of those divs to set up a new root React tree. Be sure to explicitly unmountAndReleaseReactRootNode() for each component in componentWillUnmount().
## Introduction to React Screencast
[Pete Hunt](http://www.petehunt.net/) recorded himself implementing a simple `<Blink>` tag in React.
<figure><iframe src="http://player.vimeo.com/video/67248575" width="500" height="340" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></figure>
## Snake in React
[Tom Occhino](http://tomocchino.com/) implemented Snake in 150 lines with React.
> [Check the source on Github](https://github.com/tomocchino/react-snake/blob/master/src/snake.js)
> <figure>[![](/react/img/blog/snake.png)](http://tomocchino.github.io/react-snake/)</figure>

View File

@@ -0,0 +1,63 @@
---
title: "New in React v0.4: Prop Validation and Default Values"
layout: post
author: Paul O'Shannessy
---
Many of the questions we got following the public launch of React revolved around `props`, specifically that people wanted to do validation and to make sure their components had sensible defaults.
## Validation
Oftentimes you want to validate your `props` before you use them. Perhaps you want to ensure they are a specific type. Or maybe you want to restrict your prop to specific values. Or maybe you want to make a specific prop required. This was always possible — you could have written validations in your `render` or `componentWillReceiveProps` functions, but that gets clunky fast.
React v0.4 will provide a nice easy way for you to use built-in validators, or to even write your own.
```js
React.createClass({
propTypes: {
// An optional string prop named "description".
description: React.PropTypes.string,
// A required enum prop named "category".
category: React.PropTypes.oneOf(['News','Photos']).isRequired,
// A prop named "dialog" that requires an instance of Dialog.
dialog: React.PropTypes.instanceOf(Dialog).isRequired
},
...
});
```
## Default Values
One common pattern we've seen with our React code is to do something like this:
```js
React.createClass({
render: function() {
var value = this.props.value || 'default value';
return <div>{value}</div>;
}
});
```
Do this for a few `props` across a few components and now you have a lot of redundant code. Starting with React v0.4, you can provide default values in a declarative way:
```js
React.createClass({
getDefaultProps: function() {
return {
value: 'default value'
};
}
...
});
```
We will use the cached result of this function before each `render`. We also perform all validations before each `render` to ensure that you have all of the data you need in the right form before you try to use it.
- - -
Both of these features are entirely optional. We've found them to be increasingly valuable at Facebook as our applications grow and evolve, and we hope others find them useful as well.

Some files were not shown because too many files have changed in this diff Show More