diff --git a/deps/weex-styler/lib/validator.js b/deps/weex-styler/lib/validator.js index 52782e311be663e90697e7f0a2b70cf061e01bbb..d7503dd207f1cc71ce0a22e73f2728a430aa9a7d 100644 --- a/deps/weex-styler/lib/validator.js +++ b/deps/weex-styler/lib/validator.js @@ -2004,28 +2004,28 @@ var BORDER_IMAGE_URL_VALIDATOR = function BORDER_IMAGE_URL_VALIDATOR(v) { }; let value = { url: "", - slice: [], - width: [], - outset: [], repeat: "" }; - var URL_REGEXP = /^url\(\s*['"]?\s*([^()]+?)\s*['"]?\s*\)(.*)(stretch|round|repeat)$/; + var URL_REGEXP = /^url\(\s*['"]?\s*([^()]+?)\s*['"]?\s*\)(.*)(stretch|round|repeat|space)$/; let result = URL_REGEXP.exec(v); value.url = result[1]; - let num = result[2].split(/\//); - switch (num.length) { - case 1: - value.slice = BORDER_IMAGE_SPLIT(num[0]); - break; - case 2: - value.slice = BORDER_IMAGE_SPLIT(num[0]); - value.width = BORDER_IMAGE_SPLIT(num[1]); - break; - case 3: - value.slice = BORDER_IMAGE_SPLIT(num[0]); - value.width = BORDER_IMAGE_SPLIT(num[1]); - value.outset = BORDER_IMAGE_SPLIT(num[2]); - break; + var reg = /px|%/; + if (result[2].match(reg)) { + let num = result[2].split(/\//); + switch (num.length) { + case 1: + value.slice = BORDER_IMAGE_SPLIT(num[0]); + break; + case 2: + value.slice = BORDER_IMAGE_SPLIT(num[0]); + value.width = BORDER_IMAGE_SPLIT(num[1]); + break; + case 3: + value.slice = BORDER_IMAGE_SPLIT(num[0]); + value.width = BORDER_IMAGE_SPLIT(num[1]); + value.outset = BORDER_IMAGE_SPLIT(num[2]); + break; + } } value.repeat = result[3]; base.values.push(value); @@ -2058,7 +2058,10 @@ var BORDER_IMAGE_GRADIENT_VALIDATOR = function BORDER_IMAGE_GRADIENT_VALIDATOR(v if (util.isValidValue(gradient.value)) { value = JSON.parse(gradient.value) } - value.slice = BORDER_IMAGE_SPLIT(valueMatch[3]); + var reg = /px|%/; + if (valueMatch[3].match(reg)) { + value.slice = BORDER_IMAGE_SPLIT(valueMatch[3]); + } base.values.push(value); return { value: JSON.stringify(base), @@ -2166,10 +2169,10 @@ var RICH_PROP_NAME_GROUPS = { borderBottom: BORDER_VALIDATOR, borderImage: BORDER_IMAGE_VALIDATOR, borderImageSource: URL_VALIDATOR, - borderImageSlice: SHORTHAND_LENGTH_VALIDATOR, - borderImageWidth: SHORTHAND_LENGTH_VALIDATOR, - borderImageOutset: SHORTHAND_LENGTH_VALIDATOR, - borderImageRepeat: genEnumValidator(['stretch', 'round', 'repeat']) + borderImageSlice: SHORTHAND_PERCENTAGE_LENGTH_VALIDATOR, + borderImageWidth: SHORTHAND_PERCENTAGE_LENGTH_VALIDATOR, + borderImageOutset: SHORTHAND_PERCENTAGE_LENGTH_VALIDATOR, + borderImageRepeat: genEnumValidator(['stretch', 'round', 'repeat', 'space']) }, indicator: { indicatorSize: LENGTH_VALIDATOR,