Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

v-css-var

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

v-css-var - npm Package Compare versions

Comparing version 1.0.1 to 1.0.3

22

index.js
/* eslint-disable no-useless-return,no-useless-escape,camelcase,semi,no-cond-assign,no-unused-vars */
const env = process.env.NODE_ENV
const handleVars = (varItem, addPrefix) => {
const handleVars = (varItem) => {
varItem = varItem.map(e => e + '')
if (addPrefix) {
varItem[0] = '--' + varItem[0].replace('--', '')
}
return {
varsName: varItem[0],
varsName: '--' + varItem[0].replace('--', ''),
varsValue: varItem[1]
}
}
const changeVars = (el, binding, prefix) => {
const changeVars = (el, binding) => {
const vars = Object.entries(binding.value)

@@ -20,3 +17,3 @@ const dom = binding.modifiers.root ? document.documentElement : el

varsValue
} = handleVars(k, prefix)
} = handleVars(k)
dom.style.setProperty(varsName, varsValue)

@@ -43,3 +40,3 @@ }

}
changeVars(el, binding, options.prefix)
changeVars(el, binding)
},

@@ -53,3 +50,6 @@ update: function (el, binding) {

// get all cssVars in the dom
const styleList = dom.style.cssText.split(';').map(e => e.split(':')).filter(e => e[0] !== '')
const styleList = dom.style.cssText
.split(';')
.map(e => e.split(':'))
.filter(e => e[0] !== '' && e[0].startsWith('--'))
const vars = Object.entries(binding.value)

@@ -62,3 +62,3 @@ // 更新当前变量

varsValue
} = handleVars(k, options.prefix)
} = handleVars(k)
const oldValue = document.body.style.getPropertyValue(varsName)

@@ -71,3 +71,3 @@ if (oldValue !== varsValue) {

for (const k of styleList) {
const key = options.prefix ? k[0].replace('--', '') : k[0]
const key = k[0].replace('--', '')
if (!vars.find(e => e[0] === key)) {

@@ -74,0 +74,0 @@ dom.style.removeProperty(k[0])

{
"name": "v-css-var",
"version": "1.0.1",
"version": "1.0.3",
"description": "use CSS Variables by vue directive",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -9,5 +9,3 @@ # v-css-var

import cssVar from 'v-css-var'
Vue.use(cssVar,{
prefix: true // auto add the prefix like --
})
Vue.use(cssVar)
```

@@ -24,3 +22,3 @@ #### basic use

var:{
a:'1px'
a:'1px' // not suggest start with --,like '--a':'1px',but supported
}

@@ -27,0 +25,0 @@ }

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