Skip to content

Commit bac284c

Browse files
author
iwx
committed
增加针对background后缀含有'?__spriter'才去做spriter
1 parent c8b2ccb commit bac284c

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lib/map-over-styles-and-transform-background-image-declarations.js

+9-6
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,18 @@ function mapOverStylesAndTransformAllBackgroundImageDeclarations(styles, cb) {
4545
var transformedDeclaration = extend(true, {}, declaration);
4646
transformedDeclaration = attachInfoToDeclaration(declarations, declarationIndex);
4747

48-
// background-image always has a url
49-
if(transformedDeclaration.property === 'background-image') {
48+
// background-image always has a url且判断url是否有?__spriter后缀
49+
if(transformedDeclaration.property === 'background-image' && /\?__spriter/i.test(transformedDeclaration.value)){
50+
transformedDeclaration.value=transformedDeclaration.value.replace('?__spriter','');
5051
return cb(transformedDeclaration, declarationIndex, declarations);
5152
}
52-
// Background is a shorthand property so make sure `url()` is in there
53-
else if(transformedDeclaration.property === 'background') {
54-
var hasImageValue = spriterUtil.backgroundURLRegex.test(transformedDeclaration.value);
53+
// Background is a shorthand property so make sure `url()` is in there 且判断url是否有?__spriter后缀
54+
else if(transformedDeclaration.property === 'background' && /\?__spriter/i.test(transformedDeclaration.value)){
5555

56-
if(hasImageValue) {
56+
transformedDeclaration.value = transformedDeclaration.value.replace('?__spriter','');
57+
varhasImageValue = spriterUtil.backgroundURLRegex.test(transformedDeclaration.value);
58+
59+
if(hasImageValue){
5760
return cb(transformedDeclaration, declarationIndex, declarations);
5861
}
5962
}

0 commit comments

Comments
 (0)