diff --git a/.babelrc b/.babelrc index 2ff815b425..a976990ee9 100644 --- a/.babelrc +++ b/.babelrc @@ -2,7 +2,6 @@ "presets": ["react"], "ignore": ["third_party"], "plugins": [ - "fbjs-scripts/babel-6/dev-expression", "syntax-trailing-function-commas", "babel-plugin-transform-object-rest-spread", "transform-es2015-template-literals", @@ -22,6 +21,7 @@ "transform-es2015-modules-commonjs", "transform-es3-member-expression-literals", "transform-es3-property-literals", - "./scripts/babel/transform-object-assign-require" + "./scripts/babel/transform-object-assign-require", + "transform-react-jsx-source" ] } diff --git a/.eslintignore b/.eslintignore index 87837497a0..0ffbe9528c 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,4 +1,5 @@ # We can probably lint these later but not important at this point +src/renderers/art src/shared/vendor # But not in docs/_js/examples/* docs/_js/*.js diff --git a/.eslintrc.js b/.eslintrc.js index a099d6bfca..f4773f28f2 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -30,6 +30,7 @@ module.exports = { 'indent': [ERROR, 2, {SwitchCase: 1}], 'jsx-quotes': [ERROR, 'prefer-double'], 'no-bitwise': OFF, + 'no-inner-declarations': [ERROR, 'functions'], 'no-multi-spaces': ERROR, 'no-restricted-syntax': [ERROR, 'WithStatement'], 'no-shadow': ERROR, diff --git a/.flowconfig b/.flowconfig new file mode 100644 index 0000000000..94ffcb54a2 --- /dev/null +++ b/.flowconfig @@ -0,0 +1,37 @@ +[ignore] + +.*/examples/.* +.*/build/.* +.*/node_modules/y18n/.* +.*/__mocks__/.* +.*/__tests__/.* + +# Ignore Docs +.*/docs/.* + +[include] + +[libs] +./node_modules/fbjs/flow/lib +./flow + +[options] +module.system=haste + +esproposal.class_static_fields=enable +esproposal.class_instance_fields=enable + +experimental.strict_type_args=true + +munge_underscores=false + +suppress_type=$FlowIssue +suppress_type=$FlowFixMe +suppress_type=$FixMe + +suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-4]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*\\)?)\\) +suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-4]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*\\)?)\\)? #[0-9]+ +suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy + +[version] +^0.26.0 diff --git a/.travis.yml b/.travis.yml index 1891081700..8ecb5b8661 100644 --- a/.travis.yml +++ b/.travis.yml @@ -68,7 +68,14 @@ script: fi elif [ "$TEST_TYPE" = test ]; then set -e - ./node_modules/.bin/grunt jest:normal + # Disabling coverage because it's broken: + # https://travis-ci.org/facebook/react/jobs/128163922 + if false; then + ./node_modules/.bin/grunt jest:coverage + cat ./coverage/lcov.info | ./node_modules/.bin/coveralls + else + ./node_modules/.bin/grunt jest:normal + fi echo 'Testing in server-render (HTML generation) mode...' printf '\nmodule.exports.useCreateElement = false;\n' \ >> src/renderers/dom/shared/ReactDOMFeatureFlags.js @@ -83,6 +90,7 @@ env: - TEST_TYPE=build - TEST_TYPE=test - TEST_TYPE=lint + - TEST_TYPE=flow - TEST_TYPE=build_website global: # SERVER diff --git a/CHANGELOG.md b/CHANGELOG.md index 58f370c821..a33d2b2964 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,45 @@ +/## 15.2.0 (July 1, 2016) + +### React +- Add error codes to production invariants, with links to the view the full error text. ([@keyanzhang](https://github.com/keyanzhang) in [#6948](https://github.com/facebook/react/pull/6948)) +- Include component stack information in PropType validation warnings. ([@spicyj](https://github.com/spicyj) in [#6771](https://github.com/facebook/react/pull/6771)) +- Include component stack information in key warnings. ([@keyanzhang](https://github.com/keyanzhang) in [#6799](https://github.com/facebook/react/pull/6799)) +- Stop validating props at mount time, only validate at element creation. ([@keyanzhang](https://github.com/keyanzhang) in [#6823](https://github.com/facebook/react/pull/6823)) +- New invariant providing actionable error in missing instance case. ([@yungsters](https://github.com/yungsters) in [#6990](https://github.com/facebook/react/pull/6990)) +- Add `React.PropTypes.symbol` to support ES2015 Symbols as props. ([@puradox](https://github.com/puradox) in [#6377](https://github.com/facebook/react/pull/6377)) +- Fix incorrect coercion of ref or key that are undefined in development ([@gaearon](https://github.com/gaearon) in [#6880](https://github.com/facebook/react/pull/6880)) +- Fix a false positive when passing other element’s props to cloneElement ([@ericmatthys](https://github.com/ericmatthys) in [#6268](https://github.com/facebook/react/pull/6268)) + +### React DOM +- Add warning for unknown properties on DOM elements. ([@jimfb](https://github.com/jimfb) in [#6800](https://github.com/facebook/react/pull/6800), [@gm758](https://github.com/gm758) in [#7152](https://github.com/facebook/react/pull/7152)) +- Properly remove attributes from custom elements. ([@grassator](https://github.com/grassator) in [#6748](https://github.com/facebook/react/pull/6748)) +- Fix invalid unicode escape in attribute name regular expression. ([@nbjahan](https://github.com/nbjahan) in [#6772](https://github.com/facebook/react/pull/6772)) +- Add `onLoad` handling to `` element. ([@roderickhsiao](https://github.com/roderickhsiao) in [#6815](https://github.com/facebook/react/pull/6815)) +- Add `onError` handling to `` element. ([@wadahiro](https://github.com/wadahiro) in [#6941](https://github.com/facebook/react/pull/6941)) +- Handle `value` and `defaultValue` more accurately in the DOM. ([@jimfb](https://github.com/jimfb) in [#6406](https://github.com/facebook/react/pull/6406)) +- Fix events issue in environments with mutated `Object.prototype`. ([@Weizenlol](https://github.com/Weizenlol) in [#6886](https://github.com/facebook/react/pull/6886)) +- Fix issue where `is="null"` ended up in the DOM in Firefox. ([@darobin](https://github.com/darobin) in [#6896](https://github.com/facebook/react/pull/6896)) +- Improved performance of text escaping by using [escape-html](https://github.com/component/escape-html). ([@aickin](https://github.com/aickin) in [#6862](https://github.com/facebook/react/pull/6862)) +- Fix issue with `dangerouslySetInnerHTML` and SVG in Internet Explorer. ([@joshhunt](https://github.com/joshhunt) in [#6982](https://github.com/facebook/react/pull/6982)) +- Fix issue with `, container); + + expect(node.value).toBe('0'); + }); + + it('should not incur unnecessary DOM mutations', function() { + var container = document.createElement('div'); + ReactDOM.render(; - stub = renderTextarea(stub, container); - var node = ReactDOM.findDOMNode(stub); + var node = renderTextarea(stub, container); - expect(console.error.argsForCall.length).toBe(1); + expect(console.error.calls.count()).toBe(1); expect(node.value).toBe('giraffe'); // Changing children should do nothing, it functions like `defaultValue`. @@ -189,17 +265,45 @@ describe('ReactDOMTextarea', function() { expect(node.value).toEqual('giraffe'); }); + it('should keep value when switching to uncontrolled element if not changed', function() { + var container = document.createElement('div'); + + var node = renderTextarea(, container); + + expect(node.value).toEqual('kitten'); + }); + + it('should keep value when switching to uncontrolled element if changed', function() { + var container = document.createElement('div'); + + var node = renderTextarea(, container); + + expect(node.value).toBe('puppies'); + + ReactDOM.render(, container); + + expect(node.value).toEqual('puppies'); + }); + it('should allow numbers as children', function() { spyOn(console, 'error'); - var node = ReactDOM.findDOMNode(renderTextarea()); - expect(console.error.argsForCall.length).toBe(1); + var node = renderTextarea(); + expect(console.error.calls.count()).toBe(1); expect(node.value).toBe('17'); }); it('should allow booleans as children', function() { spyOn(console, 'error'); - var node = ReactDOM.findDOMNode(renderTextarea()); - expect(console.error.argsForCall.length).toBe(1); + var node = renderTextarea(); + expect(console.error.calls.count()).toBe(1); expect(node.value).toBe('false'); }); @@ -210,8 +314,8 @@ describe('ReactDOMTextarea', function() { return 'sharkswithlasers'; }, }; - var node = ReactDOM.findDOMNode(renderTextarea()); - expect(console.error.argsForCall.length).toBe(1); + var node = renderTextarea(); + expect(console.error.calls.count()).toBe(1); expect(node.value).toBe('sharkswithlasers'); }); @@ -224,16 +328,16 @@ describe('ReactDOMTextarea', function() { ); }).toThrow(); - expect(console.error.argsForCall.length).toBe(1); + expect(console.error.calls.count()).toBe(1); var node; expect(function() { - node = ReactDOM.findDOMNode(renderTextarea()); + node = renderTextarea(); }).not.toThrow(); expect(node.value).toBe('[object Object]'); - expect(console.error.argsForCall.length).toBe(2); + expect(console.error.calls.count()).toBe(2); }); it('should support ReactLink', function() { @@ -242,18 +346,18 @@ describe('ReactDOMTextarea', function() { spyOn(console, 'error'); instance = renderTextarea(instance); - expect(console.error.argsForCall.length).toBe(1); - expect(console.error.argsForCall[0][0]).toContain( + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toContain( '`valueLink` prop on `textarea` is deprecated; set `value` and `onChange` instead.' ); - expect(ReactDOM.findDOMNode(instance).value).toBe('yolo'); + expect(instance.value).toBe('yolo'); expect(link.value).toBe('yolo'); expect(link.requestChange.mock.calls.length).toBe(0); - ReactDOM.findDOMNode(instance).value = 'test'; - ReactTestUtils.Simulate.change(ReactDOM.findDOMNode(instance)); + instance.value = 'test'; + ReactTestUtils.Simulate.change(instance); expect(link.requestChange.mock.calls.length).toBe(1); expect(link.requestChange.mock.calls[0][0]).toEqual('test'); @@ -269,14 +373,14 @@ describe('ReactDOMTextarea', function() { spyOn(console, 'error'); ReactTestUtils.renderIntoDocument(