Commit Graph
419 Commits
Author SHA1 Message Date
Ben Newman 5d878ce914 Merge pull request #550 from subtleGradient/subtlegradient/code-coverage
Code coverage grunt tasks.
2013-11-18 14:03:56 -08:00
Thomas Aylott ef5a02c164 enable coverage logging from the worker 2013-11-18 16:37:46 -05:00
Daniel Lo NigroandPaul O’Shannessy d853c8568e Propagate events to parent components when nested
When events are captured, the nearest React-rendered ancestor is found and events are propagated to its tree. This causes issues when components are nested as only the innermost component receives the events.

This change modifies this behaviour so events propagate all the way up the DOM hierarchy. To reduce the performance cost, this DOM traversal is only done if the component is actually nested (determined by the `containerIsNested` map which is lazily initialised).
2013-11-18 10:56:29 -08:00
Marshall RochandPaul O’Shannessy b91396be8e Contexts
Summary:
adds `this.context` which you can think of as implicit props, which are passed automatically down the //ownership// hierarchy.

Contexts should be used sparingly, since they essentially allow components to communicate with descendants (in the ownership sense, not parenthood sense), which is not usually a good idea. You probably would only use contexts in places where you'd normally use a global, but contexts allow you to override them for certain view subtrees which you can't do with globals.

The context starts out `null`:

  var RootComponent = React.createClass({
    render: function() {
      // this.context === null
    }
  });

You should **never** mutate the context directly, just like props and state.

You can change the context of your children (the ones you own, not `this.props.children` or via other props) using the new `withContext` method on `React`:

  var RootComponent = React.createClass({
    render: function() {
      // this.context === null
      var children = React.withContext({foo: 'a', bar: 'b'}, () => (
        // In ChildComponent#render, this.context === {foo: 'a', bar: 'b'}
        <ChildComponent />
      ));
      // this.context === null
    }
  });

Contexts are merged, so a component can override its owner's context **for its children**:

  var ChildComponent = React.createClass({
    render: function() {
      // this.context === {foo: 'a', bar: 'b'} (for the caller above)
      var children = React.withContext({foo: 'c'},() => (
        // In GrandchildComponent#render,
        // this.context === {foo: 'c', bar: 'b'}
        <GrandchildComponent />
      ));
      // this.context === {foo: 'a', bar: 'b'}
    }
  });
2013-11-18 10:56:24 -08:00
Pete HuntandPaul O’Shannessy 7df127db31 Better error message for renderComponentToString()
Reported on Twitter by AirBnb (who are integrating React into their open-source JS framework). They made a mistake and passed a string in as the
component. We should have a better error message for that.
2013-11-18 10:54:05 -08:00
Tim YungandPaul O’Shannessy 8529f1b053 Remove Obsolete IE8 Compatibility Code
See the TODO comment. Synthetic events have shipped and this is no longer necessary.
2013-11-18 10:54:03 -08:00
Marshall RochandPaul O’Shannessy 381a3392c6 Rename receiveProps to receiveComponent
This renames receiveProps and changes it to take the next component to copy props from instead of just the props. That is,

  component.receiveComponent(nextComponent, transaction)

instead of

  component.receiveProps(nextComponent.props, transaction)

This is a precursor to adding contexts, which will also need to get propagated just like props. This change allows ReactCompositeComponent to override `receiveProps` and do something like

  this._pendingContext = nextComponent.context;
2013-11-18 10:53:58 -08:00
Paul O’Shannessy d1fa53ca03 Cleanup lint warnings from recent testing changes
Also, relaxed a rule for dot notation (and unrelaxed it in src).
2013-11-14 11:24:06 -08:00
Paul O’Shannessy 1324eb5556 "use strict" in shouldUpdateReactComponent 2013-11-14 10:37:33 -08:00
Brian Kim e707ec0b1e Fix failing tests
Two of your tests were failing because of commit
1e71df5399
I fixed them by:
1) Using jasmine's spyOn in ReactCompositeComponentError-test.js
2) Inverting the function wrapping in the above commit.
Godspeed.
2013-11-13 05:07:52 -05:00
Tim YungandPaul O’Shannessy 9fd28f44df Rename nodeContains to containsNode 2013-11-11 16:39:25 -08:00
Mouad DebbarandPaul O’Shannessy 1ffe2d0927 Add support for oncontextmenu in React. 2013-11-11 16:39:25 -08:00
Marshall RochandPaul O’Shannessy 735b4f0b7c Remove transaction from componentWillUpdate
It wasn't documented and I think the transaction is supposed to be internal.
2013-11-11 16:39:25 -08:00
Felix KlingandPaul O’Shannessy 1e71df5399 Improve error logging for event handlers of React components.
This guards every auto-bound method and uses the name of the component and method as guard name.
2013-11-11 16:39:25 -08:00
Andreas Svensson 62f7cd213f Fix wheelDelta misspelled 2013-11-10 16:58:55 +01:00
Ben Newman b3c87ea017 Merge pull request #451 from subtleGradient/subtlegradient/browser-testing
Browser testing.
2013-11-07 10:20:58 -08:00
Paul O’Shannessy 192af01952 Merge pull request #488 from spicyj/gh-473
Make submit button default value appear correctly
2013-11-06 22:56:19 -08:00
Ben Alpert d5c2d5f291 Make submit button default value appear correctly
Fixes #473.
2013-11-06 21:19:44 -08:00
Ben Alpert 4fe784de1f Make propTypes DEFINE_MANY_MERGED 2013-11-06 17:13:25 -08:00
Thomas Aylott 5640d641d6 skip Worker test unless the browser supports them 2013-11-06 15:30:49 -05:00
Thomas Aylott 8205c681eb serve worker.js from its actual relative path 2013-11-06 15:30:49 -05:00
Paul ShenandPaul O’Shannessy 0fed861424 Move merge utility functions from utils to vendor/core 2013-11-05 17:17:47 -08:00
Tim YungandPaul O’Shannessy e78d580c06 Include Ownership in the Ship of Theseus
When we determine whether a React component should be updated (as opposed to destroyed or replaced), we currently only look at whether they share the same constructor. This adds a check for whether they share the same owner component.

