All done. Another look?
http://gwt-code-reviews.appspot.com/1450810/diff/5006/user/src/com/google/gwt/user/client/ui/PotentialElement.java
File user/src/com/google/gwt/user/client/ui/PotentialElement.java
(right):
http://gwt-code-reviews.appspot.com/1450810/diff/5006/user/src/com/google/gwt/user/client/ui/PotentialElement.java#newcode38
user/src/com/google/gwt/user/client/ui/PotentialElement.java:38: public
class PotentialElement extends JavaScriptObject {
On 2011/06/02 20:10:43, rjrjr wrote:
Should extend Element.
Done.
http://gwt-code-reviews.appspot.com/1450810/diff/5006/user/src/com/google/gwt/user/client/ui/PotentialElement.java#newcode46
user/src/com/google/gwt/user/client/ui/PotentialElement.java:46: public
static native Element build(UIObject o) /*-{
On 2011/06/02 20:10:43, rjrjr wrote:
When PotentialElement extends Element, you can return PotentialElement
here.
Need to fix the first sentence of the javadoc accordingly.
Done.
http://gwt-code-reviews.appspot.com/1450810/diff/5006/user/src/com/google/gwt/user/client/ui/PotentialElement.java#newcode47
user/src/com/google/gwt/user/client/ui/PotentialElement.java:47: return
{
On 2011/06/02 20:10:43, rjrjr wrote:
Pass this through Element.as() for sanity check.
Done.
http://gwt-code-reviews.appspot.com/1450810/diff/5006/user/src/com/google/gwt/user/client/ui/PotentialElement.java#newcode53
user/src/com/google/gwt/user/client/ui/PotentialElement.java:53: lang:
'',
On 2011/06/02 20:10:43, rjrjr wrote:
nodeType: @com.google.gwt.dom.client.Node.ELEMENT_NODE;
Done.
http://gwt-code-reviews.appspot.com/1450810/diff/5006/user/src/com/google/gwt/user/client/ui/PotentialElement.java#newcode56
user/src/com/google/gwt/user/client/ui/PotentialElement.java:56:
__gwt_resolve: function() {
On 2011/06/02 20:10:43, rjrjr wrote:
indent
Done.
http://gwt-code-reviews.appspot.com/1450810/diff/5006/user/src/com/google/gwt/user/client/ui/PotentialElement.java#newcode57
user/src/com/google/gwt/user/client/ui/PotentialElement.java:57:
this.__gwt_resolve = null;
On 2011/06/02 20:10:43, rjrjr wrote:
this.__gwt_resolve =
@com.google.gwt.user.client.ui.UIObject::cannotResolveTwice()();
On the other hand we could cache the real element and return it on
repeated
calls, but that seems like inviting trouble.
Done.
http://gwt-code-reviews.appspot.com/1450810/diff/5006/user/src/com/google/gwt/user/client/ui/PotentialElement.java#newcode62
user/src/com/google/gwt/user/client/ui/PotentialElement.java:62: }-*/;
On 2011/06/02 20:10:43, rjrjr wrote:
private static final void cannotResolveTwice() /*-{
throw "A PotentialElement cannot be resolved twice.";
}-*/;
Done.
http://gwt-code-reviews.appspot.com/1450810/diff/5006/user/src/com/google/gwt/user/client/ui/PotentialElement.java#newcode65
user/src/com/google/gwt/user/client/ui/PotentialElement.java:65: * Cast
an {@link Element} to be used as a PotentialElement.
On 2011/06/02 19:04:27, rjrjr wrote:
Assert that the given {@link JavaScriptObject} is a PotentialElement
and
automatically typecast it.
Done.
http://gwt-code-reviews.appspot.com/1450810/diff/5006/user/src/com/google/gwt/user/client/ui/PotentialElement.java#newcode67
user/src/com/google/gwt/user/client/ui/PotentialElement.java:67: public
static PotentialElement as(JavaScriptObject o) {
On 2011/06/02 20:10:43, rjrjr wrote:
Offline you pointed out that you can't make this assertion, because
Document.appendChild() calls it for everything. How about making this
return
Element, and inline the call to resolve? For that matter, we could
make resolve
private if this is the only call to it.
Also note the change of the argument from JSO to Element
/**
* If given a PotentialElement, returns the real Element to be
* built from it. Otherwise returns the given Element itself.
* <p>
* Note that a PotentialElement can only be resolved once.
* Making repeated calls to this method with the same PotentialElement
* is an error.
*/
public static Element resolve(Element maybePotential) {
return o.<PotentialElement>cast().resolve();
}
Done.
http://gwt-code-reviews.appspot.com/1450810/
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors