Git Product home page Git Product logo

Comments (9)

eskan avatar eskan commented on July 26, 2024 2

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

style$=${`top: ${top}; left: ${left};`}

you can also use css custom properties

:host {
          display: block;
          position:absolute;
          --my-top: 100px;
          --my-left: 300px;
          top: var(--my-top);
          left: var(--my-left);
        }

and
this.style.setProperty('--my-top','400px');

from lit-element.

valdrinkoshi avatar valdrinkoshi commented on July 26, 2024 2

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 #74 (comment)

from lit-element.

blikblum avatar blikblum commented on July 26, 2024

I see the same bug on Chrome 63 on windows

from lit-element.

jofan avatar jofan commented on July 26, 2024

Thanks @eskan, I did use inline styles to work around this but I think this limitation should be documented as the big selling point is that it's just string literals and therefor something like this would be expected to work, in my opinion.

from lit-element.

eskan avatar eskan commented on July 26, 2024

@jofan here isn't only string literal it's lit-html which use string literal to build template result with "parts" and this is dom relative.
@justinfagnani may you confirm that lit-html can't be use inside <style> ?

from lit-element.

blikblum avatar blikblum commented on July 26, 2024

Support for style is advertised as one of the lit-html features: https://github.com/polymer/lit-html#css-compatible-syntax

from lit-element.

eskan avatar eskan commented on July 26, 2024

@blikblum i understand this as "lit html syntax is compatible with css syntax" so you can write style inside template string. (vs include expression in CSS style)

from lit-element.

smalluban avatar smalluban commented on July 26, 2024

Using expressions inside of the <style> element is not supported in browsers where shadycss is required. The shim takes <style> element and put it in the head of the document (it adds also scope to template element and CSS selectors). It has to be done before render method is called, so your values are placed in incorrect place.

from lit-element.

jofan avatar jofan commented on July 26, 2024

@smalluban Thanks for that explanation. Then it's promising for the future when the shim is no longer necessary.

from lit-element.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.