You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.1 KiB
45 lines
1.1 KiB
/* eslint-disable */ |
|
|
|
/* eslint-disable */ |
|
///////////////////////////////////dist\wxs\object.wxs///////////////////////////////// |
|
var REGEXP = getRegExp('{|}|"', 'g'); |
|
|
|
function keys(obj) { |
|
return JSON.stringify(obj).replace(REGEXP, '').split(',').map(function (item) { |
|
return item.split(':')[0]; |
|
}); |
|
} |
|
|
|
///////////////////////////////////dist\wxs\array.wxs///////////////////////////////// |
|
function isArray(array) { |
|
return array && array.constructor === 'Array'; |
|
} |
|
|
|
function kebabCase(word) { |
|
var newWord = word.replace(getRegExp("[A-Z]", 'g'), function (i) { |
|
return '-' + i; |
|
}).toLowerCase(); |
|
return newWord; |
|
} |
|
|
|
function style(styles) { |
|
if (isArray(styles)) { |
|
return styles.filter(function (item) { |
|
return item != null && item !== ''; |
|
}).map(function (item) { |
|
return style(item); |
|
}).join(';'); |
|
} |
|
|
|
if ('Object' === styles.constructor) { |
|
return keys(styles).filter(function (key) { |
|
return styles[key] != null && styles[key] !== ''; |
|
}).map(function (key) { |
|
return [kebabCase(key), [styles[key]]].join(':'); |
|
}).join(';'); |
|
} |
|
|
|
return styles; |
|
} |
|
|
|
module.exports = style; |