Reviewers: jlabanca, rjrjr, pdr,

Description:
Add missing CSS_ATTRIBUTE_START case in SafeHtmlTemplates code
generator.


Please review this at http://gwt-code-reviews.appspot.com/1395803/

Affected files:
M user/src/com/google/gwt/safehtml/rebind/SafeHtmlTemplatesImplMethodCreator.java
  M user/test/com/google/gwt/safehtml/client/SafeHtmlTemplatesTest.java


Index: user/src/com/google/gwt/safehtml/rebind/SafeHtmlTemplatesImplMethodCreator.java
===================================================================
--- user/src/com/google/gwt/safehtml/rebind/SafeHtmlTemplatesImplMethodCreator.java (revision 9912) +++ user/src/com/google/gwt/safehtml/rebind/SafeHtmlTemplatesImplMethodCreator.java (working copy)
@@ -245,6 +245,7 @@
         break;

       case CSS_ATTRIBUTE:
+      case CSS_ATTRIBUTE_START:
         // TODO(xtof): Improve support for CSS.
logger.log(TreeLogger.WARN, "Template with variable in CSS context: " + "The template code generator cannot guarantee HTML-safety of "
Index: user/test/com/google/gwt/safehtml/client/SafeHtmlTemplatesTest.java
===================================================================
--- user/test/com/google/gwt/safehtml/client/SafeHtmlTemplatesTest.java (revision 9912) +++ user/test/com/google/gwt/safehtml/client/SafeHtmlTemplatesTest.java (working copy)
@@ -62,6 +62,9 @@

     @Template("<span><img src=\"{0}/{1}\"/></span>")
SafeHtml templateWithTwoPartUriAttribute(String baseUrl, String urlPart);
+
+    @Template("<span style='{0}; color: green;'></span>")
+    SafeHtml templateWithStyleAttribute(String style);
   }

   public void testSimpleTemplate() {
@@ -107,4 +110,10 @@
         templates.templateWithTwoPartUriAttribute(
             BAD_URL, "x&y").asString());
   }
+
+  public void testTemplateWithStyleAttribute() {
+    Assert.assertEquals(
+        "<span style='background: purple; color: green;'></span>",
+ templates.templateWithStyleAttribute("background: purple").asString());
+  }
 }


--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to