Open mvysny opened 4 years ago
The result in DOM is:
<div>
<div style="font-size: var(--foo)">Should be HUGE but it's not.</div>
</div>
so style="--foo:32px"
is just absent.
This happens because top-level attributes are recreated in Html.setOuterHtml(Document)
by using Element.setAttribute
. This triggers StyleAttributeHandler
which takes the values one round through CSSReaderDeclarationList.readFromString
and then passes the key through StyleUtil.styleAttributeToProperty
which changes the name to Foo
. This value is then converted "back" in Style.set
through StyleUtil.stylePropertyToAttribute
, to -foo
instead of --foo
. This means that the browser sees -foo:32px
which is subsequently ignored.
The same problem can thus also be reproduced with anyElement.setAttribute("style", "--foo:32px");
.
The
Html
component removes CSS variables from the passed-in html snippet.Example: just paste this into Skeleton Starter's
MainView.java
:Expected: huge text is rendered
Actual: the
style="--foo:32px"
is removed and the text is rendered using the default size.Vaadin 14.0.12, Java 8, Linux, Firefox