Skip to content

Commit 01425b1

Browse files
committed
content attribute value of a pseudo-attribute is no longer changed in lower case (issue #667)
1 parent 2bb9c15 commit 01425b1

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

src/changes/changes.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
<body>
1010
<release version="3.8.0" date="November xx, 2023" description="Chrome/Edge 119, Bugfixes">
11+
<action type="fix" dev="rbri" issue="#667">
12+
Content attribute value of a pseudo-attribute is no longer changed in lower case.
13+
</action>
1114
<action type="add" dev="René Schwietzke">
1215
Updated CSS3Parser pool implementation with a different concept to allow more pooling,
1316
lighter synchronization, and avoid leaks when not auto-closed. It also uses AutoCloseable

src/main/java/org/htmlunit/css/ComputedCssStyleDeclaration.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@ public String getStyleAttribute(final String name) {
214214
final StyleElement element = getStyleElement(name);
215215
if (element != null && element.getValue() != null) {
216216
final String value = element.getValue();
217-
if (!value.contains("url")) {
217+
if (!"content".equals(name)
218+
&& !value.contains("url")) {
218219
return org.htmlunit.util.StringUtils.toRootLowerCaseWithCache(value);
219220
}
220221
return value;

src/test/java/org/htmlunit/javascript/host/css/CSSStyleDeclarationTest.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3729,4 +3729,28 @@ public void item() throws Exception {
37293729

37303730
loadPageVerifyTitle2(html);
37313731
}
3732+
3733+
/**
3734+
* @throws Exception if the test fails
3735+
*/
3736+
@Test
3737+
@Alerts("\"abCD\"")
3738+
public void content() throws Exception {
3739+
final String html =
3740+
"<html>\n"
3741+
+ "</head>\n"
3742+
+ " <style type='text/css'>#myDiv::before { content: 'abCD' }</style>\n"
3743+
+ "</head>\n"
3744+
+ "<body>\n"
3745+
+ " <div id='myDiv'></div>\n"
3746+
+ " <script>\n"
3747+
+ LOG_TITLE_FUNCTION
3748+
+ " var myDiv = document.getElementById('myDiv');\n"
3749+
+ " var myDivStyle = window.getComputedStyle(myDiv, '::before');\n"
3750+
+ " log(myDivStyle.content);\n"
3751+
+ " </script>\n"
3752+
+ "</body></html>";
3753+
3754+
loadPageVerifyTitle2(html);
3755+
}
37323756
}

0 commit comments

Comments
 (0)