From 6d9639d0af8e1d5ca8570f7ab285c974f8fcbd4f Mon Sep 17 00:00:00 2001 From: Niklas von Hertzen Date: Wed, 30 Aug 2017 22:20:55 +0800 Subject: [PATCH] Use prefixed transform values --- src/parsing/transform.js | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/src/parsing/transform.js b/src/parsing/transform.js index 51d19233c..922d6fa31 100644 --- a/src/parsing/transform.js +++ b/src/parsing/transform.js @@ -14,23 +14,44 @@ export type Transform = { const MATRIX = /(matrix|matrix3d)\((.+)\)/; export const parseTransform = (style: CSSStyleDeclaration): Transform => { - // TODO get prefixed values - const transform = parseTransformMatrix(style.transform); + const transform = parseTransformMatrix( + style.transform || + style.webkitTransform || + style.mozTransform || + // $FlowFixMe + style.msTransform || + // $FlowFixMe + style.oTransform + ); if (transform === null) { return null; } return { transform, - transformOrigin: parseTransformOrigin(style.transformOrigin) + transformOrigin: parseTransformOrigin( + style.transformOrigin || + style.webkitTransformOrigin || + style.mozTransformOrigin || + // $FlowFixMe + style.msTransformOrigin || + // $FlowFixMe + style.oTransformOrigin + ) }; }; -const parseTransformOrigin = (origin: string): TransformOrigin => { +// $FlowFixMe +const parseTransformOrigin = (origin: ?string): TransformOrigin => { + if (typeof origin !== 'string') { + const v = new Length('0'); + return [v, v]; + } const values = origin.split(' ').map(Length.create); return [values[0], values[1]]; }; +// $FlowFixMe const parseTransformMatrix = (transform: ?string): Matrix | null => { if (transform === 'none' || typeof transform !== 'string') { return null;