tailwindcss
Advanced tools
Comparing version 0.4.1 to 0.4.2
@@ -9,2 +9,4 @@ 'use strict'; | ||
return function (css) { | ||
const classLookup = buildClassTable(css); | ||
css.walkRules(rule => { | ||
@@ -26,3 +28,3 @@ rule.walkAtRules('apply', atRule => { | ||
const decls = (0, _lodash2.default)(classes).reject(mixin => mixin === '!important').flatMap(mixin => { | ||
return findMixin(css, normalizeClassName(mixin), message => { | ||
return findMixin(classLookup, normalizeClassName(mixin), message => { | ||
throw atRule.error(message); | ||
@@ -62,2 +64,15 @@ }); | ||
function buildClassTable(css) { | ||
const classTable = {}; | ||
css.walkRules(rule => { | ||
if (!_lodash2.default.has(classTable, rule.selector)) { | ||
classTable[rule.selector] = []; | ||
} | ||
classTable[rule.selector].push(rule); | ||
}); | ||
return classTable; | ||
} | ||
function normalizeClassName(className) { | ||
@@ -67,16 +82,5 @@ return `.${(0, _escapeClassName2.default)(_lodash2.default.trimStart(className, '.'))}`; | ||
function findMixin(css, mixin, onError) { | ||
const matches = []; | ||
function findMixin(classTable, mixin, onError) { | ||
const matches = _lodash2.default.get(classTable, mixin, []); | ||
css.walkRules(rule => { | ||
if (rule.selectors.includes(mixin)) { | ||
if (rule.parent.type !== 'root') { | ||
// prettier-ignore | ||
onError(`\`@apply\` cannot be used with ${mixin} because ${mixin} is nested inside of an at-rule (@${rule.parent.name}).`); | ||
} | ||
matches.push(rule); | ||
} | ||
}); | ||
if (_lodash2.default.isEmpty(matches)) { | ||
@@ -92,3 +96,10 @@ // prettier-ignore | ||
return _lodash2.default.flatten(matches.map(match => match.clone().nodes)); | ||
const [match] = matches; | ||
if (match.parent.type !== 'root') { | ||
// prettier-ignore | ||
onError(`\`@apply\` cannot be used with ${mixin} because ${mixin} is nested inside of an at-rule (@${match.parent.name}).`); | ||
} | ||
return match.clone().nodes; | ||
} |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
@@ -8,6 +8,8 @@ Object.defineProperty(exports, "__esModule", { | ||
exports.default = function (css, prefix) { | ||
const getPrefix = typeof prefix === 'function' ? prefix : () => prefix; | ||
css.walkRules(rule => { | ||
rule.selectors = rule.selectors.map(selector => `.${prefix}${selector.slice(1)}`); | ||
rule.selectors = rule.selectors.map(selector => `.${getPrefix(selector)}${selector.slice(1)}`); | ||
}); | ||
return css; | ||
}; |
{ | ||
"name": "tailwindcss", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"description": "A utility-first CSS framework for rapidly building custom user interfaces.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
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
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
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
1510265
33670