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

postcss-extend

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-extend - npm Package Compare versions

Comparing version 1.0.1 to 1.0.3

0

CHANGELOG.md

@@ -0,0 +0,0 @@ # Changelog

79

index.js
'use strict';
var postcss = require('postcss');
// /*DEBUG*/ var appendout = require('fs').appendFileSync;
// /*DEBUG*/var appendout = require('fs').appendFileSync;

@@ -14,3 +14,3 @@ module.exports = postcss.plugin('postcss-extend', function extend() {

// /*DEBUG*/ appendout('./test/debugout.txt', '\n----------------------------------------');
// /*DEBUG*/appendout('./test/debugout.txt', '\n----------------------------------------');

@@ -39,4 +39,4 @@ css.walkAtRules(function(atRule) {

targetNode.remove();
// /*DEBUG*/ } else {
// /*DEBUG*/ appendout('./test/debugout.txt', '\nSifted out placeholder/silent ' + tgtSaved[i]);
// /*DEBUG*/} else {
// /*DEBUG*/appendout('./test/debugout.txt', '\nSifted out placeholder/silent ' + tgtSaved[i]);
}

@@ -70,3 +70,3 @@ }

definition.selector = '@define-placeholder ' + atRule.params.toString();
// /*DEBUG*/ appendout('./test/debugout.txt', '\nDeclaring placeholder : ' + definition.selector);
// /*DEBUG*/appendout('./test/debugout.txt', '\nDeclaring placeholder : ' + definition.selector);
atRule.parent.insertBefore(atRule, definition);

@@ -99,5 +99,5 @@ atRule.remove();

if (tgtSaved[i].substring(0, 20) === '@define-placeholder ') {
// /*DEBUG*/ appendout('./test/debugout.txt', '\nn[' + i + ']String = ' + tgtSaved[i] + ' Substring 0-20 = \'' + tgtSaved[i].substring(0, 20) + '\'');
// /*DEBUG*/appendout('./test/debugout.txt', '\nn[' + i + ']String = ' + tgtSaved[i] + ' Substring 0-20 = \'' + tgtSaved[i].substring(0, 20) + '\'');
tgtSaved[i] = tgtSaved[i].substring(20, (tgtSaved[i].length));
// /*DEBUG*/ appendout('./test/debugout.txt', '\nresString = \'' + tgtSaved[i] + '\'');
// /*DEBUG*/appendout('./test/debugout.txt', '\nresString = \'' + tgtSaved[i] + '\'');
}

@@ -113,3 +113,3 @@ }

//We need to re-evaluate the current atRule, as other classes (once passed over) may now be matching, so re-process and exit.
// /*DEBUG*/ appendout('./test/debugout.txt', '\n!Bumping evaluation of :' + atRule.parent);
// /*DEBUG*/appendout('./test/debugout.txt', '\n!Bumping evaluation of :' + atRule.parent);
processExtension(atRule);

@@ -119,6 +119,6 @@ couldExtend = true;

}
// /*DEBUG*/ appendout('./test/debugout.txt', '\nfound and extending : ' + tgtSaved[n] + ' : ' + originSels);
// /*DEBUG*/appendout('./test/debugout.txt', '\nfound and extending : ' + tgtSaved[n] + ' : ' + originSels);
tgtAccumulate = tgtAccumulate.concat(originSels);
// /*DEBUG*/ appendout('./test/debugout.txt', '\nCombined selectors :\n' + tgtAccumulate);
// /*DEBUG*/appendout('./test/debugout.txt', '\nCombined selectors :\n' + tgtAccumulate);
couldExtend = true;

@@ -133,3 +133,3 @@ //Operate on sub-elements of extendables (thus extending them)

//We need to re-evaluate the current atRule, as other classes (once passed over) may now be matching, so re-process and exit.
// /*DEBUG*/ appendout('./test/debugout.txt', '\n!Bumping evaluation of :' + atRule.parent);
// /*DEBUG*/appendout('./test/debugout.txt', '\n!Bumping evaluation of :' + atRule.parent);
processExtension(atRule);

@@ -140,7 +140,7 @@ couldExtend = true;

