Skip to content

Conversation

@titoBouzout
Copy link
Contributor

In an unrelated issue solidjs/solid#2540 , I have noticed that this

 <div
      style={{
        'padding-left': `clamp(${a}px, ${b}px, ${c}px)`,
        'padding-right': 'clamp(10px, 20px, 30px)',
        'padding-top': 'calc(12*6px)',
      }}
    >
      <p>abc</p>
    </div>

was compiling to

var _tmpl$ = /*#__PURE__*/_$template(`<div style="padding-right:clamp(10px, 20px, 30px);padding-top:calc(12*6px)"><p>abc`);
import { render } from "solid-js/web";
function Counter() {
  const a = 50;
  const b = 60;
  const c = 70;
  return (() => {
    var _el$ = _tmpl$();
    _$setStyleProperty(_el$, "padding-left", "clamp(50px, 60px, 70px)");
    return _el$;
  })();
  1. it uses evaluate().confident when possible for value
  2. it inlines when object shape is {a:'static'} as opposed to {"a":"static"}
  3. it inlines the value when computed, albeit this probably is rare or unnecessary {[style]:'${1+1}px'} =>{[style]:'2px'}

@titoBouzout titoBouzout changed the title Inline in template value of objects in style objects using èvaluate().confident Inline in template value in style objects using èvaluate().confident Oct 14, 2025
@ryansolid
Copy link
Owner

Nice.

@titoBouzout titoBouzout changed the title Inline in template value in style objects using èvaluate().confident Inline in template value in style objects using evaluate().confident Oct 18, 2025
@ryansolid ryansolid merged commit a064885 into ryansolid:main Oct 27, 2025
1 check failed
@birkskyum
Copy link
Contributor

birkskyum commented Oct 27, 2025

Oh, this PR didn't pass CI checks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants