style-unit
Advanced tools
Comparing version 3.0.4 to 3.0.5
## Changelog | ||
## v3.0.5 | ||
- Fix: fix transform rpx error in node env. | ||
## v3.0.4 | ||
@@ -4,0 +8,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { isWeb, isWeex } from 'universal-env'; | ||
import { isWeb, isWeex, isNode } from 'universal-env'; | ||
var RPX_REG = /"[^"]+"|'[^']+'|url\([^\)]+\)|(\d*\.?\d+)rpx/g; | ||
@@ -9,3 +9,3 @@ | ||
var targetPlatform = isWeb ? 'web' : isWeex ? 'weex' : ''; // Init toFixed method | ||
var targetPlatform = isWeb ? 'web' : isWeex ? 'weex' : isNode ? 'node' : ''; // Init toFixed method | ||
@@ -79,8 +79,9 @@ var unitPrecision = 4; | ||
export function calcRpx(str) { | ||
if (targetPlatform === 'web') { | ||
// In Web convert rpx to 'vw', same as driver-dom and driver-universal | ||
if (targetPlatform === 'web' || targetPlatform === 'node') { | ||
// In Web convert rpx to 'vw', same as driver-dom and driver-universal. | ||
// In Node is same as web for SSR. | ||
// '375rpx' => '50vw' | ||
return str.replace(RPX_REG, decimalVWTransformer); | ||
} else if (targetPlatform === 'weex') { | ||
// In Weex convert rpx to 'px' | ||
// In Weex convert rpx to 'px'. | ||
// '375rpx' => 375 * px | ||
@@ -87,0 +88,0 @@ return str.replace(RPX_REG, decimalPixelTransformer); |
@@ -25,3 +25,3 @@ "use strict"; | ||
var targetPlatform = _universalEnv.isWeb ? 'web' : _universalEnv.isWeex ? 'weex' : ''; // Init toFixed method | ||
var targetPlatform = _universalEnv.isWeb ? 'web' : _universalEnv.isWeex ? 'weex' : _universalEnv.isNode ? 'node' : ''; // Init toFixed method | ||
@@ -96,8 +96,9 @@ var unitPrecision = 4; | ||
function calcRpx(str) { | ||
if (targetPlatform === 'web') { | ||
// In Web convert rpx to 'vw', same as driver-dom and driver-universal | ||
if (targetPlatform === 'web' || targetPlatform === 'node') { | ||
// In Web convert rpx to 'vw', same as driver-dom and driver-universal. | ||
// In Node is same as web for SSR. | ||
// '375rpx' => '50vw' | ||
return str.replace(RPX_REG, decimalVWTransformer); | ||
} else if (targetPlatform === 'weex') { | ||
// In Weex convert rpx to 'px' | ||
// In Weex convert rpx to 'px'. | ||
// '375rpx' => 375 * px | ||
@@ -104,0 +105,0 @@ return str.replace(RPX_REG, decimalPixelTransformer); |
{ | ||
"name": "style-unit", | ||
"version": "3.0.4", | ||
"version": "3.0.5", | ||
"description": "style-unit", | ||
@@ -5,0 +5,0 @@ "license": "BSD-3-Clause", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10478
260