diff options
author | Manolo Carrasco <manolo@apache.org> | 2015-03-10 10:20:17 +0100 |
---|---|---|
committer | Manolo Carrasco <manolo@apache.org> | 2015-03-10 10:22:53 +0100 |
commit | f3c92755f53a72180469b2220da5d9b017112ec9 (patch) | |
tree | 4d45faae6bb21eed28efadbfdeb1fe20434a843c | |
parent | 7e2b73dd8014626f37f7801b17a435bfde6a696c (diff) | |
download | gwtquery-f3c92755f53a72180469b2220da5d9b017112ec9.tar.gz gwtquery-f3c92755f53a72180469b2220da5d9b017112ec9.zip |
Fix a disanbiguity introduced with SafeHtml patch
When using gwt-2.8.0 and java8 gwt compiler is more restrictive and
when you override a method(Object) with certain classes like
Interfaces or JSO, there is an error like:
The method $(Object) is ambiguous for the type GQuery.
Also updated lazy interface with new methods.
-rw-r--r-- | gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java | 12 | ||||
-rw-r--r-- | gwtquery-core/src/main/java/com/google/gwt/query/client/LazyGQuery.java | 68 |
2 files changed, 72 insertions, 8 deletions
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java index a4b92733..4ed7cad8 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java @@ -225,6 +225,9 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> { if (o instanceof String) { return $((String) o); } + if (o instanceof SafeHtml) { + return $(((SafeHtml) o).asString()); + } if (o instanceof GQuery) { return (GQuery) o; } @@ -301,13 +304,6 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> { } /** - * This function accepts a SafeHtml creating a GQuery element containing those elements. - */ - public static GQuery $(SafeHtml safeHtml) { - return $(safeHtml.asString()); - } - - /** * This function accepts a string containing a CSS selector which is then used to match a set of * elements, or it accepts raw HTML creating a GQuery element containing those elements. The * second parameter is is a class reference to a plugin to be used. @@ -4941,7 +4937,7 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> { * its structure -- it is that element that will enwrap everything else. */ public GQuery wrap(SafeHtml safeHtml) { - return wrap(safeHtml.asString()); + return wrap($(safeHtml)); } /** diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/LazyGQuery.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/LazyGQuery.java index df766f9a..c9f43345 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/LazyGQuery.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/LazyGQuery.java @@ -25,6 +25,7 @@ import com.google.gwt.query.client.js.JsNamedArray; import com.google.gwt.query.client.js.JsNodeArray; import com.google.gwt.query.client.plugins.Effects; import com.google.gwt.query.client.plugins.effects.PropertiesAnimation.Easing; +import com.google.gwt.safehtml.shared.SafeHtml; import com.google.gwt.user.client.ui.Widget; import java.util.List; @@ -79,6 +80,12 @@ public interface LazyGQuery<T> extends LazyBase<T> { LazyGQuery<T> after(String html); /** + * Insert content after each of the matched elements. The elements must already be inserted into + * the document (you can't insert an element after another if it's not in the page). + */ + LazyGQuery<T> after(SafeHtml safeHtml); + + /** * * The animate() method allows you to create animation effects on any numeric HTML Attribute, * CSS property, or color CSS property. @@ -265,6 +272,12 @@ public interface LazyGQuery<T> extends LazyBase<T> { LazyGQuery<T> append(String html); /** + * Append content to the inside of every matched element. This operation is similar to doing an + * appendChild to all the specified elements, adding them into the document. + */ + LazyGQuery<T> append(SafeHtml safeHtml); + + /** * All of the matched set of elements will be inserted at the end of the element(s) specified by * the parameter other. * @@ -292,6 +305,15 @@ public interface LazyGQuery<T> extends LazyBase<T> { LazyGQuery<T> appendTo(String html); /** + * All of the matched set of elements will be inserted at the end of the element(s) specified by + * the parameter other. + * + * The operation $(A).appendTo(B) is, essentially, the reverse of doing a regular $(A).append(B), + * instead of appending B to A, you're appending A to B. + */ + LazyGQuery<T> appendTo(SafeHtml safeHtml); + + /** * Convert to Plugin interface provided by Class literal. */ <T extends GQuery> T as(Class<T> plugin); @@ -1123,6 +1145,11 @@ public interface LazyGQuery<T> extends LazyBase<T> { LazyGQuery<T> html(String html); /** + * Set the innerHTML of every matched element. + */ + LazyGQuery<T> html(SafeHtml safeHtml); + + /** * Get the id of the first matched element. */ String id(); @@ -1941,6 +1968,16 @@ public interface LazyGQuery<T> extends LazyBase<T> { LazyGQuery<T> queue(String queueName, Function... f); /** + * Specify a function to execute when the DOM is fully loaded. + * + * While JavaScript provides the load event for executing code when a page is rendered, this event + * is not seen if we attach an event listener after the document has been loaded. + * This guarantees that our gwt code will be executed either it's executed synchronously before the + * DOM has been rendered (ie: single script linker in header) or asynchronously. + */ + Promise ready(Function... fncs); + + /** * Removes all matched elements from the DOM. */ LazyGQuery<T> remove(); @@ -2490,6 +2527,15 @@ public interface LazyGQuery<T> extends LazyBase<T> { LazyGQuery<T> wrap(String html); /** + * Wrap each matched element with the specified SafeHtml content. This wrapping process is most useful + * for injecting additional structure into a document, without ruining the original semantic + * qualities of a document. This works by going through the first element provided (which is + * generated, on the fly, from the provided SafeHtml) and finds the deepest descendant element within + * its structure -- it is that element that will enwrap everything else. + */ + LazyGQuery<T> wrap(SafeHtml safeHtml); + + /** * Wrap all the elements in the matched set into a single wrapper element. This is different from * .wrap() where each element in the matched set would get wrapped with an element. This wrapping * process is most useful for injecting additional structure into a document, without ruining the @@ -2526,6 +2572,18 @@ public interface LazyGQuery<T> extends LazyBase<T> { LazyGQuery<T> wrapAll(String html); /** + * Wrap all the elements in the matched set into a single wrapper element. This is different from + * .wrap() where each element in the matched set would get wrapped with an element. This wrapping + * process is most useful for injecting additional structure into a document, without ruining the + * original semantic qualities of a document. + * + * This works by going through the first element provided (which is generated, on the fly, from + * the provided SafeHtml) and finds the deepest descendant element within its structure -- it is that + * element that will enwrap everything else. + */ + LazyGQuery<T> wrapAll(SafeHtml safeHtml); + + /** * Wrap the inner child contents of each matched element (including text nodes) with an HTML * structure. This wrapping process is most useful for injecting additional structure into a * document, without ruining the original semantic qualities of a document. This works by going @@ -2555,4 +2613,14 @@ public interface LazyGQuery<T> extends LazyBase<T> { */ LazyGQuery<T> wrapInner(String html); + /** + * Wrap the inner child contents of each matched element (including text nodes) with an SafeHtml + * structure. This wrapping process is most useful for injecting additional structure into a + * document, without ruining the original semantic qualities of a document. This works by going + * through the first element provided (which is generated, on the fly, from the provided SafeHtml) and + * finds the deepest ancestor element within its structure -- it is that element that will enwrap + * everything else. + */ + LazyGQuery<T> wrapInner(SafeHtml safeHtml); + } |