Skip to content

Commit

Permalink
Dev (#3)
Browse files Browse the repository at this point in the history
* update

* patch version
  • Loading branch information
sky-admin committed Dec 10, 2018
1 parent 2949979 commit 69eb959
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mpxjs/core",
"version": "1.0.2",
"version": "1.0.3",
"description": "mpx runtime core",
"keywords": [
"miniprogram",
Expand Down
12 changes: 10 additions & 2 deletions packages/core/src/helper/utils.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import {
isObservableArray
} from 'mobx'

export function type (n) {
return Object.prototype.toString.call(n).slice(8, -1)
}
Expand Down Expand Up @@ -146,12 +150,16 @@ export function isObject (obj) {
return obj !== null && typeof obj === 'object'
}

export function likeArray (arr) {
return Array.isArray(arr) || isObservableArray(arr)
}

export function isDef (v) {
return v !== undefined && v !== null
}

export function stringifyClass (value) {
if (Array.isArray(value)) {
if (likeArray(value)) {
return stringifyArray(value)
}
if (isObject(value)) {
Expand Down Expand Up @@ -237,7 +245,7 @@ export function mergeObjectArray (arr) {
}

export function normalizeDynamicStyle (value) {
if (Array.isArray(value)) {
if (likeArray(value)) {
return mergeObjectArray(value)
}
if (typeof value === 'string') {
Expand Down
5 changes: 2 additions & 3 deletions packages/core/src/platform/builtInMixins/renderHelperMixin.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import {isObject} from '../../helper/utils'
import {isObject, likeArray} from '../../helper/utils'
import {toJS, isObservable} from 'mobx'

export default function renderHelperMixin () {
return {
methods: {
__iterate (val, handler) {
val = toJS(val)
let i, l, keys, key
if (Array.isArray(val) || typeof val === 'string') {
if (likeArray(val) || typeof val === 'string') {
for (i = 0, l = val.length; i < l; i++) {
handler(val[i], i)
}
Expand Down

0 comments on commit 69eb959

Please sign in to comment.