postcss-autoreset
Advanced tools
Comparing version 1.1.3 to 1.1.4
@@ -8,3 +8,6 @@ # Change Log | ||
## [1.1.3] | ||
## [1.1.4] - 2016-01-21 | ||
- Fix plugin prepublish script. Thnx @mikaa123 for bugreport | ||
## [1.1.3] - 2016-01-21 | ||
- Put all resets in one rule. Thnx @DanGamble89 for idea | ||
@@ -11,0 +14,0 @@ - Add virtual source for generated code. Thnx @ai for review |
@@ -1,44 +0,68 @@ | ||
'use strict'; | ||
(function (global, factory) { | ||
if (typeof define === "function" && define.amd) { | ||
define(['exports', 'postcss', 'postcss-js/parser', 'postcss/lib/input'], factory); | ||
} else if (typeof exports !== "undefined") { | ||
factory(exports, require('postcss'), require('postcss-js/parser'), require('postcss/lib/input')); | ||
} else { | ||
var mod = { | ||
exports: {} | ||
}; | ||
factory(mod.exports, global.postcss, global.parser, global.input); | ||
global.createResetRule = mod.exports; | ||
} | ||
})(this, function (exports, _postcss, _parser, _input) { | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _postcss = require('postcss'); | ||
var _postcss2 = _interopRequireDefault(_postcss); | ||
var _postcss2 = _interopRequireDefault(_postcss); | ||
var _parser2 = _interopRequireDefault(_parser); | ||
var _parser = require('postcss-js/parser'); | ||
var _input2 = _interopRequireDefault(_input); | ||
var _parser2 = _interopRequireDefault(_parser); | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : { | ||
default: obj | ||
}; | ||
} | ||
var _input = require('postcss/lib/input'); | ||
var source = { | ||
input: new _input2.default('', { | ||
from: 'postcss-autoreset' | ||
}), | ||
start: { | ||
line: 1, | ||
column: 1 | ||
}, | ||
end: { | ||
line: 1, | ||
column: 1 | ||
} | ||
}; | ||
var _input2 = _interopRequireDefault(_input); | ||
function createResetRule(selectors, reset) { | ||
var selector = selectors.map(function (s) { | ||
return s.trim(); | ||
}).join(',\n'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var resetRule = _postcss2.default.rule({ | ||
selector: selector, | ||
source: source, | ||
raws: { | ||
between: ' ' | ||
} | ||
}); | ||
var source = { | ||
input: new _input2.default('', { from: 'postcss-autoreset' }), | ||
start: { line: 1, column: 1 }, | ||
end: { line: 1, column: 1 } | ||
}; | ||
var root = (0, _parser2.default)(reset); | ||
root.each(function (node) { | ||
return node.source = resetRule.source; | ||
}); | ||
resetRule.append(root); | ||
return resetRule; | ||
} | ||
function createResetRule(selectors, reset) { | ||
var selector = selectors.map(function (s) { | ||
return s.trim(); | ||
}).join(',\n'); | ||
var resetRule = _postcss2.default.rule({ | ||
selector: selector, | ||
source: source, | ||
raws: { between: ' ' } | ||
}); | ||
var root = (0, _parser2.default)(reset); | ||
root.each(function (node) { | ||
return node.source = resetRule.source; | ||
}); | ||
resetRule.append(root); | ||
return resetRule; | ||
} | ||
exports.default = createResetRule; | ||
exports.default = createResetRule; | ||
}); |
@@ -1,41 +0,51 @@ | ||
'use strict'; | ||
(function (global, factory) { | ||
if (typeof define === "function" && define.amd) { | ||
define(['exports', 'postcss', './rulesMatcher', './resetRules', './createResetRule'], factory); | ||
} else if (typeof exports !== "undefined") { | ||
factory(exports, require('postcss'), require('./rulesMatcher'), require('./resetRules'), require('./createResetRule')); | ||
} else { | ||
var mod = { | ||
exports: {} | ||
}; | ||
factory(mod.exports, global.postcss, global.rulesMatcher, global.resetRules, global.createResetRule); | ||
global.index = mod.exports; | ||
} | ||
})(this, function (exports, _postcss, _rulesMatcher, _resetRules, _createResetRule) { | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _postcss = require('postcss'); | ||
var _postcss2 = _interopRequireDefault(_postcss); | ||
var _postcss2 = _interopRequireDefault(_postcss); | ||
var _rulesMatcher2 = _interopRequireDefault(_rulesMatcher); | ||
var _rulesMatcher = require('./rulesMatcher'); | ||
var _resetRules2 = _interopRequireDefault(_resetRules); | ||
var _rulesMatcher2 = _interopRequireDefault(_rulesMatcher); | ||
var _createResetRule2 = _interopRequireDefault(_createResetRule); | ||
var _resetRules = require('./resetRules'); | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : { | ||
default: obj | ||
}; | ||
} | ||
var _resetRules2 = _interopRequireDefault(_resetRules); | ||
exports.default = _postcss2.default.plugin('postcss-autoreset', function () { | ||
var opts = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
var _createResetRule = require('./createResetRule'); | ||
var _createResetRule2 = _interopRequireDefault(_createResetRule); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
exports.default = _postcss2.default.plugin('postcss-autoreset', function () { | ||
var opts = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
opts.rulesMatcher = opts.rulesMatcher || 'bem'; | ||
opts.reset = opts.reset || 'initial'; | ||
var rulesMatcher = (0, _rulesMatcher2.default)(opts.rulesMatcher); | ||
var reset = (0, _resetRules2.default)(opts.reset); | ||
return function (css) { | ||
var matchedSelectors = []; | ||
css.walkRules(function (rule) { | ||
if (rulesMatcher(rule)) { | ||
matchedSelectors.push(rule.selector); | ||
} | ||
}); | ||
css.prepend((0, _createResetRule2.default)(matchedSelectors, reset)); | ||
}; | ||
opts.rulesMatcher = opts.rulesMatcher || 'bem'; | ||
opts.reset = opts.reset || 'initial'; | ||
var rulesMatcher = (0, _rulesMatcher2.default)(opts.rulesMatcher); | ||
var reset = (0, _resetRules2.default)(opts.reset); | ||
return function (css) { | ||
var matchedSelectors = []; | ||
css.walkRules(function (rule) { | ||
if (rulesMatcher(rule)) { | ||
matchedSelectors.push(rule.selector); | ||
} | ||
}); | ||
css.prepend((0, _createResetRule2.default)(matchedSelectors, reset)); | ||
}; | ||
}); | ||
}); |
@@ -1,36 +0,59 @@ | ||
'use strict'; | ||
(function (global, factory) { | ||
if (typeof define === "function" && define.amd) { | ||
define(['exports'], factory); | ||
} else if (typeof exports !== "undefined") { | ||
factory(exports); | ||
} else { | ||
var mod = { | ||
exports: {} | ||
}; | ||
factory(mod.exports); | ||
global.resetRules = mod.exports; | ||
} | ||
})(this, function (exports) { | ||
'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var resetSizes = { | ||
margin: 0, | ||
padding: 0, | ||
border: 0, | ||
fontSize: '100%', | ||
font: 'inherit', | ||
verticalAlign: 'baseline' | ||
}; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { | ||
return typeof obj; | ||
} : function (obj) { | ||
return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; | ||
}; | ||
function isObject(variable) { | ||
return variable !== null && (typeof variable === 'undefined' ? 'undefined' : _typeof(variable)) === 'object'; | ||
} | ||
var resetSizes = { | ||
margin: 0, | ||
padding: 0, | ||
border: 0, | ||
fontSize: '100%', | ||
font: 'inherit', | ||
verticalAlign: 'baseline' | ||
}; | ||
function getReset() { | ||
var value = arguments.length <= 0 || arguments[0] === undefined ? 'initial' : arguments[0]; | ||
function isObject(variable) { | ||
return variable !== null && (typeof variable === 'undefined' ? 'undefined' : _typeof(variable)) === 'object'; | ||
} | ||
if (isObject(value)) { | ||
return value; | ||
function getReset() { | ||
var value = arguments.length <= 0 || arguments[0] === undefined ? 'initial' : arguments[0]; | ||
if (isObject(value)) { | ||
return value; | ||
} | ||
switch (value) { | ||
case 'sizes': | ||
return resetSizes; | ||
case 'initial': | ||
default: | ||
return { | ||
all: 'initial' | ||
}; | ||
} | ||
} | ||
switch (value) { | ||
case 'sizes': | ||
return resetSizes; | ||
case 'initial': | ||
default: | ||
return { all: 'initial' }; | ||
} | ||
} | ||
exports.default = getReset; | ||
exports.default = getReset; | ||
}); |
@@ -1,35 +0,48 @@ | ||
'use strict'; | ||
(function (global, factory) { | ||
if (typeof define === "function" && define.amd) { | ||
define(['exports'], factory); | ||
} else if (typeof exports !== "undefined") { | ||
factory(exports); | ||
} else { | ||
var mod = { | ||
exports: {} | ||
}; | ||
factory(mod.exports); | ||
global.rulesMatcher = mod.exports; | ||
} | ||
})(this, function (exports) { | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var matchers = { | ||
bem: function bem(_ref) { | ||
var selector = _ref.selector; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var matchers = { | ||
bem: function bem(_ref) { | ||
var selector = _ref.selector; | ||
return !selector.match(/(--|:)/); | ||
}, | ||
suit: function suit(_ref2) { | ||
var selector = _ref2.selector; | ||
return !(selector.match(/(--|:)/) || selector.match(/\.is\-/i)); | ||
} | ||
}; | ||
return !selector.match(/(--|:)/); | ||
}, | ||
suit: function suit(_ref2) { | ||
var selector = _ref2.selector; | ||
function getRulesMatcher() { | ||
var value = arguments.length <= 0 || arguments[0] === undefined ? 'bem' : arguments[0]; | ||
return !(selector.match(/(--|:)/) || selector.match(/\.is\-/i)); | ||
} | ||
}; | ||
if (typeof value === 'function') { | ||
return value; | ||
} | ||
function getRulesMatcher() { | ||
var value = arguments.length <= 0 || arguments[0] === undefined ? 'bem' : arguments[0]; | ||
switch (value) { | ||
case 'suit': | ||
return matchers.suit; | ||
if (typeof value === 'function') { | ||
return value; | ||
case 'bem': | ||
default: | ||
return matchers.bem; | ||
} | ||
} | ||
switch (value) { | ||
case 'suit': | ||
return matchers.suit; | ||
case 'bem': | ||
default: | ||
return matchers.bem; | ||
} | ||
} | ||
exports.default = getRulesMatcher; | ||
exports.default = getRulesMatcher; | ||
}); |
{ | ||
"name": "postcss-autoreset", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"description": "PostCSS plugin for partial styles reset", | ||
@@ -38,2 +38,3 @@ "main": "dist/index.js", | ||
"babel-eslint": "^5.0.0-beta6", | ||
"babel-plugin-transform-es2015-modules-umd": "^6.4.3", | ||
"babel-preset-es2015": "^6.3.13", | ||
@@ -40,0 +41,0 @@ "babel-register": "^6.3.13", |
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
12109
206
8