W3C home > Mailing lists > Public > public-css-archive@w3.org > March 2019

[csswg-drafts] [css-values] String parsing function (replaces multi-value `attr()`) (#3702)

From: Amelia Bellamy-Royds via GitHub <sysbot+gh@w3.org>
Date: Sat, 02 Mar 2019 16:37:33 +0000
To: public-css-archive@w3.org
Message-ID: <issues.opened-416414510-1551544652-sysbot+gh@w3.org>
AmeliaBR has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-values] String parsing function (replaces multi-value `attr()`) ==
With the discussion in #542 about converting non-string variables to string, it's worth discussing the reverse: a parser function that can take a string and parse it according to a specified CSS grammar.

Such a function could replace the [multi-value `attr()` function](https://drafts.csswg.org/css-values/#attr-notation) that was supposed to allow authors to extract typed values from attributes.  The type-aware `attr()` function [is not supported in any current web browsers](https://caniuse.com/#feat=css3-attr); I'm not sure if it has support in other CSS environments.

At the same time, a general parsing function could be used with CSS variables, or with strings generated by combining variables with the new concatenation function in ways that require re-tokenization.

Suggested syntax:

```
<parse-function> = parse(<string> <syntax-string> / <fallback-value>);
```

It would use [syntax strings as defined in the Properties and Values API](https://drafts.css-houdini.org/css-properties-values-api/#syntax-strings) instead of the custom keywords in the current `attr()` definition.

Examples:

```css
.icon {
  content: parse(attr(href) "<image>" / url("fallback.png"));
  width: parse( concat(attr(data-width), var(--icon-unit)) "<length>" / 1em);
}
```

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/3702 using your GitHub account
Received on Saturday, 2 March 2019 16:37:34 UTC

This archive was generated by hypermail 2.4.0 : Thursday, 24 March 2022 20:26:57 UTC