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

postcss-scss

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-scss - npm Package Compare versions

Comparing version 4.0.6 to 4.0.7

130

lib/scss-parser.js

@@ -8,2 +8,45 @@ let { Comment } = require('postcss')

class ScssParser extends Parser {
atrule(token) {
let name = token[1]
let prev = token
while (!this.tokenizer.endOfFile()) {
let next = this.tokenizer.nextToken()
if (next[0] === 'word' && next[2] === prev[3] + 1) {
name += next[1]
prev = next
} else {
this.tokenizer.back(next)
break
}
}
super.atrule(['at-word', name, token[2], prev[3]])
}
comment(token) {
if (token[4] === 'inline') {
let node = new Comment()
this.init(node, token[2])
node.raws.inline = true
let pos = this.input.fromOffset(token[3])
node.source.end = { column: pos.col, line: pos.line, offset: token[3] }
let text = token[1].slice(2)
if (/^\s*$/.test(text)) {
node.text = ''
node.raws.left = text
node.raws.right = ''
} else {
let match = text.match(/^(\s*)([^]*\S)(\s*)$/)
let fixed = match[2].replace(/(\*\/|\/\*)/g, '*//*')
node.text = fixed
node.raws.left = match[1]
node.raws.right = match[3]
node.raws.text = match[2]
}
} else {
super.comment(token)
}
}
createTokenizer() {

@@ -13,2 +56,20 @@ this.tokenizer = scssTokenizer(this.input)

raw(node, prop, tokens, customProperty) {
super.raw(node, prop, tokens, customProperty)
if (node.raws[prop]) {
let scss = node.raws[prop].raw
node.raws[prop].raw = tokens.reduce((all, i) => {
if (i[0] === 'comment' && i[4] === 'inline') {
let text = i[1].slice(2).replace(/(\*\/|\/\*)/g, '*//*')
return all + '/*' + text + '*/'
} else {
return all + i[1]
}
}, '')
if (scss !== node.raws[prop].raw) {
node.raws[prop].scss = scss
}
}
}
rule(tokens) {

@@ -50,6 +111,6 @@ let withColon = false

let pos = this.input.fromOffset(last[3])
node.source.end = { offset: last[3], line: pos.line, column: pos.col }
node.source.end = { column: pos.col, line: pos.line, offset: last[3] }
} else {
let pos = this.input.fromOffset(last[2])
node.source.end = { offset: last[2], line: pos.line, column: pos.col }
node.source.end = { column: pos.col, line: pos.line, offset: last[2] }
}

@@ -64,5 +125,5 @@

node.source.start = {
offset: tokens[0][2],
column: pos.col,
line: pos.line,
column: pos.col
offset: tokens[0][2]
}

@@ -142,65 +203,4 @@ }

}
comment(token) {
if (token[4] === 'inline') {
let node = new Comment()
this.init(node, token[2])
node.raws.inline = true
let pos = this.input.fromOffset(token[3])
node.source.end = { offset: token[3], line: pos.line, column: pos.col }
let text = token[1].slice(2)
if (/^\s*$/.test(text)) {
node.text = ''
node.raws.left = text
node.raws.right = ''
} else {
let match = text.match(/^(\s*)([^]*\S)(\s*)$/)
let fixed = match[2].replace(/(\*\/|\/\*)/g, '*//*')
node.text = fixed
node.raws.left = match[1]
node.raws.right = match[3]
node.raws.text = match[2]
}
} else {
super.comment(token)
}
}
atrule(token) {
let name = token[1]
let prev = token
while (!this.tokenizer.endOfFile()) {
let next = this.tokenizer.nextToken()
if (next[0] === 'word' && next[2] === prev[3] + 1) {
name += next[1]
prev = next
} else {
this.tokenizer.back(next)
break
}
}
super.atrule(['at-word', name, token[2], prev[3]])
}
raw(node, prop, tokens, customProperty) {
super.raw(node, prop, tokens, customProperty)
if (node.raws[prop]) {
let scss = node.raws[prop].raw
node.raws[prop].raw = tokens.reduce((all, i) => {
if (i[0] === 'comment' && i[4] === 'inline') {
let text = i[1].slice(2).replace(/(\*\/|\/\*)/g, '*//*')
return all + '/*' + text + '*/'
} else {
return all + i[1]
}
}, '')
if (scss !== node.raws[prop].raw) {
node.raws[prop].scss = scss
}
}
}
}
module.exports = ScssParser

@@ -331,6 +331,6 @@ 'use strict'

back,
endOfFile,
nextToken,
endOfFile,
position
}
}
{
"name": "postcss-scss",
"version": "4.0.6",
"version": "4.0.7",
"description": "SCSS parser for PostCSS",

@@ -23,2 +23,3 @@ "keywords": [

".": {
"types": "./lib/scss-syntax.d.ts",
"require": "./lib/scss-syntax.js",

@@ -43,2 +44,6 @@ "import": "./lib/scss-syntax.mjs"

"url": "https://tidelift.com/funding/github/npm/postcss-scss"
},
{
"type": "github",
"url": "https://github.com/sponsors/ai"
}

@@ -45,0 +50,0 @@ ],

@@ -23,2 +23,2 @@ # PostCSS SCSS Syntax

## Docs
Read **[full docs](https://github.com/postcss/postcss-scss#readme)** on GitHub.
Read full docs **[here](https://github.com/postcss/postcss-scss#readme)**.
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