Skip to content
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

[Fiber] Normalize className passed to dom from fiber #8247

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion scripts/fiber/tests-failing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ src/renderers/dom/shared/__tests__/ReactBrowserEventEmitter-test.js
* should bubble onTouchTap

src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
* should handle className
* should gracefully handle various style value types
* should update styles when mutating style object
* should warn when mutating style
Expand Down
1 change: 1 addition & 0 deletions scripts/fiber/tests-passing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ src/renderers/dom/shared/__tests__/ReactBrowserEventEmitter-test.js
* should not crash ensureScrollValueMonitoring when createEvent returns null

src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
* should handle className
* should not warn for "0" as a unitless style value
* should skip reserved props on web components
* should skip dangerouslySetInnerHTML on web components
Expand Down
8 changes: 6 additions & 2 deletions src/renderers/dom/fiber/ReactDOMFiber.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ function recursivelyAppendChildren(parent : Element, child : HostChildren<Instan
}
}

function normalizeClassName(className) : string {
return (className === null) ? '' : className;
}

var DOMRenderer = ReactFiberReconciler({

updateContainer(container : Container, children : HostChildren<Instance | TextInstance>) : void {
Expand All @@ -55,7 +59,7 @@ var DOMRenderer = ReactFiberReconciler({
const domElement = document.createElement(type);
recursivelyAppendChildren(domElement, children);
if (typeof props.className !== 'undefined') {
domElement.className = props.className;
domElement.className = normalizeClassName(props.className);
}
if (typeof props.children === 'string') {
domElement.textContent = props.children;
Expand All @@ -75,7 +79,7 @@ var DOMRenderer = ReactFiberReconciler({

commitUpdate(domElement : Instance, oldProps : Props, newProps : Props) : void {
if (typeof newProps.className !== 'undefined') {
domElement.className = newProps.className;
domElement.className = normalizeClassName(newProps.className);
}
if (typeof newProps.children === 'string') {
domElement.textContent = newProps.children;
Expand Down