Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 323929 - [api] Class cast exception in org.eclipse.wst.css.core.internal.document.CSSSelector.getParentElement(Element)
Summary: [api] Class cast exception in org.eclipse.wst.css.core.internal.document.CSSS...
Status: CLOSED FIXED
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: wst.css (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2.3   Edit
Assignee: Sarika Sinha CLA
QA Contact: Nick Sandonato CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-30 01:31 EDT by Sarika Sinha CLA
Modified: 2011-01-07 16:26 EST (History)
1 user (show)

See Also:


Attachments
Patch to replace class cast exception with instanceof check in cssselector (1.05 KB, patch)
2010-08-30 01:40 EDT, Sarika Sinha CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sarika Sinha CLA 2010-08-30 01:31:49 EDT
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.
Comment 1 Sarika Sinha CLA 2010-08-30 01:40:26 EDT
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
Comment 2 Nick Sandonato CLA 2010-09-28 14:01:56 EDT
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.
Comment 3 Nick Sandonato CLA 2010-09-28 14:09:15 EDT
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.
Comment 4 Sarika Sinha CLA 2010-09-29 01:01:59 EDT
Thanks Nick.