Skip to content

Commit d94c30c

Browse files
committed
Define regexp().
1 parent da13b0e commit d94c30c

2 files changed

Lines changed: 67 additions & 4 deletions

File tree

css3-conditional/Overview.html

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,8 @@ <h2 id=at-document><span class=secno>6. </span>Document queries: the
685685
<p class=issue>Given that this @-rule is intended primarily for user style
686686
sheets, what should this specification say about its use in author style
687687
sheets? Should it be forbidden? Should use instead be discouraged? Or
688-
should this specification remain neutral on the topic?
688+
should this specification remain neutral on the topic, since there are
689+
valid uses in author style sheets?
689690

690691
<p>The &lsquo;<code class=css>@document</code>&rsquo; rule's condition is
691692
written as a comma-separated list of <dfn id=url-matching-functions>URL
@@ -772,14 +773,42 @@ <h2 id=at-document><span class=secno>6. </span>Document queries: the
772773
<dt>regexp(&lt;string&gt;)
773774

774775
<dd>
775-
<p class=issue>Write me</p>
776+
<p>The contents of the &lt;string&gt; argument <strong>must</strong>
777+
match the JavaScript <code>Pattern</code> production. However, failing
778+
to do so is not a CSS syntax error and does not trigger any error
779+
handling for CSS syntax errors.</p>
780+
781+
<p>The &lsquo;<code class=css>regexp()</code>&rsquo; function evaluates
782+
to true whenever the string argument compiled as a JavaScript regular
783+
expression with the <code>global</code>, <code>ignoreCase</code> and
784+
<code>multiline</code> flags <em>disabled</em> (see <a href="#ECMA-262"
785+
rel=biblioentry>[ECMA-262]<!--{{!ECMA-262}}--></a> Edition 5, sections
786+
15.10.7.2 through 15.10.7.4) compiles successfully and the resulting
787+
regular expression matches the entirety of the URL of the page.</p>
788+
789+
<p class=note>Note that regular expression must match the entire URL, not
790+
just a part of it.</p>
776791

777792
<p class=note>This definition intentionally matches the behavior of the
778793
<a
779794
href="http://dev.w3.org/html5/spec/common-input-element-attributes.html#attr-input-pattern"><code
780795
class=html>pattern</code> attribute</a> on the <code
781796
class=html>input</code> element in <a href="#HTML5"
782797
rel=biblioentry>[HTML5]<!--{{HTML5}}--></a>.</p>
798+
799+
<div class=example>
800+
<p>For example, this rule:</p>
801+
802+
<pre>@document regexp("http://www.w3.org/TR/\\d{4}/[^/]*-CSS2-\\d{8}/") {
803+
body { font-size: 20px ! important }
804+
}</pre>
805+
806+
<p>changes the font size of the body element for pages such as
807+
<code>http://www.w3.org/TR/2011/PR-CSS2-20110412/</code>.</p>
808+
809+
<p class=note>Note that the backslashes in the regular expression
810+
require CSS escaping as &lsquo;<code class=css>\\</code>&rsquo;.</p>
811+
</div>
783812
</dl>
784813

785814
<p class=issue>What form of normalization is done on URLs and domains
@@ -996,6 +1025,15 @@ <h3 class=no-num id=normative-references>Normative references</h3>
9961025
</dd>
9971026
<!---->
9981027

1028+
<dt id=ECMA-262>[ECMA-262]
1029+
1030+
<dd><a
1031+
href="http://www.ecma-international.org/publications/standards/Ecma-262.htm"><cite>ECMAScript
1032+
Language Specification, Third Edition.</cite></a> December 1999. URL: <a
1033+
href="http://www.ecma-international.org/publications/standards/Ecma-262.htm">http://www.ecma-international.org/publications/standards/Ecma-262.htm</a>
1034+
</dd>
1035+
<!---->
1036+
9991037
<dt id=MEDIAQ>[MEDIAQ]
10001038

10011039
<dd>H&#229;kon Wium Lie; et al. <a

css3-conditional/Overview.src.html

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ <h2 id="at-document">Document queries: the '@document' rule</h2>
495495
style sheets, what should this specification say about its use in author
496496
style sheets? Should it be forbidden? Should use instead be
497497
discouraged? Or should this specification remain neutral on the
498-
topic?</p>
498+
topic, since there are valid uses in author style sheets?</p>
499499

500500
<p>The '@document' rule's condition is written as a
501501
comma-separated list of <dfn>URL matching functions</dfn>, and the
@@ -577,13 +577,38 @@ <h2 id="at-document">Document queries: the '@document' rule</h2>
577577
<dt>regexp(&lt;string&gt;)</dt>
578578

579579
<dd>
580-
<p class="issue">Write me</p>
580+
<p>The contents of the &lt;string&gt; argument <strong>must</strong>
581+
match the JavaScript <code>Pattern</code> production. However,
582+
failing to do so is not a CSS syntax error and does not trigger any
583+
error handling for CSS syntax errors.</p>
584+
585+
<p>The ''regexp()'' function evaluates to true whenever the string
586+
argument compiled as a JavaScript regular expression with the
587+
<code>global</code>, <code>ignoreCase</code> and
588+
<code>multiline</code> flags <em>disabled</em>
589+
(see [[!ECMA-262]] Edition 5, sections 15.10.7.2 through 15.10.7.4)
590+
compiles successfully and the resulting regular expression matches
591+
the entirety of the URL of the page.</p>
592+
593+
<p class="note">Note that regular expression must match the entire
594+
URL, not just a part of it.</p>
581595

582596
<p class="note">This definition intentionally matches the behavior
583597
of the <a
584598
href="http://dev.w3.org/html5/spec/common-input-element-attributes.html#attr-input-pattern"><code class="html">pattern</code>
585599
attribute</a> on the <code class="html">input</code> element
586600
in [[HTML5]].</p>
601+
602+
<div class="example">
603+
<p>For example, this rule:</p>
604+
<pre>@document regexp("http://www.w3.org/TR/\\d{4}/[^/]*-CSS2-\\d{8}/") {
605+
body { font-size: 20px ! important }
606+
}</pre>
607+
<p>changes the font size of the body element for pages such as
608+
<code>http://www.w3.org/TR/2011/PR-CSS2-20110412/</code>.</p>
609+
<p class="note">Note that the backslashes in the regular
610+
expression require CSS escaping as ''\\''.</p>
611+
</div>
587612
</dd>
588613

589614
</dl>

0 commit comments

Comments
 (0)