postcss-pxtovw-new
Advanced tools
Comparing version 1.0.0 to 1.1.0
48
index.js
@@ -26,3 +26,3 @@ 'use strict'; | ||
module.exports = postcss.plugin('postcss-px-to-viewport', function (options) { | ||
var opts = objectAssign({}, defaults, options); | ||
@@ -33,3 +33,3 @@ | ||
var landscapeRules = []; | ||
return function (css) { | ||
@@ -51,3 +51,3 @@ css.walkRules(function (rule) { | ||
} | ||
if (blacklistedSelector(opts.selectorBlackList, rule.selector)) return; | ||
@@ -58,6 +58,6 @@ | ||
rule.walkDecls(function(decl) { | ||
rule.walkDecls(function (decl) { | ||
if (decl.value.indexOf(opts.unitToConvert) === -1) return; | ||
if (!satisfyPropList(decl.prop)) return; | ||
landscapeRule.append(decl.clone({ | ||
@@ -67,5 +67,5 @@ value: decl.value.replace(pxRegex, createPxReplace(opts, opts.landscapeUnit, opts.landscapeWidth)) | ||
}); | ||
if (landscapeRule.nodes.length > 0) { | ||
landscapeRules.push(landscapeRule); | ||
landscapeRules.push(landscapeRule); | ||
} | ||
@@ -75,4 +75,4 @@ } | ||
if (!validateParams(rule.parent.params, opts.mediaQuery)) return; | ||
rule.walkDecls(function(decl, i) { | ||
rule.walkDecls(function (decl, i) { | ||
if (decl.value.indexOf(opts.unitToConvert) === -1) return; | ||
@@ -84,3 +84,3 @@ if (!satisfyPropList(decl.prop)) return; | ||
var params = rule.parent.params; | ||
if (opts.landscape && params && params.indexOf('landscape') !== -1) { | ||
@@ -98,24 +98,22 @@ unit = opts.landscapeUnit; | ||
// next declaration is comment and comment text is no or px | ||
if (next && next.type === 'comment' && (next.text === 'to-vw-disable')) { | ||
if (next && next.type === 'comment' && (next.text === 'to-vw')) { | ||
var value = decl.value.replace(pxRegex, createPxReplace(opts, unit, size)); | ||
if (declarationExists(decl.parent, decl.prop, value)) return; | ||
if (opts.replace) { | ||
decl.value = value; | ||
} else { | ||
decl.parent.insertAfter(i, decl.clone({ value: value })); | ||
} | ||
// remove comment | ||
nodes.splice(indexes + 1, 1); | ||
} else { | ||
return; | ||
} | ||
var value = decl.value.replace(pxRegex, createPxReplace(opts, unit, size)); | ||
if (declarationExists(decl.parent, decl.prop, value)) return; | ||
if (opts.replace) { | ||
decl.value = value; | ||
} else { | ||
decl.parent.insertAfter(i, decl.clone({ value: value })); | ||
} | ||
}); | ||
}); | ||
if (landscapeRules.length > 0) { | ||
var landscapeRoot = new postcss.atRule({ params: '(orientation: landscape)', name: 'media' }); | ||
landscapeRules.forEach(function(rule) { | ||
landscapeRules.forEach(function (rule) { | ||
landscapeRoot.append(rule); | ||
@@ -165,3 +163,3 @@ }); | ||
return decls.some(function (decl) { | ||
return (decl.prop === prop && decl.value === value); | ||
return (decl.prop === prop && decl.value === value); | ||
}); | ||
@@ -168,0 +166,0 @@ } |
{ | ||
"name": "postcss-pxtovw-new", | ||
"description": "A CSS post-processor that converts px to viewport units (vw, vh, vmin, vmax).", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"author": "cenkai88 <cenkai29@gmail.com>", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
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
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
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
359
12324
9
2
0