10BC0 [selectors] Ignore empty trailing path segments. More clean-up. · w3c/csswg-drafts@fd99877 · GitHub
Skip to content

Commit fd99877

Browse files
committed
[selectors] Ignore empty trailing path segments. More clean-up.
1 parent cd6f532 commit fd99877

2 files changed

Lines changed: 57 additions & 33 deletions

File tree

selectors/Overview.html

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2416,7 +2416,9 @@ <h3 id=local-pseudo><span class=secno>7.3. </span> The local link
24162416
<p>The <dfn id=local-link-pseudo>:local-link</dfn> pseudo-class allows
24172417
authors to style <a href="#the-any-link-pseudo">hyperlinks</a> based on
24182418
the users current location within a site and to differentiate
2419-
site-internal versus site-external links. The <a
2419+
site-internal versus site-external links.
2420+
2421+
<p>The (non-functional) <a
24202422
href="#local-link-pseudo"><code>:local-link</code></a> pseudo-class
24212423
represents an element that is the source anchor of a hyperlink whose
24222424
target's absolute URL matches the element's own document URL. Any fragment
@@ -2430,9 +2432,10 @@ <h3 id=local-pseudo><span class=secno>7.3. </span> The local link
24302432
<pre>nav :local-link { text-decoration: none; }</pre>
24312433
</div>
24322434

2433-
<p>The pseudo-class can also accept a non-negative integer as its sole
2434-
argument, which, if the document's URL belongs to a hierarchical scheme,
2435-
indicates the number of path levels to match:
2435+
<p>As a functional pseudo-class, <code>:local-link()</code> can also accept
2436+
a non-negative integer as its sole argument, which, if the document's URL
2437+
belongs to a hierarchical scheme, indicates the number of path levels to
2438+
match:
24362439

24372440
<ul>
24382441
<li><code class=css>:local-link(0)</code>’ represents a link element
@@ -2455,12 +2458,9 @@ <h3 id=local-pseudo><span class=secno>7.3. </span> The local link
24552458
</div>
24562459

24572460
<p>Path segments are portions of the URL's path that are separated by
2458-
forward slashes (/). The scheme, username, password, port, query string,
2459-
and fragment portions of the URL are not considered when matching against
2460-
<code>:local-link(<var>n</var>)</code>. If a segment is missing from the
2461-
document's URL, a pseudo-class requiring that segment to match does not
2462-
match anything. If the document's URL does not belong to a hierarchical
2463-
scheme, the functional pseudo-class matches nothing.
2461+
forward slashes (/). If a segment is missing from the document's URL, a
2462+
pseudo-class requiring that segment to match does not match anything.
2463+
However, an empty final path segment is ignored.
24642464

24652465
<div class=example>
24662466
<p>So, given the links:
@@ -2470,18 +2470,23 @@ <h3 id=local-pseudo><span class=secno>7.3. </span> The local link
24702470

24712471
<li><code>&lt;a href="http://www.example.com/2011">2011&lt;/a></code>
24722472

2473-
<li><code>&lt;a
2474-
href="https://www.example.com/2011/03">March&lt;/a></code>
2473+
<li><code>&lt;a href="http://www.example.com/2011/03">March&lt;/a></code>
24752474

24762475
<li><code>&lt;a
24772476
href="http://www.example.com/2011/03/">March&lt;/a></code>
24782477

2478+
<li><code>&lt;a href="http://www.example.com/2011/03/21">21
2479+
March&lt;/a></code>
2480+
2481+
<li><code>&lt;a
2482+
href="https://www.example.com/2011/03/">March&lt;/a></code>
2483+
24792484
<li><code>&lt;a href="http://example.com/2011/03">March&lt;/a></code>
24802485
</ol>
24812486

24822487
<p>and the styles:
24832488

2484-
<ol>
2489+
<ol type=A>
24852490
<li><code>a:local-link {...}</code>
24862491

24872492
<li><code>a:local-link(0) {...}</code>
@@ -2496,19 +2501,30 @@ <h3 id=local-pseudo><span class=secno>7.3. </span> The local link
24962501
<p>If the document's URL is <code>http://www.example.com/2011/03/</code>:
24972502

24982503
<ol>
2499-
<li>Link 1 would receive Style 2
2504+
<li>Link 1 would receive Style B
25002505

2501-
<li>Link 2 would receive Styles 2 and 3
2506+
<li>Link 2 would receive Styles B and C
25022507

2503-
<li>Link 3 would receive Styles 2, 3, and 4
2508+
<li>Link 3 would receive Styles B, C, and D
25042509

2505-
<li>Link 4 would receive Style 1
2510+
<li>Link 4 would also receive Styles A, B, C, and D
25062511

2507-
<li>Link 5 would remain unstyled, and Style 5 would not be applied to
2508-
anything.
2512+
<li>Link 5 would receive Styles B, C, and D
2513+
2514+
<li>Link 6 would receive Styles B, C, and D
2515+
2516+
<li>Link 7 would remain unstyled
2517+
2518+
<li>Style E would not be applied to anything
25092519
</ol>
25102520
</div>
25112521

