Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Commit

Permalink
Merge pull request #9951 from adobe/rlim/issue-9840
Browse files Browse the repository at this point in the history
Don't misidentify pseudo selector/element as a property while parsing CSS.
  • Loading branch information
redmunds committed Nov 18, 2014
2 parents 56662ba + 3b4db10 commit 5480341
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/language/CSSUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ define(function (require, exports, module) {

function _maybeProperty() {
return (/^-(moz|ms|o|webkit)-$/.test(token) ||
(state.state !== "top" && state.state !== "block" &&
(state.state !== "top" && state.state !== "block" && state.state !== "pseudo" &&
// Has a semicolon as in "rgb(0,0,0);", but not one of those after a LESS
// mixin parameter variable as in ".size(@width; @height)"
stream.string.indexOf(";") !== -1 && !/\([^)]+;/.test(stream.string)));
Expand Down
21 changes: 21 additions & 0 deletions test/spec/CSSUtils-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1298,6 +1298,27 @@ define(function (require, exports, module) {
expect(result.length).toBe(0);
});

it("should find selectors that are after a rule starting with a pseudo selector/element", function () {
var css = ":focus { color:red; } \n" +
"div { color:blue; } \n" +
"::selection { color:green; } \n" +
".Foo { color:black } \n" +
"#bar { color:blue } \n" +
"#baR { color:white }";

var result = match(css, { tag: "div" });
expect(result.length).toBe(1);

result = matchAgain({ clazz: "Foo" });
expect(result.length).toBe(1);

result = matchAgain({ id: "bar" });
expect(result.length).toBe(1);

result = matchAgain({ id: "baR" });
expect(result.length).toBe(1);
});

}); // describe("Simple selectors")


Expand Down

0 comments on commit 5480341

Please sign in to comment.