Skip to content

Commit ce71f80

Browse files
Denisvaadin-bot
authored andcommitted
fix: allow spaces between html function call and back tick (#10523)
fixes #8881
1 parent 7d01481 commit ce71f80

2 files changed

Lines changed: 16 additions & 7 deletions

File tree

flow-server/src/main/java/com/vaadin/flow/component/polymertemplate/BundleParser.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@
1515
*/
1616
package com.vaadin.flow.component.polymertemplate;
1717

18-
import static com.vaadin.flow.server.frontend.FrontendUtils.DEAULT_FLOW_RESOURCES_FOLDER;
19-
import static com.vaadin.flow.server.frontend.FrontendUtils.FLOW_NPM_PACKAGE_NAME;
20-
import static elemental.json.JsonType.ARRAY;
21-
import static elemental.json.JsonType.OBJECT;
22-
import static elemental.json.JsonType.STRING;
23-
2418
import java.util.Optional;
2519
import java.util.regex.Matcher;
2620
import java.util.regex.Pattern;
@@ -39,6 +33,12 @@
3933
import elemental.json.JsonObject;
4034
import elemental.json.JsonType;
4135

36+
import static com.vaadin.flow.server.frontend.FrontendUtils.DEAULT_FLOW_RESOURCES_FOLDER;
37+
import static com.vaadin.flow.server.frontend.FrontendUtils.FLOW_NPM_PACKAGE_NAME;
38+
import static elemental.json.JsonType.ARRAY;
39+
import static elemental.json.JsonType.OBJECT;
40+
import static elemental.json.JsonType.STRING;
41+
4242
/**
4343
* Parse statistics data provided by webpack.
4444
*
@@ -84,7 +84,7 @@ public final class BundleParser {
8484
* end character with <code>;}</code> e.g. <code>';}</code>
8585
*/
8686
private static final Pattern POLYMER_TEMPLATE_PATTERN = Pattern.compile(
87-
"get[\\s]*template\\(\\)[\\s]*\\{[\\s]*return[\\s]*html([\\`\\'\\\"])([\\s\\S]*)\\1;[\\s]*\\}");
87+
"get[\\s]*template\\(\\)[\\s]*\\{[\\s]*return[\\s]*html[\\s]*([\\`\\'\\\"])([\\s\\S]*)\\1;[\\s]*\\}");
8888

8989
private static final Pattern NO_TEMPLATE_PATTERN = Pattern.compile(
9090
"innerHTML[\\s]*=[\\s]*([\\`\\'\\\"])([\\s]*<dom-module\\s+[\\s\\S]*)\\1;");

flow-server/src/test/java/com/vaadin/flow/component/polymertemplate/BundleParserTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import elemental.json.Json;
1414
import elemental.json.JsonObject;
15+
1516
import static com.vaadin.flow.server.Constants.VAADIN_SERVLET_RESOURCES;
1617

1718
public class BundleParserTest {
@@ -85,4 +86,12 @@ public void parseTemplateElement_stringContentNotSeenAsComment() {
8586
"nats://server:port", natsElement.attr("placeholder"));
8687

8788
}
89+
90+
@Test
91+
public void parseTemplateElement_spacesBetweenHtmlAndTick() {
92+
String source = "static get template() { return html `<div id='bar'></div>`;}";
93+
Element element = BundleParser.parseTemplateElement("foo.js", source);
94+
95+
Assert.assertNotNull(element.getElementById("bar"));
96+
}
8897
}

0 commit comments

Comments
 (0)