fix: support for array type `class` #322
parent
6d32836fd8
commit
ae1f924c70
|
@ -1,5 +1,5 @@
|
||||||
import isPlainObject from 'lodash/isPlainObject'
|
import isPlainObject from 'lodash/isPlainObject'
|
||||||
|
import classNames from 'classnames'
|
||||||
function getType (fn) {
|
function getType (fn) {
|
||||||
const match = fn && fn.toString().match(/^\s*function (\w+)/)
|
const match = fn && fn.toString().match(/^\s*function (\w+)/)
|
||||||
return match ? match[1] : ''
|
return match ? match[1] : ''
|
||||||
|
@ -184,6 +184,8 @@ export function getClass (ele) {
|
||||||
let cls = {}
|
let cls = {}
|
||||||
if (typeof tempCls === 'string') {
|
if (typeof tempCls === 'string') {
|
||||||
tempCls.split(' ').forEach(c => { cls[c.trim()] = true })
|
tempCls.split(' ').forEach(c => { cls[c.trim()] = true })
|
||||||
|
} else if (Array.isArray(tempCls)) {
|
||||||
|
classNames(tempCls).split(' ').forEach(c => { cls[c.trim()] = true })
|
||||||
} else {
|
} else {
|
||||||
cls = tempCls
|
cls = tempCls
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue