Skip to content

Commit e334318

Browse files
committed
fix(wx-react): 修复StyleSheet flatten
1 parent 76b0c70 commit e334318

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

packages/wx-react/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@areslabs/wx-react",
3-
"version": "1.0.32",
3+
"version": "1.0.33",
44
"description": "微信版本的React",
55
"files": [
66
"miniprogram_dist",

packages/wx-react/src/tackleWithStyleObj.js

+10-13
Original file line numberDiff line numberDiff line change
@@ -280,33 +280,30 @@ function parseObj(obj) {
280280
return out;
281281
}
282282

283-
function flattenArray(arr, ans = {}) {
284-
if (!Array.isArray(arr)) return arr
285-
283+
function flattenArray(arr, ans = []) {
284+
if (!Array.isArray(arr)) return arr;
286285
for (let m in arr) {
287286
if (!Array.isArray(arr[m])) {
288-
Object.assign(ans, arr[m])
287+
ans.push(arr[m]);
289288
} else {
290-
flattenArray(arr[m], ans)
289+
flattenArray(arr[m], ans);
291290
}
292291
}
293-
return ans
292+
return ans;
294293
}
295294

296295

297296
/**
298297
* the inverse process of tackleWithStyleObj
299298
* @param str
300299
*/
301-
export function flattenStyle(str) {
302-
303-
if (Array.isArray(str)) {
304-
return flattenArray(str)
300+
export function flattenStyle(fstyle) {
301+
let str = fstyle
302+
if (typeof fstyle !== 'string') {
303+
// 可能是数组,可能是字符串,可能是其组合
304+
str = tackleWithStyleObj(fstyle)
305305
}
306306

307-
if (typeof str === 'object') {
308-
return str
309-
}
310307

311308
const array = str.split(';').filter(i => i)
312309
const obj = {}

0 commit comments

Comments
 (0)