Socket
Socket
Sign inDemoInstall

style-mod

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

style-mod - npm Package Compare versions

Comparing version 2.0.1 to 2.1.0

16

dist/style-mod.js

@@ -21,3 +21,3 @@ function sym(name, random) {

// CSS rules generated for a given DOM root is bounded by the amount
// of style modules that were used. To avoid leaking rules, don't
// of style modules that were used. So to avoid leaking rules, don't
// create these dynamically, but treat them as one-time allocations.

@@ -28,4 +28,12 @@ var StyleModule = exports.StyleModule = function(spec) {

for (var name in spec) {
var className = this[name] = "\u037c" + (top[COUNT]++).toString(36)
renderStyle("." + className, spec[name], this[RULES])
var style = spec[name], specificity = style.specificity || 0
var id = "\u037c" + (top[COUNT]++).toString(36)
var selector = "." + id, className = id
for (var i = 0; i < specificity; i++) {
var name$1 = "\u037c_" + (i ? i.toString(36) : "")
selector += "." + name$1
className += " " + name$1
}
this[name] = className
renderStyle(selector, spec[name], this[RULES])
}

@@ -101,3 +109,3 @@ }

renderStyle(prop.replace(/&/g, selector), spec[prop], output)
} else {
} else if (prop != "specificity") {
if (typeof spec[prop] == "object") { throw new RangeError("The value of a property (" + prop + ") should be a primitive value.") }

@@ -104,0 +112,0 @@ props.push(prop.replace(/_.*/, "").replace(/[A-Z]/g, function (l) { return "-" + l.toLowerCase(); }) + ": " + spec[prop])

{
"name": "style-mod",
"version": "2.0.1",
"version": "2.1.0",
"description": "A minimal CSS module shim",

@@ -5,0 +5,0 @@ "main": "dist/style-mod.js",

@@ -45,3 +45,3 @@ <!-- To edit this file, edit /src/README.md, not /README.md -->

CSS rules generated for a given DOM root is bounded by the amount
of style modules that were used. To avoid leaking rules, don't
of style modules that were used. So to avoid leaking rules, don't
create these dynamically, but treat them as one-time allocations.

@@ -48,0 +48,0 @@

@@ -21,3 +21,3 @@ function sym(name, random) {

// CSS rules generated for a given DOM root is bounded by the amount
// of style modules that were used. To avoid leaking rules, don't
// of style modules that were used. So to avoid leaking rules, don't
// create these dynamically, but treat them as one-time allocations.

@@ -28,4 +28,12 @@ export function StyleModule(spec) {

for (let name in spec) {
let className = this[name] = "\u037c" + (top[COUNT]++).toString(36)
renderStyle("." + className, spec[name], this[RULES])
let style = spec[name], specificity = style.specificity || 0
let id = "\u037c" + (top[COUNT]++).toString(36)
let selector = "." + id, className = id
for (let i = 0; i < specificity; i++) {
let name = "\u037c_" + (i ? i.toString(36) : "")
selector += "." + name
className += " " + name
}
this[name] = className
renderStyle(selector, spec[name], this[RULES])
}

@@ -103,3 +111,3 @@ }

renderStyle(prop.replace(/&/g, selector), spec[prop], output)
} else {
} else if (prop != "specificity") {
if (typeof spec[prop] == "object") throw new RangeError("The value of a property (" + prop + ") should be a primitive value.")

@@ -106,0 +114,0 @@ props.push(prop.replace(/_.*/, "").replace(/[A-Z]/g, l => "-" + l.toLowerCase()) + ": " + spec[prop])

@@ -51,2 +51,18 @@ const {StyleModule} = require("..")

})
it("can add specificity", () => {
let mod = new StyleModule({
main: {
specificity: 1,
color: "yellow"
},
other: {
specificity: 2,
color: "blue"
}
})
ist(rules(mod), [".c1.c_ {color: yellow}", ".c2.c_.c_1 {color: blue}"], eqRules)
ist(mod.main.split(" ").length, 2)
ist(mod.other.split(" ").length, 3)
})
})

@@ -60,3 +76,3 @@

function norm(rules) {
let names = [], re = /\.[c\u037c](\d+)/g, m
let names = [], re = /\.[c\u037c](\w+)/g, m
for (let rule of rules) while (m = re.exec(rule)) if (names.indexOf(m[1]) < 0) names.push(m[1])

@@ -63,0 +79,0 @@ return rules.map(rule => rule.replace(re, (_, id) => ".c" + (names.indexOf(id) + 1)))

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