I've also consolidated this logic (I cannot believe this was not already done).
2013-11-05 17:14:57 -08:00
Paul O’Shannessy 5dad5e92a9 Merge pull request #476 from SanderSpies/unused-onselect
Removing unused useSelect variable.
2013-11-05 15:17:45 -08:00
SanderSpies 27fa1f5c9c Removing 'isEventSupported' 2013-11-05 22:53:50 +01:00
SanderSpies dede55d27d Removing unused useSelect variable. 2013-11-05 22:45:02 +01:00
Laurence Rowe 1bcca22719 Script async and defer properties 2013-11-04 20:40:53 -08:00
Paul O’Shannessy da5c61afe4 Oxford comma 2013-11-04 11:34:56 -08:00
Josh DuckandPaul O’Shannessy 18bf0b80bc Fix ReactDOMSelection for IE 11
IE 11 no longer supports the legacy document.selection API.
Their implementation of window.getSelection() doesn't support
the extend() method, which we were relying on.

If the selection is RTL and selection extend is missing, then just
flip the selection.
2013-11-04 11:34:39 -08:00
Matti Nelimarkka 9e24257a4e Clear error message when rendering a nonvalid component 2013-11-01 17:32:09 -07:00
Tim YungandPaul O’Shannessy 0dc011c40c Better getUnboundedScrollPosition for windows
Instead of using browser sniffing, `getUnboundedScrollPosition` can do
better and not have to depend on the `getDocumentScrollElement` module.
2013-10-31 15:24:58 -07:00
Paul O'ShannessyandPaul O’Shannessy 2cf7d943df Reorder DefaultDOMPropertyConfig
`autoCorrect` belongs with the non-standard properties list.
2013-10-30 16:58:05 -07:00
Mark RichardsonandPaul O’Shannessy 9b44ad6ce5 Add autoCorrect to list of supported DOM properties 2013-10-30 16:57:53 -07:00
Tim YungandPaul O’Shannessy 7789a32438 Forward Compatibility w/ WebKit & Blink
Newer versions of WebKit and Blink will support both `document.body.scrollTop` and `document.documentElement.scrollTop`. Therefore, implementing cross-browser compatibility by summing the two will no longer work.

This changes React to use `getUnboundedScrollPosition` so we get the fix and consistency in one change!

See: https://rniwa.com/2013-10-29/web-compatibility-story-of-scrolltop-and-scrollleft/
2013-10-30 16:56:55 -07:00
Laurence Rowe 280eff41f3 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-28 18:53:19 -07:00
Paul O’Shannessy 214e9103bf Merge pull request #423 from andreypopp/master
Re-rendering components into a document leaks components
2013-10-28 17:00:19 -07:00
Andrey Popp ac9dd92272 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 02:49:00 +04:00
Ian ObermillerandPaul O’Shannessy fbb741febb Fix ReactTransitionEvents detectEvents 2013-10-25 18:11:58 -07:00
Cat ChenandPaul O’Shannessy 0ef1ca0024 fixed %d in invariant call 2013-10-25 18:03:26 -07:00
Josh DuckandPaul O’Shannessy 0d2d3360d0 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-22 14:09:33 -07:00
Tim YungandPaul O’Shannessy 58b3ae3136 Use Default Value for Undefined Props
Currently, default props as defined by `getDefaultProps` are only used if a prop is not specified (using `X in Y` check).

However, this makes it difficult for composing components to pass along the state of not being defined, for example:

  render: function() {
    // If `this.props.someProp` is not set, `InnerThing` should use the default value.
    return <InnerThing someProp={this.props.someProp} />;
  }

This changes the requirement for falling back to the default value to an undefined check (using `typeof X === 'undefined'`).
2013-10-21 13:17:44 -07:00
Ben Alpert 893fba8373 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-20 14:39:37 -07:00
Paul O’Shannessy 48281a17e4 bump version to 0.6.0-alpha 2013-10-15 22:39:28 -07:00
Paul O’Shannessy cff62f8d72 Enable linting for bitwise operators 2013-10-15 18:02:28 -07:00
Paul O'ShannessyandPaul 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'ShannessyandPaul 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 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
SanderSpiesandPaul O’Shannessy 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'ShannessyandPaul 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