postcss-svg
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -0,3 +1,10 @@ | ||
### 1.0.1 - 2015-07-10 | ||
Fix some issues: | ||
* [Raise a error on unknown file](https://github.com/Pavliko/postcss-svg/issues/7) | ||
* [Absolute paths](https://github.com/Pavliko/postcss-svg/issues/8) | ||
* [SVG names with single quotes do not get replaced](https://github.com/Pavliko/postcss-svg/issues/10) | ||
# 1.0.0 - 2015-07-10 | ||
Initial release from [postcss-svg](https://github.com/Pavliko/postcss-svg) |
@@ -12,3 +12,3 @@ (function() { | ||
module.exports = postcss.plugin("postcss-svg", function(options) { | ||
var SVGRegExp, funcName, silent; | ||
var SVGRegExp, funcName, replaceRegExp, silent; | ||
if (options == null) { | ||
@@ -19,2 +19,3 @@ options = {}; | ||
SVGRegExp = new RegExp(funcName + "\\(\"([^\"]+)\"(,\\s*\"([^\"]+)\")?\\)"); | ||
replaceRegExp = new RegExp(funcName + "\\((\"[^\"]+\"|\'[^\']+\')(,\\s*(\"[^\"]+\"|\'[^\']+\'))?\\)"); | ||
silent = _.isBoolean(options.silent) ? options.silent : true; | ||
@@ -27,3 +28,3 @@ if (options.debug) { | ||
return style.eachDecl(/^background|^filter|^content|image$/, function(decl) { | ||
var args, error, matches, name, params, replace, svg; | ||
var ___, error, matches, name, params, replace, svg; | ||
if (!decl.value) { | ||
@@ -33,4 +34,3 @@ return; | ||
if (matches = SVGRegExp.exec(decl.value.replace(/'/g, '"'))) { | ||
replace = matches[0], args = 2 <= matches.length ? slice.call(matches, 1) : []; | ||
name = args[0], params = 2 <= args.length ? slice.call(args, 1) : []; | ||
___ = matches[0], name = matches[1], params = 3 <= matches.length ? slice.call(matches, 2) : []; | ||
if (options.debug) { | ||
@@ -43,3 +43,5 @@ console.time("Render svg " + name); | ||
error = _error; | ||
if (!silent) { | ||
if (silent) { | ||
console.info("postcss-svg: " + error); | ||
} else { | ||
throw decl.error(error); | ||
@@ -51,2 +53,3 @@ } | ||
} | ||
replace = replaceRegExp.exec(decl.value)[0]; | ||
decl.value = decl.value.replace(replace, svg.dataUrl(params[1])); | ||
@@ -53,0 +56,0 @@ if (options.debug) { |
@@ -16,3 +16,3 @@ (function() { | ||
init: function(options) { | ||
var debug, filename, i, j, len, len1, myPath, ref, ref1, stat, svgOptions; | ||
var debug, filename, i, j, len, len1, myPath, ref, ref1, stat; | ||
debug = _.isBoolean(options.debug) && options.debug; | ||
@@ -36,4 +36,5 @@ options.svgo || (options.svgo = false); | ||
} | ||
svgOptions = _.pick(options, 'defaults', 'svgo'); | ||
ref = options.paths || this.defaultPaths; | ||
this.svgOptions = _.pick(options, 'defaults', 'svgo'); | ||
this.paths = options.paths || this.defaultPaths; | ||
ref = this.paths; | ||
for (i = 0, len = ref.length; i < len; i++) { | ||
@@ -47,7 +48,7 @@ myPath = ref[i]; | ||
filename = ref1[j]; | ||
this.addToIndex("" + myPath + path.sep + filename, svgOptions); | ||
this.addToIndex("" + myPath + path.sep + filename, this.svgOptions); | ||
} | ||
} else { | ||
if (stat.isFile()) { | ||
this.addToIndex(myPath, svgOptions); | ||
this.addToIndex(myPath, this.svgOptions); | ||
} | ||
@@ -75,3 +76,3 @@ } | ||
getMessage: function() { | ||
return "You have some files with this basename: " + (this.paths.join(', ')); | ||
return "You have some files with this basename: " + (this.filesIndex[basename].paths.join(', ')); | ||
}, | ||
@@ -86,4 +87,7 @@ paths: [this.filesIndex[basename].path, svg.path] | ||
}, | ||
get: function(identifier) { | ||
get: function(identifier, second) { | ||
var ids, link, ref, svg; | ||
if (second == null) { | ||
second = false; | ||
} | ||
ref = identifier.split('#'), link = ref[0], ids = 2 <= ref.length ? slice.call(ref, 1) : []; | ||
@@ -97,3 +101,9 @@ if (svg = this.filesIndex[link]) { | ||
} else { | ||
throw "'" + link + "' not found in SVG csche"; | ||
if (second) { | ||
throw "'" + link + "' not found in SVG csche (paths: " + (this.paths.join(', ')) + ")"; | ||
} else { | ||
identifier = (identifier.indexOf('.svg') === -1 ? identifier + ".svg" : identifier); | ||
this.addToIndex(identifier, this.svgOptions); | ||
return this.get(identifier, true); | ||
} | ||
} | ||
@@ -100,0 +110,0 @@ } |
{ | ||
"name": "postcss-svg", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Postcss plugin for insert inline SVG to CSS", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
#[postcss-svg](http://pavliko.github.io/postcss-svg/) | ||
[PostCSS](https://github.com/postcss/postcss) plug-in which to insert a built-in SVG and allows you to manage it colors. | ||
[PostCSS](https://github.com/postcss/postcss) plug-in which to insert inline SVG to CSS and allows you to manage it colors. | ||
Examples [here](http://pavliko.github.io/postcss-svg/#examples) | ||
@@ -4,0 +4,0 @@ |
Sorry, the diff of this file is not supported yet
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
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
54836
723
0