Skip to content

Commit 293adfa

Browse files
committed
'.only' is a valid class name (see #36)
1 parent f60e5c6 commit 293adfa

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

src/main/javacc/CSS3Parser.jj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1212,7 +1212,7 @@ Condition _class(boolean pseudoElementFound) :
12121212
locator = createLocator(token);
12131213
}
12141214

1215-
( t = <IDENT> | t = <INHERIT> )
1215+
( t = <IDENT> | t = <INHERIT> | t = <ONLY> )
12161216
{
12171217
if (pseudoElementFound) { throw pe; }
12181218
return new ClassCondition(unescape(t.image, false), locator);

src/test/java/org/htmlunit/cssparser/parser/CSS3ParserTest.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ public void selector() throws Exception {
107107
SelectorType.ELEMENT_NODE_SELECTOR);
108108
selectorType("h1 a", SelectorType.DESCENDANT_SELECTOR, SelectorType.ELEMENT_NODE_SELECTOR,
109109
SelectorType.ELEMENT_NODE_SELECTOR);
110+
111+
selectorType(".inherit", SelectorType.ELEMENT_NODE_SELECTOR);
112+
selectorType(".only", SelectorType.ELEMENT_NODE_SELECTOR);
110113
}
111114

112115
/**
@@ -223,6 +226,9 @@ public void condition() throws Exception {
223226
conditionType(".class:link", ConditionType.CLASS_CONDITION, ConditionType.PSEUDO_CLASS_CONDITION);
224227
conditionType(".class", ConditionType.CLASS_CONDITION);
225228
conditionType(":link", ConditionType.PSEUDO_CLASS_CONDITION);
229+
230+
conditionType(".inherit", ConditionType.CLASS_CONDITION);
231+
conditionType(".only", ConditionType.CLASS_CONDITION);
226232
}
227233

228234
/**
@@ -4217,7 +4223,7 @@ public void realStackoverflow() throws Exception {
42174223
+ "screen and (max-height: 750px);"
42184224
+ "screen and (max-width: 1090px);"
42194225
+ "screen and (max-width: 920px);";
4220-
realWorld("realworld/all.css", 5235, 12401, media, 2, 2);
4226+
realWorld("realworld/all.css", 5237, 12403, media, 0, 0);
42214227
}
42224228

42234229
/**
@@ -4542,6 +4548,23 @@ public void inheritClassName() throws Exception {
45424548
assertEquals("*.inherit { color: red; }", rule.getCssText());
45434549
}
45444550

4551+
/**
4552+
* @throws Exception if the test fails
4553+
*/
4554+
@Test
4555+
public void onlyClassName() throws Exception {
4556+
final String css = ".only { color: red }\n";
4557+
4558+
final CSSStyleSheetImpl sheet = parse(css);
4559+
final CSSRuleListImpl rules = sheet.getCssRules();
4560+
4561+
assertEquals(1, rules.getLength());
4562+
4563+
final AbstractCSSRuleImpl rule = rules.getRules().get(0);
4564+
assertEquals("*.only { color: red; }", rule.toString());
4565+
assertEquals("*.only { color: red; }", rule.getCssText());
4566+
}
4567+
45454568
//
45464569
// /**
45474570
// * @throws Exception if any error occurs

0 commit comments

Comments
 (0)