Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #3

Merged
merged 2 commits into from
Dec 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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