From df2157ab9f39f7170675c8540a589cdc101d9456 Mon Sep 17 00:00:00 2001 From: Adam Wagner Date: Fri, 20 Oct 2017 10:14:33 +0200 Subject: Check class name type on Grid cell mouse over (#10194) * Check whether className is of type string * Move string type checker method to widget util * Fix formatting of WidgetUtil * Break svg into lines --- client/src/main/java/com/vaadin/client/WidgetUtil.java | 13 +++++++++++++ client/src/main/java/com/vaadin/client/widgets/Grid.java | 7 ++++++- 2 files changed, 19 insertions(+), 1 deletion(-) (limited to 'client') diff --git a/client/src/main/java/com/vaadin/client/WidgetUtil.java b/client/src/main/java/com/vaadin/client/WidgetUtil.java index 94439dc945..e6304343aa 100644 --- a/client/src/main/java/com/vaadin/client/WidgetUtil.java +++ b/client/src/main/java/com/vaadin/client/WidgetUtil.java @@ -1866,6 +1866,19 @@ public class WidgetUtil { return WidgetUtil.getTouchOrMouseClientY(event) - relativeTop; } + /** + * Returns whether the given object is a string. + * + * @param obj + * the object of which the type is examined + * @return {@code true} if the object is a string; {@code false} if not + * @since + */ + public static native boolean isString(Object obj) + /*-{ + return typeof obj === 'string' || obj instanceof String; + }-*/; + /** * Utility methods for displaying error message on components. * diff --git a/client/src/main/java/com/vaadin/client/widgets/Grid.java b/client/src/main/java/com/vaadin/client/widgets/Grid.java index 43f85a9848..4651c534dc 100755 --- a/client/src/main/java/com/vaadin/client/widgets/Grid.java +++ b/client/src/main/java/com/vaadin/client/widgets/Grid.java @@ -7528,7 +7528,12 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, boolean isElement = Element.is(n); if (isElement) { String className = Element.as(n).getClassName(); - if (className.contains(getStylePrimaryName() + "-spacer")) { + + // Also check whether className is indeed a string. For + // SVGElement it may be of type SVGAnimatedString. + // https://developer.mozilla.org/en-US/docs/Web/API/Element/className#Notes + if (WidgetUtil.isString(className) && className + .contains(getStylePrimaryName() + "-spacer")) { return true; } } -- cgit v1.2.3