mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-15 06:15:43 +00:00
Bug 1323713 - fix prettify CSS error when encountering extra closing brace;r=tromey
MozReview-Commit-ID: 5TAxEP5561K --HG-- extra : rebase_source : 41fdc014c018d2f2611e698a2292d15978e49df8
This commit is contained in:
parent
49420991ca
commit
4a16348236
@ -284,7 +284,11 @@ function prettifyCSS(text, ruleCount) {
|
||||
}
|
||||
|
||||
if (isCloseBrace) {
|
||||
indent = TAB_CHARS.repeat(--indentLevel);
|
||||
// Even if the stylesheet contains extra closing braces, the indent level should
|
||||
// remain > 0.
|
||||
indentLevel = Math.max(0, indentLevel - 1);
|
||||
|
||||
indent = TAB_CHARS.repeat(indentLevel);
|
||||
result = result + indent + "}";
|
||||
}
|
||||
|
||||
|
@ -49,6 +49,19 @@ const TESTS = [
|
||||
"}"
|
||||
]
|
||||
},
|
||||
|
||||
{ name: "CSS with extra closing brace",
|
||||
input: "body{margin:0}} div{color:red}",
|
||||
expected: [
|
||||
"body {",
|
||||
"\tmargin:0",
|
||||
"}",
|
||||
"}",
|
||||
"div {",
|
||||
"\tcolor:red",
|
||||
"}",
|
||||
]
|
||||
},
|
||||
];
|
||||
|
||||
function run_test() {
|
||||
|
Loading…
Reference in New Issue
Block a user