11<pre class="metadata">
2- Title : CSS Route and Navigation Matching
2+ Title : CSS Navigation Matching
33Status : ED
44Work Status : Exploring
55Shortname : css-navigation
@@ -42,58 +42,57 @@ url: https://drafts.csswg.org/css-view-transitions-1/#capture-the-image
4242
4343<h2 id="url-patterns-in-css">Defining URL patterns in CSS</h2>
4444
45- <h3 id="route- value-type">The <<route -location>> value type</h3>
45+ <h3 id="nav-location- value-type">The <<navigation -location>> value type</h3>
4646
4747<pre class="prod def" dfn-type="type" nohighlight>
48- <dfn><<route -location>></dfn> = <<url>> | [ <<route -name>> | <<url-pattern()>> ]
49- <dfn><<route -name>></dfn> = <<dashed-ident>>
48+ <dfn><<navigation -location>></dfn> = <<url>> | [ <<location -name>> | <<url-pattern()>> ]
49+ <dfn><<location -name>></dfn> = <<dashed-ident>>
5050</pre>
5151
52- A <<route -location>> is defined to
53- <dfn for="route -location">match</dfn> a [=/URL=] -or-null <var> input</var> if <var> input</var> is non-null,
52+ A <<navigation -location>> is defined to
53+ <dfn for="navigation -location">match</dfn> a [=/URL=] -or-null <var> input</var> if <var> input</var> is non-null,
5454and the corresponding statement:
5555
5656<dl class=switch>
5757
58- : the <<route -location>> is a <<route -name>>
59- :: The [=URL pattern=] represented by the ''@route '' rule referenced by the name [=URL pattern/match|matching=] <var> input</var> .
58+ : the <<navigation -location>> is a <<location -name>>
59+ :: The [=URL pattern=] represented by the ''@location '' rule referenced by the name [=URL pattern/match|matching=] <var> input</var> .
6060
61- : the <<route -location>> is a <<url-pattern()>>
61+ : the <<navigation -location>> is a <<url-pattern()>>
6262:: The provided [=URL pattern=][=URL pattern/match|matches=] <var> input</var> .
6363
64- : the <<route -location>> is a <<url>>
64+ : the <<navigation -location>> is a <<url>>
6565:: The provided [=/URL=] [=url/equals=] <var> input</var> .
6666
6767</dl>
6868
6969The <css> navigation-source-url</css> represents the [=current navigation URL=] given ''from'' .
7070The <css> navigation-destination-url</css> represents the [=current navigation URL=] given ''to'' .
7171The <css> navigation-current-url</css> represents the [=current navigation URL=] given ''at'' .
72- The <css> navigation-peer-url</css> represents the [=current navigation URL=] given ''with'' .
7372
7473ISSUE: bikeshed on naming these keywords.
7574
76- <h3 id="at-route ">Declaring named URL patterns: the ''@route '' rule</h3>
75+ <h3 id="at-location ">Declaring named URL patterns: the ''@location '' rule</h3>
7776
78- The <dfn at-rule id="at-ruledef-route ">@route </dfn> rule
77+ The <dfn at-rule id="at-ruledef-location ">@location </dfn> rule
7978is an at-rule that associates an author-defined name with a [=URL pattern=] .
8079This name can be referenced in ''@navigation'' rules
8180and in '':link-to()'' pseudo-classes.
8281
83- The syntax of the ''@route '' rule is described by the <<route -rule>> production in:
82+ The syntax of the ''@location '' rule is described by the <<location -rule>> production in:
8483
8584<pre class="prod def" dfn-type="type" nohighlight>
86- <dfn><<route -rule>></dfn> = @route <<dashed-ident>> { <<declaration-list>> }
85+ <dfn><<location -rule>></dfn> = @location <<dashed-ident>> { <<declaration-list>> }
8786</pre>
8887
8988This means that the rule accepts a sequence of descriptors
9089that have the syntax of declarations.
9190However, in valid style sheets the only descriptors must match
92- the <<route -descriptor>> production below.
91+ the <<location -descriptor>> production below.
9392Any other descriptors are ignored.
9493
9594<pre class="prod def" dfn-type="type" nohighlight>
96- <dfn><<route -descriptor>></dfn> = <<pattern-descriptor>> |
95+ <dfn><<location -descriptor>></dfn> = <<pattern-descriptor>> |
9796 <<init-descriptor>> |
9897 <<base-descriptor>>
9998<dfn><<pattern-descriptor>></dfn> = pattern : <<url-pattern()>>
@@ -110,7 +109,7 @@ If a rule has both a valid <<pattern-descriptor>>
110109and a valid <<init-descriptor>>
111110then it is ignored.
112111
113- The ''@route '' rule can be defined in one of two ways:
112+ The ''@location '' rule can be defined in one of two ways:
114113
115114: with the <code> pattern</code> descriptor
116115:: in this case the URL pattern represented is
@@ -135,20 +134,20 @@ ISSUE: ''document'' should probably only apply in origin-clean stylesheets.
135134Is this more confusing? Should we have that rather than the ordinary stylesheet-based URLs?
136135
137136ISSUE: Should this use <<dashed-ident>> , <<custom-ident>> , or <<ident>>
138- for the route names?
137+ for the location names?
139138
140139ISSUE: Should we use <code> base-url</code> or just <code> base</code> as the descriptor name?
141140
142141NOTE: The list of allowed init descriptors does not include <code> username</code>
143142or <code> password</code> since they seem unlikely to be useful.
144143
145144<div class="issue">
146- It's possible that this syntax with init descriptors in the ''@route '' rule
145+ It's possible that this syntax with init descriptors in the ''@location '' rule
147146would make more sense as part of the ''url-pattern()'' function
148147(that is, as an alternate syntax for what goes inside the function).
149148
150149This would also give us the option to remove the braces from
151- the syntax of the ''@route '' rule
150+ the syntax of the ''@location '' rule
152151and make it more like ''@import'' or ''@namespace'' .
153152This does remove a potential future extensibility point,
154153but it could also be added back later if we need it.
@@ -157,17 +156,17 @@ but it could also be added back later if we need it.
157156<div class="example">
158157Either this rule:
159158<pre highlight=css>
160- @route --movie-list {
159+ @location --movie-list {
161160 pattern: url-pattern("/movies");
162161}
163162</pre>
164163or this rule:
165164<pre highlight=css>
166- @route --movie-list {
165+ @location --movie-list {
167166 pathname: "/movies";
168167}
169168</pre>
170- define an ''@route '' rule that associates
169+ define an ''@location '' rule that associates
171170the name <code> --movie-list</code>
172171with the URL <code> "/movies"</code> resolved relative to the style sheet.
173172</div>
@@ -263,11 +262,11 @@ which can be ''document'', ''stylesheet'', or a URL, is:
263262<div class="example">
264263This rule:
265264<pre highlight=css>
266- @route --movie-detail {
265+ @location --movie-detail {
267266 pattern: url-pattern("/movies/:id");
268267}
269268</pre>
270- defines an ''@route '' rule that associates
269+ defines an ''@location '' rule that associates
271270the name <code> --movie-detail</code>
272271with any URL that matches the [=URL pattern=] <code> /movies/:id</code> .
273272
@@ -288,25 +287,25 @@ These URLs will not match:
288287</div>
289288
290289<div class="example">
291- To have the <code> --movie-details</code> route
290+ To have the <code> --movie-details</code> location
292291match only numeric <code> :id</code> values,
293- define the route eiter as:
292+ define the location either as:
294293
295294<pre highlight=css>
296- @route --movie-detail {
295+ @location --movie-detail {
297296 pattern: url-pattern("/movies/:id(\\d+)");
298297}
299298</pre>
300299
301300or as:
302301
303302<pre highlight=css>
304- @route --movie-detail {
303+ @location --movie-detail {
305304 pattern: url-pattern("/movies/(\\d+)");
306305}
307306</pre>
308307
309- This way, <code> /movies/something</code> won’t be matched by the route .
308+ This way, <code> /movies/something</code> won’t be matched by the location .
310309
311310NOTE: Even though the capture groups are not currently exposed,
312311it is recommended to give the capture groups a name for future use.
@@ -352,10 +351,10 @@ which matches any links that link to the site's homepage:
352351}
353352</pre>
354353
355- Passing in a named route is also possible:
354+ Passing in a named location is also possible:
356355
357356<pre highlight=css>
358- @route --homepage {
357+ @location --homepage {
359358 pattern: url-pattern("/");
360359}
361360
@@ -376,10 +375,10 @@ you might be tempted to pass in a <<url>> directly:
376375However, <code> url("/")</code> won't match URLs such as
377376<code> /#scroll-to-here</code> or <code> /?utm_id=something</code>
378377so it is recommended to use the <<url-pattern()>>
379- or <<route -location>> variants, or use the following alternative:
378+ or <<navigation -location>> variants, or use the following alternative:
380379
381380<pre highlight=css>
382- @route --homepage {
381+ @location --homepage {
383382 pathname: "/";
384383 base-url: document;
385384}
@@ -409,7 +408,7 @@ by matching the relevant parts of the navigation URL to the link URL.
409408 navigation: auto;
410409}
411410
412- @route --movie-detail {
411+ @location --movie-detail {
413412 /* match URLs like /en/movies/123 which is the English page
414413 about a movie with ID 123. Be careful to specify the
415414 language part with a "*" but the ID part with a named
@@ -506,25 +505,25 @@ This is particularly useful for defining
506505styles that cause [=view transitions=] .
507506
508507<pre highlight="css">
509- @route --search-results-page {
508+ @location --search-results-page {
510509 pattern: url-pattern("/search-results");
511510}
512- @route --product-page {
511+ @location --product-page {
513512 pattern: url-pattern("/product/:id");
514513}
515514
516515@navigation (from: --search-results-page) and
517516 (to: --product-page) {
518517 /* These styles apply when a navigation is in progress
519518 from a search results page to a product page (as
520- defined by the @route rules above), but not in the
519+ defined by the @location rules above), but not in the
521520 reverse direction. */
522521}
523522
524523@navigation (between: --search-results-page and --product-page) {
525524 /* These styles apply when a navigation is in progress
526525 between a search results page and a product page (as
527- defined by the @route rules above), in either
526+ defined by the @location rules above), in either
528527 direction. */
529528}
530529</pre>
@@ -551,11 +550,11 @@ with <<navigation-condition>> defined as:
551550 <<navigation-type-test>> |
552551 <<navigation-phase-test>>
553552
554- <dfn><<navigation-location-test>></dfn> = <<navigation-relation>> : <<route -location>>
555- <dfn><<navigation-relation>></dfn> = at | with | from | to
553+ <dfn><<navigation-location-test>></dfn> = <<navigation-relation>> : <<navigation -location>>
554+ <dfn><<navigation-relation>></dfn> = at | from | to
556555
557556<dfn><<navigation-location-between-test>></dfn> =
558- between : <<route -location>> and <<route -location>>
557+ between : <<navigation -location>> and <<navigation -location>>
559558
560559<dfn><<navigation-type-test>></dfn> = history : <<navigation-type-keyword>>
561560<dfn><<navigation-type-keyword>></dfn> = traverse | back | forward | reload
@@ -564,7 +563,7 @@ with <<navigation-condition>> defined as:
564563<dfn><<navigation-phase-keyword>></dfn> = loading | ready | committed
565564</pre>
566565
567- ISSUE: Should we use ''at'' /''with'' / '' from'' /''to'' or ''current'' /''other'' /''from'' /''to'' ?
566+ ISSUE: Should we use ''at'' /''from'' /''to'' or ''current'' /''other'' /''from'' /''to'' ?
568567
569568The above grammar is purposely very loose for forwards-compatibility reasons,
570569since the <<general-enclosed>> production
@@ -598,17 +597,17 @@ as follows:
598597
599598: <<navigation-location-test>>
600599:: The result is true if
601- the <<route -location>> [=route -location/matches=] [=current navigation URL=] of the document given the <<navigation-relation>> .
600+ the <<navigation -location>> [=navigation -location/matches=] [=current navigation URL=] of the document given the <<navigation-relation>> .
602601
603602: <<navigation-location-between-test>>
604- :: : between: <<route -location>> and <<route -location>>
603+ :: : between: <<navigation -location>> and <<navigation -location>>
605604 :: The result is true if
606605 the [=current navigation URL=] <var> from</var> of the document given ''from'' is non-null,
607606 the [=current navigation URL=] <var> to</var> of the document ''to'' is non-null,
608- one of the two <<route -location>> s
609- [=route -location/matches=] <var> from</var> ,
610- and the other of the two <<route -location>> s
611- [=route -location/matches=] <var> to</var> .
607+ one of the two <<navigation -location>> s
608+ [=navigation -location/matches=] <var> from</var> ,
609+ and the other of the two <<navigation -location>> s
610+ [=navigation -location/matches=] <var> to</var> .
612611
613612: <<navigation-type-test>>
614613:: : history: traverse
@@ -751,10 +750,6 @@ To get the <dfn>current navigation URL</dfn> given a {{Document}} |document| and
751750
752751: ''at''
753752:: |state|'s [=navigation state/new URL=] if |state|' s [=navigation state/phase=] is `committed`; Otherwise |state|'s [=navigation state/old URL=] .
754-
755- : ''with''
756- :: |state|'s [=navigation state/old URL=] if |state|' s [=navigation state/phase=] is `committed`; Otherwise |state|'s [=navigation state/new URL=] .
757-
758753</dl>
759754
760755To get the <dfn>current navigation type</dfn> of a [=/document=] |document|:
0 commit comments