2522+
<p>The scheme, username, password, port, query string, and fragment
2523+
portions of the URL are not considered when matching against
2524+
<code>:local-link(<var>n</var>)</code>. If the document's URL does not
2525+
belong to a hierarchical scheme, the functional pseudo-class matches
2526+
nothing.
2527+
25122528
<p class=issue> Should a <code>:local-link(2)</code> match a link from the
25132529
document <code>http://example.com/foo</code> to itself? (This would make
25142530
Style 5 apply to Link 4.) (Relatedly, should a link from a document at an

selectors/Overview.src.html

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1596,8 +1596,9 @@ <h3 id="local-pseudo">
15961596

15971597
<p>The <dfn id='local-link-pseudo'>:local-link</dfn> pseudo-class allows authors to style
15981598
<a href="#the-any-link-pseudo">hyperlinks</a> based on the users current location within a site and to
1599-
differentiate site-internal versus site-external links. The
1600-
<code>:local-link</code> pseudo-class represents an element that is
1599+
differentiate site-internal versus site-external links.
1600+
1601+
<p>The (non-functional) <code>:local-link</code> pseudo-class represents an element that is
16011602
the source anchor of a hyperlink whose target's absolute URL
16021603
matches the element's own document URL.
16031604
Any fragment identifiers are stripped before matching the document's URL against the link's URL;
@@ -1610,7 +1611,7 @@ <h3 id="local-pseudo">
16101611
<pre>nav :local-link { text-decoration: none; }</pre>
16111612
</div>
16121613

1613-
<p>The pseudo-class can also accept a non-negative integer as its sole argument,
1614+
<p>As a functional pseudo-class, <code>:local-link()</code> can also accept a non-negative integer as its sole argument,
16141615
which, if the document's URL belongs to a hierarchical scheme,
16151616
indicates the number of path levels to match:
16161617
<ul>
@@ -1627,24 +1628,23 @@ <h3 id="local-pseudo">
16271628
</div>
16281629

16291630
<p>Path segments are portions of the URL's path that are separated by forward slashes (/).
1630-
The scheme, username, password, port, query string, and fragment portions of the URL are not considered
1631-
when matching against <code>:local-link(<var>n</var>)</code>.
16321631
If a segment is missing from the document's URL,
16331632
a pseudo-class requiring that segment to match does not match anything.
1634-
If the document's URL does not belong to a hierarchical scheme,
1635-
the functional pseudo-class matches nothing.
1633+
However, an empty final path segment is ignored.
16361634

16371635
<div class="example">
16381636
<p>So, given the links:
16391637
<ol>
16401638
<li><code>&lt;a href="http://www.example.com">Home&lt;/a></code>
16411639
<li><code>&lt;a href="http://www.example.com/2011">2011&lt;/a></code>
1642-
<li><code>&lt;a href="https://www.example.com/2011/03">March&lt;/a></code>
1640+
<li><code>&lt;a href="http://www.example.com/2011/03">March&lt;/a></code>
16431641
<li><code>&lt;a href="http://www.example.com/2011/03/">March&lt;/a></code>
1642+
<li><code>&lt;a href="http://www.example.com/2011/03/21">21 March&lt;/a></code>
1643+
<li><code>&lt;a href="https://www.example.com/2011/03/">March&lt;/a></code>
16441644
<li><code>&lt;a href="http://example.com/2011/03">March&lt;/a></code>
16451645
</ol>
16461646
<p>and the styles:
1647-
<ol>
1647+
<ol type=A>
16481648
<li><code>a:local-link {...}</code>
16491649
<li><code>a:local-link(0) {...}</code>
16501650
<li><code>a:local-link(1) {...}</code>
@@ -1653,14 +1653,22 @@ <h3 id="local-pseudo">
16531653
</ol>
16541654
<p>If the document's URL is <code>http://www.example.com/2011/03/</code>:
16551655
<ol>
1656-
<li>Link 1 would receive Style 2
1657-
<li>Link 2 would receive Styles 2 and 3
1658-
<li>Link 3 would receive Styles 2, 3, and 4
1659-
<li>Link 4 would receive Style 1
1660-
<li>Link 5 would remain unstyled, and Style 5 would not be applied to anything.
1656+
<li>Link 1 would receive Style B
1657+
<li>Link 2 would receive Styles B and C
1658+
<li>Link 3 would receive Styles B, C, and D
1659+
<li>Link 4 would also receive Styles A, B, C, and D
1660+
<li>Link 5 would receive Styles B, C, and D
1661+
<li>Link 6 would receive Styles B, C, and D
1662+
<li>Link 7 would remain unstyled
1663+
<li>Style E would not be applied to anything
16611664
</ol>
16621665
</div>
16631666

1667+
<p>The scheme, username, password, port, query string, and fragment portions of the URL are not considered
1668+
when matching against <code>:local-link(<var>n</var>)</code>.
1669+
If the document's URL does not belong to a hierarchical scheme,
1670+
the functional pseudo-class matches nothing.
1671+
16641672
<p class="issue">
16651673
Should a <code>:local-link(2)</code> match a link from the document <code>http://example.com/foo</code>
16661674
to itself? (This would make Style 5 apply to Link 4.)

0 commit comments

Comments
 (0)