postcss-normalize-charset
Advanced tools
Comparing version
@@ -0,1 +1,7 @@ | ||
# 1.1.1 | ||
* Performance tweaks; test that `node.parent` is equal to the AST rather than | ||
checking its type is `root`, and use the AST directly to prepend the | ||
`@charset` to, rather than using the superfluous `root()` method. | ||
# 1.1.0 | ||
@@ -2,0 +8,0 @@ |
12
index.js
var postcss = require('postcss'); | ||
module.exports = postcss.plugin('postcss-normalize-charset', function (opts) { | ||
var charset = 'charset'; | ||
module.exports = postcss.plugin('postcss-normalize-' + charset, function (opts) { | ||
opts = opts || {}; | ||
@@ -12,3 +14,3 @@ | ||
css.walk(function (node) { | ||
if (node.type === 'atrule' && node.name === 'charset') { | ||
if (node.type === 'atrule' && node.name === charset) { | ||
if (!charsetRule) { | ||
@@ -18,3 +20,3 @@ charsetRule = node; | ||
node.remove(); | ||
} else if (!nonAsciiNode && node.parent && node.parent.type === 'root' && nonAscii.test(node)) { | ||
} else if (!nonAsciiNode && node.parent === css && nonAscii.test(node)) { | ||
nonAsciiNode = node; | ||
@@ -27,3 +29,3 @@ } | ||
charsetRule = postcss.atRule({ | ||
name: 'charset', | ||
name: charset, | ||
params: '"utf-8"' | ||
@@ -34,3 +36,3 @@ }); | ||
charsetRule.source = nonAsciiNode.source; | ||
css.root().prepend(charsetRule); | ||
css.prepend(charsetRule); | ||
} | ||
@@ -37,0 +39,0 @@ } |
{ | ||
"name": "postcss-normalize-charset", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Add necessary or remove extra charset with PostCSS", | ||
@@ -16,7 +16,7 @@ "keywords": [ | ||
"license": "MIT", | ||
"repository": "TrySound/postcss-charset", | ||
"repository": "ben-eb/postcss-charset", | ||
"bugs": { | ||
"url": "https://github.com/TrySound/postcss-charset/issues" | ||
"url": "https://github.com/ben-eb/postcss-charset/issues" | ||
}, | ||
"homepage": "https://github.com/TrySound/postcss-charset", | ||
"homepage": "https://github.com/ben-eb/postcss-charset", | ||
"dependencies": { | ||
@@ -26,9 +26,9 @@ "postcss": "^5.0.5" | ||
"devDependencies": { | ||
"ava": "^0.16.0", | ||
"eslint": "^1.4.1", | ||
"tap-spec": "^4.1.0", | ||
"tape": "^4.2.0" | ||
"postcss-devtools": "^1.1.1" | ||
}, | ||
"scripts": { | ||
"test": "eslint index.js test && tape test/*.js | tap-spec" | ||
"test": "eslint index.js test && ava" | ||
} | ||
} |
@@ -43,3 +43,3 @@ # postcss-normalize-charset [![Build Status][ci-img]][ci] | ||
[PostCSS]: https://github.com/postcss/postcss | ||
[ci-img]: https://travis-ci.org/TrySound/postcss-normalize-charset.svg | ||
[ci]: https://travis-ci.org/TrySound/postcss-normalize-charset | ||
[ci-img]: https://travis-ci.org/ben-eb/postcss-normalize-charset.svg | ||
[ci]: https://travis-ci.org/ben-eb/postcss-normalize-charset |
Sorry, the diff of this file is not supported yet
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 bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
3994
2.36%32
3.23%1
Infinity%