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 1c504753f98493780187276d2f74f6a27e0b287c..295476c9fc69c010fa91a386a6b4df34c28e2eae 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 @@ -16,15 +16,32 @@ function clearImportant (value) { } function transition (declaration) { - var CHUNK_REGEXP = /^(\S*)?\s*(\d*\.?\d+(?:ms|s)?)?\s*(\S*)?\s*(\d*\.?\d+(?:ms|s)?)?$/ + var CHUNK_REGEXP = /^([a-z-_]\S*)(\s+[\d.]+m?s)?(\s+[a-z-_]\S*)?(\s+[\d.]+m?s)?/ var { value, important } = clearImportant(declaration.value) - var match = value.match(CHUNK_REGEXP) - var result = [] + var values = value.replace(/(\d)\s*,\s*/g, '$1#').split(',') var position = declaration.position - match[1] && result.push(generateDeclaration('transition-property', match[1], important, position)) - match[2] && result.push(generateDeclaration('transition-duration', match[2], important, position)) - match[3] && result.push(generateDeclaration('transition-timing-function', match[3], important, position)) - match[4] && result.push(generateDeclaration('transition-delay', match[4], important, position)) + var result = [] + var map = { + 'transition-property': [], + 'transition-duration': [], + 'transition-timing-function': [], + 'transition-delay': [] + } + if (values.length) { + for (var i1 = 0; i1 < values.length; i1++) { + var match = values[i1].trim().match(CHUNK_REGEXP) + if (!match) { + return [] + } + map['transition-property'].push(match[1] || 'all') + map['transition-duration'].push((match[2] || '0s').trim()) + map['transition-timing-function'].push((match[3] || 'ease').trim().replace(/#/g, ', ')) + map['transition-delay'].push((match[4] || '0s').trim()) + } + for (var key in map) { + result.push(generateDeclaration(key, map[key].join(', '), 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 41d7cd5967b4081a3f8a0c98bb1e97e86ccf050d..8f4a13fe330b6246038c17a1b529b5cb1d85e58d 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 @@ -43,6 +43,36 @@ describe('shorthand-parser', function () { position: {} } ]) + + expect(shorthandParser([{ + type: 'declaration', + property: 'transition', + value: 'width 2s ease-in-out, height 1s 1s, top cubic-bezier(0.1, 0.7, 1.0, 0.1)', + position: {} + }])).eql([{ + type: 'declaration', + property: 'transition-property', + value: 'width, height, top', + position: {} + }, + { + type: 'declaration', + property: 'transition-duration', + value: '2s, 1s, 0s', + position: {} + }, + { + type: 'declaration', + property: 'transition-timing-function', + value: 'ease-in-out, ease, cubic-bezier(0.1, 0.7, 1.0, 0.1)', + position: {} + }, + { + type: 'declaration', + property: 'transition-delay', + value: '0s, 1s, 0s', + position: {} + }]) }) it('parse margin', function () { diff --git a/src/platforms/app-plus/view/elements/hover.js b/src/platforms/app-plus/view/elements/hover.js index deee362ba8749cd94481ceea45b18f5adc498bff..1f238090346cdbdb9f90973891b37d849518c50c 100644 --- a/src/platforms/app-plus/view/elements/hover.js +++ b/src/platforms/app-plus/view/elements/hover.js @@ -2,7 +2,6 @@ import UniAnimationElement from './animation' export default class UniHoverElement extends UniAnimationElement { setAttribute (key, value) { - console.log('setAttribute:', key, value) if (key === 'hover-class') { this._updateHoverClass(value) }