Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Commit

Permalink
Merge pull request #8057 from HighwayChile/highway/issue-8028
Browse files Browse the repository at this point in the history
made whitespace character optional
  • Loading branch information
redmunds committed Jun 16, 2014
2 parents ee20b54 + c8cf483 commit 138e963
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/extensions/default/QuickView/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ define(function (require, exports, module) {

// Check for gradient. -webkit-gradient() can have parens in parameters
// nested 2 levels. Other gradients can only nest 1 level.
var gradientRegEx = /-webkit-gradient\((?:[^\(]*?(?:\((?:[^\(]*?(?:\([^\)]*?\))*?)*?\))*?)*?\)|(?:(?:-moz-|-ms-|-o-|-webkit-|\s)((repeating-)?linear-gradient)|(?:-moz-|-ms-|-o-|-webkit-|\s)((repeating-)?radial-gradient))(\((?:[^\)]*?(?:\([^\)]*?\))*?)*?\))/gi,
var gradientRegEx = /-webkit-gradient\((?:[^\(]*?(?:\((?:[^\(]*?(?:\([^\)]*?\))*?)*?\))*?)*?\)|(?:(?:-moz-|-ms-|-o-|-webkit-|:|\s)((repeating-)?linear-gradient)|(?:-moz-|-ms-|-o-|-webkit-|:|\s)((repeating-)?radial-gradient))(\((?:[^\)]*?(?:\([^\)]*?\))*?)*?\))/gi,
colorRegEx = new RegExp(ColorUtils.COLOR_REGEX);

function areParensBalanced(str) {
Expand Down
14 changes: 14 additions & 0 deletions src/extensions/default/QuickView/unittest-files/test.css
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,17 @@ background: -ms-linear-gradient(top, #d2dfed 0%,#c8d7eb 26%,#bed0ea 51%,#a6c0e3
background-image: repeating-linear-gradient(red, blue 20px, red 40px);
background-image: repeating-radial-gradient(red, blue 20px, red 40px);
}

.whitespaceCheck_linear_gradient {
background : linear-gradient(to bottom, black 0%, white 100%);
background: linear-gradient(to bottom, black 0%, white 100%);
background :linear-gradient(to bottom, black 0%, white 100%);
background:linear-gradient(to bottom, black 0%, white 100%);
}

.whitespaceCheck_radial_gradient {
background : radial-gradient(red, white 50%, blue 100%);
background: radial-gradient(red, white 50%, blue 100%);
background :radial-gradient(red, white 50%, blue 100%);
background:radial-gradient(red, white 50%, blue 100%);
}
22 changes: 21 additions & 1 deletion src/extensions/default/QuickView/unittests.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,27 @@ define(function (require, exports, module) {
checkGradientAtPos(expectedGradient4, 90, 36); // test parameters with 2 levels of nested parens
});
});


it("Should show linear gradient preview for those with colon or space before", function () {
runs(function () {
var expectedGradient = "linear-gradient(to bottom, black 0%, white 100%)";
checkGradientAtPos(expectedGradient, 169, 25); // space colon space
checkGradientAtPos(expectedGradient, 170, 25); // colon space
checkGradientAtPos(expectedGradient, 171, 25); // space colon
checkGradientAtPos(expectedGradient, 172, 25); // colon
});
});

it("Should show radial gradient preview for those with colon or space before", function () {
runs(function () {
var expectedGradient = "radial-gradient(red, white 50%, blue 100%)";
checkGradientAtPos(expectedGradient, 176, 25); // space colon space
checkGradientAtPos(expectedGradient, 177, 25); // colon space
checkGradientAtPos(expectedGradient, 178, 25); // space colon
checkGradientAtPos(expectedGradient, 179, 25); // colon
});
});

it("Should show linear gradient preview for those with w3c standard syntax (no prefix)", function () {
runs(function () {
checkGradientAtPos("linear-gradient(#333, #CCC)", 99, 50);
Expand Down

0 comments on commit 138e963

Please sign in to comment.