Skip to content

Allowing number values in CSSResults #471

Closed
@daKmoR

Description

@daKmoR

hey,

we have some default number values for our styling.
Reason:

  • We want to keep them the same across multiple elements
  • These values should not be changeable (e.g. we don't want to use css variables)
    • as we don't want them as part of our "api"
    • as we want to do javascript calculations
    • as we want to keep the door open to optimize these variables "away" inside css via a build step

Live Demo

https://stackblitz.com/edit/ems7at?file=custom-greeting.js

Steps to Reproduce

Use a number

import { defaultPadding } from './css-constants.js';
// const defaultPadding = 5;

static get styles() {
  return [css`
    :host {
      padding: ${defaultPadding*2}px;
    }
  `];
}

Expected Results

Renders with padding of 10px.

imho Numbers should be allowed as they "are save" and can not be used for any form of css attack right?

Actual Results

Error thrown

Error: Value passed to 'css' function must be a 'css' function result: 10.

Browsers Affected

  • all

Versions

  • lit-element: v2.0.0-rc.x

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions