Giter Site home page Giter Site logo

Comments (4)

lilnasy avatar lilnasy commented on May 18, 2024

define:vars is weird. It only works on the html element the compiler notices on the file. In a page with only components and no html tags, it has no effect at all.

I want to see it deprecated altogether. Maybe we can offer a function as a replacement.

-<div>
+<div style={defineVars({ color })}>
  1111
  <button type="button">button</button>
</div>

-<style define:vars={{ color }}>
+<style>
  button {
    color: var(--color)
  }
</style>

from roadmap.

mikestopcontinues avatar mikestopcontinues commented on May 18, 2024

I'm all for it!

from roadmap.

imaginarny avatar imaginarny commented on May 18, 2024

I would also like to draw attention to the behavior when you actually set define:vars along with the is:inline directive on a style tag.

<style is:inline define:vars={{ cssVar: 'example' }}>...</style>

Compiles to:

<style>--cssVar: 'example';...</style>

This way, you can't use the variable as it was inlined as-is right into the style tag. All you need would be if it either:

  • added :root {} wrapper around the variables
  • or offered some way/option that lets you define your own element/wrapper

The first option would be perfect for use in <head> with inline styles, for example, when you want to set something immediately that you also preload. You can achieve this another (better) way, though.

Although, I don't see a use case for it outside of the <head>. Just wanted to point out another "questionable" behavior while I was trying to pass a variable used in head and found this open issue among the many closed ones.


I want to see it deprecated altogether. Maybe we can offer a function as a replacement.

In the case of deprecating it, how would the function work for the <script> tag?

from roadmap.

lilnasy avatar lilnasy commented on May 18, 2024

In the case of deprecating it, how would the function work for the <script> tag?

<script define:vars> already has a replacement lined up

from roadmap.

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.