Css: Change java.lang.String.charAt to JsString_.charAt [#741]

staging
gnosygnu 4 years ago
parent 27756f8056
commit 1103674d88

@ -107,7 +107,7 @@ public class XoCssMin {
// ! in the first position of the comment means preserve
// so push to the preserved tokens keeping the !
if (token.charAt(0) == '!') {
if (JsString_.charAtEq(token, 0, '!')) {
preservedTokens.add(token);
css = css.replace(placeholder, "___YUICSSMIN_PRESERVED_TOKEN_" + (preservedTokens.size() - 1) + "___");
continue;
@ -115,7 +115,7 @@ public class XoCssMin {
// \ in the last position looks like hack for Mac/IE5
// shorten that to /*\*/ and the next one to /**/
if (token.charAt(token.length() - 1) == '\\') {
if (JsString_.charAtEq(token, token.length() - 1, '\\')) {
preservedTokens.add("\\");
css = css.replace(placeholder, "___YUICSSMIN_PRESERVED_TOKEN_" + (preservedTokens.size() - 1) + "___");
i = i + 1; // attn: advancing the loop
@ -129,7 +129,7 @@ public class XoCssMin {
if (token.length() == 0) {
startIndex = css.indexOf(placeholder);
if (startIndex > 2) {
if (css.charAt(startIndex - 3) == '>') {
if (JsString_.charAtEq(css, startIndex - 3, '>')) {
preservedTokens.add("");
css = css.replace(placeholder, "___YUICSSMIN_PRESERVED_TOKEN_" + (preservedTokens.size() - 1) + "___");
}
@ -267,7 +267,7 @@ public class XoCssMin {
// XO: desb42 comments this
while (i < css.length()) {
i = i + 1;
if (css.charAt(i - 1) == '}' && i - startIndex > linebreakpos) {
if (JsString_.charAtEq(css, i - 1, '}') && i - startIndex > linebreakpos) {
css = JsString_.slice(css, 0, i) + '\n' + JsString_.slice(css, i);
startIndex = i;
}
@ -326,7 +326,7 @@ public class XoCssMin {
endIndex = css.indexOf(terminator, endIndex + 1);
// endIndex == 0 doesn't really apply here
if ((endIndex > 0) && (css.charAt(endIndex - 1) != '\\')) {// XO:found terminator; check it isn't escaped; EX: `\'`
if ((endIndex > 0) && JsString_.charAtEqNot(css, endIndex - 1, '\\')) {// XO:found terminator; check it isn't escaped; EX: `\'`
foundTerminator = true;
if (!(")".equals(terminator))) {// XO:cur terminator is either `'` or `"`; grab next `)`
endIndex = css.indexOf(")", endIndex);

@ -61,6 +61,16 @@ public class XoCssMinTest {
)
);
}
@Test public void commentsEmpty() {// PURPOSE:handle empty comments; ISSUE#:741 DATE:2020-06-08
tstr.Test("collectComments.empty"
, "a /**/ b"
, "a b" // NOTE: `\s` instead of `\s\s` b/c of "Normalize all whitespace strings to single spaces"
, new TestAssert.Grp("collectComments"
, new TestAssert.ListEq("comments", "")
, new TestAssert.StringEq("css", "a /*___YUICSSMIN_PRESERVE_CANDIDATE_COMMENT_0___*/ b")
)
);
}
@Test public void rgb() {
tstr.Test("rgb.basic" ,"rgb (128,128,128)", "#808080");
tstr.Test("rgb.casing" ,"RgB (128,128,128)", "#808080");

Loading…
Cancel
Save