开发者

How do I create a documentFragment in GWT?

开发者 https://www.devze.com 2023-01-16 03:59 出处:网络
Creating a document fragment using plain Javascript is dead simple: var docFragment = document.createDocumentFragment();.

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.


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).


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号