Skip to content

Commit

Permalink
Revert #2375 due to #2730
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirill Bulatov committed Oct 20, 2017
1 parent 97f6baf commit 38f053e
Show file tree
Hide file tree
Showing 33 changed files with 151 additions and 187 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
import java.util.Locale;
import java.util.concurrent.atomic.AtomicInteger;

import org.jsoup.helper.StringUtil;

import com.vaadin.external.jsoup.helper.StringUtil;
import com.vaadin.ui.Component;
import com.vaadin.ui.common.HasComponents;
import com.vaadin.ui.common.HasSize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
*/
package com.vaadin.flow.tutorial;

import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;

import com.vaadin.external.jsoup.nodes.Document;
import com.vaadin.external.jsoup.nodes.Element;
import com.vaadin.flow.tutorial.annotations.CodeFor;
import com.vaadin.server.BootstrapListener;
import com.vaadin.server.BootstrapPageResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,18 @@
*/
package com.vaadin.flow.tutorial.binder;

import java.util.List;
import java.util.stream.Collectors;

import javax.validation.constraints.Max;
import javax.validation.constraints.NotEmpty;

import org.jsoup.Jsoup;
import org.jsoup.safety.Whitelist;
import java.util.List;
import java.util.stream.Collectors;

import com.vaadin.data.BeanValidationBinder;
import com.vaadin.data.Binder;
import com.vaadin.data.BinderValidationStatusHandler;
import com.vaadin.data.ValidationResult;
import com.vaadin.data.converter.StringToIntegerConverter;
import com.vaadin.external.jsoup.Jsoup;
import com.vaadin.external.jsoup.safety.Whitelist;
import com.vaadin.flow.tutorial.annotations.CodeFor;
import com.vaadin.ui.html.Label;
import com.vaadin.ui.textfield.TextField;
Expand Down
6 changes: 3 additions & 3 deletions flow-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@

<!-- Jsoup for BootstrapHandler, Template, ... -->
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.10.3</version>
<groupId>com.vaadin.external.jsoup</groupId>
<artifactId>jsoup-case-sensitive</artifactId>
<version>1.9.2</version>
</dependency>
<dependency>
<groupId>com.helger</groupId>
Expand Down
3 changes: 1 addition & 2 deletions flow-server/src/main/java/com/vaadin/flow/dom/Element.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
import java.util.stream.IntStream;
import java.util.stream.Stream;

import org.jsoup.nodes.Document;

import com.vaadin.external.jsoup.nodes.Document;
import com.vaadin.flow.JsonCodec;
import com.vaadin.flow.StateNode;
import com.vaadin.flow.dom.impl.BasicElementStateProvider;
Expand Down
56 changes: 21 additions & 35 deletions flow-server/src/main/java/com/vaadin/flow/dom/ElementUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@
import java.util.Optional;
import java.util.regex.Pattern;

import org.jsoup.nodes.Document;
import org.jsoup.nodes.Node;
import org.jsoup.nodes.TextNode;

import com.vaadin.external.jsoup.nodes.Document;
import com.vaadin.external.jsoup.nodes.Node;
import com.vaadin.external.jsoup.nodes.TextNode;
import com.vaadin.ui.Component;
import com.vaadin.ui.Composite;

