Skip to content

Commit

Permalink
A Test which indicates that the gHorizontalPercentageRegExp Regexp is…
Browse files Browse the repository at this point in the history
… too greedy and a fix for the pattern which might not be optimal

See http://core.trac.wordpress.org/ticket/26181
  • Loading branch information
dd32 authored and nacin committed Dec 4, 2013
1 parent 15d6b6d commit 964f83f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/cssjanus.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function CSSJanus() {
cursorWestRegExp = new RegExp( nonLetterPattern + '([ns]?)w-resize', 'gi' ),
fourNotationQuantRegExp = new RegExp( fourNotationQuantPropsPattern + signedQuantPattern + '(\\s+)' + signedQuantPattern + '(\\s+)' + signedQuantPattern + '(\\s+)' + signedQuantPattern, 'gi' ),
fourNotationColorRegExp = new RegExp( fourNotationColorPropsPattern + colorPattern + '(\\s+)' + colorPattern + '(\\s+)' + colorPattern + '(\\s+)' + colorPattern, 'gi' ),
bgHorizontalPercentageRegExp = new RegExp( '(background(?:-position)?\\s*:\\s*[^%]*?)(-?' + numPattern + ')(%\\s*(?:' + quantPattern + '|' + identPattern + '))', 'gi' ),
bgHorizontalPercentageRegExp = new RegExp( '(background(?:-position)?\\s*:\\s*[^%:;}]*?)(-?' + numPattern + ')(%\\s*(?:' + quantPattern + '|' + identPattern + '))', 'gi' ),
bgHorizontalPercentageXRegExp = new RegExp( '(background-position-x\\s*:\\s*)(-?' + numPattern + ')(%)', 'gi' ),
borderRadiusRegExp = new RegExp( '(border-radius\\s*:\\s*)([^;]*)', 'gi' );

Expand Down
9 changes: 9 additions & 0 deletions test/cssjanus.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,15 @@ var tests = {
flip( '.foo { background: 100% 20% } .bar { background: 60% 30% }' ),
'.foo { background: 0% 20% } .bar { background: 40% 30% }'
);
// Test that it doesn't modify other styles
assert.equal(
flip( '.foo { background: #777 } .bar{ margin: 0 5% 4% 0 }' ),
'.foo { background: #777 } .bar{ margin: 0 0 4% 5% }'
);
assert.equal(
flip( '.foo { background: #777; margin: 0 5% 4% 0 }' ),
'.foo { background: #777; margin: 0 0 4% 5% }'
);
},
'leaves class names alone': function() {
// Makes sure we don't unnecessarily destroy classnames with tokens in them.
Expand Down

0 comments on commit 964f83f

Please sign in to comment.