Community
Participate
Working Groups
Build Identifier: M20100811-0800 Instead of throwing Class cast exception, instance of check can be added to increase performance of css traversal. Reproducible: Sometimes Steps to Reproduce: 1.While trying to get the default style ofa page where css is applied,class cast exception comes sometime. This can be replaced by instance of check.
Created attachment 177700 [details] Patch to replace class cast exception with instanceof check in cssselector This patch replace the throwing of class cast exception with instance of check in cssSelector.getParentElement
Hi, Sarika. Patch looks good overall. The one change I made was just a simplification of the if statement to be if(parent instanceof Element) since null is not an instance of Element, it would fail the check anyway. Thanks for the fix.
Actually, it looks like Nitin released a fix yesterday that accomplished this change. His is slightly different though, but doesn't use the instanceof check. instead it uses Node#getNodeType() == Node.ELEMENT_NODE. Thanks for the patch, though.
Thanks Nick.