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

@stylable/core

Package Overview
Dependencies
Maintainers
6
Versions
218
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stylable/core - npm Package Compare versions

Comparing version 3.12.0 to 3.12.1

5

cjs/selector-utils.d.ts

@@ -17,6 +17,7 @@ import * as postcss from 'postcss';

}
export declare type Visitor = (node: SelectorAstNode, index: number, nodes: SelectorAstNode[]) => boolean | void;
export declare type Visitor = (node: SelectorAstNode, index: number, nodes: SelectorAstNode[], parents: SelectorAstNode[]) => boolean | void;
export declare function parseSelector(selector: string): SelectorAstNode;
export declare function stringifySelector(ast: SelectorAstNode): string;
export declare function traverseNode(node: SelectorAstNode, visitor: Visitor, index?: number, nodes?: SelectorAstNode[]): boolean | void;
export declare function traverseNode(node: SelectorAstNode, visitor: Visitor, index?: number, nodes?: SelectorAstNode[], parents?: SelectorAstNode[]): boolean | void;
export declare function isNested(parentChain: SelectorAstNode[]): boolean;
export declare function createChecker(types: Array<string | string[]>): () => (node: SelectorAstNode) => boolean;

@@ -23,0 +24,0 @@ export declare function isGlobal(node: SelectorAstNode): boolean;

19

cjs/selector-utils.js

@@ -25,3 +25,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.createWarningRule = exports.isCompRoot = exports.isChildOfAtRule = exports.fixChunkOrdering = exports.matchSelectorTarget = exports.filterChunkNodesByType = exports.separateChunks = exports.getOriginDefinition = exports.separateChunks2 = exports.mergeChunks = exports.isNodeMatch = exports.matchAtMedia = exports.matchAtKeyframes = exports.isImport = exports.isSimpleSelector = exports.createSimpleSelectorChecker = exports.isRootValid = exports.isGlobal = exports.createChecker = exports.traverseNode = exports.stringifySelector = exports.parseSelector = void 0;
exports.createWarningRule = exports.isCompRoot = exports.isChildOfAtRule = exports.fixChunkOrdering = exports.matchSelectorTarget = exports.filterChunkNodesByType = exports.separateChunks = exports.getOriginDefinition = exports.separateChunks2 = exports.mergeChunks = exports.isNodeMatch = exports.matchAtMedia = exports.matchAtKeyframes = exports.isImport = exports.isSimpleSelector = exports.createSimpleSelectorChecker = exports.isRootValid = exports.isGlobal = exports.createChecker = exports.isNested = exports.traverseNode = exports.stringifySelector = exports.parseSelector = void 0;
const postcss = __importStar(require("postcss"));

@@ -38,3 +38,3 @@ const css_selector_tokenizer_1 = __importDefault(require("css-selector-tokenizer"));

exports.stringifySelector = stringifySelector;
function traverseNode(node, visitor, index = 0, nodes = [node]) {
function traverseNode(node, visitor, index = 0, nodes = [node], parents = []) {
if (!node) {

@@ -44,3 +44,3 @@ return;

const cNodes = node.nodes;
let doNext = visitor(node, index, nodes);
let doNext = visitor(node, index, nodes, parents);
if (doNext === false) {

@@ -53,4 +53,5 @@ return false;

if (cNodes) {
parents = [...parents, node];
for (let i = 0; i < node.nodes.length; i++) {
doNext = traverseNode(node.nodes[i], visitor, i, node.nodes);
doNext = traverseNode(node.nodes[i], visitor, i, node.nodes, parents);
if (doNext === false) {

@@ -63,2 +64,12 @@ return false;

exports.traverseNode = traverseNode;
function isNested(parentChain) {
let i = parentChain.length;
while (i--) {
if (parentChain[i].type === 'nested-pseudo-class') {
return true;
}
}
return false;
}
exports.isNested = isNested;
function createChecker(types) {

@@ -65,0 +76,0 @@ return () => {

@@ -312,4 +312,4 @@ "use strict";

let locallyScoped = false;
selector_utils_1.traverseNode(rule.selectorAst, (node, index, nodes) => {
if (node.type === 'selector') {
selector_utils_1.traverseNode(rule.selectorAst, (node, index, nodes, parents) => {
if (node.type === 'selector' && !selector_utils_1.isNested(parents)) {
locallyScoped = false;

@@ -316,0 +316,0 @@ }

{
"name": "@stylable/core",
"version": "3.12.0",
"version": "3.12.1",
"description": "CSS for Components",

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

@@ -25,3 +25,4 @@ import * as postcss from 'postcss';

index: number,
nodes: SelectorAstNode[]
nodes: SelectorAstNode[],
parents: SelectorAstNode[]
) => boolean | void;

@@ -42,3 +43,4 @@ type nodeWithPseudo = Partial<SelectorAstNode> & { pseudo: Array<Partial<SelectorAstNode>> };

index = 0,
nodes: SelectorAstNode[] = [node]
nodes: SelectorAstNode[] = [node],
parents: SelectorAstNode[] = []
): boolean | void {

@@ -49,3 +51,3 @@ if (!node) {

const cNodes = node.nodes;
let doNext = visitor(node, index, nodes);
let doNext = visitor(node, index, nodes, parents);
if (doNext === false) {

@@ -58,4 +60,5 @@ return false;

if (cNodes) {
parents = [...parents, node];
for (let i = 0; i < node.nodes.length; i++) {
doNext = traverseNode(node.nodes[i], visitor, i, node.nodes);
doNext = traverseNode(node.nodes[i], visitor, i, node.nodes, parents);
if (doNext === false) {

@@ -68,2 +71,12 @@ return false;

export function isNested(parentChain: SelectorAstNode[]) {
let i = parentChain.length;
while (i--) {
if (parentChain[i].type === 'nested-pseudo-class') {
return true;
}
}
return false;
}
export function createChecker(types: Array<string | string[]>) {

@@ -70,0 +83,0 @@ return () => {

@@ -11,2 +11,3 @@ import hash from 'murmurhash';

isCompRoot,
isNested,
isRootValid,

@@ -355,4 +356,4 @@ parseSelector,

traverseNode(rule.selectorAst, (node, index, nodes) => {
if (node.type === 'selector') {
traverseNode(rule.selectorAst, (node, index, nodes, parents) => {
if (node.type === 'selector' && !isNested(parents)) {
locallyScoped = false;

@@ -359,0 +360,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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