[Firefox] Attributes are reassigned if used in styles
See original GitHub issueIf using the attribute values in the style tag, the values of attributes are reassigned between each other. I created a simple demo: Stackblitz Demo
In the demo the relevant code looks like:
_render({top, left, animal, whales}) {
return html`
<style>
:host {
display: block;
position:absolute;
top: ${top}px;
left: ${left}px;
}
</style>
<h4>Type: ${animal}</h4>
<div>Whales: ${'🐳'.repeat(whales)}</div>
<p>Top: ${top}, Left: ${left}</p>
<slot></slot>
`;
}
In Chrome it works but in Firefox animal and top, and whales and left will have changed values with each other. Removing top and left from style declaration makes the issue go away.

Issue Analytics
- State:
- Created 5 years ago
- Comments:9
Top Results From Across the Web
Examine and edit CSS — Firefox Source Docs documentation
It represents the CSS properties assigned to the element via its style attribute. , giving you a convenient way to highlight the currently...
Read more >HTMLElement.style - Web APIs | MDN
The style read-only property returns the inline style of an element in the form of a CSSStyleDeclaration object that contains a list of...
Read more >256630 - [firefox only] style attribute doesn't show up in style rules view
People. (Reporter: dbaron, Assigned: dbaron) ... I don't see how the style attribute can be used "to help webpages attack the user's computer"....
Read more >Poor style calculation performance for attribute selectors ...
Click "Force style recalc". Actual results: The duration of style/layout/render as measured by the benchmark is ~190ms on my MacBook Pro running Firefox...
Read more >C++ Coding style — Firefox Source Docs documentation
This document attempts to explain the basic styles and patterns used in the Mozilla codebase. New code should try to conform to these...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Modifying the content of a stylesheet is bad practice, because that invalidates all the styles of that stylesheet, potentially causing unnecessary layout/paint. The most efficient way would be to use css custom properties as suggested in https://github.com/Polymer/lit-element/issues/74#issuecomment-391368188
Hi, this look more a lit-html issue but i’m not sure you can use expression inside <style>, template are a dom hack to substitute values in places. To achieve this you need to use inline style
you can also use css custom properties
and
this.style.setProperty('--my-top','400px');