Skip to content

Commit d40366f

Browse files
committed
[css-navigation-1] Improve descriptor interactions in @route and enhance base-url.
This improves the interaction of descriptors inside of the @route rule by defining the normal error handling behavior for property- or descriptor-like things. It also allows the base-url descriptor to work with the pattern descriptor rather than only with the init-descriptors. Finally, it gives the base-url descriptor stylesheet (default) and document values.
1 parent 3317e61 commit d40366f

1 file changed

Lines changed: 70 additions & 43 deletions

File tree

css-navigation-1/Overview.bs

Lines changed: 70 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -44,52 +44,64 @@ is an at-rule that associates a name with a [=URL pattern=].
4444
This name can be referenced in ''@navigation'' rules
4545
and in '':active-navigation()'' pseudo-classes.
4646

47-
The syntax of the ''@route'' rule is:
47+
The syntax of the ''@route'' rule is described by the <<route-rule>> production in:
4848

4949
<pre class="prod def" nohighlight>
50-
@route <<dashed-ident>> {
51-
[ <<pattern-descriptors>> | <<init-descriptors>> ]
52-
}
50+
<dfn><<route-rule>></dfn> = @route <<dashed-ident>> { <<declaration-list>> }
5351
</pre>
5452

55-
based on the following definitions:
53+
This means that the rule accepts a sequence of descriptors
54+
that have the syntax of declarations.
55+
However, in valid style sheets the only descriptors must match
56+
the <<route-descriptor>> production below.
57+
Any other descriptors are ignored.
5658

57-
<pre class="prod def" dfn-type="type" nohighlight>
58-
<dfn><<pattern-descriptors>></dfn> = ;* <<pattern-descriptor>> ;*
59+
<pre class="prod def" nohighlight>
60+
<dfn><<route-descriptor>></dfn> = <<pattern-descriptor>> |
61+
<<init-descriptor>> |
62+
<<base-descriptor>>
5963
<dfn><<pattern-descriptor>></dfn> = pattern : <<url-pattern()>>
60-
<dfn><<init-descriptors>></dfn> = ;* <<init-descriptor>> [ ;+ <<init-descriptor>> ]* ;*
6164
<dfn><<init-descriptor>></dfn> = <<init-descriptor-name>> : <<string>>
6265
<dfn><<init-descriptor-name>></dfn> = protocol | hostname | port | pathname |
63-
search | hash | base-url
66+
search | hash
67+
<dfn><<base-descriptor>></dfn> = base-url : stylesheet | document | <<url>>
6468
</pre>
6569

66-
This associates an author-defined keyword with a URL pattern,
70+
If two valid descriptors in a single rule have the same name,
71+
the last one is used and the others are ignored.
72+
If a rule has both a valid <<pattern-descriptor>>
73+
and a valid <<init-descriptor>>
74+
then it is ignored.
75+
76+
This rule associates an author-defined keyword with a URL pattern,
6777
so that any URL that matches one of the URL patterns
6878
matches the route named by the keyword.
6979

7080
The ''@route'' rule can be defined in one of two ways:
7181

7282
: with the <code>pattern</code> descriptor
7383
:: in this case the URL pattern represented is
74-
the one represented by the <<url-pattern()>> function
75-
given as the descriptor's value.
84+
the result of invoking
85+
[=create a URL pattern for url-pattern()=] given
86+
<var>arg</var> as the argument to the ''url-pattern()'' function
87+
and <var>baseURLSpecifier</var> as
88+
the (optional) value of the rule's <<base-descriptor>>.
7689
: with the other descriptors named by <<init-descriptor-name>>
7790
:: In this case the URL pattern represented is the result of invoking
7891
[=URL pattern/create|create a URL pattern=] given
7992
<var>input</var> as {{URLPatternInit}}
8093
constructed from the descriptors and their values.
8194
Each dictionary member is given the value of
8295
the descriptor with the same name,
83-
except the <code>baseURL</code> member is given the value of
84-
the <code>base-url</code> descriptor.
85-
If a <code>base-url</code> descriptor is not given then one is created from
86-
the [=style resource base URL=] of the rule.
96+
except the <code>baseURL</code> member is given the result of
97+
[=create a URL for a base descriptor=]
98+
given <var>baseURLSpecifier</var> as
99+
the (optional) value of the rule's <<base-descriptor>>.
87100

