Hi,

I'm trying to use Node.hasAttributes to determine if an xml node has
attributes but I've got an issue using it :

if my node n is not an Element, the code below will throw an exception :

if(n.hasAttributes()){
   // doing something with its attributes
}

throwing com.google.gwt.core.client.JavaScriptException: (TypeError):
jsObject.attributes is null

Of course I can catch this exception and deduct that this node has no
attributes but this is the goal of hasAttributes to determine it.

Then the hasAttributes implementation could be :

static native boolean hasAttributes(JavaScriptObject jsObject) /*-{
     try{
         return jsObject.attributes.length != 0;
     }catch(exception){
         return false;
     }
}-*/;

By this way, asAttributes will always returns a result.

Is this a good idea or am I wrong in this use ?

-- 
Damien Picard
Axeiya Services : http://axeiya.com/
gwt-ckeditor : http://code.google.com/p/gwt-ckeditor/

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to