Skip to content
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

ie-specific property #15

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 5 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -20,6 +20,10 @@ function uniq(ar) {
}
return a
}
function escapeRegExp(str) {
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
}


function sqwish(css, strict) {
// allow /*! bla */ style comments to retain copyrights etc.
@@ -97,7 +101,7 @@ function strict_css(css) {
// pre-existing properties are not wanted anymore
return !declarations.some(function (dec) {
// must include '^' as to not confuse "color" with "border-color" etc.
return dec.match(new RegExp('^' + prop + ':'))
return dec.match(new RegExp('^' + escapeRegExp(prop) + ':'))
})
})

7 changes: 7 additions & 0 deletions tests/tests.js
Original file line number Diff line number Diff line change
@@ -71,6 +71,13 @@ sink('strict mode', function (test, ok) {
ok(actual == expected, 'collapsed duplicate into a single declaration')
})

test('ie-specific properties *prop', 1, function() {
var input = '.class {*display:block; display:inline-block;}'
,expected = '.class{display:inline-block;*display:block}'
console.log(sqwish.minify(input,true));
ok(sqwish.minify(input,true) == expected, 'ie-specific properties are tolerated')
})

})

start()