-
Notifications
You must be signed in to change notification settings - Fork 48.7k
fix option update. Fixes #2620 #3817
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
Changes from all commits
1fda257
2ba849b
f64aae5
f229d51
4b8b1fd
f37ea65
4456337
4817236
44e4123
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ var CSSPropertyOperations = require('CSSPropertyOperations'); | |
var DOMProperty = require('DOMProperty'); | ||
var DOMPropertyOperations = require('DOMPropertyOperations'); | ||
var ReactBrowserEventEmitter = require('ReactBrowserEventEmitter'); | ||
var ReactChildren = require('ReactChildren'); | ||
var ReactComponentBrowserEnvironment = | ||
require('ReactComponentBrowserEnvironment'); | ||
var ReactMount = require('ReactMount'); | ||
|
@@ -232,6 +233,26 @@ function processChildContext(context, tagName) { | |
return context; | ||
} | ||
|
||
var onlyNestTextTags = { | ||
'option': true | ||
}; | ||
|
||
function getChildrenTextContent(tag, children) { | ||
var childrenContent = ''; | ||
ReactChildren.forEach(children, function (c) { | ||
var childType = typeof c; | ||
if (childType !== 'string' && childType !== 'number') { | ||
// not null/undefined/boolean | ||
if (c !== null) { | ||
warning(false, '%s can not have complex children/content', tag); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you put the warning in an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @spicyj Could it not make sense to |
||
} | ||
} else { | ||
childrenContent += c; | ||
} | ||
}); | ||
return childrenContent; | ||
} | ||
|
||
/** | ||
* Creates a new React class that is idempotent and capable of containing other | ||
* React components. It accepts event listeners and DOM properties that are | ||
|
@@ -369,6 +390,10 @@ ReactDOMComponent.Mixin = { | |
ret = innerHTML.__html; | ||
} | ||
} else { | ||
if (onlyNestTextTags[this._tag]) { | ||
var childrenContent = getChildrenTextContent(this._tag, props.children); | ||
return escapeTextContentForBrowser(childrenContent); | ||
} | ||
var contentToUse = | ||
CONTENT_TYPES[typeof props.children] ? props.children : null; | ||
var childrenToUse = contentToUse != null ? null : props.children; | ||
|
@@ -567,6 +592,11 @@ ReactDOMComponent.Mixin = { | |
var nextContent = | ||
CONTENT_TYPES[typeof nextProps.children] ? nextProps.children : null; | ||
|
||
if (onlyNestTextTags[this._tag]) { | ||
lastContent = getChildrenTextContent(this._tag, lastProps.children); | ||
nextContent = getChildrenTextContent(this._tag, nextProps.children); | ||
} | ||
|
||
var lastHtml = | ||
lastProps.dangerouslySetInnerHTML && | ||
lastProps.dangerouslySetInnerHTML.__html; | ||
|
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.
This if statement would be clearer with the branches swapped.