forked from facebook/react
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move ReactDOMFactories into separate package (facebook#8356)
- Update examples to no longer use React.DOM - Add package and documentation entries for react-addons-dom-factories - Update dom-factories readme - Set up proxy to intercept React.DOM usage - Update ReactDOM children tests to use createElement - Add more specific warning assertion for React DOM factories - Do not use expectDev in ReactDOMFactories tests
- Loading branch information
Showing
11 changed files
with
123 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# `react-addons-dom-factories` | ||
|
||
> Note: | ||
> `ReactDOMFactories` is a legacy add-on. Consider using | ||
> `React.createFactory` or JSX instead. | ||
Prior to version 16.0.0, React maintained a whitelist of | ||
pre-configured DOM factories. These predefined factories have been | ||
moved to the `react-addons-dom-factories` library. | ||
|
||
## Example | ||
|
||
```javascript | ||
import ReactDOM from 'react-dom'; | ||
import DOM from 'react-addons-dom-factories'; // ES6 | ||
|
||
const greeting = DOM.div({ className: 'greeting' }, DOM.p(null, 'Hello, world!')); | ||
|
||
ReactDOM.render(greeting, document.getElementById('app')) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
'use strict'; | ||
|
||
module.exports = require('./lib/ReactDOMFactories'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"name": "react-dom-factories", | ||
"version": "16.0.0-alpha", | ||
"description": "React package for DOM factory methods.", | ||
"main": "index.js", | ||
"repository": "facebook/react", | ||
"keywords": [ | ||
"react" | ||
], | ||
"license": "BSD-3-Clause", | ||
"bugs": { | ||
"url": "https://github.com/facebook/react/issues" | ||
}, | ||
"homepage": "https://facebook.github.io/react/", | ||
"peerDependencies": { | ||
"react": "^16.0.0-alpha" | ||
}, | ||
"files": [ | ||
"LICENSE", | ||
"PATENTS", | ||
"README.md", | ||
"index.js", | ||
"lib/" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* Copyright 2013-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
* @emails react-core | ||
*/ | ||
|
||
'use strict'; | ||
|
||
var React = require('React'); | ||
var {div} = require('ReactDOMFactories'); | ||
|
||
describe('ReactDOMFactories', () => { | ||
it('allow factories to be called without warnings', () => { | ||
spyOn(console, 'error'); | ||
var element = div(); | ||
expect(element.type).toBe('div'); | ||
expect(console.error).not.toHaveBeenCalled(); | ||
}); | ||
|
||
it('warns once when accessing React.DOM methods', () => { | ||
spyOn(console, 'error'); | ||
|
||
var a = React.DOM.a(); | ||
var p = React.DOM.p(); | ||
|
||
expect(a.type).toBe('a'); | ||
expect(p.type).toBe('p'); | ||
|
||
expect(console.error).toHaveBeenCalledTimes(1); | ||
expect(console.error.calls.first().args[0]).toContain( | ||
'Warning: Accessing factories like React.DOM.a has been deprecated', | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters