From 7ad40e0e8f5da731c7f057e651bb0892eecedf54 Mon Sep 17 00:00:00 2001 From: qiang Date: Mon, 16 May 2022 16:06:34 +0800 Subject: [PATCH] fix: weex-styler shorthandParser update transition parser --- .../weex-styler/lib/shorthand-parser.js | 4 ++- .../weex-styler/test/shorthand-parser.spec.js | 30 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/packages/vue-cli-plugin-hbuilderx/packages/weex-styler/lib/shorthand-parser.js b/packages/vue-cli-plugin-hbuilderx/packages/weex-styler/lib/shorthand-parser.js index 295476c9f..ddb2ac19b 100644 --- a/packages/vue-cli-plugin-hbuilderx/packages/weex-styler/lib/shorthand-parser.js +++ b/packages/vue-cli-plugin-hbuilderx/packages/weex-styler/lib/shorthand-parser.js @@ -39,7 +39,9 @@ function transition (declaration) { map['transition-delay'].push((match[4] || '0s').trim()) } for (var key in map) { - result.push(generateDeclaration(key, map[key].join(', '), important, position)) + var value = map[key] + value = value.find(item => item !== value[0]) ? value.join(', ') : value[0] + result.push(generateDeclaration(key, value, important, position)) } } return result diff --git a/packages/vue-cli-plugin-hbuilderx/packages/weex-styler/test/shorthand-parser.spec.js b/packages/vue-cli-plugin-hbuilderx/packages/weex-styler/test/shorthand-parser.spec.js index 8f4a13fe3..6e7af0a9e 100644 --- a/packages/vue-cli-plugin-hbuilderx/packages/weex-styler/test/shorthand-parser.spec.js +++ b/packages/vue-cli-plugin-hbuilderx/packages/weex-styler/test/shorthand-parser.spec.js @@ -73,6 +73,36 @@ describe('shorthand-parser', function () { value: '0s, 1s, 0s', position: {} }]) + + expect(shorthandParser([{ + type: 'declaration', + property: 'transition', + value: 'width 2s, height 2s', + position: {} + }])).eql([{ + type: 'declaration', + property: 'transition-property', + value: 'width, height', + position: {} + }, + { + type: 'declaration', + property: 'transition-duration', + value: '2s', + position: {} + }, + { + type: 'declaration', + property: 'transition-timing-function', + value: 'ease', + position: {} + }, + { + type: 'declaration', + property: 'transition-delay', + value: '0s', + position: {} + }]) }) it('parse margin', function () { -- GitLab