Bug 1222291 - change getRuleText to handle token-less rules; r=bgrins

This commit is contained in:
Tom Tromey 2015-11-09 12:27:00 +01:00
Родитель 903b8a7a0e
Коммит 5e926a6a07
2 изменённых файлов: 14 добавлений и 0 удалений

Просмотреть файл

@ -2084,6 +2084,13 @@ function getRuleText(initialText, line, column) {
if (startOffset === undefined) {
return {offset: 0, text: ""};
}
// If the input didn't have any tokens between the braces (e.g.,
// "div {}"), then the endOffset won't have been set yet; so account
// for that here.
if (endOffset === undefined) {
endOffset = startOffset;
}
// Note that this approach will preserve comments, despite the fact
// that cssTokenizer skips them.
return {offset: textOffset + startOffset,

Просмотреть файл

@ -100,6 +100,13 @@ const TEST_DATA = [
column: 4,
expected: {offset: 7, text: "border:1px solid red;content: '}';color:red;"}
},
{
desc: "Rule contains no tokens",
input: "div{}",
line: 1,
column: 1,
expected: {offset: 4, text: ""}
},
];
function run_test() {