-
Notifications
You must be signed in to change notification settings - Fork 46.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create react-addons-dom-factories package #8356
Merged
flarnie
merged 1 commit into
facebook:master
from
nhunzaker:react-dom-factories-package
Apr 24, 2017
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we remove them immediately in master and keep them only in 15.6?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would think that makes sense - it was nice to have them put back in this PR though, so I can more easily cherry-pick it to the 15.6 branch. Removing can be in a follow-up that does not get cherry-picked.