stylehacks
Advanced tools
Comparing version 2.3.1 to 2.3.2
@@ -0,1 +1,5 @@ | ||
# 2.3.2 | ||
* Resolves an issue where stylehacks would crash on CSS mixins. | ||
# 2.3.1 | ||
@@ -2,0 +6,0 @@ |
@@ -20,2 +20,4 @@ #!/usr/bin/env node | ||
var _package = require('../package.json'); | ||
var _ = require('./'); | ||
@@ -25,4 +27,2 @@ | ||
var _package = require('../package.json'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -43,32 +43,30 @@ | ||
} else { | ||
(function () { | ||
var file = opts._[0]; | ||
var out = opts._[1]; | ||
var file = opts._[0]; | ||
var out = opts._[1]; | ||
if (file === 'help' || opts.help) { | ||
_fs2.default.createReadStream(__dirname + '/../usage.txt').pipe(process.stdout).on('close', function () { | ||
return process.exit(1); | ||
}); | ||
} else { | ||
(0, _readFileStdin2.default)(file, function (err, buf) { | ||
if (err) { | ||
throw err; | ||
if (file === 'help' || opts.help) { | ||
_fs2.default.createReadStream(__dirname + '/../usage.txt').pipe(process.stdout).on('close', function () { | ||
return process.exit(1); | ||
}); | ||
} else { | ||
(0, _readFileStdin2.default)(file, function (err, buf) { | ||
if (err) { | ||
throw err; | ||
} | ||
if (file) { | ||
opts.from = file; | ||
} | ||
if (out) { | ||
opts.to = out; | ||
} | ||
_2.default.process(String(buf), opts).then(function (result) { | ||
if (result.warnings().length) { | ||
process.exit(1); | ||
} | ||
if (file) { | ||
opts.from = file; | ||
if (!opts.lint) { | ||
(0, _writeFileStdout2.default)(result.css); | ||
} | ||
if (out) { | ||
opts.to = out; | ||
} | ||
_2.default.process(String(buf), opts).then(function (result) { | ||
if (result.warnings().length) { | ||
process.exit(1); | ||
} | ||
if (!opts.lint) { | ||
(0, _writeFileStdout2.default)(result.css); | ||
} | ||
}); | ||
}); | ||
} | ||
})(); | ||
}); | ||
} | ||
} |
@@ -9,2 +9,2 @@ "use strict"; | ||
} | ||
module.exports = exports['default']; | ||
module.exports = exports["default"]; |
@@ -5,2 +5,6 @@ 'use strict'; | ||
var _path = require('path'); | ||
var _path2 = _interopRequireDefault(_path); | ||
var _chalk = require('chalk'); | ||
@@ -10,6 +14,2 @@ | ||
var _path = require('path'); | ||
var _path2 = _interopRequireDefault(_path); | ||
var _textTable = require('text-table'); | ||
@@ -16,0 +16,0 @@ |
@@ -73,3 +73,3 @@ 'use strict'; | ||
var stylehacks = _postcss2.default.plugin('stylehacks', function () { | ||
var opts = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
@@ -80,4 +80,4 @@ var b = opts.browsers; | ||
return function (css, result) { | ||
plugins.forEach(function (Plugin) { | ||
var hack = new Plugin(css, result); | ||
var processors = plugins.reduce(function (list, Plugin) { | ||
var hack = new Plugin(result); | ||
var applied = browsers.some(function (browser) { | ||
@@ -89,8 +89,16 @@ return hack.targets.some(function (target) { | ||
if (applied) { | ||
return; | ||
return list; | ||
} | ||
if (opts.lint) { | ||
return hack.detectAndWarn(); | ||
} | ||
return hack.detectAndResolve(); | ||
return [].concat(list, [hack]); | ||
}, []); | ||
css.walk(function (node) { | ||
processors.forEach(function (proc) { | ||
if (!~proc.nodeTypes.indexOf(node.type)) { | ||
return; | ||
} | ||
if (opts.lint) { | ||
return proc.detectAndWarn(node); | ||
} | ||
return proc.detectAndResolve(node); | ||
}); | ||
}); | ||
@@ -110,3 +118,3 @@ }; | ||
stylehacks.process = function (css) { | ||
var opts = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
@@ -113,0 +121,0 @@ opts.reporter = {}; |
@@ -5,11 +5,14 @@ "use strict"; | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
exports.default = plugin; | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function plugin(targets, nodeTypes, _detect) { | ||
function plugin(targets, nodeTypes, detect) { | ||
var Plugin = function () { | ||
function Plugin(css, result) { | ||
function Plugin(result) { | ||
_classCallCheck(this, Plugin); | ||
this.nodes = []; | ||
this.css = css; | ||
this.result = result; | ||
@@ -21,5 +24,6 @@ this.targets = targets; | ||
Plugin.prototype.push = function push(node, metadata) { | ||
metadata.message = "Bad " + metadata.identifier + ": " + metadata.hack; | ||
metadata.browsers = this.targets; | ||
node._stylehacks = metadata; | ||
node._stylehacks = _extends({}, metadata, { | ||
message: "Bad " + metadata.identifier + ": " + metadata.hack, | ||
browsers: this.targets | ||
}); | ||
this.nodes.push(node); | ||
@@ -29,22 +33,17 @@ }; | ||
Plugin.prototype.any = function any(node) { | ||
var hasHack = false; | ||
if (~this.nodeTypes.indexOf(node.type)) { | ||
_detect.apply(this, arguments); | ||
if (node._stylehacks) { | ||
hasHack = true; | ||
} | ||
detect.apply(this, arguments); | ||
return !!node._stylehacks; | ||
} | ||
return hasHack; | ||
return false; | ||
}; | ||
Plugin.prototype.detect = function detect() { | ||
this.css.walk(function (node) { | ||
if (~this.nodeTypes.indexOf(node.type)) { | ||
_detect.apply(this, arguments); | ||
} | ||
}.bind(this)); | ||
}; | ||
Plugin.prototype.detectAndResolve = function detectAndResolve() { | ||
this.nodes = []; | ||
Plugin.prototype.detectAndResolve = function detectAndResolve() { | ||
this.detect(); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
detect.apply(this, args); | ||
return this.resolve(); | ||
@@ -54,3 +53,9 @@ }; | ||
Plugin.prototype.detectAndWarn = function detectAndWarn() { | ||
this.detect(); | ||
this.nodes = []; | ||
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
args[_key2] = arguments[_key2]; | ||
} | ||
detect.apply(this, args); | ||
return this.warn(); | ||
@@ -69,7 +74,7 @@ }; | ||
return this.nodes.forEach(function (node) { | ||
var _node$_stylehacks = node._stylehacks; | ||
var message = _node$_stylehacks.message; | ||
var browsers = _node$_stylehacks.browsers; | ||
var identifier = _node$_stylehacks.identifier; | ||
var hack = _node$_stylehacks.hack; | ||
var _node$_stylehacks = node._stylehacks, | ||
message = _node$_stylehacks.message, | ||
browsers = _node$_stylehacks.browsers, | ||
identifier = _node$_stylehacks.identifier, | ||
hack = _node$_stylehacks.hack; | ||
@@ -85,3 +90,2 @@ return node.warn(_this.result, message, { browsers: browsers, identifier: identifier, hack: hack }); | ||
} | ||
exports.default = plugin; | ||
module.exports = exports['default']; | ||
module.exports = exports["default"]; |
@@ -5,2 +5,6 @@ 'use strict'; | ||
var _postcssSelectorParser = require('postcss-selector-parser'); | ||
var _postcssSelectorParser2 = _interopRequireDefault(_postcssSelectorParser); | ||
var _exists = require('../exists'); | ||
@@ -10,2 +14,6 @@ | ||
var _isMixin = require('../isMixin'); | ||
var _isMixin2 = _interopRequireDefault(_isMixin); | ||
var _plugin = require('../plugin'); | ||
@@ -15,16 +23,18 @@ | ||
var _postcssSelectorParser = require('postcss-selector-parser'); | ||
var _browsers = require('../dictionary/browsers'); | ||
var _postcssSelectorParser2 = _interopRequireDefault(_postcssSelectorParser); | ||
var _identifiers = require('../dictionary/identifiers'); | ||
var _postcss = require('../dictionary/postcss'); | ||
var _tags = require('../dictionary/tags'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var targets = ['firefox 2']; | ||
function analyse(ctx, rule) { | ||
return function (selectors) { | ||
selectors.each(function (selector) { | ||
if ((0, _exists2.default)(selector, 0, 'body') && (0, _exists2.default)(selector, 1, ':empty') && (0, _exists2.default)(selector, 2, ' ') && selector.at(3)) { | ||
if ((0, _exists2.default)(selector, 0, _tags.BODY) && (0, _exists2.default)(selector, 1, ':empty') && (0, _exists2.default)(selector, 2, ' ') && selector.at(3)) { | ||
ctx.push(rule, { | ||
identifier: 'selector', | ||
identifier: _identifiers.SELECTOR, | ||
hack: selector.toString() | ||
@@ -37,7 +47,8 @@ }); | ||
exports.default = (0, _plugin2.default)(targets, ['rule'], function (rule) { | ||
if (rule.selector) { | ||
(0, _postcssSelectorParser2.default)(analyse(this, rule)).process(rule.selector); | ||
exports.default = (0, _plugin2.default)([_browsers.FF_2], [_postcss.RULE], function (rule) { | ||
if ((0, _isMixin2.default)(rule)) { | ||
return; | ||
} | ||
(0, _postcssSelectorParser2.default)(analyse(this, rule)).process(rule.selector); | ||
}); | ||
module.exports = exports['default']; |
@@ -5,2 +5,6 @@ 'use strict'; | ||
var _postcssSelectorParser = require('postcss-selector-parser'); | ||
var _postcssSelectorParser2 = _interopRequireDefault(_postcssSelectorParser); | ||
var _exists = require('../exists'); | ||
@@ -10,2 +14,6 @@ | ||
var _isMixin = require('../isMixin'); | ||
var _isMixin2 = _interopRequireDefault(_isMixin); | ||
var _plugin = require('../plugin'); | ||
@@ -15,16 +23,18 @@ | ||
var _postcssSelectorParser = require('postcss-selector-parser'); | ||
var _browsers = require('../dictionary/browsers'); | ||
var _postcssSelectorParser2 = _interopRequireDefault(_postcssSelectorParser); | ||
var _identifiers = require('../dictionary/identifiers'); | ||
var _postcss = require('../dictionary/postcss'); | ||
var _tags = require('../dictionary/tags'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var targets = ['ie 7', 'ie 6', 'ie 5.5']; | ||
function analyse(ctx, rule) { | ||
return function (selectors) { | ||
selectors.each(function (selector) { | ||
if ((0, _exists2.default)(selector, 0, 'html') && ((0, _exists2.default)(selector, 1, '>') || (0, _exists2.default)(selector, 1, '~')) && selector.at(2) && selector.at(2).type === 'comment' && (0, _exists2.default)(selector, 3, ' ') && (0, _exists2.default)(selector, 4, 'body') && (0, _exists2.default)(selector, 5, ' ') && selector.at(6)) { | ||
if ((0, _exists2.default)(selector, 0, _tags.HTML) && ((0, _exists2.default)(selector, 1, '>') || (0, _exists2.default)(selector, 1, '~')) && selector.at(2) && selector.at(2).type === 'comment' && (0, _exists2.default)(selector, 3, ' ') && (0, _exists2.default)(selector, 4, _tags.BODY) && (0, _exists2.default)(selector, 5, ' ') && selector.at(6)) { | ||
ctx.push(rule, { | ||
identifier: 'selector', | ||
identifier: _identifiers.SELECTOR, | ||
hack: selector.toString() | ||
@@ -37,4 +47,7 @@ }); | ||
exports.default = (0, _plugin2.default)(targets, ['rule'], function (rule) { | ||
if (rule.selector && rule.raws.selector && rule.raws.selector.raw) { | ||
exports.default = (0, _plugin2.default)([_browsers.IE_5_5, _browsers.IE_6, _browsers.IE_7], [_postcss.RULE], function (rule) { | ||
if ((0, _isMixin2.default)(rule)) { | ||
return; | ||
} | ||
if (rule.raws.selector && rule.raws.selector.raw) { | ||
(0, _postcssSelectorParser2.default)(analyse(this, rule)).process(rule.raws.selector.raw); | ||
@@ -41,0 +54,0 @@ } |
@@ -5,2 +5,6 @@ 'use strict'; | ||
var _postcssSelectorParser = require('postcss-selector-parser'); | ||
var _postcssSelectorParser2 = _interopRequireDefault(_postcssSelectorParser); | ||
var _exists = require('../exists'); | ||
@@ -10,2 +14,6 @@ | ||
var _isMixin = require('../isMixin'); | ||
var _isMixin2 = _interopRequireDefault(_isMixin); | ||
var _plugin = require('../plugin'); | ||
@@ -15,16 +23,18 @@ | ||
var _postcssSelectorParser = require('postcss-selector-parser'); | ||
var _browsers = require('../dictionary/browsers'); | ||
var _postcssSelectorParser2 = _interopRequireDefault(_postcssSelectorParser); | ||
var _identifiers = require('../dictionary/identifiers'); | ||
var _postcss = require('../dictionary/postcss'); | ||
var _tags = require('../dictionary/tags'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var targets = ['opera 9']; | ||
function analyse(ctx, rule) { | ||
return function (selectors) { | ||
selectors.each(function (selector) { | ||
if ((0, _exists2.default)(selector, 0, 'html') && (0, _exists2.default)(selector, 1, ':first-child') && (0, _exists2.default)(selector, 2, ' ') && selector.at(3)) { | ||
if ((0, _exists2.default)(selector, 0, _tags.HTML) && (0, _exists2.default)(selector, 1, ':first-child') && (0, _exists2.default)(selector, 2, ' ') && selector.at(3)) { | ||
ctx.push(rule, { | ||
identifier: 'selector', | ||
identifier: _identifiers.SELECTOR, | ||
hack: selector.toString() | ||
@@ -37,7 +47,8 @@ }); | ||
exports.default = (0, _plugin2.default)(targets, ['rule'], function (rule) { | ||
if (rule.selector) { | ||
(0, _postcssSelectorParser2.default)(analyse(this, rule)).process(rule.selector); | ||
exports.default = (0, _plugin2.default)([_browsers.OP_9], [_postcss.RULE], function (rule) { | ||
if ((0, _isMixin2.default)(rule)) { | ||
return; | ||
} | ||
(0, _postcssSelectorParser2.default)(analyse(this, rule)).process(rule.selector); | ||
}); | ||
module.exports = exports['default']; |
@@ -9,13 +9,15 @@ 'use strict'; | ||
var _browsers = require('../dictionary/browsers'); | ||
var _postcss = require('../dictionary/postcss'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var targets = ['ie 5.5', 'ie 6', 'ie 7']; | ||
exports.default = (0, _plugin2.default)(targets, ['decl'], function (decl) { | ||
exports.default = (0, _plugin2.default)([_browsers.IE_5_5, _browsers.IE_6, _browsers.IE_7], [_postcss.DECL], function (decl) { | ||
var match = decl.value.match(/!\w/); | ||
if (match) { | ||
var text = decl.value.substr(match.index, decl.value.length - 1); | ||
var hack = decl.value.substr(match.index, decl.value.length - 1); | ||
this.push(decl, { | ||
identifier: '!important', | ||
hack: text | ||
hack: hack | ||
}); | ||
@@ -22,0 +24,0 @@ } |
@@ -5,4 +5,2 @@ '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; }; | ||
var _plugin = require('../plugin'); | ||
@@ -12,43 +10,42 @@ | ||
var _browsers = require('../dictionary/browsers'); | ||
var _identifiers = require('../dictionary/identifiers'); | ||
var _postcss = require('../dictionary/postcss'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var targets = ['ie 5.5', 'ie 6', 'ie 7']; | ||
var hacks = '!_$_&_*_)_=_%_+_,_._/_`_]_#_~_?_:_|'.split('_'); | ||
exports.default = (0, _plugin2.default)(targets, ['decl', 'atrule'], function (node) { | ||
exports.default = (0, _plugin2.default)([_browsers.IE_5_5, _browsers.IE_6, _browsers.IE_7], [_postcss.ATRULE, _postcss.DECL], function (node) { | ||
var _this = this; | ||
if (node.type === 'decl') { | ||
var _ret = function () { | ||
// some values are not picked up by before, so ensure they are | ||
// at the beginning of the value | ||
hacks.some(function (hack) { | ||
if (!node.prop.indexOf(hack)) { | ||
_this.push(node, { | ||
identifier: 'property', | ||
hack: node.prop | ||
}); | ||
return true; | ||
} | ||
}); | ||
var before = node.raws.before; | ||
if (node.type === _postcss.DECL) { | ||
// some values are not picked up by before, so ensure they are | ||
// at the beginning of the value | ||
hacks.some(function (hack) { | ||
if (!node.prop.indexOf(hack)) { | ||
_this.push(node, { | ||
identifier: _identifiers.PROPERTY, | ||
hack: node.prop | ||
}); | ||
return true; | ||
} | ||
}); | ||
var before = node.raws.before; | ||
if (!before) { | ||
return { | ||
v: void 0 | ||
}; | ||
if (!before) { | ||
return; | ||
} | ||
hacks.some(function (hack) { | ||
if (~before.indexOf(hack)) { | ||
_this.push(node, { | ||
identifier: _identifiers.PROPERTY, | ||
hack: '' + before.trim() + node.prop | ||
}); | ||
return true; | ||
} | ||
hacks.some(function (hack) { | ||
if (~before.indexOf(hack)) { | ||
_this.push(node, { | ||
identifier: 'property', | ||
hack: '' + before.trim() + node.prop | ||
}); | ||
return true; | ||
} | ||
}); | ||
}(); | ||
if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v; | ||
} else if (node.type === 'atrule') { | ||
}); | ||
} else { | ||
// test for the @property: value; hack | ||
@@ -60,3 +57,3 @@ var name = node.name; | ||
this.push(node, { | ||
identifier: 'property', | ||
identifier: _identifiers.PROPERTY, | ||
hack: '@' + name.substr(0, len) | ||
@@ -63,0 +60,0 @@ }); |
@@ -9,8 +9,13 @@ 'use strict'; | ||
var _browsers = require('../dictionary/browsers'); | ||
var _identifiers = require('../dictionary/identifiers'); | ||
var _postcss = require('../dictionary/postcss'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var targets = ['ie 6']; | ||
exports.default = (0, _plugin2.default)([_browsers.IE_6], [_postcss.DECL], function (decl) { | ||
var before = decl.raws.before; | ||
exports.default = (0, _plugin2.default)(targets, ['decl'], function (decl) { | ||
var before = decl.raws.before; | ||
if (!before) { | ||
@@ -21,3 +26,3 @@ return; | ||
this.push(decl, { | ||
identifier: 'property', | ||
identifier: _identifiers.PROPERTY, | ||
hack: '' + before.trim() + decl.prop | ||
@@ -24,0 +29,0 @@ }); |
@@ -9,11 +9,15 @@ 'use strict'; | ||
var _browsers = require('../dictionary/browsers'); | ||
var _identifiers = require('../dictionary/identifiers'); | ||
var _postcss = require('../dictionary/postcss'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var targets = ['ie 8']; | ||
exports.default = (0, _plugin2.default)(targets, ['atrule'], function (rule) { | ||
exports.default = (0, _plugin2.default)([_browsers.IE_8], [_postcss.ATRULE], function (rule) { | ||
var params = rule.params.trim(); | ||
if (params === '\\0screen') { | ||
this.push(rule, { | ||
identifier: 'media query', | ||
identifier: _identifiers.MEDIA_QUERY, | ||
hack: params | ||
@@ -20,0 +24,0 @@ }); |
@@ -9,11 +9,15 @@ 'use strict'; | ||
var _browsers = require('../dictionary/browsers'); | ||
var _identifiers = require('../dictionary/identifiers'); | ||
var _postcss = require('../dictionary/postcss'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var targets = ['ie 5.5', 'ie 6', 'ie 7']; | ||
exports.default = (0, _plugin2.default)(targets, ['atrule'], function (rule) { | ||
exports.default = (0, _plugin2.default)([_browsers.IE_5_5, _browsers.IE_6, _browsers.IE_7], [_postcss.ATRULE], function (rule) { | ||
var params = rule.params.trim(); | ||
if (params === 'screen\\9') { | ||
this.push(rule, { | ||
identifier: 'media query', | ||
identifier: _identifiers.MEDIA_QUERY, | ||
hack: params | ||
@@ -20,0 +24,0 @@ }); |
@@ -9,11 +9,15 @@ 'use strict'; | ||
var _browsers = require('../dictionary/browsers'); | ||
var _identifiers = require('../dictionary/identifiers'); | ||
var _postcss = require('../dictionary/postcss'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var targets = ['ie 8', 'ie 7', 'ie 6']; | ||
exports.default = (0, _plugin2.default)(targets, ['decl'], function (decl) { | ||
exports.default = (0, _plugin2.default)([_browsers.IE_6, _browsers.IE_7, _browsers.IE_8], [_postcss.DECL], function (decl) { | ||
var v = decl.value; | ||
if (v && v.length > 2 && v.indexOf('\\9') === v.length - 2) { | ||
this.push(decl, { | ||
identifier: 'value', | ||
identifier: _identifiers.VALUE, | ||
hack: v | ||
@@ -20,0 +24,0 @@ }); |
@@ -5,2 +5,6 @@ 'use strict'; | ||
var _postcssSelectorParser = require('postcss-selector-parser'); | ||
var _postcssSelectorParser2 = _interopRequireDefault(_postcssSelectorParser); | ||
var _exists = require('../exists'); | ||
@@ -10,2 +14,6 @@ | ||
var _isMixin = require('../isMixin'); | ||
var _isMixin2 = _interopRequireDefault(_isMixin); | ||
var _plugin = require('../plugin'); | ||
@@ -15,16 +23,18 @@ | ||
var _postcssSelectorParser = require('postcss-selector-parser'); | ||
var _browsers = require('../dictionary/browsers'); | ||
var _postcssSelectorParser2 = _interopRequireDefault(_postcssSelectorParser); | ||
var _identifiers = require('../dictionary/identifiers'); | ||
var _postcss = require('../dictionary/postcss'); | ||
var _tags = require('../dictionary/tags'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var targets = ['ie 6', 'ie 5.5']; | ||
function analyse(ctx, rule) { | ||
return function (selectors) { | ||
selectors.each(function (selector) { | ||
if ((0, _exists2.default)(selector, 0, '*') && (0, _exists2.default)(selector, 1, ' ') && (0, _exists2.default)(selector, 2, 'html') && (0, _exists2.default)(selector, 3, ' ') && selector.at(4)) { | ||
if ((0, _exists2.default)(selector, 0, '*') && (0, _exists2.default)(selector, 1, ' ') && (0, _exists2.default)(selector, 2, _tags.HTML) && (0, _exists2.default)(selector, 3, ' ') && selector.at(4)) { | ||
ctx.push(rule, { | ||
identifier: 'selector', | ||
identifier: _identifiers.SELECTOR, | ||
hack: selector.toString() | ||
@@ -37,7 +47,8 @@ }); | ||
exports.default = (0, _plugin2.default)(targets, ['rule'], function (rule) { | ||
if (rule.selector) { | ||
(0, _postcssSelectorParser2.default)(analyse(this, rule)).process(rule.selector); | ||
exports.default = (0, _plugin2.default)([_browsers.IE_5_5, _browsers.IE_6], [_postcss.RULE], function (rule) { | ||
if ((0, _isMixin2.default)(rule)) { | ||
return; | ||
} | ||
(0, _postcssSelectorParser2.default)(analyse(this, rule)).process(rule.selector); | ||
}); | ||
module.exports = exports['default']; |
@@ -9,19 +9,28 @@ 'use strict'; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _isMixin = require('../isMixin'); | ||
var targets = ['ie 7', 'ie 6', 'ie 5.5']; | ||
var _isMixin2 = _interopRequireDefault(_isMixin); | ||
exports.default = (0, _plugin2.default)(targets, ['rule'], function (rule) { | ||
if (rule.selector) { | ||
var selector = rule.selector; | ||
var _browsers = require('../dictionary/browsers'); | ||
var trim = selector.trim(); | ||
if (trim.lastIndexOf(',') === selector.length - 1 || trim.lastIndexOf('\\') === selector.length - 1) { | ||
this.push(rule, { | ||
identifier: 'selector', | ||
hack: selector | ||
}); | ||
} | ||
var _identifiers = require('../dictionary/identifiers'); | ||
var _postcss = require('../dictionary/postcss'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
exports.default = (0, _plugin2.default)([_browsers.IE_5_5, _browsers.IE_6, _browsers.IE_7], [_postcss.RULE], function (rule) { | ||
if ((0, _isMixin2.default)(rule)) { | ||
return; | ||
} | ||
var selector = rule.selector; | ||
var trim = selector.trim(); | ||
if (trim.lastIndexOf(',') === selector.length - 1 || trim.lastIndexOf('\\') === selector.length - 1) { | ||
this.push(rule, { | ||
identifier: _identifiers.SELECTOR, | ||
hack: selector | ||
}); | ||
} | ||
}); | ||
module.exports = exports['default']; |
{ | ||
"name": "stylehacks", | ||
"version": "2.3.1", | ||
"version": "2.3.2", | ||
"description": "Detect/remove browser hacks from CSS files.", | ||
@@ -17,3 +17,5 @@ "main": "dist/index.js", | ||
"prepublish": "del-cli dist && BABEL_ENV=publish babel src --out-dir dist --ignore /__tests__/", | ||
"test": "ava src/__tests__" | ||
"report": "nyc report --reporter=html", | ||
"test": "nyc ava src/__tests__", | ||
"test-012": "nyc ava src/__tests__" | ||
}, | ||
@@ -32,3 +34,3 @@ "keywords": [ | ||
"devDependencies": { | ||
"ava": "^0.14.0", | ||
"ava": "^0.17.0", | ||
"babel-cli": "^6.5.1", | ||
@@ -40,5 +42,9 @@ "babel-core": "^6.5.2", | ||
"babel-preset-stage-0": "^6.5.0", | ||
"babel-register": "^6.9.0", | ||
"del-cli": "^0.2.0", | ||
"eslint": "^2.2.0", | ||
"eslint-config-cssnano": "^2.0.0" | ||
"eslint": "^3.0.0", | ||
"eslint-config-cssnano": "^3.0.0", | ||
"eslint-plugin-babel": "^3.3.0", | ||
"eslint-plugin-import": "^2.0.1", | ||
"nyc": "^10.0.0" | ||
}, | ||
@@ -69,4 +75,11 @@ "homepage": "https://github.com/ben-eb/stylehacks", | ||
"ava": { | ||
"require": "babel-core/register" | ||
"require": "babel-register" | ||
}, | ||
"nyc": { | ||
"exclude": [ | ||
"dist", | ||
"node_modules", | ||
"src/__tests__" | ||
] | ||
} | ||
} |
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
31810
26
567
14