88101
ISSUE: Should this use <<dashed-ident>>, <<custom-ident>>, or <<ident>>
89102
for the route names?
90103

91-
ISSUE: Is there value in being able to provide a list of <<url-pattern()>>
92-
rather than just one?
104+
ISSUE: Should we use <code>base-url</code> or just <code>base</code> as the descriptor name?
93105

94106
NOTE: The list of allowed init descriptors does not include <code>username</code>
95107
or <code>password</code> since they seem unlikely to be useful.
@@ -147,33 +159,16 @@ which can be used to match URLs.
147159
<<url-pattern()>> = url-pattern( <<string>> )
148160
</pre>
149161

150-
This function represents a [=URL pattern=] that can be created
151-
using the steps of the <dfn>create a URL pattern for url-pattern()</dfn> algorithm:
152-
153-
1. Let <var>arg</var> be the <<string>> argument to the ''url-pattern()'' function.
162+
This function represents the [=URL pattern=] resulting from
163+
invoking [=create a URL pattern for url-pattern()=] with its string argument.
154164

155-
1. Let <var>baseURL</var> be the [=style resource base URL=] of
156-
the rule or declaration block containing the ''url-pattern()'' function.
165+
The steps of the <dfn>create a URL pattern for url-pattern()</dfn> algorithm,
166+
given a string <var>arg</var> and
167+
an optional <var>baseURLSpecifier</var>
168+
which can be ''document'', ''stylesheet'', or a URL, are:
157169

158-
<div class="issue">
159-
Do we want this to be the base URL all the time?
160-
For use of ''url-pattern()'' in ''@navigation'',
161-
it's likely more useful for the base URL
162-
to be the document URL rather than the style sheet URL.
163-
However, it would be very awkward for ''url-pattern()''
164-
to be inconsistent with ''url()''.
165-
166-
Should we allow the base URL of ''url-pattern()''
167-
to be defined by the consumer?
168-
Should we introduce <code>document-url-pattern()</code>?
169-
Should we do something similar to
170-
[[css-images-3#ambiguous-urls]]
171-
(see <w3c/csswg-drafts#383>)?
172-
173-
Also see other proposed uses of {{URLPattern}} in CSS
174-
in <w3c/csswg-drafts#10975>,
175-
for '':local-link''.
176-
</div>
170+
1. Let <var>baseURL</var> be the result of
171+
[=create a URL for a base descriptor=] given <var>baseURLSpecifier</var>.
177172

178173
1. Return the result of [=URL pattern/create|create a URL pattern=] given
179174
<var>arg</var>, <var>baseURL</var>, and an empty [=map=].
@@ -182,6 +177,38 @@ NOTE: This function requires that its argument is quoted.
182177
This differs from the ''url()'' function,
183178
which allows its argument to be quoted or unquoted.
184179

180+
The <dfn>create a URL for a base descriptor</dfn> algorithm, given
181+
an optional <var>baseURLSpecifier</var>
182+
which can be ''document'', ''stylesheet'', or a URL, is:
183+
184+
<dl class=switch>
185+
186+
: if <var>baseURLSpecifier</var> is not present or is ''stylesheet''
187+
:: the [=style resource base URL=] of
188+
the rule or declaration block containing the ''url-pattern()'' function.
189+
190+
: if <var>baseURLSpecifier</var> is ''document''
191+
:: the [=document base URL=] of the document
192+
193+
: if <var>baseURLSpecifier</var> is a URL
194+
:: <var>baseURLSpecifier</var>
195+
196+
</dl>
197+
198+
<div class="issue">
199+
Should the default always be ''stylesheet''?
200+
For use of ''url-pattern()'' in ''@navigation'',
201+
it's likely more useful for the base URL
202+
to be the document URL rather than the style sheet URL.
203+
However, it would be very awkward for ''url-pattern()''
204+
to be inconsistent with ''url()''.
205+
206+
Also see other proposed uses of {{URLPattern}} in CSS
207+
in <w3c/csswg-drafts#10975>,
208+
for '':local-link''.
209+
</div>
210+
211+
185212
To <dfn export>serialize a ''url-pattern()'' function</dfn> <var>f</var>,
186213
[=serialize a function=] <var>f</var>,
187214
using [=serialize a string=] on the single argument

0 commit comments

Comments
 (0)