mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-06-01 10:07:35 +00:00
Rename some variables in StyleRegistry
This commit is contained in:
@@ -88,10 +88,10 @@ class StyleRegistry {
|
|||||||
* To determine the next style, some of the existing DOM state must be
|
* To determine the next style, some of the existing DOM state must be
|
||||||
* converted back into React Native styles.
|
* converted back into React Native styles.
|
||||||
*/
|
*/
|
||||||
resolveStateful(rnStyleNext, domStyleProps) {
|
resolveStateful(rnStyleNext, { classList: domClassList, style: domStyle }) {
|
||||||
// Convert the DOM classList back into a React Native form
|
// Convert the DOM classList back into a React Native form
|
||||||
// Preserves unrecognized class names.
|
// Preserves unrecognized class names.
|
||||||
const rnStyleProps = domStyleProps.classList.reduce(
|
const { classList: rnClassList, style: rnStyle } = domClassList.reduce(
|
||||||
(styleProps, className) => {
|
(styleProps, className) => {
|
||||||
const { prop, value } = this.styleManager.getDeclaration(className);
|
const { prop, value } = this.styleManager.getDeclaration(className);
|
||||||
if (prop) {
|
if (prop) {
|
||||||
@@ -106,8 +106,8 @@ class StyleRegistry {
|
|||||||
|
|
||||||
// DOM style may include vendor prefixes and properties set by other libraries.
|
// DOM style may include vendor prefixes and properties set by other libraries.
|
||||||
// Preserve it but transform back into React DOM style.
|
// Preserve it but transform back into React DOM style.
|
||||||
const rdomStyle = Object.keys(domStyleProps.style).reduce((acc, styleName) => {
|
const rdomStyle = Object.keys(domStyle).reduce((acc, styleName) => {
|
||||||
const value = domStyleProps.style[styleName];
|
const value = domStyle[styleName];
|
||||||
if (value !== '') {
|
if (value !== '') {
|
||||||
const reactStyleName = vendorPrefixPattern.test(styleName)
|
const reactStyleName = vendorPrefixPattern.test(styleName)
|
||||||
? styleName.charAt(0).toUpperCase() + styleName.slice(1)
|
? styleName.charAt(0).toUpperCase() + styleName.slice(1)
|
||||||
@@ -119,11 +119,9 @@ class StyleRegistry {
|
|||||||
|
|
||||||
// Create next DOM style props from current and next RN styles
|
// Create next DOM style props from current and next RN styles
|
||||||
const { classList: rdomClassListNext, style: rdomStyleNext } = this.resolve([
|
const { classList: rdomClassListNext, style: rdomStyleNext } = this.resolve([
|
||||||
rnStyleProps.style,
|
rnStyle,
|
||||||
rnStyleNext
|
rnStyleNext
|
||||||
]);
|
]);
|
||||||
// Add the current class names not managed by React Native
|
|
||||||
rdomClassListNext.push(...rnStyleProps.classList);
|
|
||||||
// Next class names take priority over current inline styles
|
// Next class names take priority over current inline styles
|
||||||
const style = { ...rdomStyle };
|
const style = { ...rdomStyle };
|
||||||
rdomClassListNext.forEach(className => {
|
rdomClassListNext.forEach(className => {
|
||||||
@@ -134,7 +132,8 @@ class StyleRegistry {
|
|||||||
});
|
});
|
||||||
// Next inline styles take priority over current inline styles
|
// Next inline styles take priority over current inline styles
|
||||||
Object.assign(style, rdomStyleNext);
|
Object.assign(style, rdomStyleNext);
|
||||||
const className = classListToString(rdomClassListNext);
|
// Add the current class names not managed by React Native
|
||||||
|
const className = classListToString(rdomClassListNext.concat(rnClassList));
|
||||||
|
|
||||||
return { className, style };
|
return { className, style };
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user