Skip to content

Commit

Permalink
Bug 1478184 - fix handling of html comments in parseDeclarations; r=gl
Browse files Browse the repository at this point in the history
parseDeclarations was ignoring html comment tokens, but in fact they
should not be treated any differently from other CSS tokens.

MozReview-Commit-ID: 27Mxt5zbSSJ

--HG--
extra : amend_source : 91e47bbf6951ac9dd4709ac10c49ff51c1781ce8
  • Loading branch information
tromey committed Aug 7, 2018
1 parent 1617b3d commit 1ca6fd6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
10 changes: 5 additions & 5 deletions devtools/client/shared/test/unit/test_parseDeclarations.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,15 +374,15 @@ const TEST_DATA = [
offsets: [3, 30], commentOffsets: [0, 33]}]
},

// HTML comments are ignored.
// HTML comments are not special -- they are just ordinary tokens.
{
parseComments: true,
input: "<!-- color: red; --> color: blue;",
expected: [
{name: "color", value: "red", priority: "",
offsets: [5, 16]},
{name: "color", value: "blue", priority: "",
offsets: [21, 33]}]
{name: "<!-- color", value: "red", priority: "",
offsets: [0, 16]},
{name: "--> color", value: "blue", priority: "",
offsets: [17, 33]}]
},

// Don't error on an empty comment.
Expand Down
6 changes: 0 additions & 6 deletions devtools/shared/css/parsing-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,6 @@ function parseDeclarationsInternal(isCssPropertyKnown, inputString,
break;
}

// Ignore HTML comment tokens (but parse anything they might
// happen to surround).
if (token.tokenType === "htmlcomment") {
continue;
}

// Update the start and end offsets of the declaration, but only
// when we see a significant token.
if (token.tokenType !== "whitespace" && token.tokenType !== "comment") {
Expand Down

0 comments on commit 1ca6fd6

Please sign in to comment.