Skip to content

Commit

Permalink
Ensure - is not used as an identifier
Browse files Browse the repository at this point in the history
`-` is not a valid identifier, so it must be either escaped as `\-` or used as a string (i.e. wrapped in quotes).

Ref. c5095eb.
Ref. #73.
  • Loading branch information
mathiasbynens committed Jan 14, 2016
1 parent 42582aa commit f4e9244
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/compressor/compress/Attribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var escapesRx = /\\([0-9A-Fa-f]{1,6})[ \t\n\f\r]?|\\./g;
var blockUnquoteRx = /^(-?\d|--)|[\u0000-\u002c\u002e\u002f\u003A-\u0040\u005B-\u005E\u0060\u007B-\u009f]/;

function canUnquote(value) {
if (!value) {
if (value === '' || value === '-') {
return;
}

Expand Down
1 change: 1 addition & 0 deletions test/fixture/compress/attrib.string/1.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[title="test"],
[title="123"],
[title="test test"],
[title="-"],
[title=""]
{
p: v;
Expand Down
2 changes: 1 addition & 1 deletion test/fixture/compress/attrib.string/1.min.css
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[title=""],[title="123"],[title="test test"],[title=test]{p:v}
[title=""],[title="-"],[title="123"],[title="test test"],[title=test]{p:v}
1 change: 1 addition & 0 deletions test/fixture/compress/attrib.string/2.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[title='test'],
[title='123'],
[title='test test'],
[title='-'],
[title='']
{
p: v;
Expand Down
2 changes: 1 addition & 1 deletion test/fixture/compress/attrib.string/2.min.css
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[title=''],[title='123'],[title='test test'],[title=test]{p:v}
[title=''],[title='-'],[title='123'],[title='test test'],[title=test]{p:v}

0 comments on commit f4e9244

Please sign in to comment.