assetgraph-sprite
Advanced tools
Comparing version 0.4.0 to 0.5.0
@@ -35,3 +35,3 @@ var queryString = require('querystring'), | ||
canvas.toBuffer(passError(cb, function (pngBuffer) { | ||
cb(null, new AssetGraph.assets.Png({ | ||
cb(null, new AssetGraph.Png({ | ||
rawSrc: pngBuffer | ||
@@ -45,3 +45,3 @@ })); | ||
}).on('end', function () { | ||
cb(null, new AssetGraph.assets.Jpeg({ | ||
cb(null, new AssetGraph.Jpeg({ | ||
rawSrc: Buffer.concat(jpegChunks) | ||
@@ -86,2 +86,17 @@ })); | ||
function extractInfoFromCssRule(cssRule, propertyNamePrefix) { | ||
var info = {}; | ||
for (var i = 0 ; i < cssRule.style.length ; i += 1) { | ||
var propertyName = cssRule.style[i]; | ||
if (!propertyNamePrefix || propertyName.indexOf(propertyNamePrefix) === 0) { | ||
var keyName = propertyName.substr(propertyNamePrefix.length).replace(/-([a-z])/g, function ($0, $1) { | ||
return $1.toUpperCase(); | ||
}); | ||
info[keyName] = cssRule.style[propertyName].replace(/^([\'\"])(.*)\1$/, "$2"); | ||
} | ||
} | ||
return info; | ||
}; | ||
module.exports = function () { | ||
@@ -120,3 +135,3 @@ return function spriteBackgroundImages(assetGraph, cb) { | ||
assetGraph.findAssets({type: 'Css'}).forEach(function (cssAsset) { | ||
AssetGraph.assets.Css.eachRuleInParseTree(cssAsset.parseTree, function (cssRule) { | ||
cssAsset.eachRuleInParseTree(function (cssRule) { | ||
if (cssRule.type !== 1) { // cssom.CSSRule.STYLE_RULE | ||
@@ -126,3 +141,3 @@ return; | ||
if (('-sprite-selector-for-group') in cssRule.style) { | ||
var spriteInfo = AssetGraph.assets.Css.extractInfoFromRule(cssRule, '-sprite-'), | ||
var spriteInfo = extractInfoFromCssRule(cssRule, '-sprite-'), | ||
spriteGroupName = spriteInfo.selectorForGroup; | ||
@@ -206,3 +221,3 @@ if ('location' in spriteInfo) { | ||
var cssRule = spriteGroup.placeHolder.cssRule, | ||
relation = new AssetGraph.relations.CssImage({ | ||
relation = new AssetGraph.CssImage({ | ||
cssRule: cssRule, | ||
@@ -291,3 +306,3 @@ from: spriteGroup.placeHolder.asset, | ||
// matched by the sprite group's "main" selector, which would have been preferable. | ||
var relation = new AssetGraph.relations.CssImage({ | ||
var relation = new AssetGraph.CssImage({ | ||
cssRule: incomingRelation.cssRule, | ||
@@ -294,0 +309,0 @@ propertyName: incomingRelation.propertyName, |
@@ -5,3 +5,3 @@ { | ||
"repository": "git://github.com/One-com/assetgraph-sprite.git", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"maintainers": [ | ||
@@ -8,0 +8,0 @@ { |
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
49540
794
0