Socket
Socket
Sign inDemoInstall

postcss-styl

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-styl - npm Package Compare versions

Comparing version 0.5.3 to 0.5.4

63

lib/parser/parse-selector.js

@@ -56,33 +56,42 @@ "use strict"

function getSelectors(sourceCode, selectorLocations) {
if (selectorLocations.length <= 0) {
return []
}
const selectors = []
let nextStartIndex = 0
for (const selectorLocation of selectorLocations) {
if (nextStartIndex > selectorLocation[1]) {
continue
}
const selector = []
const endIndex = selectorLocation[1]
const cursor = sourceCode.createScopeTokenCursor(
Math.max(selectorLocation[0], nextStartIndex)
)
const startIndex = selectorLocations[0][0]
const endIndex = selectorLocations[selectorLocations.length - 1][1]
let token = cursor.next()
while (token) {
if (endIndex < token.range[0] && cursor.scopeLevel === 0) {
nextStartIndex = token.range[0]
break
}
const cursor = sourceCode.createScopeTokenCursor(startIndex, {
endLocationIndex: endIndex,
})
let token = cursor.next()
let selector = []
let linebreak = false
while (token) {
if (token.value === "," && cursor.scopeLevel === 0) {
selector.push(token)
token = cursor.next()
selectors.push(selector)
selector = []
linebreak = false
} else if (token.type === "linebreak" && cursor.scopeLevel === 0) {
selector.push(token)
linebreak = true
} else if (
linebreak &&
token.type !== "whitespace" &&
token.type !== "linebreak" &&
token.type !== "comment" &&
token.type !== "inline-comment"
) {
selectors.push(selector)
selector = []
linebreak = false
selector.push(token)
} else {
selector.push(token)
}
const str = selector
.map(t => t.value)
.join("")
.trim()
if (str === "," || str === "") {
selectors[selectors.length - 1].push(...selector)
continue
}
token = cursor.next()
}
if (selector.length > 0) {
selectors.push(selector)

@@ -89,0 +98,0 @@ }

{
"name": "postcss-styl",
"version": "0.5.3",
"version": "0.5.4",
"description": "PostCSS parser plugin for converting Stylus syntax to PostCSS AST.",

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

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