//tack onto target node
// /*DEBUG*/ appendout('./test/debugout.txt', '\nfound and extending : ' + tgtSaved[n].substring(0, tgtSaved[n].substring(1).search(/[\s.:#]/) + 1) + ' :\n' + tgtBase + ' (' + tgtSub + ')');
// /*DEBUG*/appendout('./test/debugout.txt', '\nfound and extending : ' + tgtSaved[n].substring(0, tgtSaved[n].substring(1).search(/[\s.:#]/) + 1) + ' :\n' + tgtBase + ' (' + tgtSub + ')');
// /*DEBUG*/ appendout('./test/debugout.txt', '\nCalling formSubSelector with (\n' + originSels + ',\n' + tgtSub);
// /*DEBUG*/appendout('./test/debugout.txt', '\nCalling formSubSelector with (\n' + originSels + ',\n' + tgtSub);
tgtAccumulate = tgtAccumulate.concat(formSubSelector(originSels, tgtSub));
// /*DEBUG*/ appendout('./test/debugout.txt', '\nCombined selectors :\n' + tgtAccumulate);
// /*DEBUG*/appendout('./test/debugout.txt', '\nCombined selectors :\n' + tgtAccumulate);
couldExtend = true;

@@ -151,6 +151,6 @@ }

if (couldExtend) {
// /*DEBUG*/ appendout('./test/debugout.txt', '\nStart uniqreq2 :\n' + tgtAccumulate);
// /*DEBUG*/appendout('./test/debugout.txt', '\nStart uniqreq2 :\n' + tgtAccumulate);
//Kill off duplicate selectors
tgtAccumulate = uniqreq(tgtAccumulate).toString().replace(/,/g, ', ');
// /*DEBUG*/ appendout('./test/debugout.txt', '\nPost uniqreq2 :\n' + tgtAccumulate);
// /*DEBUG*/appendout('./test/debugout.txt', '\nPost uniqreq2 :\n' + tgtAccumulate);
targetNode.selector = tgtAccumulate;

@@ -161,3 +161,3 @@ }

} else {
// /*DEBUG*/ appendout('./test/debugout.txt', '\nAttempting to fetch declarations for ' + atRule.params + '...');
// /*DEBUG*/appendout('./test/debugout.txt', '\nAttempting to fetch declarations for ' + atRule.params + '...');
var backFirstTargetNode;

@@ -190,3 +190,3 @@ var targetNodeArray = [];

//We need to re-evaluate the current atRule, as other classes (once passed over) may now be matching, so re-process and exit.
// /*DEBUG*/ appendout('./test/debugout.txt', '\n!Bumping evaluation of :' + atRule.parent);
// /*DEBUG*/appendout('./test/debugout.txt', '\n!Bumping evaluation of :' + atRule.parent);
processExtension(atRule);

@@ -198,3 +198,3 @@ couldExtend = true;

if (backFirstTargetNode.parent === atRule.parent.parent) {
// /*DEBUG*/ appendout('./test/debugout.txt', '\n...tacking onto backFirstTargetNode :' + backFirstTargetNode);
// /*DEBUG*/appendout('./test/debugout.txt', '\n...tacking onto backFirstTargetNode :' + backFirstTargetNode);
selectorRetainer = backFirstTargetNode.selectors;

@@ -204,3 +204,3 @@ backFirstTargetNode.selector = uniqreq(selectorRetainer.concat(originSels)).join(', ');

} else {
// /*DEBUG*/ appendout('./test/debugout.txt', '\n...grabbing backFirstTargetNode :\n' + backFirstTargetNode);
// /*DEBUG*/appendout('./test/debugout.txt', '\n...grabbing backFirstTargetNode :\n' + backFirstTargetNode);
safeCopyDeclarations(backFirstTargetNode, atRule.parent);

@@ -218,3 +218,3 @@ }

//We need to re-evaluate the current atRule, as other classes (once passed over) may now be matching, so re-process and exit.
// /*DEBUG*/ appendout('./test/debugout.txt', '\n!Bumping evaluation of :' + atRule.parent);
// /*DEBUG*/appendout('./test/debugout.txt', '\n!Bumping evaluation of :' + atRule.parent);
processExtension(atRule);

@@ -226,3 +226,3 @@ couldExtend = true;

//Use Tacking onto exiting selectors instead of new creation
// /*DEBUG*/ appendout('./test/debugout.txt', '\nUtilizing existing brother subclass for extension, as nothing matches: \n' + atRule.parent.selector + ' sub-' + extTgtSub);
// /*DEBUG*/appendout('./test/debugout.txt', '\nUtilizing existing brother subclass for extension, as nothing matches: \n' + atRule.parent.selector + ' sub-' + extTgtSub);
selectorRetainer = backFirstTargetNode.selectors;

@@ -235,7 +235,7 @@ backFirstTargetNode.selector = uniqreq(selectorRetainer.concat(formSubSelector(originSels, extTgtSub))).join(', ');

//utilize existing subclass for extension
// /*DEBUG*/ appendout('./test/debugout.txt', '\nUtilizing existing subclass for extension:\n' + subTarget.selector);
// /*DEBUG*/appendout('./test/debugout.txt', '\nUtilizing existing subclass for extension:\n' + subTarget.selector);
safeCopyDeclarations(backFirstTargetNode, subTarget.node);
} else {
//create additional nodes below existing for each instance of subs
// /*DEBUG*/ appendout('./test/debugout.txt', '\nUtilizing new subclass for extension, as nothing matches: \n' + atRule.parent.selector + ' sub-' + extTgtSub);
// /*DEBUG*/appendout('./test/debugout.txt', '\nUtilizing new subclass for extension, as nothing matches: \n' + atRule.parent.selector + ' sub-' + extTgtSub);
var newNode = postcss.rule();

@@ -256,3 +256,3 @@ newNode.semicolon = atRule.semicolon;

result.warn('\'' + atRule.params + '\', has not been defined, so it cannot be extended', { node: atRule });
// /*DEBUG*/ appendout('./test/debugout.txt', '\n\'' + atRule.params + '\' has not been defined!!!');
// /*DEBUG*/appendout('./test/debugout.txt', '\n\'' + atRule.params + '\' has not been defined!!!');
}

