@@ -40,7 +40,7 @@ url: https://drafts.csswg.org/css-view-transitions-1/#capture-the-image
4040The <dfn at-rule id="at-ruledef-route">@route</dfn> rule
4141is an at-rule that associates a name with a [=URL pattern=] .
4242This name can be referenced in ''@navigation'' rules
43- and in '':link-to ()'' pseudo-classes.
43+ and in '':active-navigation ()'' pseudo-classes.
4444
4545The syntax of the ''@route'' rule is:
4646
@@ -270,34 +270,22 @@ as follows:
270270:: : at: <<navigation-location>>
271271 :: The result is true if
272272 the [=current at URL=] <var> at</var> of the document is non-null and
273- [=URL pattern/match|match a URL pattern=] is non-null
274- given <var> urlPattern</var> as
275- the [=navigation location URL pattern=] of <<navigation-location>>
276- and <var> input</var> as <var> at</var> .
273+ the <<navigation-location>> [=navigation-location/matches=] <var> at</var> .
277274
278275 : with: <<navigation-location>>
279276 :: The result is true if
280277 the [=current with URL=] <var> other</var> of the document is non-null and
281- [=URL pattern/match|match a URL pattern=] is non-null when
282- given <var> urlPattern</var> as
283- the [=navigation location URL pattern=] of <<navigation-location>>
284- and <var> input</var> as <var> other</var> .
278+ the <<navigation-location>> [=navigation-location/matches=] <var> other</var> .
285279
286280 : from: <<navigation-location>>
287281 :: The result is true if
288282 the [=current from URL=] <var> from</var> of the document is non-null and
289- [=URL pattern/match|match a URL pattern=] is non-null when
290- given <var> urlPattern</var> as
291- the [=navigation location URL pattern=] of <<navigation-location>>
292- and <var> input</var> as <var> from</var> .
283+ the <<navigation-location>> [=navigation-location/matches=] <var> from</var> .
293284
294285 : to: <<navigation-location>>
295286 :: The result is true if
296287 the [=current to URL=] <var> to</var> of the document is non-null and
297- [=URL pattern/match|match a URL pattern=] is non-null when
298- given <var> urlPattern</var> as
299- the [=navigation location URL pattern=] of <<navigation-location>>
300- and <var> input</var> as <var> to</var> .
288+ the <<navigation-location>> [=navigation-location/matches=] <var> to</var> .
301289
302290: <<navigation-location-between-test>>
303291:: : between: <<navigation-location>> and <<navigation-location>>
@@ -349,6 +337,13 @@ See the
349337<a href="https://github.com/WICG/declarative-partial-updates/blob/main/route-matching-explainer.md">route matching explainer</a>
350338for details.
351339
340+ A <<navigation-location>> is defined to
341+ <dfn for="navigation-location">match</dfn> a URL <var> input</var> if
342+ [=URL pattern/match|match a URL pattern=] is non-null given
343+ <var> urlPattern</var> as the [=navigation location URL pattern=] of the
344+ <<navigation-location>> and
345+ <var> input</var> as <var> input</var> .
346+
352347A <dfn>document's navigation API</dfn> is
353348the result of the following steps on <var> document</var> :
354349
@@ -390,7 +385,9 @@ ISSUE: This should probably have a more formal definition of the function,
390385but I can't find the formal definitions of the existing ''if()'' functions
391386to model it after.
392387
393- <h2 id="link-navigation-pseudo-classes">Pseudo-class for navigation-related links: '':link-to()''</h2>
388+ <h2 id="link-navigation-pseudo-classes">Pseudo-class for navigation-related links: '':link-to()'' and '':active-navigation()''</h2>
389+
390+ <h3 id="link-to-pseudo-class">The ''::link-to()'' pseudo-class</h3>
394391
395392This specification defines a new
396393<dfn id="link-to-pseudo" selector>'':link-to()''</dfn> functional pseudo-class
@@ -409,9 +406,22 @@ which matches any links that link to the site's homepage:
409406
410407</div>
411408
409+ The '':link-to()'' pseudo-class takes a single argument, a <<navigation-location>> ,
410+ and the pseudo-class matches any element where both:
411+ * the element matches '':any-link''
412+ * the <<navigation-location>> [=navigation-location/matches=] the target of the link
413+
414+ <h3 id="active-navigation-pseudo-class">The ''::active-navigation()'' pseudo-class</h3>
415+
416+ This specification defines a new
417+ <dfn id="active-navigation-pseudo" selector>'':active-navigation()''</dfn>
418+ functional pseudo-class
419+ that matches link elements that link to a certain URL
420+ that is related to a navigation that is currently active.
421+
412422<div class="example">
413423
414- A more interesting example of the '':link-to ()'' pseudo-class
424+ A an example of the '':active-navigation ()'' pseudo-class
415425is this example which creates a view transition between
416426a item in a list that contains a link (in this document)
417427and the details page for that link (in a different document).
@@ -457,7 +467,7 @@ by matching the relevant parts of the navigation URL to the link URL.
457467 match, containing the language, can be different.)
458468 */
459469.movie-container:has(
460- > .movie-title:link-to (with --movie-details-with-id)) {
470+ > .movie-title:active-navigation (with --movie-details-with-id)) {
461471
462472 view-transition-name: movie-container;
463473
@@ -472,84 +482,69 @@ by matching the relevant parts of the navigation URL to the link URL.
472482
473483</div>
474484
475- The '':link-to ()'' pseudo-class takes a single argument, a <<link -condition>> ,
485+ The '':active-navigation ()'' pseudo-class takes a single argument, a <<active-navigation -condition>> ,
476486and the pseudo-class matches any element where:
477487* the element matches '':any-link''
478- * the target of link matches the <<link -condition>> , as defined below.
488+ * the target of the link matches the <<active-navigation -condition>> , as defined below.
479489
480490<pre class="prod def" dfn-type="type" nohighlight>
481- <dfn><<link- condition>></dfn> = [ <<navigation-relation>> ]? <<link-condition-base>>
482- <dfn><<link-condition-base>></dfn> = <<navigation-location>>
491+ <dfn><<active-navigation- condition>></dfn> =
492+ <<navigation-relation>> ? [ <<navigation-location>> | link-href ] ?
483493<dfn><<navigation-relation>></dfn> = at | with | from | to
484494</pre>
485495
486- ISSUE: Should we use ''navigation-'' (''at'' /''with'' /''from'' /''to'' ) or
487- ''navigation-'' (''current'' /''other'' /''from'' /''to'' )?
488-
489- ISSUE: Should the '':link-to()'' variant that has a <<link-condition>> have a different name,
490- such as '':navigating-link()'' ?
491-
492- A <<link-condition>> matches the target of the link when both:
493- * the <<link-condition-base>> matches the target of the link, and
494- * either:
495- * a <<navigation-match>> is not present, or
496- * the <<navigation-match>> matches the target of the link,
497- with the [=URL pattern=] represented by the <<link-condition-base>> as context
498-
499- A <<link-condition-base>> represents a [=URL pattern=] .
500- If the <<link-condition-base>> is a <<url-pattern()>> ,
501- then it represents the URL pattern
502- represented by the <<url-pattern()>> function
503- (see [=create a URL pattern for url-pattern()=] ).
504- If it is a <<route-name>> , then it represents the URL pattern
505- represented by the ''@route'' rule.
506-
507- A <<link-condition-base>> matches a URL
508- when [=URL pattern/match|match a URL pattern=] is non-null
509- given <var> urlPattern</var> as
510- the [=URL pattern=] that it represents and
511- <var> input</var> as the given URL.
512-
513- A <<navigation-match>> matches the URL <var> linkTarget</var>
514- (with a URL Pattern <var> urlPattern</var> as context)
515- if the following steps return true:
516- 1. Let <var> targetMatchResult</var> be the result of
517- [=URL pattern/match|match a URL pattern=]
518- given <var> urlPattern</var> and <var> linkTarget</var> .
519- 1. If <var> targetMatchResult</var> is null, return false.
520-
521- NOTE: This doesn't really matter because
522- in this case the <<link-condition-base>> also doesn't match.
523- 1. Let <var> matchRelation</var> be the <<navigation-relation>> argument
524- of the <<navigation-match>> .
525- 1. Let <var> navigationURL</var> be:
526- : If <var> matchRelation</var> is ''at'' ,
527- :: the <a>current at URL</a> of the document.
528- : Otherwise, if <var> matchRelation</var> is ''with'' ,
529- :: the <a>current with URL</a> of the document.
530- : Otherwise, if <var> matchRelation</var> is ''from'' ,
531- :: the <a>current from URL</a> of the document.
532- : Otherwise (Assert: <var> matchRelation</var> is ''to'' ),
533- :: the <a>current to URL</a> of the document.
496+ NOTE: The ''link-href'' keyword is an explicit way to represent the default,
497+ but there is no difference between specifying it explicitly or omitting it.
498+
499+ ISSUE: Should we use ''at'' /''with'' /''from'' /''to'' or
500+ ''current'' /''other'' /''from'' /''to'' ?
501+
502+ The <dfn>active navigation URL</dfn> for an <<active-navigation-condition>> is:
503+ <dl switch>
504+ <dt> If the <<navigation-relation>> is ''at''
505+ <dd> The [=current at URL=] of the document
506+ <dt> If the <<navigation-relation>> is ''with'' or is omitted
507+ <dd> The [=current with URL=] of the document
508+ <dt> If the <<navigation-relation>> is ''from''
509+ <dd> The [=current from URL=] of the document
510+ <dt> If the <<navigation-relation>> is ''to''
511+ <dd> The [=current to URL=] of the document
512+ </dl>
513+
514+ An <<active-navigation-condition>> matches the target <var> linkTarget</var> of the link when
515+ the following steps return true:
516+ 1. Let <var> navigationURL</var> be
517+ the [=active navigation URL=] of the <<active-navigation-condition>>
5345181. If <var> navigationURL</var> is null, return false.
535- 1. Let <var> navigationMatchResult</var> be the result of
536- [=URL pattern/match|match a URL pattern=] given
537- <var> navigationURL</var> and <var> urlPattern</var> .
519+ 1. If a <<navigation-location>> is present:
520+ 1. Let <var> targetMatchResult</var> be the result of
521+ [=URL pattern/match|match a URL pattern=]
522+ given <var> urlPattern</var> and <var> linkTarget</var> .
523+
524+ 1. Let <var> navigationMatchResult</var> be the result of
525+ [=URL pattern/match|match a URL pattern=] given
526+ <var> urlPattern</var> and <var> navigationURL</var> .
527+
528+ 1. If <var> navigationMatchResult</var> or <var> targetMatchResult</var> is null, return false.
529+
530+ 1. For each property <var> prop</var> of {{URLPatternResult}} that is a
531+ {{URLPatternComponentResult}} :
532+
533+ 1. If {{URLPatternComponentResult/groups}} of <var> prop</var> of
534+ <var> targetMatchResult</var> is not equal to
535+ {{URLPatternComponentResult/groups}} of <var> prop</var> of
536+ <var> navigationMatchResult</var> ,
537+ then return false.
538538
539- 1. If <var> navigationMatchResult </var> is null, return false .
539+ ISSUE: Need to formally define equality of ordered maps .
540540
541- 1. For each property <var> prop</var> of {{URLPatternResult}} that is a
542- {{URLPatternComponentResult}} :
541+ 1. Return true.
543542
544- 1. If {{URLPatternComponentResult/groups}} of <var> prop</var> of
545- <var> targetMatchResult</var> is not equal to
546- {{URLPatternComponentResult/groups}} of <var> prop</var> of
547- <var> navigationMatchResult</var> ,
548- then return false.
543+ 1. Otherwise:
549544
550- ISSUE: Need to formally define equality of ordered maps .
545+ 1. Return true if <var> linkTarget </var> [=url/equals=] <var> navigationURL </var> .
551546
552- 1. Return true .
547+ 1. Return false .
553548
554549NOTE: Some of the design discussion for this feature has been in
555550<a href="https://github.com/w3c/csswg-drafts/issues/13163">w3c/csswg-drafts#13163</a> .
0 commit comments