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

Commit 5480341

Browse files
committed
Merge pull request #9951 from adobe/rlim/issue-9840
Don't misidentify pseudo selector/element as a property while parsing CSS.
2 parents 56662ba + 3b4db10 commit 5480341

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/language/CSSUtils.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ define(function (require, exports, module) {
844844

845845
function _maybeProperty() {
846846
return (/^-(moz|ms|o|webkit)-$/.test(token) ||
847-
(state.state !== "top" && state.state !== "block" &&
847+
(state.state !== "top" && state.state !== "block" && state.state !== "pseudo" &&
848848
// Has a semicolon as in "rgb(0,0,0);", but not one of those after a LESS
849849
// mixin parameter variable as in ".size(@width; @height)"
850850
stream.string.indexOf(";") !== -1 && !/\([^)]+;/.test(stream.string)));

test/spec/CSSUtils-test.js

+21
Original file line numberDiff line numberDiff line change
@@ -1298,6 +1298,27 @@ define(function (require, exports, module) {
12981298
expect(result.length).toBe(0);
12991299
});
13001300

1301+
it("should find selectors that are after a rule starting with a pseudo selector/element", function () {
1302+
var css = ":focus { color:red; } \n" +
1303+
"div { color:blue; } \n" +
1304+
"::selection { color:green; } \n" +
1305+
".Foo { color:black } \n" +
1306+
"#bar { color:blue } \n" +
1307+
"#baR { color:white }";
1308+
1309+
var result = match(css, { tag: "div" });
1310+
expect(result.length).toBe(1);
1311+
1312+
result = matchAgain({ clazz: "Foo" });
1313+
expect(result.length).toBe(1);
1314+
1315+
result = matchAgain({ id: "bar" });
1316+
expect(result.length).toBe(1);
1317+
1318+
result = matchAgain({ id: "baR" });
1319+
expect(result.length).toBe(1);
1320+
});
1321+
13011322
}); // describe("Simple selectors")
13021323

13031324

0 commit comments

Comments
 (0)