@@ -307,3 +307,3 @@ if (atRule.parent !== undefined) {

if (hasMediaAncestor(targetNode) && hasMediaAncestor(atRule) && targetNode.parent !== atRule.parent.parent) {
// /*DEBUG*/ appendout('./test/debugout.txt', '\nMEDIA2MEDIA extention detected, node :\n' + atRule.parent);
// /*DEBUG*/appendout('./test/debugout.txt', '\nMEDIA2MEDIA extention detected, node :\n' + atRule.parent);
result.warn('@extend was called to extend something in an @media from within another @media, this was safely ignored. For more information see the README under \'Quirks\'', {node: atRule});

@@ -338,6 +338,6 @@ return true;

if (nodeDest.some(function(decl) { return decl.prop === node.prop; })) {
// /*DEBUG*/ appendout('./test/debugout.txt', '\nsafeIgnored : ' + node + ' for ' + nodeDest.selector);
// /*DEBUG*/appendout('./test/debugout.txt', '\nsafeIgnored : ' + node + ' for ' + nodeDest.selector);
return;
}
// /*DEBUG*/ appendout('./test/debugout.txt', '\nnodeDest Nodes:\n' + nodeDest.nodes);
// /*DEBUG*/appendout('./test/debugout.txt', '\nnodeDest Nodes:\n' + nodeDest.nodes);
var clone = node.clone();

@@ -386,3 +386,3 @@ //For lack of a better way to analyse how much tabbing is required:

if (css.index(atRule.parent) !== -1) {
// /*DEBUG*/ appendout('./test/debugout.txt', '\nANTIPATTERN CSS detected parent at: ' + css.index(atRule.parent) + ' target at: ' + css.index(targetNode) + ' parent :\n' + atRule.parent);
// /*DEBUG*/appendout('./test/debugout.txt', '\nANTIPATTERN CSS detected parent at: ' + css.index(atRule.parent) + ' target at: ' + css.index(targetNode) + ' parent :\n' + atRule.parent);
result.warn('@extend is being used in an anti-pattern (extending things not yet defined). This is your first and final warning', {node: atRule});

@@ -392,3 +392,3 @@ isAntiPatternCSS = true;

} else if (css.index(atRule.parent.parent) !== -1 && css.index(atRule.parent.parent) < css.index(targetNode)) {
// /*DEBUG*/ appendout('./test/debugout.txt', '\nANTIPATTERN CSS detected parent\'s parent at: ' + css.index(atRule.parent.parent) + ' target at: ' + css.index(targetNode) + ' parent :\n' + atRule.parent);
// /*DEBUG*/appendout('./test/debugout.txt', '\nANTIPATTERN CSS detected parent\'s parent at: ' + css.index(atRule.parent.parent) + ' target at: ' + css.index(targetNode) + ' parent :\n' + atRule.parent);
result.warn('@extend is being used in an anti-pattern (extending things not yet defined). This is your first and final warning', {node: atRule});

@@ -402,9 +402,14 @@ isAntiPatternCSS = true;

if (recurseStack.indexOf(recursableRule.node.params) === -1) {
// /*DEBUG*/ appendout('./test/debugout.txt', '\nRecursing from ' + atRule.parent.selector + ' on: ' + recursableRule.node.parent + '\n\\/\\/\\/\\/\\/\\/\\/\\/ ' + recurseStack.length);
// /*DEBUG*/appendout('./test/debugout.txt', '\nRecursing from ' + atRule.parent.selector + ' on: ' + recursableRule.node.parent + '\n\\/\\/\\/\\/\\/\\/\\/\\/ ' + recurseStack);
processExtension(recursableRule.node);
// /*DEBUG*/ appendout('./test/debugout.txt', '\n ^ ^ ^ ^ ^ ^ ^ ^ ' + recurseStack.length);
// /*DEBUG*/appendout('./test/debugout.txt', '\n ^ ^ ^ ^ ^ ^ ^ ^ ' + recurseStack);
// In case of slippage in processExtention recursion, clean up @extend
if (recursableRule.node !== undefined) {
// /*DEBUG*/appendout('./test/debugout.txt', '\npreventing slippage in recursion by removing resolved :' + recursableRule.node);
recursableRule.node.remove();
}
recursableRule = findUnresolvedExtendChild(targetNode);
} else {
result.warn('Infinite extension recursion detected', { node: atRule });
// /*DEBUG*/ appendout('./test/debugout.txt', '\nInfinite Recursion detected, recurseStack : ' + recurseStack + '\n -- on :\n' + atRule.parent + '\n!!!!!!!!!!!!');
// /*DEBUG*/appendout('./test/debugout.txt', '\nInfinite Recursion detected, recurseStack : ' + recurseStack + '\n -- on :\n' + atRule.parent + '\n!!!!!!!!!!!!');
//clean out the recurse stack of duplicates (from early aborts like this) before dropping

@@ -416,6 +421,6 @@ recurseStack = uniqreq(recurseStack);

// /*DEBUG*/ appendout('./test/debugout.txt', '\npre-pop recurseStack : ' + recurseStack);
// /*DEBUG*/appendout('./test/debugout.txt', '\npre-pop recurseStack : ' + recurseStack);
if (recurseStack.pop() !== atRule.params && recurseStack.indexOf(atRule.params) === -1) {
result.warn('Detected critically mis-aligned recursion stack! (Please post your CSS in a github issue, this shouldn\'t ever happen!)', { node: atRule });
// /*DEBUG*/ appendout('./test/debugout.txt', '\n!!!!!!!!!!!!CRITICALLY MISALIGNED RECURSE STACK\nexpected : ' + atRule.params + '\npost-pop recurseStack : ' + recurseStack);
// /*DEBUG*/appendout('./test/debugout.txt', '\n!!!!!!!!!!!!CRITICALLY MISALIGNED RECURSE STACK\nexpected : ' + atRule.params + '\npost-pop recurseStack : ' + recurseStack);
}

@@ -425,3 +430,3 @@ //Empty history if this is top of a recursion (as process preserves detections as it backs-out)

recurseStack = [];
// /*DEBUG*/ appendout('./test/debugout.txt', '\nrecurseStack dumped, at top');
// /*DEBUG*/appendout('./test/debugout.txt', '\nrecurseStack dumped, at top');
}

@@ -444,3 +449,3 @@ return true;

seldiff = uniqreq(seldiff);
// /*DEBUG*/ appendout('./test/debugout.txt', '\nseldiff : ' + seldiff + '\n\tBetween:\n' + node.selectors + '\n\tand:\n' + selectorAccumulator);
// /*DEBUG*/appendout('./test/debugout.txt', '\nseldiff : ' + seldiff + '\n\tBetween:\n' + node.selectors + '\n\tand:\n' + selectorAccumulator);
if (seldiff.length === selectorAccumulator.length) {

@@ -447,0 +452,0 @@ foundNode = node;

@@ -8,3 +8,3 @@ {

"license": "MIT",
"version": "1.0.1",
"version": "1.0.3",
"description": "As close to cssnext @extend as possible for PostCSS",

@@ -11,0 +11,0 @@ "homepage": "https://github.com/travco/postcss-extend",

@@ -0,0 +0,0 @@ # postcss-extend [![Build Status](https://travis-ci.org/travco/postcss-extend.svg?branch=master)](https://travis-ci.org/travco/postcss-extend)

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