Skip to content

Commit

Permalink
fix(taro-weapp): 修复setData 前移出掉数据中的函数时将null转换成空对象问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Simbachen committed Aug 1, 2018
1 parent 6e61d48 commit 3a914ca
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/taro-weapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"license": "MIT",
"dependencies": {
"@tarojs/taro": "1.0.0-beta.4",
"lodash": "^4.17.10",
"prop-types": "^15.6.1"
}
}
15 changes: 12 additions & 3 deletions packages/taro-weapp/src/util.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import isPlainObject from 'lodash/isPlainObject'
export function isEmptyObject (obj) {
if (!obj) {
return false
Expand Down Expand Up @@ -56,18 +57,26 @@ export function getPrototypeChain (obj) {

export function noop () {}

export function isFunction (arg) {
return typeof arg === 'function'
}

export function isArray (arg) {
return Array.isArray(arg)
}

export function shakeFnFromObject (obj) {
let newObj
if (Array.isArray(obj)) {
if (isArray(obj)) {
newObj = []
const len = obj.length
for (let i = 0; i < len; i++) {
newObj.push(shakeFnFromObject(obj[i]))
}
} else if (typeof obj === 'object') {
} else if (isPlainObject(obj)) {
newObj = {}
for (const key in obj) {
if (typeof obj[key] === 'function') {
if (isFunction(obj[key])) {
continue
}
const ret = shakeFnFromObject(obj[key])
Expand Down

0 comments on commit 3a914ca

Please sign in to comment.