Expand All @@ -48,8 +47,7 @@ private ElementUtil() {
/**
* Checks if the given tag name is valid.
*
* @param tag
* the tag name
* @param tag the tag name
* @return true if the string is valid as a tag name, false otherwise
*/
public static boolean isValidTagName(String tag) {
Expand All @@ -59,8 +57,7 @@ public static boolean isValidTagName(String tag) {
/**
* Checks if the given attribute name is valid.
*
* @param attribute
* the name of the attribute in lower case
* @param attribute the name of the attribute in lower case
* @return true if the name is valid, false otherwise
*/
public static boolean isValidAttributeName(String attribute) {
Expand All @@ -75,8 +72,8 @@ public static boolean isValidAttributeName(String attribute) {
// APOSTROPHE ('), U+003E GREATER-THAN SIGN (>), U+002F SOLIDUS (/), and
// U+003D EQUALS SIGN (=) characters, the control characters, and any
// characters that are not defined by Unicode.
char[] illegalCharacters = new char[] { 0, ' ', '"', '\'', '>', '/',
'=' };
char[] illegalCharacters = new char[]{0, ' ', '"', '\'', '>', '/',
'='};
for (char c : illegalCharacters) {
if (attribute.indexOf(c) != -1) {
return false;
Expand All @@ -89,8 +86,7 @@ public static boolean isValidAttributeName(String attribute) {
* Validates the given style property name and throws an exception if the
* name is invalid.
*
* @param name
* the style property name to validate
* @param name the style property name to validate
*/
public static void validateStylePropertyName(String name) {
String reason = getInvalidStylePropertyNameError(name);
Expand Down Expand Up @@ -128,8 +124,7 @@ private static String getInvalidStylePropertyNameError(String name) {
/**
* Checks if the given style property name is valid.
*
* @param name
* the name to validate
* @param name the name to validate
* @return true if the name is valid, false otherwise
*/
public static boolean isValidStylePropertyName(String name) {
Expand All @@ -139,8 +134,7 @@ public static boolean isValidStylePropertyName(String name) {
/**
* Checks if the given style property value is valid.
*
* @param value
* the value to validate
* @param value the value to validate
* @return true if the value is valid, false otherwise
*/
public static boolean isValidStylePropertyValue(String value) {
Expand All @@ -152,8 +146,7 @@ public static boolean isValidStylePropertyValue(String value) {
* <p>
* Throws an exception if it's certain the value is invalid
*
* @param value
* the value to validate
* @param value the value to validate
*/
public static void validateStylePropertyValue(String value) {
String reason = getInvalidStylePropertyValueError(value);
Expand All @@ -179,10 +172,8 @@ private static String getInvalidStylePropertyValueError(String value) {
* changed. The only exception is {@link Composite} which can overwrite the
* mapping for its content.
*
* @param element
* the element to map to the component
* @param component
* the component this element is attached to
* @param element the element to map to the component
* @param component the component this element is attached to
*/
public static void setComponent(Element element, Component component) {
if (element == null) {
Expand All @@ -197,7 +188,7 @@ public static void setComponent(Element element, Component component) {
// Composite can replace its content
boolean isCompositeReplacingItsContent = component instanceof Composite
&& component.getChildren().findFirst()
.get() == currentComponent.get();
.get() == currentComponent.get();
if (!isCompositeReplacingItsContent) {
throw new IllegalStateException("A component of type "
+ currentComponent.get().getClass().getName()
Expand All @@ -213,10 +204,9 @@ public static void setComponent(Element element, Component component) {
* If the element is mapped to a {@link Composite} or a {@link Composite}
* chain, this will always return the outermost {@link Composite}.
*
* @param element
* the element to retrieve the component for
* @param element the element to retrieve the component for
* @return an optional component, or an empty optional if no component has
* been mapped to this element
* been mapped to this element
*/
public static Optional<Component> getComponent(Element element) {
return element.getStateProvider().getComponent(element.getNode());
Expand All @@ -226,18 +216,16 @@ public static Optional<Component> getComponent(Element element) {
* Converts the given element and its children to a JSoup node with
* children.
*
* @param document
* A JSoup document
* @param element
* The element to convert
* @param document A JSoup document
* @param element The element to convert
* @return A JSoup node containing the converted element
*/
public static Node toJsoup(Document document, Element element) {
if (element.isTextNode()) {
return new TextNode(element.getText(), document.baseUri());
}

org.jsoup.nodes.Element target = document
com.vaadin.external.jsoup.nodes.Element target = document
.createElement(element.getTag());
if (element.hasProperty("innerHTML")) {
target.html((String) element.getPropertyRaw("innerHTML"));
Expand All @@ -264,8 +252,7 @@ public static Node toJsoup(Document document, Element element) {
* Custom elements (Web Components) are recognized by having at least one
* dash in the tag name.
*
* @param element
* the element to check
* @param element the element to check
* @return <code>true</code> if a custom element, <code>false</code> if not
*/
public static boolean isCustomElement(Element element) {
Expand All @@ -275,8 +262,7 @@ public static boolean isCustomElement(Element element) {
/**
* Checks whether the given element is a <code>script</code> or not.
*
* @param element
* the element to check
* @param element the element to check
* @return <code>true</code> if a script, <code>false</code> if not
*/
public static boolean isScript(Element element) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@

import java.util.regex.Pattern;

import org.jsoup.nodes.Node;

import com.vaadin.external.jsoup.nodes.Node;
import com.vaadin.flow.template.angular.AbstractBindingValueProvider;
import com.vaadin.flow.template.angular.JsExpressionBindingProvider;
import com.vaadin.flow.template.angular.ModelValueBindingProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
import java.util.Optional;
import java.util.function.Function;

import org.jsoup.nodes.DataNode;
import org.jsoup.nodes.Node;

import com.vaadin.external.jsoup.nodes.DataNode;
import com.vaadin.external.jsoup.nodes.Node;
import com.vaadin.flow.template.angular.StaticBindingValueProvider;
import com.vaadin.flow.template.angular.TemplateNodeBuilder;
import com.vaadin.flow.template.angular.TextTemplateBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@
import java.util.function.Function;
import java.util.stream.Stream;

import org.jsoup.nodes.Attribute;
import org.jsoup.nodes.Element;
import org.jsoup.nodes.Node;

import com.vaadin.external.jsoup.nodes.Attribute;
import com.vaadin.external.jsoup.nodes.Element;
import com.vaadin.external.jsoup.nodes.Node;
import com.vaadin.flow.template.angular.AbstractBindingValueProvider;
import com.vaadin.flow.template.angular.ElementTemplateBuilder;
import com.vaadin.flow.template.angular.StaticBindingValueProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@
import java.util.function.Function;
import java.util.stream.Collectors;

import org.jsoup.nodes.Node;
import org.jsoup.nodes.TextNode;

import com.vaadin.external.jsoup.nodes.Node;
import com.vaadin.external.jsoup.nodes.TextNode;
import com.vaadin.flow.template.angular.ChildSlotBuilder;
import com.vaadin.flow.template.angular.StaticBindingValueProvider;
import com.vaadin.flow.template.angular.TemplateNodeBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
import java.util.StringTokenizer;
import java.util.function.Function;

import org.jsoup.nodes.Element;
import org.jsoup.nodes.Node;

import com.vaadin.external.jsoup.nodes.Element;
import com.vaadin.external.jsoup.nodes.Node;
import com.vaadin.flow.template.angular.ElementTemplateBuilder;
import com.vaadin.flow.template.angular.ForTemplateBuilder;
import com.vaadin.flow.template.angular.TemplateNodeBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
import java.util.Optional;
import java.util.function.Function;

import org.jsoup.nodes.Node;

import com.vaadin.external.jsoup.nodes.Node;
import com.vaadin.flow.template.angular.TemplateNodeBuilder;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,15 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Comment;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.nodes.Node;
import org.jsoup.nodes.TextNode;
import org.jsoup.select.Elements;
import org.jsoup.select.NodeTraversor;
import org.jsoup.select.NodeVisitor;

import com.vaadin.external.jsoup.Jsoup;
import com.vaadin.external.jsoup.nodes.Comment;
import com.vaadin.external.jsoup.nodes.Document;
import com.vaadin.external.jsoup.nodes.Element;
import com.vaadin.external.jsoup.nodes.Node;
import com.vaadin.external.jsoup.nodes.TextNode;
import com.vaadin.external.jsoup.select.Elements;
import com.vaadin.external.jsoup.select.NodeTraversor;
import com.vaadin.external.jsoup.select.NodeVisitor;
import com.vaadin.flow.template.angular.DelegateResolver;
import com.vaadin.flow.template.angular.TemplateNode;
import com.vaadin.flow.template.angular.TemplateNodeBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package com.vaadin.flow.util;

import org.jsoup.nodes.TextNode;
import com.vaadin.external.jsoup.nodes.TextNode;

/**
* Helpers for HTML related aspects.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,11 @@
import java.util.regex.Pattern;
import java.util.stream.Stream;

import org.jsoup.nodes.DataNode;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.DocumentType;
import org.jsoup.nodes.Element;
import org.jsoup.parser.Tag;

import com.vaadin.external.jsoup.nodes.DataNode;
import com.vaadin.external.jsoup.nodes.Document;
import com.vaadin.external.jsoup.nodes.DocumentType;
import com.vaadin.external.jsoup.nodes.Element;
import com.vaadin.external.jsoup.parser.Tag;
import com.vaadin.function.DeploymentConfiguration;
import com.vaadin.server.communication.AtmospherePushConnection;
import com.vaadin.server.communication.UidlWriter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@

package com.vaadin.server;

import org.jsoup.nodes.Document;

import com.vaadin.external.jsoup.nodes.Document;
import com.vaadin.shared.VaadinUriResolver;
import com.vaadin.ui.UI;

Expand Down
9 changes: 4 additions & 5 deletions flow-server/src/main/java/com/vaadin/ui/Html.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@
import java.io.UncheckedIOException;
import java.util.logging.Logger;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Attributes;
import org.jsoup.nodes.Document;

import com.vaadin.external.jsoup.Jsoup;
import com.vaadin.external.jsoup.nodes.Attributes;
import com.vaadin.external.jsoup.nodes.Document;
import com.vaadin.flow.dom.Element;
import com.vaadin.ui.common.PropertyDescriptor;
import com.vaadin.ui.common.PropertyDescriptors;
Expand Down Expand Up @@ -110,7 +109,7 @@ private void setOuterHtml(Document doc) {
+ nrChildren);
}

org.jsoup.nodes.Element root = doc.body().child(0);
com.vaadin.external.jsoup.nodes.Element root = doc.body().child(0);
Attributes attrs = root.attributes();

Component.setElement(this, new Element(root.tagName()));
Expand Down
Loading

0 comments on commit 38f053e

Please sign in to comment.