Browse Source

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.
tags/gwtquery-project-1.5-beta1
Manolo Carrasco 9 years ago
parent
commit
f3c92755f5

+ 4
- 8
gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java View File

@@ -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;
}
@@ -300,13 +303,6 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
return $(selectorOrHtml, document);
}
/**
* 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
@@ -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));
}

/**

+ 68
- 0
gwtquery-core/src/main/java/com/google/gwt/query/client/LazyGQuery.java View File

@@ -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;
@@ -78,6 +79,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,
@@ -264,6 +271,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.
@@ -291,6 +304,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.
*/
@@ -1122,6 +1144,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.
*/
@@ -1940,6 +1967,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.
*/
@@ -2489,6 +2526,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
@@ -2525,6 +2571,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
@@ -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);

}

Loading…
Cancel
Save