stylehacks
Advanced tools
Comparing version 4.0.3 to 5.0.0-rc.0
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,7 +6,14 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
const FF_2 = exports.FF_2 = 'firefox 2'; | ||
const IE_5_5 = exports.IE_5_5 = 'ie 5.5'; | ||
const IE_6 = exports.IE_6 = 'ie 6'; | ||
const IE_7 = exports.IE_7 = 'ie 7'; | ||
const IE_8 = exports.IE_8 = 'ie 8'; | ||
const OP_9 = exports.OP_9 = 'opera 9'; | ||
exports.OP_9 = exports.IE_8 = exports.IE_7 = exports.IE_6 = exports.IE_5_5 = exports.FF_2 = void 0; | ||
const FF_2 = 'firefox 2'; | ||
exports.FF_2 = FF_2; | ||
const IE_5_5 = 'ie 5.5'; | ||
exports.IE_5_5 = IE_5_5; | ||
const IE_6 = 'ie 6'; | ||
exports.IE_6 = IE_6; | ||
const IE_7 = 'ie 7'; | ||
exports.IE_7 = IE_7; | ||
const IE_8 = 'ie 8'; | ||
exports.IE_8 = IE_8; | ||
const OP_9 = 'opera 9'; | ||
exports.OP_9 = OP_9; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,5 +6,10 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
const MEDIA_QUERY = exports.MEDIA_QUERY = 'media query'; | ||
const PROPERTY = exports.PROPERTY = 'property'; | ||
const SELECTOR = exports.SELECTOR = 'selector'; | ||
const VALUE = exports.VALUE = 'value'; | ||
exports.VALUE = exports.SELECTOR = exports.PROPERTY = exports.MEDIA_QUERY = void 0; | ||
const MEDIA_QUERY = 'media query'; | ||
exports.MEDIA_QUERY = MEDIA_QUERY; | ||
const PROPERTY = 'property'; | ||
exports.PROPERTY = PROPERTY; | ||
const SELECTOR = 'selector'; | ||
exports.SELECTOR = SELECTOR; | ||
const VALUE = 'value'; | ||
exports.VALUE = VALUE; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,4 +6,8 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
const ATRULE = exports.ATRULE = 'atrule'; | ||
const DECL = exports.DECL = 'decl'; | ||
const RULE = exports.RULE = 'rule'; | ||
exports.RULE = exports.DECL = exports.ATRULE = void 0; | ||
const ATRULE = 'atrule'; | ||
exports.ATRULE = ATRULE; | ||
const DECL = 'decl'; | ||
exports.DECL = DECL; | ||
const RULE = 'rule'; | ||
exports.RULE = RULE; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,3 +6,6 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
const BODY = exports.BODY = 'body'; | ||
const HTML = exports.HTML = 'html'; | ||
exports.HTML = exports.BODY = void 0; | ||
const BODY = 'body'; | ||
exports.BODY = BODY; | ||
const HTML = 'html'; | ||
exports.HTML = HTML; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.default = exists; | ||
function exists(selector, index, value) { | ||
const node = selector.at(index); | ||
const node = selector.at(index); | ||
return node && node.value && node.value.toLowerCase() === value; | ||
} | ||
return node && node.value && node.value.toLowerCase() === value; | ||
} | ||
module.exports = exports["default"]; | ||
module.exports = exports.default; |
@@ -1,67 +0,69 @@ | ||
'use strict'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _postcss = require('postcss'); | ||
var _browserslist = _interopRequireDefault(require("browserslist")); | ||
var _postcss2 = _interopRequireDefault(_postcss); | ||
var _plugins = _interopRequireDefault(require("./plugins")); | ||
var _browserslist = require('browserslist'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _browserslist2 = _interopRequireDefault(_browserslist); | ||
function pluginCreator(opts = {}) { | ||
return { | ||
postcssPlugin: 'stylehacks', | ||
var _plugins = require('./plugins'); | ||
OnceExit(css, { | ||
result | ||
}) { | ||
const resultOpts = result.opts || {}; | ||
const browsers = (0, _browserslist.default)(null, { | ||
stats: resultOpts.stats, | ||
path: __dirname, | ||
env: resultOpts.env | ||
}); | ||
var _plugins2 = _interopRequireDefault(_plugins); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
const stylehacks = _postcss2.default.plugin('stylehacks', (opts = {}) => { | ||
return (css, result) => { | ||
const resultOpts = result.opts || {}; | ||
const browsers = (0, _browserslist2.default)(null, { | ||
stats: resultOpts.stats, | ||
path: __dirname, | ||
env: resultOpts.env | ||
const processors = _plugins.default.reduce((list, Plugin) => { | ||
const hack = new Plugin(result); | ||
const applied = browsers.some(browser => { | ||
return hack.targets.some(target => browser === target); | ||
}); | ||
const processors = _plugins2.default.reduce((list, Plugin) => { | ||
const hack = new Plugin(result); | ||
const applied = browsers.some(browser => { | ||
return hack.targets.some(target => browser === target); | ||
}); | ||
if (applied) { | ||
return list; | ||
} | ||
if (applied) { | ||
return list; | ||
} | ||
return [...list, hack]; | ||
}, []); | ||
return [...list, hack]; | ||
}, []); | ||
css.walk(node => { | ||
processors.forEach(proc => { | ||
if (!~proc.nodeTypes.indexOf(node.type)) { | ||
return; | ||
} | ||
css.walk(node => { | ||
processors.forEach(proc => { | ||
if (!~proc.nodeTypes.indexOf(node.type)) { | ||
return; | ||
} | ||
if (opts.lint) { | ||
return proc.detectAndWarn(node); | ||
} | ||
if (opts.lint) { | ||
return proc.detectAndWarn(node); | ||
} | ||
return proc.detectAndResolve(node); | ||
}); | ||
return proc.detectAndResolve(node); | ||
}); | ||
}; | ||
}); | ||
}); | ||
} | ||
stylehacks.detect = node => { | ||
return _plugins2.default.some(Plugin => { | ||
const hack = new Plugin(); | ||
}; | ||
} | ||
return hack.any(node); | ||
}); | ||
pluginCreator.detect = node => { | ||
return _plugins.default.some(Plugin => { | ||
const hack = new Plugin(); | ||
return hack.any(node); | ||
}); | ||
}; | ||
exports.default = stylehacks; | ||
module.exports = exports['default']; | ||
pluginCreator.postcss = true; | ||
var _default = pluginCreator; | ||
exports.default = _default; | ||
module.exports = exports.default; |
@@ -1,17 +0,20 @@ | ||
'use strict'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.default = isMixin; | ||
function isMixin(node) { | ||
const { selector } = node; | ||
const { | ||
selector | ||
} = node; // If the selector ends with a ':' it is likely a part of a custom mixin. | ||
// If the selector ends with a ':' it is likely a part of a custom mixin. | ||
if (!selector || selector[selector.length - 1] === ':') { | ||
return true; | ||
} | ||
if (!selector || selector[selector.length - 1] === ':') { | ||
return true; | ||
} | ||
return false; | ||
return false; | ||
} | ||
module.exports = exports['default']; | ||
module.exports = exports.default; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.default = plugin; | ||
function plugin(targets, nodeTypes, detect) { | ||
class Plugin { | ||
constructor(result) { | ||
this.nodes = []; | ||
this.result = result; | ||
this.targets = targets; | ||
this.nodeTypes = nodeTypes; | ||
} | ||
class Plugin { | ||
constructor(result) { | ||
this.nodes = []; | ||
this.result = result; | ||
this.targets = targets; | ||
this.nodeTypes = nodeTypes; | ||
} | ||
push(node, metadata) { | ||
node._stylehacks = Object.assign({}, metadata, { | ||
message: `Bad ${metadata.identifier}: ${metadata.hack}`, | ||
browsers: this.targets | ||
}); | ||
push(node, metadata) { | ||
node._stylehacks = Object.assign({}, metadata, { | ||
message: `Bad ${metadata.identifier}: ${metadata.hack}`, | ||
browsers: this.targets | ||
}); | ||
this.nodes.push(node); | ||
} | ||
this.nodes.push(node); | ||
} | ||
any(node) { | ||
if (~this.nodeTypes.indexOf(node.type)) { | ||
detect.apply(this, arguments); | ||
return !!node._stylehacks; | ||
} | ||
any(node) { | ||
if (~this.nodeTypes.indexOf(node.type)) { | ||
detect.apply(this, arguments); | ||
return false; | ||
} | ||
return !!node._stylehacks; | ||
} | ||
detectAndResolve(...args) { | ||
this.nodes = []; | ||
detect.apply(this, args); | ||
return this.resolve(); | ||
} | ||
return false; | ||
} | ||
detectAndWarn(...args) { | ||
this.nodes = []; | ||
detect.apply(this, args); | ||
return this.warn(); | ||
} | ||
detectAndResolve(...args) { | ||
this.nodes = []; | ||
resolve() { | ||
return this.nodes.forEach(node => node.remove()); | ||
} | ||
detect.apply(this, args); | ||
warn() { | ||
return this.nodes.forEach(node => { | ||
const { | ||
message, | ||
browsers, | ||
identifier, | ||
hack | ||
} = node._stylehacks; | ||
return node.warn(this.result, message, { | ||
browsers, | ||
identifier, | ||
hack | ||
}); | ||
}); | ||
} | ||
return this.resolve(); | ||
} | ||
} | ||
detectAndWarn(...args) { | ||
this.nodes = []; | ||
return Plugin; | ||
} | ||
detect.apply(this, args); | ||
return this.warn(); | ||
} | ||
resolve() { | ||
return this.nodes.forEach(node => node.remove()); | ||
} | ||
warn() { | ||
return this.nodes.forEach(node => { | ||
const { message, browsers, identifier, hack } = node._stylehacks; | ||
return node.warn(this.result, message, { browsers, identifier, hack }); | ||
}); | ||
} | ||
} | ||
return Plugin; | ||
} | ||
module.exports = exports["default"]; | ||
module.exports = exports.default; |
@@ -1,52 +0,48 @@ | ||
'use strict'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _postcssSelectorParser = require('postcss-selector-parser'); | ||
var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser")); | ||
var _postcssSelectorParser2 = _interopRequireDefault(_postcssSelectorParser); | ||
var _exists = _interopRequireDefault(require("../exists")); | ||
var _exists = require('../exists'); | ||
var _isMixin = _interopRequireDefault(require("../isMixin")); | ||
var _exists2 = _interopRequireDefault(_exists); | ||
var _plugin = _interopRequireDefault(require("../plugin")); | ||
var _isMixin = require('../isMixin'); | ||
var _browsers = require("../dictionary/browsers"); | ||
var _isMixin2 = _interopRequireDefault(_isMixin); | ||
var _identifiers = require("../dictionary/identifiers"); | ||
var _plugin = require('../plugin'); | ||
var _postcss = require("../dictionary/postcss"); | ||
var _plugin2 = _interopRequireDefault(_plugin); | ||
var _tags = require("../dictionary/tags"); | ||
var _browsers = require('../dictionary/browsers'); | ||
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 }; } | ||
function analyse(ctx, rule) { | ||
return selectors => { | ||
selectors.each(selector => { | ||
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: _identifiers.SELECTOR, | ||
hack: selector.toString() | ||
}); | ||
} | ||
return selectors => { | ||
selectors.each(selector => { | ||
if ((0, _exists.default)(selector, 0, _tags.BODY) && (0, _exists.default)(selector, 1, ':empty') && (0, _exists.default)(selector, 2, ' ') && selector.at(3)) { | ||
ctx.push(rule, { | ||
identifier: _identifiers.SELECTOR, | ||
hack: selector.toString() | ||
}); | ||
}; | ||
} | ||
}); | ||
}; | ||
} | ||
exports.default = (0, _plugin2.default)([_browsers.FF_2], [_postcss.RULE], function (rule) { | ||
if ((0, _isMixin2.default)(rule)) { | ||
return; | ||
} | ||
(0, _postcssSelectorParser2.default)(analyse(this, rule)).processSync(rule.selector); | ||
var _default = (0, _plugin.default)([_browsers.FF_2], [_postcss.RULE], function (rule) { | ||
if ((0, _isMixin.default)(rule)) { | ||
return; | ||
} | ||
(0, _postcssSelectorParser.default)(analyse(this, rule)).processSync(rule.selector); | ||
}); | ||
module.exports = exports['default']; | ||
exports.default = _default; | ||
module.exports = exports.default; |
@@ -1,54 +0,50 @@ | ||
'use strict'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _postcssSelectorParser = require('postcss-selector-parser'); | ||
var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser")); | ||
var _postcssSelectorParser2 = _interopRequireDefault(_postcssSelectorParser); | ||
var _exists = _interopRequireDefault(require("../exists")); | ||
var _exists = require('../exists'); | ||
var _isMixin = _interopRequireDefault(require("../isMixin")); | ||
var _exists2 = _interopRequireDefault(_exists); | ||
var _plugin = _interopRequireDefault(require("../plugin")); | ||
var _isMixin = require('../isMixin'); | ||
var _browsers = require("../dictionary/browsers"); | ||
var _isMixin2 = _interopRequireDefault(_isMixin); | ||
var _identifiers = require("../dictionary/identifiers"); | ||
var _plugin = require('../plugin'); | ||
var _postcss = require("../dictionary/postcss"); | ||
var _plugin2 = _interopRequireDefault(_plugin); | ||
var _tags = require("../dictionary/tags"); | ||
var _browsers = require('../dictionary/browsers'); | ||
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 }; } | ||
function analyse(ctx, rule) { | ||
return selectors => { | ||
selectors.each(selector => { | ||
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: _identifiers.SELECTOR, | ||
hack: selector.toString() | ||
}); | ||
} | ||
return selectors => { | ||
selectors.each(selector => { | ||
if ((0, _exists.default)(selector, 0, _tags.HTML) && ((0, _exists.default)(selector, 1, '>') || (0, _exists.default)(selector, 1, '~')) && selector.at(2) && selector.at(2).type === 'comment' && (0, _exists.default)(selector, 3, ' ') && (0, _exists.default)(selector, 4, _tags.BODY) && (0, _exists.default)(selector, 5, ' ') && selector.at(6)) { | ||
ctx.push(rule, { | ||
identifier: _identifiers.SELECTOR, | ||
hack: selector.toString() | ||
}); | ||
}; | ||
} | ||
}); | ||
}; | ||
} | ||
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)).processSync(rule.raws.selector.raw); | ||
} | ||
var _default = (0, _plugin.default)([_browsers.IE_5_5, _browsers.IE_6, _browsers.IE_7], [_postcss.RULE], function (rule) { | ||
if ((0, _isMixin.default)(rule)) { | ||
return; | ||
} | ||
if (rule.raws.selector && rule.raws.selector.raw) { | ||
(0, _postcssSelectorParser.default)(analyse(this, rule)).processSync(rule.raws.selector.raw); | ||
} | ||
}); | ||
module.exports = exports['default']; | ||
exports.default = _default; | ||
module.exports = exports.default; |
@@ -1,52 +0,48 @@ | ||
'use strict'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _postcssSelectorParser = require('postcss-selector-parser'); | ||
var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser")); | ||
var _postcssSelectorParser2 = _interopRequireDefault(_postcssSelectorParser); | ||
var _exists = _interopRequireDefault(require("../exists")); | ||
var _exists = require('../exists'); | ||
var _isMixin = _interopRequireDefault(require("../isMixin")); | ||
var _exists2 = _interopRequireDefault(_exists); | ||
var _plugin = _interopRequireDefault(require("../plugin")); | ||
var _isMixin = require('../isMixin'); | ||
var _browsers = require("../dictionary/browsers"); | ||
var _isMixin2 = _interopRequireDefault(_isMixin); | ||
var _identifiers = require("../dictionary/identifiers"); | ||
var _plugin = require('../plugin'); | ||
var _postcss = require("../dictionary/postcss"); | ||
var _plugin2 = _interopRequireDefault(_plugin); | ||
var _tags = require("../dictionary/tags"); | ||
var _browsers = require('../dictionary/browsers'); | ||
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 }; } | ||
function analyse(ctx, rule) { | ||
return selectors => { | ||
selectors.each(selector => { | ||
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: _identifiers.SELECTOR, | ||
hack: selector.toString() | ||
}); | ||
} | ||
return selectors => { | ||
selectors.each(selector => { | ||
if ((0, _exists.default)(selector, 0, _tags.HTML) && (0, _exists.default)(selector, 1, ':first-child') && (0, _exists.default)(selector, 2, ' ') && selector.at(3)) { | ||
ctx.push(rule, { | ||
identifier: _identifiers.SELECTOR, | ||
hack: selector.toString() | ||
}); | ||
}; | ||
} | ||
}); | ||
}; | ||
} | ||
exports.default = (0, _plugin2.default)([_browsers.OP_9], [_postcss.RULE], function (rule) { | ||
if ((0, _isMixin2.default)(rule)) { | ||
return; | ||
} | ||
(0, _postcssSelectorParser2.default)(analyse(this, rule)).processSync(rule.selector); | ||
var _default = (0, _plugin.default)([_browsers.OP_9], [_postcss.RULE], function (rule) { | ||
if ((0, _isMixin.default)(rule)) { | ||
return; | ||
} | ||
(0, _postcssSelectorParser.default)(analyse(this, rule)).processSync(rule.selector); | ||
}); | ||
module.exports = exports['default']; | ||
exports.default = _default; | ||
module.exports = exports.default; |
@@ -1,27 +0,29 @@ | ||
'use strict'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _plugin = require('../plugin'); | ||
var _plugin = _interopRequireDefault(require("../plugin")); | ||
var _plugin2 = _interopRequireDefault(_plugin); | ||
var _browsers = require("../dictionary/browsers"); | ||
var _browsers = require('../dictionary/browsers'); | ||
var _postcss = require("../dictionary/postcss"); | ||
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.DECL], function (decl) { | ||
const match = decl.value.match(/!\w/); | ||
if (match) { | ||
const hack = decl.value.substr(match.index, decl.value.length - 1); | ||
this.push(decl, { | ||
identifier: '!important', | ||
hack | ||
}); | ||
} | ||
var _default = (0, _plugin.default)([_browsers.IE_5_5, _browsers.IE_6, _browsers.IE_7], [_postcss.DECL], function (decl) { | ||
const match = decl.value.match(/!\w/); | ||
if (match) { | ||
const hack = decl.value.substr(match.index, decl.value.length - 1); | ||
this.push(decl, { | ||
identifier: '!important', | ||
hack | ||
}); | ||
} | ||
}); | ||
module.exports = exports['default']; | ||
exports.default = _default; | ||
module.exports = exports.default; |
@@ -1,58 +0,36 @@ | ||
'use strict'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _bodyEmpty = require('./bodyEmpty'); | ||
var _bodyEmpty = _interopRequireDefault(require("./bodyEmpty")); | ||
var _bodyEmpty2 = _interopRequireDefault(_bodyEmpty); | ||
var _htmlCombinatorCommentBody = _interopRequireDefault(require("./htmlCombinatorCommentBody")); | ||
var _htmlCombinatorCommentBody = require('./htmlCombinatorCommentBody'); | ||
var _htmlFirstChild = _interopRequireDefault(require("./htmlFirstChild")); | ||
var _htmlCombinatorCommentBody2 = _interopRequireDefault(_htmlCombinatorCommentBody); | ||
var _important = _interopRequireDefault(require("./important")); | ||
var _htmlFirstChild = require('./htmlFirstChild'); | ||
var _leadingStar = _interopRequireDefault(require("./leadingStar")); | ||
var _htmlFirstChild2 = _interopRequireDefault(_htmlFirstChild); | ||
var _leadingUnderscore = _interopRequireDefault(require("./leadingUnderscore")); | ||
var _important = require('./important'); | ||
var _mediaSlash = _interopRequireDefault(require("./mediaSlash0")); | ||
var _important2 = _interopRequireDefault(_important); | ||
var _mediaSlash0Slash = _interopRequireDefault(require("./mediaSlash0Slash9")); | ||
var _leadingStar = require('./leadingStar'); | ||
var _mediaSlash2 = _interopRequireDefault(require("./mediaSlash9")); | ||
var _leadingStar2 = _interopRequireDefault(_leadingStar); | ||
var _slash = _interopRequireDefault(require("./slash9")); | ||
var _leadingUnderscore = require('./leadingUnderscore'); | ||
var _starHtml = _interopRequireDefault(require("./starHtml")); | ||
var _leadingUnderscore2 = _interopRequireDefault(_leadingUnderscore); | ||
var _trailingSlashComma = _interopRequireDefault(require("./trailingSlashComma")); | ||
var _mediaSlash = require('./mediaSlash0'); | ||
var _mediaSlash2 = _interopRequireDefault(_mediaSlash); | ||
var _mediaSlash0Slash = require('./mediaSlash0Slash9'); | ||
var _mediaSlash0Slash2 = _interopRequireDefault(_mediaSlash0Slash); | ||
var _mediaSlash3 = require('./mediaSlash9'); | ||
var _mediaSlash4 = _interopRequireDefault(_mediaSlash3); | ||
var _slash = require('./slash9'); | ||
var _slash2 = _interopRequireDefault(_slash); | ||
var _starHtml = require('./starHtml'); | ||
var _starHtml2 = _interopRequireDefault(_starHtml); | ||
var _trailingSlashComma = require('./trailingSlashComma'); | ||
var _trailingSlashComma2 = _interopRequireDefault(_trailingSlashComma); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
exports.default = [_bodyEmpty2.default, _htmlCombinatorCommentBody2.default, _htmlFirstChild2.default, _important2.default, _leadingStar2.default, _leadingUnderscore2.default, _mediaSlash2.default, _mediaSlash0Slash2.default, _mediaSlash4.default, _slash2.default, _starHtml2.default, _trailingSlashComma2.default]; | ||
module.exports = exports['default']; | ||
var _default = [_bodyEmpty.default, _htmlCombinatorCommentBody.default, _htmlFirstChild.default, _important.default, _leadingStar.default, _leadingUnderscore.default, _mediaSlash.default, _mediaSlash0Slash.default, _mediaSlash2.default, _slash.default, _starHtml.default, _trailingSlashComma.default]; | ||
exports.default = _default; | ||
module.exports = exports.default; |
@@ -1,17 +0,16 @@ | ||
'use strict'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _plugin = require('../plugin'); | ||
var _plugin = _interopRequireDefault(require("../plugin")); | ||
var _plugin2 = _interopRequireDefault(_plugin); | ||
var _browsers = require("../dictionary/browsers"); | ||
var _browsers = require('../dictionary/browsers'); | ||
var _identifiers = require("../dictionary/identifiers"); | ||
var _identifiers = require('../dictionary/identifiers'); | ||
var _postcss = require("../dictionary/postcss"); | ||
var _postcss = require('../dictionary/postcss'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -21,40 +20,49 @@ | ||
exports.default = (0, _plugin2.default)([_browsers.IE_5_5, _browsers.IE_6, _browsers.IE_7], [_postcss.ATRULE, _postcss.DECL], function (node) { | ||
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(hack => { | ||
if (!node.prop.indexOf(hack)) { | ||
this.push(node, { | ||
identifier: _identifiers.PROPERTY, | ||
hack: node.prop | ||
}); | ||
return true; | ||
} | ||
var _default = (0, _plugin.default)([_browsers.IE_5_5, _browsers.IE_6, _browsers.IE_7], [_postcss.ATRULE, _postcss.DECL], function (node) { | ||
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(hack => { | ||
if (!node.prop.indexOf(hack)) { | ||
this.push(node, { | ||
identifier: _identifiers.PROPERTY, | ||
hack: node.prop | ||
}); | ||
let { before } = node.raws; | ||
if (!before) { | ||
return; | ||
} | ||
hacks.some(hack => { | ||
if (~before.indexOf(hack)) { | ||
this.push(node, { | ||
identifier: _identifiers.PROPERTY, | ||
hack: `${before.trim()}${node.prop}` | ||
}); | ||
return true; | ||
} | ||
return true; | ||
} | ||
}); | ||
let { | ||
before | ||
} = node.raws; | ||
if (!before) { | ||
return; | ||
} | ||
hacks.some(hack => { | ||
if (~before.indexOf(hack)) { | ||
this.push(node, { | ||
identifier: _identifiers.PROPERTY, | ||
hack: `${before.trim()}${node.prop}` | ||
}); | ||
} else { | ||
// test for the @property: value; hack | ||
let { name } = node; | ||
let len = name.length - 1; | ||
if (name.lastIndexOf(':') === len) { | ||
this.push(node, { | ||
identifier: _identifiers.PROPERTY, | ||
hack: `@${name.substr(0, len)}` | ||
}); | ||
} | ||
return true; | ||
} | ||
}); | ||
} else { | ||
// test for the @property: value; hack | ||
let { | ||
name | ||
} = node; | ||
let len = name.length - 1; | ||
if (name.lastIndexOf(':') === len) { | ||
this.push(node, { | ||
identifier: _identifiers.PROPERTY, | ||
hack: `@${name.substr(0, len)}` | ||
}); | ||
} | ||
} | ||
}); | ||
module.exports = exports['default']; | ||
exports.default = _default; | ||
module.exports = exports.default; |
@@ -1,40 +0,49 @@ | ||
'use strict'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _postcss = require('postcss'); | ||
var _plugin = _interopRequireDefault(require("../plugin")); | ||
var _postcss2 = _interopRequireDefault(_postcss); | ||
var _browsers = require("../dictionary/browsers"); | ||
var _plugin = require('../plugin'); | ||
var _identifiers = require("../dictionary/identifiers"); | ||
var _plugin2 = _interopRequireDefault(_plugin); | ||
var _postcss = require("../dictionary/postcss"); | ||
var _browsers = require('../dictionary/browsers'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _identifiers = require('../dictionary/identifiers'); | ||
function vendorPrefix(prop) { | ||
let match = prop.match(/^(-\w+-)/); | ||
var _postcss3 = require('../dictionary/postcss'); | ||
if (match) { | ||
return match[0]; | ||
} | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
return ''; | ||
} | ||
exports.default = (0, _plugin2.default)([_browsers.IE_6], [_postcss3.DECL], function (decl) { | ||
const { before } = decl.raws; | ||
var _default = (0, _plugin.default)([_browsers.IE_6], [_postcss.DECL], function (decl) { | ||
const { | ||
before | ||
} = decl.raws; | ||
if (before && ~before.indexOf('_')) { | ||
this.push(decl, { | ||
identifier: _identifiers.PROPERTY, | ||
hack: `${before.trim()}${decl.prop}` | ||
}); | ||
} | ||
if (before && ~before.indexOf('_')) { | ||
this.push(decl, { | ||
identifier: _identifiers.PROPERTY, | ||
hack: `${before.trim()}${decl.prop}` | ||
}); | ||
} | ||
if (decl.prop[0] === '-' && decl.prop[1] !== '-' && _postcss2.default.vendor.prefix(decl.prop) === '') { | ||
this.push(decl, { | ||
identifier: _identifiers.PROPERTY, | ||
hack: decl.prop | ||
}); | ||
} | ||
if (decl.prop[0] === '-' && decl.prop[1] !== '-' && vendorPrefix(decl.prop) === '') { | ||
this.push(decl, { | ||
identifier: _identifiers.PROPERTY, | ||
hack: decl.prop | ||
}); | ||
} | ||
}); | ||
module.exports = exports['default']; | ||
exports.default = _default; | ||
module.exports = exports.default; |
@@ -1,29 +0,30 @@ | ||
'use strict'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _plugin = require('../plugin'); | ||
var _plugin = _interopRequireDefault(require("../plugin")); | ||
var _plugin2 = _interopRequireDefault(_plugin); | ||
var _browsers = require("../dictionary/browsers"); | ||
var _browsers = require('../dictionary/browsers'); | ||
var _identifiers = require("../dictionary/identifiers"); | ||
var _identifiers = require('../dictionary/identifiers'); | ||
var _postcss = require("../dictionary/postcss"); | ||
var _postcss = require('../dictionary/postcss'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
exports.default = (0, _plugin2.default)([_browsers.IE_8], [_postcss.ATRULE], function (rule) { | ||
const params = rule.params.trim(); | ||
var _default = (0, _plugin.default)([_browsers.IE_8], [_postcss.ATRULE], function (rule) { | ||
const params = rule.params.trim(); | ||
if (params.toLowerCase() === '\\0screen') { | ||
this.push(rule, { | ||
identifier: _identifiers.MEDIA_QUERY, | ||
hack: params | ||
}); | ||
} | ||
if (params.toLowerCase() === '\\0screen') { | ||
this.push(rule, { | ||
identifier: _identifiers.MEDIA_QUERY, | ||
hack: params | ||
}); | ||
} | ||
}); | ||
module.exports = exports['default']; | ||
exports.default = _default; | ||
module.exports = exports.default; |
@@ -1,29 +0,30 @@ | ||
'use strict'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _plugin = require('../plugin'); | ||
var _plugin = _interopRequireDefault(require("../plugin")); | ||
var _plugin2 = _interopRequireDefault(_plugin); | ||
var _browsers = require("../dictionary/browsers"); | ||
var _browsers = require('../dictionary/browsers'); | ||
var _identifiers = require("../dictionary/identifiers"); | ||
var _identifiers = require('../dictionary/identifiers'); | ||
var _postcss = require("../dictionary/postcss"); | ||
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, _browsers.IE_8], [_postcss.ATRULE], function (rule) { | ||
const params = rule.params.trim(); | ||
var _default = (0, _plugin.default)([_browsers.IE_5_5, _browsers.IE_6, _browsers.IE_7, _browsers.IE_8], [_postcss.ATRULE], function (rule) { | ||
const params = rule.params.trim(); | ||
if (params.toLowerCase() === '\\0screen\\,screen\\9') { | ||
this.push(rule, { | ||
identifier: _identifiers.MEDIA_QUERY, | ||
hack: params | ||
}); | ||
} | ||
if (params.toLowerCase() === '\\0screen\\,screen\\9') { | ||
this.push(rule, { | ||
identifier: _identifiers.MEDIA_QUERY, | ||
hack: params | ||
}); | ||
} | ||
}); | ||
module.exports = exports['default']; | ||
exports.default = _default; | ||
module.exports = exports.default; |
@@ -1,29 +0,30 @@ | ||
'use strict'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _plugin = require('../plugin'); | ||
var _plugin = _interopRequireDefault(require("../plugin")); | ||
var _plugin2 = _interopRequireDefault(_plugin); | ||
var _browsers = require("../dictionary/browsers"); | ||
var _browsers = require('../dictionary/browsers'); | ||
var _identifiers = require("../dictionary/identifiers"); | ||
var _identifiers = require('../dictionary/identifiers'); | ||
var _postcss = require("../dictionary/postcss"); | ||
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.ATRULE], function (rule) { | ||
const params = rule.params.trim(); | ||
var _default = (0, _plugin.default)([_browsers.IE_5_5, _browsers.IE_6, _browsers.IE_7], [_postcss.ATRULE], function (rule) { | ||
const params = rule.params.trim(); | ||
if (params.toLowerCase() === 'screen\\9') { | ||
this.push(rule, { | ||
identifier: _identifiers.MEDIA_QUERY, | ||
hack: params | ||
}); | ||
} | ||
if (params.toLowerCase() === 'screen\\9') { | ||
this.push(rule, { | ||
identifier: _identifiers.MEDIA_QUERY, | ||
hack: params | ||
}); | ||
} | ||
}); | ||
module.exports = exports['default']; | ||
exports.default = _default; | ||
module.exports = exports.default; |
@@ -1,28 +0,30 @@ | ||
'use strict'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _plugin = require('../plugin'); | ||
var _plugin = _interopRequireDefault(require("../plugin")); | ||
var _plugin2 = _interopRequireDefault(_plugin); | ||
var _browsers = require("../dictionary/browsers"); | ||
var _browsers = require('../dictionary/browsers'); | ||
var _identifiers = require("../dictionary/identifiers"); | ||
var _identifiers = require('../dictionary/identifiers'); | ||
var _postcss = require("../dictionary/postcss"); | ||
var _postcss = require('../dictionary/postcss'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
exports.default = (0, _plugin2.default)([_browsers.IE_6, _browsers.IE_7, _browsers.IE_8], [_postcss.DECL], function (decl) { | ||
let v = decl.value; | ||
if (v && v.length > 2 && v.indexOf('\\9') === v.length - 2) { | ||
this.push(decl, { | ||
identifier: _identifiers.VALUE, | ||
hack: v | ||
}); | ||
} | ||
var _default = (0, _plugin.default)([_browsers.IE_6, _browsers.IE_7, _browsers.IE_8], [_postcss.DECL], function (decl) { | ||
let v = decl.value; | ||
if (v && v.length > 2 && v.indexOf('\\9') === v.length - 2) { | ||
this.push(decl, { | ||
identifier: _identifiers.VALUE, | ||
hack: v | ||
}); | ||
} | ||
}); | ||
module.exports = exports['default']; | ||
exports.default = _default; | ||
module.exports = exports.default; |
@@ -1,53 +0,48 @@ | ||
'use strict'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _postcssSelectorParser = require('postcss-selector-parser'); | ||
var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser")); | ||
var _postcssSelectorParser2 = _interopRequireDefault(_postcssSelectorParser); | ||
var _exists = _interopRequireDefault(require("../exists")); | ||
var _exists = require('../exists'); | ||
var _isMixin = _interopRequireDefault(require("../isMixin")); | ||
var _exists2 = _interopRequireDefault(_exists); | ||
var _plugin = _interopRequireDefault(require("../plugin")); | ||
var _isMixin = require('../isMixin'); | ||
var _browsers = require("../dictionary/browsers"); | ||
var _isMixin2 = _interopRequireDefault(_isMixin); | ||
var _identifiers = require("../dictionary/identifiers"); | ||
var _plugin = require('../plugin'); | ||
var _postcss = require("../dictionary/postcss"); | ||
var _plugin2 = _interopRequireDefault(_plugin); | ||
var _tags = require("../dictionary/tags"); | ||
var _browsers = require('../dictionary/browsers'); | ||
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 }; } | ||
function analyse(ctx, rule) { | ||
return selectors => { | ||
selectors.each(selector => { | ||
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: _identifiers.SELECTOR, | ||
hack: selector.toString() | ||
}); | ||
} | ||
return selectors => { | ||
selectors.each(selector => { | ||
if ((0, _exists.default)(selector, 0, '*') && (0, _exists.default)(selector, 1, ' ') && (0, _exists.default)(selector, 2, _tags.HTML) && (0, _exists.default)(selector, 3, ' ') && selector.at(4)) { | ||
ctx.push(rule, { | ||
identifier: _identifiers.SELECTOR, | ||
hack: selector.toString() | ||
}); | ||
}; | ||
} | ||
}); | ||
}; | ||
} | ||
exports.default = (0, _plugin2.default)([_browsers.IE_5_5, _browsers.IE_6], [_postcss.RULE], function (rule) { | ||
if ((0, _isMixin2.default)(rule)) { | ||
return; | ||
} | ||
var _default = (0, _plugin.default)([_browsers.IE_5_5, _browsers.IE_6], [_postcss.RULE], function (rule) { | ||
if ((0, _isMixin.default)(rule)) { | ||
return; | ||
} | ||
(0, _postcssSelectorParser2.default)(analyse(this, rule)).processSync(rule.selector); | ||
(0, _postcssSelectorParser.default)(analyse(this, rule)).processSync(rule.selector); | ||
}); | ||
module.exports = exports['default']; | ||
exports.default = _default; | ||
module.exports = exports.default; |
@@ -1,38 +0,39 @@ | ||
'use strict'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _plugin = require('../plugin'); | ||
var _plugin = _interopRequireDefault(require("../plugin")); | ||
var _plugin2 = _interopRequireDefault(_plugin); | ||
var _isMixin = _interopRequireDefault(require("../isMixin")); | ||
var _isMixin = require('../isMixin'); | ||
var _browsers = require("../dictionary/browsers"); | ||
var _isMixin2 = _interopRequireDefault(_isMixin); | ||
var _identifiers = require("../dictionary/identifiers"); | ||
var _browsers = require('../dictionary/browsers'); | ||
var _postcss = require("../dictionary/postcss"); | ||
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 _default = (0, _plugin.default)([_browsers.IE_5_5, _browsers.IE_6, _browsers.IE_7], [_postcss.RULE], function (rule) { | ||
if ((0, _isMixin.default)(rule)) { | ||
return; | ||
} | ||
const { selector } = rule; | ||
const trim = selector.trim(); | ||
const { | ||
selector | ||
} = rule; | ||
const trim = selector.trim(); | ||
if (trim.lastIndexOf(',') === selector.length - 1 || trim.lastIndexOf('\\') === selector.length - 1) { | ||
this.push(rule, { | ||
identifier: _identifiers.SELECTOR, | ||
hack: selector | ||
}); | ||
} | ||
if (trim.lastIndexOf(',') === selector.length - 1 || trim.lastIndexOf('\\') === selector.length - 1) { | ||
this.push(rule, { | ||
identifier: _identifiers.SELECTOR, | ||
hack: selector | ||
}); | ||
} | ||
}); | ||
module.exports = exports['default']; | ||
exports.default = _default; | ||
module.exports = exports.default; |
{ | ||
"name": "stylehacks", | ||
"version": "4.0.3", | ||
"version": "5.0.0-rc.0", | ||
"description": "Detect/remove browser hacks from CSS files.", | ||
@@ -11,3 +11,5 @@ "main": "dist/index.js", | ||
"scripts": { | ||
"prepublish": "cross-env BABEL_ENV=publish babel src --out-dir dist --ignore /__tests__/" | ||
"prebuild": "del-cli dist", | ||
"build": "cross-env BABEL_ENV=publish babel src --config-file ../../babel.config.js --out-dir dist --ignore \"**/__tests__/\"", | ||
"prepublish": "yarn build" | ||
}, | ||
@@ -25,6 +27,2 @@ "keywords": [ | ||
"license": "MIT", | ||
"devDependencies": { | ||
"babel-cli": "^6.0.0", | ||
"cross-env": "^5.0.0" | ||
}, | ||
"homepage": "https://github.com/cssnano/cssnano", | ||
@@ -38,5 +36,4 @@ "author": { | ||
"dependencies": { | ||
"browserslist": "^4.0.0", | ||
"postcss": "^7.0.0", | ||
"postcss-selector-parser": "^3.0.0" | ||
"browserslist": "^4.16.0", | ||
"postcss-selector-parser": "^6.0.4" | ||
}, | ||
@@ -47,4 +44,11 @@ "bugs": { | ||
"engines": { | ||
"node": ">=6.9.0" | ||
} | ||
"node": "^10 || ^12 || >=14.0" | ||
}, | ||
"devDependencies": { | ||
"postcss": "^8.2.1" | ||
}, | ||
"peerDependencies": { | ||
"postcss": "^8.2.1" | ||
}, | ||
"gitHead": "8c16e67a4d24a13ac7e09a36d4faf504196efd0f" | ||
} |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
25486
1
25
552
1
1
+ Addedcssesc@3.0.0(transitive)
+ Addednanoid@3.3.7(transitive)
+ Addedpostcss@8.4.47(transitive)
+ Addedpostcss-selector-parser@6.1.2(transitive)
+ Addedsource-map-js@1.2.1(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
- Removedpostcss@^7.0.0
- Removeddot-prop@5.3.0(transitive)
- Removedindexes-of@1.0.1(transitive)
- Removedis-obj@2.0.0(transitive)
- Removedpicocolors@0.2.1(transitive)
- Removedpostcss@7.0.39(transitive)
- Removedpostcss-selector-parser@3.1.2(transitive)
- Removedsource-map@0.6.1(transitive)
- Removeduniq@1.0.1(transitive)
Updatedbrowserslist@^4.16.0