Skip to content

Commit c2ebfec

Browse files
committed
Update to Jsoup 1.14.2 (vaadin#12381)
1 parent 5cfd5fc commit c2ebfec

File tree

6 files changed

+22
-8
lines changed

6 files changed

+22
-8
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
<!-- Used in OSGi manifests -->
3333
<javax.validation.version>1.0.0.GA</javax.validation.version>
34-
<jsoup.version>1.11.2</jsoup.version>
34+
<jsoup.version>1.14.2</jsoup.version>
3535
<javax.portlet.version>2.0</javax.portlet.version>
3636
<vaadin.sass.version>0.9.13</vaadin.sass.version>
3737
<!-- Note that this should be kept in sync with the class Constants -->

server/src/main/java/com/vaadin/ui/declarative/Design.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ private static DesignContext designToComponentTree(Document doc,
535535
private static Document createHtml(DesignContext designContext) {
536536
// Create the html tree skeleton.
537537
Document doc = new Document("");
538-
DocumentType docType = new DocumentType("html", "", "", "");
538+
DocumentType docType = new DocumentType("html", "", "");
539539
doc.appendChild(docType);
540540
Element html = doc.createElement("html");
541541
doc.appendChild(html);

server/src/test/java/com/vaadin/tests/design/DeclarativeTestBaseBase.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.io.ByteArrayOutputStream;
2020
import java.io.UnsupportedEncodingException;
2121
import java.util.ArrayList;
22+
import java.util.Arrays;
2223
import java.util.Collection;
2324
import java.util.Collections;
2425
import java.util.HashSet;
@@ -29,7 +30,6 @@
2930

3031
import org.jsoup.Jsoup;
3132
import org.jsoup.nodes.Attribute;
32-
import org.jsoup.nodes.BooleanAttribute;
3333
import org.jsoup.nodes.Element;
3434
import org.jsoup.nodes.Node;
3535
import org.jsoup.nodes.TextNode;
@@ -42,6 +42,13 @@
4242
import com.vaadin.ui.declarative.ShouldWriteDataDelegate;
4343

4444
public abstract class DeclarativeTestBaseBase<T extends Component> {
45+
private static final String[] booleanAttributes = { "allowfullscreen",
46+
"async", "autofocus", "checked", "compact", "declare", "default",
47+
"defer", "disabled", "formnovalidate", "hidden", "inert", "ismap",
48+
"itemscope", "multiple", "muted", "nohref", "noresize", "noshade",
49+
"novalidate", "nowrap", "open", "readonly", "required", "reversed",
50+
"seamless", "selected", "sortable", "truespeed", "typemustmatch" };
51+
4552
private static final class AlwaysWriteDelegate
4653
implements ShouldWriteDataDelegate {
4754
private static final long serialVersionUID = -6345914431997793599L;
@@ -271,7 +278,7 @@ private String elementToHtml(Element producedElem, StringBuilder sb) {
271278
ArrayList<String> names = new ArrayList<>();
272279
for (Attribute a : producedElem.attributes().asList()) {
273280
names.add(a.getKey());
274-
if (a instanceof BooleanAttribute) {
281+
if (isBooleanAttribute(a.getKey())) {
275282
booleanAttributes.add(a.getKey());
276283
}
277284
}
@@ -298,6 +305,13 @@ private String elementToHtml(Element producedElem, StringBuilder sb) {
298305
return sb.toString();
299306
}
300307

308+
/**
309+
* Checks if this attribute name is defined as a boolean attribute in HTML5
310+
*/
311+
protected static boolean isBooleanAttribute(final String key) {
312+
return Arrays.binarySearch(booleanAttributes, key) >= 0;
313+
}
314+
301315
protected String stripOptionTags(String design) {
302316
return design.replaceAll("[ \n]*<option(.*)</option>[ \n]*", "");
303317

server/src/test/java/com/vaadin/tests/design/LocaleTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public void testHtmlGeneration() {
113113
private Document componentToDoc(DesignContext dc) {
114114
// Create the html tree skeleton.
115115
Document doc = new Document("");
116-
DocumentType docType = new DocumentType("html", "", "", "");
116+
DocumentType docType = new DocumentType("html", "", "");
117117
doc.appendChild(docType);
118118
Element html = doc.createElement("html");
119119
doc.appendChild(html);
@@ -140,7 +140,7 @@ private Document componentToDoc(DesignContext dc) {
140140
public void testParsing() {
141141
// create an html document
142142
Document doc = new Document("");
143-
DocumentType docType = new DocumentType("html", "", "", "");
143+
DocumentType docType = new DocumentType("html", "", "");
144144
doc.appendChild(docType);
145145
Element html = doc.createElement("html");
146146
doc.appendChild(html);

server/src/test/java/com/vaadin/tests/server/component/ReadEmptyDesignTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public void testReadContextWithRootParameter() {
7474

7575
private Document createDesign() {
7676
Document doc = new Document("");
77-
DocumentType docType = new DocumentType("html", "", "", "");
77+
DocumentType docType = new DocumentType("html", "", "");
7878
doc.appendChild(docType);
7979
Element html = doc.createElement("html");
8080
doc.appendChild(html);

uitest/src/main/java/com/vaadin/tests/minitutorials/v7b1/BootstrapListenerCode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class BootstrapListenerCode {
4040
@Override
4141
public void modifyBootstrapPage(BootstrapPageResponse response) {
4242
response.getDocument().body()
43-
.appendChild(new Comment("Powered by Vaadin!", ""));
43+
.appendChild(new Comment("Powered by Vaadin!"));
4444
response.setHeader("X-Powered-By", "Vaadin 7");
4545
}
4646

0 commit comments

Comments
 (0)