Socket
Socket
Sign inDemoInstall

style-unit

Package Overview
Dependencies
Maintainers
7
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

style-unit - npm Package Compare versions

Comparing version 3.0.4 to 3.0.5

4

CHANGELOG.md
## Changelog
## v3.0.5
- Fix: fix transform rpx error in node env.
## v3.0.4

@@ -4,0 +8,0 @@

11

es/index.js

@@ -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",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc