Browse Source

Safeguard Container style when used cross-platform

master
Bettenbuk Zoltan 6 years ago
parent
commit
31638133b7

+ 9
- 1
react/features/base/react/components/AbstractContainer.js View File

2
 
2
 
3
 import React, { Component } from 'react';
3
 import React, { Component } from 'react';
4
 
4
 
5
+import { getFixedPlatformStyle } from '../../styles';
6
+
5
 /**
7
 /**
6
  * {@code AbstractContainer} component's property types.
8
  * {@code AbstractContainer} component's property types.
7
  */
9
  */
80
     _render(type, props?: P) {
82
     _render(type, props?: P) {
81
         const {
83
         const {
82
             children,
84
             children,
85
+            style,
83
 
86
 
84
             /* eslint-disable no-unused-vars */
87
             /* eslint-disable no-unused-vars */
85
 
88
 
94
             ...filteredProps
97
             ...filteredProps
95
         } = props || this.props;
98
         } = props || this.props;
96
 
99
 
100
+        const _style = getFixedPlatformStyle(style);
101
+
97
         // $FlowFixMe
102
         // $FlowFixMe
98
-        return React.createElement(type, filteredProps, children);
103
+        return React.createElement(type, {
104
+            style: _style,
105
+            ...filteredProps
106
+        }, children);
99
     }
107
     }
100
 }
108
 }

react/features/base/styles/functions.js → react/features/base/styles/functions.any.js View File


+ 18
- 0
react/features/base/styles/functions.native.js View File

1
+// @flow
2
+
3
+import { type StyleType } from './functions.any';
4
+
5
+export * from './functions.any';
6
+
7
+/**
8
+ * Fixes the style prop that is passed to a platform generic component based on platform specific
9
+ * format requirements.
10
+ *
11
+ * @param {StyleType} style - The passed style prop to the component.
12
+ * @returns {StyleType}
13
+ */
14
+export function getFixedPlatformStyle(style: StyleType): StyleType {
15
+    // There is nothing to do on mobile - yet.
16
+
17
+    return style;
18
+}

+ 26
- 0
react/features/base/styles/functions.web.js View File

1
+// @flow
2
+
3
+import { type StyleType } from './functions.any';
4
+
5
+export * from './functions.any';
6
+
7
+/**
8
+ * Fixes the style prop that is passed to a platform generic component based on platform specific
9
+ * format requirements.
10
+ *
11
+ * @param {StyleType} style - The passed style prop to the component.
12
+ * @returns {StyleType}
13
+ */
14
+export function getFixedPlatformStyle(style: StyleType): StyleType {
15
+    if (Array.isArray(style)) {
16
+        const _style = {};
17
+
18
+        for (const component of style) {
19
+            Object.assign(_style, component);
20
+        }
21
+
22
+        return _style;
23
+    }
24
+
25
+    return style;
26
+}

Loading…
Cancel
Save