Skip to content

feat: add IE filter support (AlphaImageLoader) #638

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions lib/processCss.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,20 @@ var parserPlugin = postcss.plugin("css-loader-parser", function(options) {
item.nodes.forEach(processNode);
break;
case "item":
if (item.name.indexOf('progid:DXImageTransform.Microsoft.AlphaImageLoader') >= 0){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment (in brief) here, describing what the following code/case is doing

delete item.innerSpacingBefore;
delete item.innerSpacingAfter;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\n

var matchSrc = item.name.match(/src=['"]([^'"]+)['"]/);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

matchSrc => match && \n

if (!matchSrc) break;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\n

var srcUrl = matchSrc[1];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

srcUrl => url && \n

if (options.url && !/^#/.test(srcUrl) && (isAlias(srcUrl) || loaderUtils.isUrlRequest(srcUrl, options.root))) {
item.name = item.name.replace(srcUrl, "___CSS_LOADER_URL___" + urlItems.length + "___");
urlItems.push({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

urlItems.push({ url: url })

url: srcUrl
});
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\n

break;
}
var importIndex = imports["$" + item.name];
if (typeof importIndex === "number") {
item.name = "___CSS_LOADER_IMPORT___" + importIndex + "___";
Expand Down
8 changes: 8 additions & 0 deletions test/urlTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,12 @@ describe("url", function() {
test("external schema-less url", ".class { background: green url(//raw.githubusercontent.com/webpack/media/master/logo/icon.png) xyz }", [
[1, ".class { background: green url(//raw.githubusercontent.com/webpack/media/master/logo/icon.png) xyz }", ""]
], "?-url");
test("filter ie AlphaImageLoader ",
".highlight { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\"http://example.com/image.jpg\", sizingMethod='scale'); }", [
[1, ".highlight { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\"http://example.com/image.jpg\", sizingMethod='scale'); }", ""]
], "?-url");
test("filter ie AlphaImageLoader relativePath",
".highlight { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\"./image.png\", sizingMethod='scale'); }", [
[1, ".highlight { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\"./image.png\", sizingMethod='scale'); }", ""]
], "?-url");
});