提交 e932de17 编写于 作者: Q qiang

fix(App): nvue-style border/flex-flow

上级 5883c2c5
...@@ -57,14 +57,18 @@ function border (declaration) { ...@@ -57,14 +57,18 @@ function border (declaration) {
var { value, important } = clearImportant(declaration.value) var { value, important } = clearImportant(declaration.value)
var property = declaration.property var property = declaration.property
var position = declaration.position var position = declaration.position
var result = (' ' + value).match(/^(\s+[\d\.]+\S*)?(\s+(?:solid|dashed|dotted))?(\s+\S+)?$/) var splitResult = value.replace(/\s*,\s*/g, ',').split(/\s+/)
if (!result) { var result = [/^[\d\.]+\S*$/, /^(solid|dashed|dotted)$/, /\S+/].map(item => {
declaration var index = splitResult.findIndex(str => item.test(str))
return index < 0 ? null : splitResult.splice(index, 1)[0]
})
if (splitResult.length) {
return declaration
} }
return [ return [
generateDeclaration(property + '-width', (result[1] || '0').trim(), important, position), generateDeclaration(property + '-width', (result[0] || '0').trim(), important, position),
generateDeclaration(property + '-style', (result[2] || 'solid').trim(), important, position), generateDeclaration(property + '-style', (result[1] || 'solid').trim(), important, position),
generateDeclaration(property + '-color', (result[3] || '#000000').trim(), important, position) generateDeclaration(property + '-color', (result[2] || '#000000').trim(), important, position)
] ]
} }
...@@ -123,13 +127,17 @@ function borderRadius (declaration) { ...@@ -123,13 +127,17 @@ function borderRadius (declaration) {
function flexFlow (declaration) { function flexFlow (declaration) {
var { value, important } = clearImportant(declaration.value) var { value, important } = clearImportant(declaration.value)
var position = declaration.position var position = declaration.position
var result = value.match(/^(column|column-reverse|row|row-reverse)?\s*(\bnowrap|\bwrap|\bwrap-reverse)?$/) var splitResult = value.split(/\s+/)
if (!result) { var result = [/^(column|column-reverse|row|row-reverse)$/, /^(nowrap|wrap|wrap-reverse)$/].map(item => {
declaration var index = splitResult.findIndex(str => item.test(str))
return index < 0 ? null : splitResult.splice(index, 1)[0]
})
if (splitResult.length) {
return declaration
} }
return [ return [
generateDeclaration('flex-direction', result[1] || 'column', important, position), generateDeclaration('flex-direction', result[0] || 'column', important, position),
generateDeclaration('flex-wrap', result[2] || 'nowrap', important, position) generateDeclaration('flex-wrap', result[1] || 'nowrap', important, position)
] ]
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册