Skip to content

fixes frozen props when element not frozen #262

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

Closed
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
13 changes: 10 additions & 3 deletions src/linkClass.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,19 @@ const linkArray = (array: Array, styles: Object, configuration: Object) => {
const linkElement = (element: ReactElement, styles: Object, configuration: Object): ReactElement => {
let appendClassName;
let elementIsFrozen;
let elementPropsIsFrozen;
let elementShallowCopy;

elementShallowCopy = element;

// https://github.com/facebook/react/blob/v0.13.3/src/classic/element/ReactElement.js#L131
if (Object.isFrozen && Object.isFrozen(elementShallowCopy)) {
elementIsFrozen = true;

// https://github.com/facebook/react/blob/v0.13.3/src/classic/element/ReactElement.js#L131
elementShallowCopy = objectUnfreeze(elementShallowCopy);
}

if (Object.isFrozen && Object.isFrozen(elementShallowCopy.props)) {
elementPropsIsFrozen = true;
elementShallowCopy.props = objectUnfreeze(elementShallowCopy.props);
}

Expand Down Expand Up @@ -74,10 +78,13 @@ const linkElement = (element: ReactElement, styles: Object, configuration: Objec
delete elementShallowCopy.props.styleName;

if (elementIsFrozen) {
Object.freeze(elementShallowCopy.props);
Object.freeze(elementShallowCopy);
}

if (elementPropsIsFrozen) {
Object.freeze(elementShallowCopy.props);
}

return elementShallowCopy;
};

Expand Down