postcss-modules-scope
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -17,2 +17,4 @@ 'use strict'; | ||
var hasOwnProperty = Object.prototype.hasOwnProperty; | ||
function getSingleLocalNamesForComposes(selectors) { | ||
@@ -89,2 +91,12 @@ return selectors.nodes.map(function (node) { | ||
// Find any :import and remember imported names | ||
var importedNames = {}; | ||
css.eachRule(function (rule) { | ||
if (/^:import\(.+\)$/.test(rule.selector)) { | ||
rule.eachDecl(function (decl) { | ||
importedNames[decl.prop] = true; | ||
}); | ||
} | ||
}); | ||
// Find any :local classes | ||
@@ -99,5 +111,15 @@ css.eachRule(function (rule) { | ||
classes.forEach(function (className) { | ||
localNames.forEach(function (exportedName) { | ||
exports[exportedName].push(className); | ||
}); | ||
if (hasOwnProperty.call(importedNames, className)) { | ||
localNames.forEach(function (exportedName) { | ||
exports[exportedName].push(className); | ||
}); | ||
} else if (hasOwnProperty.call(exports, className)) { | ||
localNames.forEach(function (exportedName) { | ||
exports[className].forEach(function (item) { | ||
exports[exportedName].push(item); | ||
}); | ||
}); | ||
} else { | ||
throw decl.error('referenced class name "' + className + '" in composes not found'); | ||
} | ||
}); | ||
@@ -137,3 +159,3 @@ decl.removeSelf(); | ||
if (exportedNames.length > 0) { | ||
css.prepend(_postcss2['default'].rule({ | ||
css.append(_postcss2['default'].rule({ | ||
selector: ':export', | ||
@@ -144,3 +166,4 @@ nodes: exportedNames.map(function (exportedName) { | ||
value: exports[exportedName].join(' '), | ||
before: '\n ' | ||
before: '\n ', | ||
_autoprefixerDisabled: true | ||
}); | ||
@@ -147,0 +170,0 @@ }) |
{ | ||
"name": "postcss-modules-scope", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "A CSS Modules transform to extract export statements from local-scope classes", | ||
@@ -37,3 +37,3 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"css-selector-tokenizer": "^0.3.1", | ||
"css-selector-tokenizer": "^0.5.0", | ||
"postcss": "^4.1.11" | ||
@@ -40,0 +40,0 @@ }, |
# CSS Modules: Scope Locals & Extend | ||
[![Build Status](https://travis-ci.org/css-modules/postcss-modules-scope.svg?branch=master)](https://travis-ci.org/css-modules/postcss-modules-scope) | ||
Transforms: | ||
@@ -4,0 +6,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10262
157
101
+ Addedcss-selector-tokenizer@0.5.4(transitive)
+ Addedcssesc@0.1.0(transitive)
- Removedcss-selector-tokenizer@0.3.1(transitive)