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 1 commit
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
Next Next commit
ie-specific *property support
shepik committed Dec 15, 2012
commit 2c3cf84121d561754a20142efce7615576a16281
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) + ':'))
})
})

6 changes: 6 additions & 0 deletions tests/tests.js
Original file line number Diff line number Diff line change
@@ -54,6 +54,12 @@ sink('basic mode', function (test, ok) {

})

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

})

sink('strict mode', function (test, ok) {