зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1419301 - Make HTML comments removal in prettifyCSS faster; r=tromey
MozReview-Commit-ID: LG8GKccRlXr --HG-- extra : rebase_source : 86eb5612f8264bbe4f765ab5baaea4db8c7a84a3
This commit is contained in:
Родитель
334f5f8700
Коммит
2036033118
|
@ -158,8 +158,13 @@ function prettifyCSS(text, ruleCount) {
|
|||
prettifyCSS.LINE_SEPARATOR = (os === "WINNT" ? "\r\n" : "\n");
|
||||
}
|
||||
|
||||
// remove initial and terminating HTML comments and surrounding whitespace
|
||||
text = text.replace(/(?:^\s*<!--[\r\n]*)|(?:\s*-->\s*$)/g, "");
|
||||
// Stylesheets may start and end with HTML comment tags (possibly with whitespaces
|
||||
// before and after). Remove those first. Don't do anything there aren't any.
|
||||
let trimmed = text.trim();
|
||||
if (trimmed.startsWith("<!--")) {
|
||||
text = trimmed.replace(/^<!--/, "").replace(/-->$/, "").trim();
|
||||
}
|
||||
|
||||
let originalText = text;
|
||||
text = text.trim();
|
||||
|
||||
|
|
|
@ -122,6 +122,24 @@ const TESTS_SPACE_INDENT = [
|
|||
"}",
|
||||
]
|
||||
},
|
||||
|
||||
{ name: "HTML comments with some whitespace padding",
|
||||
input: " \n\n\t <!--\n\n\t body {color:red} \n\n--> \t\n",
|
||||
expected: [
|
||||
"body {",
|
||||
" color:red",
|
||||
"}"
|
||||
]
|
||||
},
|
||||
|
||||
{ name: "HTML comments without whitespace padding",
|
||||
input: "<!--body {color:red}-->",
|
||||
expected: [
|
||||
"body {",
|
||||
" color:red",
|
||||
"}"
|
||||
]
|
||||
},
|
||||
];
|
||||
|
||||
function run_test() {
|
||||
|
|
Загрузка…
Ссылка в новой задаче