Skip to content

Commit e3d2bf1

Browse files
committed
[css-link-params-1] Switch to using fragment directives. #14235
1 parent 8b6ae6d commit e3d2bf1

1 file changed

Lines changed: 28 additions & 14 deletions

File tree

css-link-params-1/Overview.bs

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ spec:html; type:element
2323
text: a
2424
spec:fill-stroke-3; type:property; text:fill
2525
spec:css-env-1; type:function; text:env()
26+
spec:scroll-to-text-fragment; type:dfn;
27+
text:fragment directive
28+
text:text directive
2629
</pre>
2730

2831
Introduction {#intro}
@@ -48,7 +51,8 @@ are a way to set CSS <a>custom environment variables</a> on an "external" resour
4851
either by a CSS property
4952
or thru a special fragment scheme on the URL.
5053
This gives a limited, but powerful, subset of the customizability that "inline" SVG images have
51-
to "external" SVG images.
54+
to "external" SVG images,
55+
or to other linked resources that use CSS to style themselves.
5256

5357
A [=link parameter=] is a pair of a <<dashed-ident>> name,
5458
and an arbitrary (possibly empty) <<declaration-value>> value.
@@ -70,7 +74,7 @@ and an arbitrary (possibly empty) <<declaration-value>> value.
7074
in several ways:
7175

7276
<xmp highlight=html>
73-
<img src="image.svg#param(--color,green)">
77+
<img src="image.svg#:~:param(--color,green)">
7478
</xmp>
7579

7680
<pre highlight=css>
@@ -99,7 +103,7 @@ There are three ways to specify a [=link parameter=]:
99103
which applies to the resource itself
100104
(if the element represents an external resource),
101105
and to all external resources used in CSS properties on the element
102-
* via a special syntax in the fragment portion of the URL of an external resource
106+
* via a [=fragment directive=] directly in the URL of an external resource.
103107
* via a ''param()'' argument in the ''url()'' syntax
104108

105109
If specified in multiple of these ways,
@@ -108,7 +112,7 @@ for the external resource,
108112
in the order:
109113

110114
1. the 'link-parameters' property on the element, if relevant
111-
2. the [=param()=] URL fragment identifiers
115+
2. the [=link parameter directives=] of the URL
112116
3. the ''param()'' <<url-modifier>>s in ''url()''
113117

114118
If multiple [=link parameters=] exist with the same name,
@@ -163,33 +167,43 @@ It has the syntax:
163167
In The URL {#url-frag}
164168
----------
165169

166-
A special "fragment identifier" can be used in the <a for=url>fragment</a> of a URL
167-
used to reference an external resource.
168-
Several examples of existing "fragment identifiers" for SVG documents can be found in <a href="http://www.w3.org/TR/SVG/linking.html#LinksIntoSVG">the SVG 1.1 specification</a>.
170+
[=Link parameters=] can be passed to an external resource directly,
171+
as a [=fragment directive=].
169172

170-
The syntax of an <dfn export local-lt="param()">SVG parameter fragment identifier</dfn> is:
173+
Note: [=Text directives=] are another example of [=fragment directives=],
174+
letting you link to specific text somewhere in a document.
171175

172-
<pre class=prod>param( <<dashed-ident>> , <<declaration-value>>? )</pre>
176+
The <dfn export>link parameter directive</dfn> is a [=fragment directive=]
177+
with the following syntax:
173178

174-
(using the <a>CSS value definition syntax</a>; TODO define an actual parser for it).
179+
```
180+
:~:param(...)
181+
```
182+
183+
Where the <code>...</code> represents any sequence of URL codepoints and/or <l spec=url>[=percent-encoded bytes=]</l>.
184+
185+
After URL-decoding, the [=link parameter directive=] is then [=CSS/parsed=] as a <<param()>>.
186+
If it fails to parse, the directive is ignored.
187+
Otherwise, it's added to the embedded document's list of link parameters,
188+
with a name given by the <<dashed-ident>> and a value given by the <<declaration-value>>?.
175189

176190
<div class="example">
177191
For example, to set the ''env(--text-color)'' [=custom environment variable=]
178192
of an SVG image to ''blue'',
179193
one can reference the image with a url like
180-
<code>http://example.com/image.svg#param(--text-color,blue)</code>”.
194+
<code>http://example.com/image.svg#:~:param(--text-color,blue)</code>”.
181195
</div>
182196

183197
Multiple [=link parameters=] can be passed to an image
184-
by appending multiple [=param()=] fragment identifiers to the URL.
198+
by appending multiple [=link parameter directives=] to the URL.
185199
When combined, either with each other or with other "fragment identifiers",
186200
each value is separated with an <code>&</code> character,
187201
as in a URL's query parameters.
188202

189203
<div class="example">
190204
For example, if the image from the previous example also used ''env(--bg-color)'',
191205
it could be referenced with a url like
192-
<code>http://example.com/image.svg#param(--text-color,blue)&amp;param(--bg-color,white)</code>
206+
<code>http://example.com/image.svg#:~:param(--text-color,blue)&amp;param(--bg-color,white)</code>
193207
to set both ''env(--text-color)'' and ''env(--bg-color)''.
194208
</div>
195209

@@ -205,7 +219,7 @@ Setting via the CSS ''url()'' Function {#setting-url}
205219
-----------------------------------------------------
206220

207221
When referencing an external resource via CSS,
208-
the <a>param()</a> function can be used in the ''url()'' function.
222+
the ''param()'' function can be used in the ''url()'' function.
209223
But a common use-case is passing in values of the page's own <a>custom properties</a>;
210224
for example, a page might use a ''--primary-color'' <a>custom property</a>,
211225
and want to make an SVG image match.

0 commit comments

Comments
 (0)