views:

42

answers:

2

Creating a document fragment using plain Javascript is dead simple: var docFragment = document.createDocumentFragment();.
However, in GWT, this does not appear to be available, though there is a DocumentFragment interface in package com.google.gwt.xml.client that does not appear to be applicable. Does anyone know of a way, either using the aforementioned interface, or creating a class with a simple JSNI method that creates the documentFragment?

Thanks.

A: 

Creating a JSNI method returning a DocumentFragment is dead simple.. you just return document.createDocumentFragment(); :) The JSNI method should either return JavaScriptObject or some other type that you know will work (like Node - I'm not sure were you are going with this, but JSOs work that way - you can cast<T>() any subclass of JavaScriptObject to any other JavaScriptObject).

Igor Klimer
A: 

This particular question is addressed (with a workaround similar to Klimer's suggestion) in "Issue 2955: Not able to create a document fragment object for dom" on GWT's issue tracker.

You could also contribute to this ticket and "star" the issue to show your interest in seeing this added to the GWT framework.

haylem