Menu

#616 Class cast exception in Stylesheet selector

2.0
closed
None
5
2012-10-21
2008-05-08
jrustine
No

Weird error, completely reproducible, requiring minor code change...

We have a page with a child combinator in the CSS that throws a class cast exception during a JavaScript function that iterates up the offset parent of the DOM. You can open up the attached sample HTML page using the WebClient to reproduce.

It reaches the HtmlHtml element on the page and attempts to get its parent. The following code snippet in the selects() function of the Stylesheet class does a check and fixes it for us locally:

case Selector.SAC_CHILD_SELECTOR:
final DescendantSelector cs = (DescendantSelector) selector;
if (element.getParentNode() instanceof HtmlElement) {
final HtmlElement parent = (HtmlElement) element.getParentNode();
return selects(cs.getSimpleSelector(), element) && parent != null
&& selects(cs.getAncestorSelector(), parent);
} else {
return false;
}

Discussion

  • jrustine

    jrustine - 2008-05-08

    Reproduces class cast exception in Stylesheet class.

     
  • Marc Guillemot

    Marc Guillemot - 2008-05-09

    Logged In: YES
    user_id=402164
    Originator: NO

    Now fixed in SVN. Thanks for reporting.

     

Log in to post a comment.