Skip to content

Commit 204817a

Browse files
committed
support providing an CSSErrorHandler
1 parent 9f6d76d commit 204817a

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>net.sourceforge.htmlunit</groupId>
66
<artifactId>htmlunit-cssparser</artifactId>
7-
<version>1.9.0</version>
7+
<version>1.10.0-SNAPSHOT</version>
88
<name>HtmlUnit CSS Parser</name>
99
<packaging>jar</packaging>
1010
<description>CSS parser for HtmlUnit.</description>

src/main/java/com/gargoylesoftware/css/dom/CSSStyleDeclarationImpl.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import org.w3c.dom.DOMException;
2222

23+
import com.gargoylesoftware.css.parser.CSSErrorHandler;
2324
import com.gargoylesoftware.css.parser.CSSOMParser;
2425
import com.gargoylesoftware.css.util.LangUtils;
2526
import com.gargoylesoftware.css.util.ThrowCssExceptionErrorHandler;
@@ -76,9 +77,19 @@ public String getCssText() {
7677
* @throws DOMException in case of error
7778
*/
7879
public void setCssText(final String cssText) throws DOMException {
80+
setCssText(cssText, ThrowCssExceptionErrorHandler.INSTANCE);
81+
}
82+
83+
/**
84+
* Sets the css text.
85+
* @param cssText the new css text
86+
* @param cssErrorHandler the CSSErrorHandler to be used
87+
* @throws DOMException in case of error
88+
*/
89+
public void setCssText(final String cssText, final CSSErrorHandler cssErrorHandler) throws DOMException {
7990
try {
8091
final CSSOMParser parser = new CSSOMParser();
81-
parser.setErrorHandler(ThrowCssExceptionErrorHandler.INSTANCE);
92+
parser.setErrorHandler(cssErrorHandler);
8293
properties_.clear();
8394
parser.parseStyleDeclaration(this, cssText);
8495
}
@@ -90,6 +101,7 @@ public void setCssText(final String cssText) throws DOMException {
90101
}
91102
}
92103

104+
93105
/**
94106
* @param propertyName the property name
95107
* @return the property value

0 commit comments

Comments
 (0)