diff --git a/packages/hippy-vue-native-components/src/animation.js b/packages/hippy-vue-native-components/src/animation.js index e36c43ca95b..70e27e22f0d 100644 --- a/packages/hippy-vue-native-components/src/animation.js +++ b/packages/hippy-vue-native-components/src/animation.js @@ -85,9 +85,15 @@ function registerAnimation(Vue) { let animationIds = Object.keys(otherStyles).map(key => style[key].animationId); if (Array.isArray(transform) && transform.length > 0) { const transformIds = []; - transform.forEach(entity => Object.values(entity) - .forEach(value => Number.isInteger(value.animationId) - && transformIds.push(value.animationId))); + transform.forEach(entity => Object.keys(entity) + .forEach((key) => { + if (entity[key]) { + const { animationId } = entity[key]; + if (typeof animationId === 'number' && animationId % 1 === 0) { + transformIds.push(animationId); + } + } + })); animationIds = [...animationIds, ...transformIds]; } return animationIds; diff --git a/packages/hippy-vue/src/util/__tests__/index.test.js b/packages/hippy-vue/src/util/__tests__/index.test.js index a587da61e51..7eaab263ffc 100644 --- a/packages/hippy-vue/src/util/__tests__/index.test.js +++ b/packages/hippy-vue/src/util/__tests__/index.test.js @@ -61,7 +61,7 @@ test('tryConvertNumber output test', (t) => { t.is(util.tryConvertNumber(123), 123); t.is(util.tryConvertNumber('123'), 123); t.is(util.tryConvertNumber('abc'), 'abc'); - t.is(util.tryConvertNumber('123abc'), '123abc'); + t.is(util.tryConvertNumber('123abc'), 123); t.is(util.tryConvertNumber('abc123'), 'abc123'); const obj = {}; t.is(util.tryConvertNumber(obj), obj); diff --git a/packages/hippy-vue/src/util/index.js b/packages/hippy-vue/src/util/index.js index 411508fba77..8a1b3ddd97f 100644 --- a/packages/hippy-vue/src/util/index.js +++ b/packages/hippy-vue/src/util/index.js @@ -86,14 +86,15 @@ function capitalizeFirstLetter(str) { /** * Convert string to number as possible */ -const numberRegEx = new RegExp('^[+-]?(\\d+)?(\\.\\d+)?$'); +// const numberRegEx = new RegExp('^[+-]?(\\d+)?(\\.\\d+)?$'); function tryConvertNumber(str) { if (typeof str === 'number') { return str; } - if (typeof str === 'string' && numberRegEx.test(str)) { + if (typeof str === 'string') { try { - return parseFloat(str); + const parsedNumber = parseFloat(str); + if (!Number.isNaN(parsedNumber)) return parsedNumber; } catch (err) { // pass }