Skip to content

Commit 4fd6303

Browse files
authored
Merge pull request #113 from css-modules/remove-url
Remove url rewriting in favour of path resolving
2 parents 636c2c0 + f1c642d commit 4fd6303

File tree

2 files changed

+0
-53
lines changed

2 files changed

+0
-53
lines changed

src/index.js

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -177,14 +177,6 @@ function localizeDeclNode(node, context) {
177177
node = Object.create(node)
178178
node.nodes = newNodes
179179
break
180-
181-
case 'url':
182-
if (context.options && context.options.rewriteUrl) {
183-
newNode = Object.create(node)
184-
newNode.url = context.options.rewriteUrl(context.global, node.url)
185-
return newNode
186-
}
187-
break
188180
}
189181
return node
190182
}
@@ -345,15 +337,6 @@ module.exports = postcss.plugin(
345337
global: globalKeyframes
346338
})
347339
})
348-
} else if (atrule.nodes) {
349-
atrule.nodes.forEach(function(decl) {
350-
if (decl.type === 'decl') {
351-
localizeDecl(decl, {
352-
options: options,
353-
global: globalMode
354-
})
355-
}
356-
})
357340
}
358341
})
359342
css.walkRules(function(rule) {

test.js

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -377,42 +377,6 @@ const tests = [
377377
input: '[type="radio"] {}',
378378
expected: '[type="radio"] {}'
379379
},
380-
{
381-
should: 'not modify urls without option',
382-
input: '.a { background: url(./image.png); }\n' +
383-
':global .b { background: url(image.png); }\n' +
384-
'.c { background: url("./image.png"); }',
385-
expected: ':local(.a) { background: url(./image.png); }\n' +
386-
'.b { background: url(image.png); }\n' +
387-
':local(.c) { background: url("./image.png"); }'
388-
},
389-
{
390-
should: 'rewrite url in local block',
391-
input: '.a { background: url(./image.png); }\n' +
392-
':global .b { background: url(image.png); }\n' +
393-
'.c { background: url("./image.png"); }\n' +
394-
'.d { background: -webkit-image-set(url("./image.png") 1x, url("./image2x.png") 2x); }\n' +
395-
'@font-face { src: url("./font.woff"); }\n' +
396-
'@-webkit-font-face { src: url("./font.woff"); }\n' +
397-
'@media screen { .a { src: url("./image.png"); } }\n' +
398-
'@keyframes :global(ani1) { 0% { src: url("image.png"); } }\n' +
399-
'@keyframes ani2 { 0% { src: url("./image.png"); } }',
400-
options: {
401-
rewriteUrl: function(global, url) {
402-
var mode = global ? 'global' : 'local'
403-
return '(' + mode + ')' + url + '"' + mode + '"'
404-
}
405-
},
406-
expected: ':local(.a) { background: url((local\\)./image.png\\"local\\"); }\n' +
407-
'.b { background: url((global\\)image.png\\"global\\"); }\n' +
408-
':local(.c) { background: url("(local)./image.png\\"local\\""); }\n' +
409-
':local(.d) { background: -webkit-image-set(url("(local)./image.png\\"local\\"") 1x, url("(local)./image2x.png\\"local\\"") 2x); }\n' +
410-
'@font-face { src: url("(local)./font.woff\\"local\\""); }\n' +
411-
'@-webkit-font-face { src: url("(local)./font.woff\\"local\\""); }\n' +
412-
'@media screen { :local(.a) { src: url("(local)./image.png\\"local\\""); } }\n' +
413-
'@keyframes ani1 { 0% { src: url("(global)image.png\\"global\\""); } }\n' +
414-
'@keyframes :local(ani2) { 0% { src: url("(local)./image.png\\"local\\""); } }'
415-
},
416380
{
417381
should: 'not crash on atrule without nodes',
418382
input: '@charset "utf-8";',

0 commit comments

Comments
 (0)