-
Notifications
You must be signed in to change notification settings - Fork 792
Expand file tree
/
Copy pathOverview.html
More file actions
748 lines (616 loc) · 40.1 KB
/
Overview.html
File metadata and controls
748 lines (616 loc) · 40.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
<!DOCTYPE html><html lang=en><head>
<meta content="text/html; charset=utf-8" http-equiv=Content-Type>
<title>CSS Extensions</title>
<link href=../default.css rel=stylesheet type=text/css>
<link href=../csslogo.ico rel="shortcut icon" type=image/x-icon>
<style>
body {
background: url("https://www.w3.org/StyleSheets/TR/logo-ED") top left no-repeat white;
background-attachment: fixed;
color: black;
font-family: sans-serif;
margin: 0 auto;
max-width: 50em;
padding: 2em 1em 2em 70px;
}
:link { color: #00C; background: transparent }
:visited { color: #609; background: transparent }
a[href]:active { color: #C00; background: transparent }
a[href]:hover { background: #ffa }
a[href] img { border-style: none }
h1, h2, h3, h4, h5, h6 { text-align: left }
h1, h2, h3 { color: #005A9C; }
h1 { font: 170% sans-serif }
h2 { font: 140% sans-serif }
h3 { font: 120% sans-serif }
h4 { font: bold 100% sans-serif }
h5 { font: italic 100% sans-serif }
h6 { font: small-caps 100% sans-serif }
.hide { display: none }
div.head { margin-bottom: 1em }
div.head h1 { margin-top: 2em; clear: both }
div.head table { margin-left: 2em; margin-top: 2em }
p.copyright { font-size: small }
p.copyright small { font-size: small }
pre { margin-left: 2em }
dt { font-weight: bold }
ul.toc, ol.toc {
list-style: none;
}
</style>
</head>
<body class=h-entry>
<div class=head>
<p data-fill-with=logo><a class=logo href=http://www.w3.org/>
<img alt=W3C height=48 src=http://www.w3.org/Icons/w3c_home width=72>
</a>
</p>
<h1 class="p-name no-ref" id=title>CSS Extensions</h1>
<h2 class="no-num no-toc no-ref heading settled heading" id=subtitle><span class=content>Editor’s Draft,
<span class=dt-updated><span class=value-title title=20140412>12 April 2014</span></span></span></h2>
<div data-fill-with=spec-metadata><dl><dt>This version:<dd><a class=u-url href=http://dev.w3.org/csswg/css-extensions>http://dev.w3.org/csswg/css-extensions</a><dt>Editor’s Draft:<dd><a href=http://dev.w3.org/csswg/css-extensions>http://dev.w3.org/csswg/css-extensions</a>
<dt>Feedback:</dt>
<dd><a href="mailto:www-style@w3.org?subject=%5Bcss-extensions%5D%20feedback">www-style@w3.org</a>
with subject line
“<kbd>[css-extensions] <var>… message topic …</var></kbd>”(<a href=http://lists.w3.org/Archives/Public/www-style/ rel=discussion>archives</a>)<dt>Test Suite:<dd>None Yet<dt>Editors:
<dd class="p-author h-card vcard"><a class="p-name fn u-url url" href=http://xanthir.com/contact/>Tab Atkins</a> (<span class="p-org org">Google</span>)</dl></div>
<div data-fill-with=warning></div>
<p class=copyright data-fill-with=copyright><a href=http://www.w3.org/Consortium/Legal/ipr-notice#Copyright>Copyright</a> © 2014 <a href=http://www.w3.org/><abbr title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup> (<a href=http://www.csail.mit.edu/><abbr title="Massachusetts Institute of Technology">MIT</abbr></a>, <a href=http://www.ercim.eu/><abbr title="European Research Consortium for Informatics and Mathematics">ERCIM</abbr></a>, <a href=http://www.keio.ac.jp/>Keio</a>, <a href=http://ev.buaa.edu.cn/>Beihang</a>), All Rights Reserved. W3C <a href=http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer>liability</a>, <a href=http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks>trademark</a> and <a href=http://www.w3.org/Consortium/Legal/copyright-documents>document use</a> rules apply.
</p>
<hr title="Separator for header">
</div>
<h2 class="no-num no-toc no-ref heading settled heading" id=abstract><span class=content>Abstract</span></h2>
<p class=p-summary data-fill-with=abstract>This specification defines methods for authors to extend and enhance various CSS features.
<a href=http://www.w3.org/TR/CSS/>CSS</a> is a language for describing the rendering of structured documents
(such as HTML and XML)
on screen, on paper, in speech, etc.</p>
<h2 class="no-num no-toc no-ref heading settled heading" id=status><span class=content>Status of this document</span></h2>
<div data-fill-with=status><p>
This is a public copy of the editors’ draft.
It is provided for discussion only and may change at any moment.
Its publication here does not imply endorsement of its contents by W3C.
Don’t cite this document other than as work in progress.
<p>
The (<a href=http://lists.w3.org/Archives/Public/www-style/>archived</a>) public mailing list
<a href="mailto:www-style@w3.org?Subject=%5Bcss-extensions%5D%20PUT%20SUBJECT%20HERE">www-style@w3.org</a>
(see <a href=http://www.w3.org/Mail/Request>instructions</a>)
is preferred for discussion of this specification.
When sending e-mail,
please put the text “css-extensions” in the subject,
preferably like this:
“[css-extensions] <em>…summary of comment…</em>”
<p>
This document was produced by the <a href=http://www.w3.org/Style/CSS/members>CSS Working Group</a>
(part of the <a href=http://www.w3.org/Style/>Style Activity</a>).
<p>
This document was produced by a group operating under
the <a href=http://www.w3.org/Consortium/Patent-Policy-20040205/>5 February 2004 W3C Patent Policy</a>.
W3C maintains a <a href=http://www.w3.org/2004/01/pp-impl/32061/status rel=disclosure>public list of any patent disclosures</a>
made in connection with the deliverables of the group;
that page also includes instructions for disclosing a patent.
An individual who has actual knowledge of a patent which the individual believes contains <a href=http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential>Essential Claim(s)</a>
must disclose the information in accordance with <a href=http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure>section 6 of the W3C Patent Policy</a>.</div>
<div data-fill-with=at-risk></div>
<h2 class="no-num no-toc no-ref heading settled heading" id=contents><span class=content>Table of Contents</span></h2>
<div data-fill-with=table-of-contents><ul class=toc>
<li><a href=#intro><span class=secno>1</span> Introduction</a>
<li><a href=#extension-name><span class=secno>2</span> Extension Names</a>
<li><a href=#custom-selectors><span class=secno>3</span> Custom Selectors</a>
<ul class=toc>
<li><a href=#script-custom-selectors><span class=secno>3.1</span> Script-based Custom Selectors</a>
<li><a href=#custom-selectors-cssom><span class=secno>3.2</span> CSSOM</a></ul>
<li><a href=#custom-property><span class=secno>4</span> Custom Properties</a>
<li><a href=#custom-functions><span class=secno>5</span> Custom Functions</a>
<li><a href=#custom-combinators><span class=secno>6</span> Custom Selector Combinators</a>
<li><a href=#custom-atrules><span class=secno>7</span> Custom At-Rules</a>
<li><a href=#conformance><span class=secno></span> Conformance</a>
<ul class=toc>
<li><a href=#conventions><span class=secno></span> Document conventions</a>
<li><a href=#conformance-classes><span class=secno></span> Conformance classes</a>
<li><a href=#partial><span class=secno></span> Partial implementations</a>
<li><a href=#experimental><span class=secno></span> Experimental implementations</a>
<li><a href=#testing><span class=secno></span> Non-experimental implementations</a></ul>
<li><a href=#references><span class=secno></span> References</a>
<ul class=toc>
<li><a href=#normative><span class=secno></span> Normative References</a>
<li><a href=#informative><span class=secno></span> Informative References</a></ul>
<li><a href=#index><span class=secno></span> Index</a>
<li><a href=#property-index><span class=secno></span> Property index</a>
<li><a href=#issues-index><span class=secno></span>Issues Index</a></ul></div>
<h2 class="heading settled heading" data-level=1 id=intro><span class=secno>1 </span><span class=content>
Introduction</span><a class=self-link href=#intro></a></h2>
<p> When authoring CSS,
one often encounters significant repetition in certain features.
For example, a given media query might be repeated in several places,
or a selector meant to apply to all heading elements
requires specifying <span class=css data-link-type=maybe title=":matches(h1, h2, h3, h4, h5, h6)">:matches(h1, h2, h3, h4, h5, h6)</span> in every location that uses it.
<p> This repetition makes stylesheets more verbose and difficult to read,
and also affects maintenance,
as the author has to keep each repetition in sync when making any changes.
<p> This specification defines methods for extending several CSS features
so that a long or repeatedly-used value can be given a short, memorable name instead,
or a feature can be given a more complex definition controlled by a scripting language.
This makes stylesheets easier to read,
and more powerful in general,
as authors can extend the feature-set of CSS themselves
rather than waiting for standards bodies to define new features for them.
<h2 class="heading settled heading" data-level=2 id=extension-name><span class=secno>2 </span><span class=content>
Extension Names</span><a class=self-link href=#extension-name></a></h2>
<p> All extensions defined in this specification use a common syntax for defining their ”names”:
the <a class="production css-code" data-link-type=type href=#typedef-extension-name title="<extension-name>"><extension-name></a> production.
An <dfn class=css-code data-dfn-type=type data-export="" id=typedef-extension-name><extension-name><a class=self-link href=#typedef-extension-name></a></dfn> is any <a data-link-type=dfn href=http://dev.w3.org/csswg/css-syntax-3/#identifier title=identifier>identifier</a> that starts with two dashes (U+002D HYPHEN-MINUS),
like <span class=css data-link-type=maybe title=--foo>--foo</span>, or even exotic names like <span class=css data-link-type=maybe title=-->--</span> or <span class=css data-link-type=maybe title=------>------</span>.
The CSS language will never use identifiers of this form for any language-defined purpose,
so it’s safe to use them for author-defined purposes
without ever having to worry about colliding with CSS-defined names.
<h2 class="heading settled heading" data-level=3 id=custom-selectors><span class=secno>3 </span><span class=content>
Custom Selectors</span><a class=self-link href=#custom-selectors></a></h2>
<p> A <dfn data-dfn-type=dfn data-noexport="" id=custom-selector>custom selector<a class=self-link href=#custom-selector></a></dfn> is defined with the <a class=css data-link-type=maybe href=#at-ruledef-custom-selector title=@custom-selector>@custom-selector</a> rule:
<pre class=prod><dfn class=css-code data-dfn-type=at-rule data-export="" id=at-ruledef-custom-selector>@custom-selector<a class=self-link href=#at-ruledef-custom-selector></a></dfn> = @custom-selector <a class="production css-code" data-link-type=type href=#typedef-extension-name title="<extension-name>"><extension-name></a> <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/selectors-4/#typedef-selector title="<selector>"><selector></a> ;</pre>
<p> This defines a <a data-link-type=dfn href=#custom-selector title="custom selector">custom selector</a> which is written as a <a data-link-spec=selectors data-link-type=dfn href=http://dev.w3.org/csswg/selectors-4/#pseudo-class title=pseudo-class>pseudo-class</a> with the given <a class="production css-code" data-link-type=type href=#typedef-extension-name title="<extension-name>"><extension-name></a>,
and represents a <a class=css data-link-type=maybe href=http://dev.w3.org/csswg/selectors-4/#matches-pseudo title=:matches()>:matches()</a> selector using the provided <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/selectors-4/#typedef-selector title="<selector>"><selector></a> as its argument.
<div class=example>
For example, if an author wanted to easily refer to all heading elements in their HTML document,
they could create an alias:
<pre> @custom-selector :--heading h1, h2, h3, h4, h5, h6;
:--heading { /* styles for all headings */ }
:--heading + p { /* more styles */ }
/* etc */
</pre> </div>
<h3 class="heading settled heading" data-level=3.1 id=script-custom-selectors><span class=secno>3.1 </span><span class=content>
Script-based Custom Selectors</span><a class=self-link href=#script-custom-selectors></a></h3>
<div class=issue id=issue-92c93e68><a class=self-link href=#issue-92c93e68></a>
This one’s more complicated than MQs.
Brian Kardell came up with a good proposal for evaluating selectors as JS functions that return a boolean,
which had decent performance characteristics by specifying the qualities of the element it was based on
(which determined when it would be called).
<pre><script>
CSS.customSelector.set("_foo",
{"predicate": function(el){...},
"matches": "a"});
</script>
</pre>
<p> "matches" is an optional selector specifying what subset of elements the custom selector is valid for.
The selector is automatically false for elements that don’t match,
and the predicate isn’t called.
<p> By default, the predicate is called whenever there’s a mutation in an element that matches the "matches" selector,
or one of its descendants.
<p> You should be able to suppress the auto-calling,
and be able to trigger the predicate to run manually.
That way you can use mutation listeners manually to only call the predicate when necessary.
<p> We should probably offer some sugar for filtering the list of mutations that trigger the predicate to be called.
Maybe just a list of attributes that you’ll be caring about? And/or tagnames?
<p> Maybe let the pseudo-class also accept an argument,
and pass it (as a serialized string) as a second argument to the predicate.
<span class=css data-link-type=maybe title=:_foo>:_foo</span> would pass <code>null</code>,
while <span class=css data-link-type=maybe title=:_foo()>:_foo()</span> would pass <code>""</code>.
</div>
<h3 class="heading settled heading" data-level=3.2 id=custom-selectors-cssom><span class=secno>3.2 </span><span class=content>
CSSOM</span><a class=self-link href=#custom-selectors-cssom></a></h3>
<p class=issue id=issue-cb6e966f><a class=self-link href=#issue-cb6e966f></a>
Fill in.
<h2 class="heading settled heading" data-level=4 id=custom-property><span class=secno>4 </span><span class=content>
Custom Properties</span><a class=self-link href=#custom-property></a></h2>
<div class=issue id=issue-234df7b0><a class=self-link href=#issue-234df7b0></a>
Need to more fully support Custom Properties
(and eventually remove them from the variable spec entirely, since they’ll be defined here).
<p> By default, custom properties are optimized for use as <a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-variables-1/#funcdef-var title=var()>var()</a> values—<wbr>they inherit,
have an empty initial value,
don’t do any syntax checking,
and don’t animate.
All of these should be adjustable somehow.
<pre>@custom-property --foo {
scope: [ inherit | local ];
initial: <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-variables-1/#typedef-any-value title="<any-value>"><any-value></a>*;
value: <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#length-value title="<length>"><length></a> <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#length-value title="<length>"><length></a> <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-color-3/#valuea-def-color title="<color>"><color></a>;
/* Literally, define a simplistic definition syntax.
OR FULL CSS PROPERTY GRAMMAR?!? */
}
</pre>
<p> If you provide a "value" field with animatable types,
we can animate in the most direct fashion automatically.
We could also let you hook into that:
you register a callback,
and whenever a property starts animating,
we call it with the starting and ending values.
You have to return a function which takes a progress value (between 0 and 1)
and returns a value for your property;
we’ll call it as we animate the value.
(How can we hook into Web Anim here? Can you just return an Animation object?)
<p> Do we need a hook for computed values? Interesting.
We could just hand your callback a set of property values for the element and its parent (maybe siblings, if you ask for it?),
and you can return a new value for the property.
This is probably an advanced feature for a later date.
<p> Definitely need a way to listen for elements receiving and changing property values,
so you can efficiently polyfill things and make your own properties.
Unsure how it would look at the moment.
</div>
<h2 class="heading settled heading" data-level=5 id=custom-functions><span class=secno>5 </span><span class=content>
Custom Functions</span><a class=self-link href=#custom-functions></a></h2>
<div class=issue id=issue-a45b4c04><a class=self-link href=#issue-a45b4c04></a>
Interesting possibilities here.
Definitely need some way to define custom functions in CSS.
This would, for example, let people define whatever color function they want,
such as implementing the <a href=http://www.boronine.com/husl/>HUSL</a> color space.
<p> Definitely need a JS interface.
What options are needed?
<p> Call time/frequency:
<p> <ul>
<li>
Default should probably treat the function as a preprocessor,
calling the JS function once per instance in the stylesheet
and substituting in the returned value.
<li>
Should probably have an option to allow calling per element/instance combo, too.
Gets called more as match results change.
</ul>
<p> We can take some cues from my thoughts on a random() function.
It needs per-instance,
per-element&instance,
and per "identifier", so you can reuse the same value in multiple spots.
That last one can probably be handled manually by the JS,
so we don’t have to privilege a particular argument as an identifier.
<p> We’d need to provide the context in which it’s used.
Which property, for example.
Should we allow them to be used in other places,
or should we just define more contextual locations as we go?
That is, should we allow custom-defined functions in @supports with this API,
or should we add a <code>.customSupports</code> map?
I suspect that individual cases will have their own useful contextual information,
so it’s better to specialize each instance of custom functions.
<p> How much can we do in pure CSS?
Being able to substitute values depending on MQs or support queries would be useful.
(However, we can do that much just by using custom properties and <a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-variables-1/#funcdef-var title=var()>var()</a>.)
To get *real* use out of it, though, I suspect we’d need fuller support for conditionals,
likely in the form of SASS’s <span class=css data-link-type=maybe title=@if>@if</span> or something similar.
</div>
<h2 class="heading settled heading" data-level=6 id=custom-combinators><span class=secno>6 </span><span class=content>
Custom Selector Combinators</span><a class=self-link href=#custom-combinators></a></h2>
<div class=issue id=issue-e3f29f62><a class=self-link href=#issue-e3f29f62></a>
Selectors are made of two pieces:
simple selectors,
and combinators.
We should allow custom combinators too.
<p> This is JS-only, because it’s transforming elements, not filtering them,
and you can’t express any useful transformations in pure CSS.
<p> You provide a function which,
when given an element,
produces a list of zero or more elements.
<p> For examples, with <span class=css data-link-type=maybe title="div /--foo/ span">div /--foo/ span</span>,
the CSS engine will match the first part of the selector
and find all the div elements.
It passes that list to the function registered for the --foo combinator,
and expects to get a new list of elements returned.
It then continues on its way,
filtering that list to include only span elements, etc.
<p> A child combinator would be something like:
<pre>CSS.customCombinator.set("--child", function(el) {
return el.children;
});
</pre>
<p> Then <span class=css data-link-type=maybe title="div /--child/ span">div /--child/ span</span> would be identical to <span class=css data-link-type=maybe title="div > span">div > span</span>.
<p> If we generalize a selector with a custom combinator to <span class=css data-link-type=maybe title="a /--custom/ b">A /--custom/ B</span>,
then the UA would automatically call the --custom function
whenever new elements match <span class=css data-link-type=maybe title=a>A</span>.
If elements stop matching <span class=css data-link-type=maybe title=a>A</span>,
it won’t bother;
it’ll just drop them from the result.
<p> Alternately, the function could take a list of elements
(all the elements matching <span class=css data-link-type=maybe title=a>A</span>)
and return a new list of elements.
This would be a bit more complicated for the author,
but would allow more variety in the types of combinators that could be defined,
as you could define things that depend on the entire set of matched elements.
For example, you could define <span class=css data-link-type=maybe title="a /nth 1/ b">A /nth 1/ B</span>
to give only the first element from the set of <span class=css data-link-type=maybe title=a>A</span> matches.
<p> (Maybe we allow both variants,
since the per-element one is easier to optimize and program against,
but the per-set one allows some useful stuff.)
<p> Similarly to custom pseudo-classes,
we’d allow arguments,
with them parsed eagerly per-instance
and passed to the combinator function.
<p> If we do the per-element combinator function,
we could potentially cache the results,
so that it never needs to be called again for the same element.
Possibly have a flag that turns off this behavior,
so that you’re guaranteed to be called again.
</div>
<h2 class="heading settled heading" data-level=7 id=custom-atrules><span class=secno>7 </span><span class=content>
Custom At-Rules</span><a class=self-link href=#custom-atrules></a></h2>
<div class=issue id=issue-ba92a73c><a class=self-link href=#issue-ba92a73c></a>
This one’s even less developed,
but it would be interesting to allow custom at-rules as well.
It’s definitely pure-JS as well.
<p> Unsure exactly what’s best here.
Possibly register a callback per rule,
which is called with the prelude/contents of the at-rule?
<p> Should we do the callback approach,
or just maintain a list of custom at-rules
and let scripts parse them themselves?
Unfortunately, the latter means we’d have to have a special mechanism to alert scripts
when new at-rules get added or removed.
<p> For a lot of these at-rules, we may want a way to know when they’re "applied"—<wbr>when, according to the built-in at-rules like @media and @supports,
the rule would be applied.
</div>
<h2 class="no-ref no-num heading settled heading" id=conformance><span class=content>
Conformance</span><a class=self-link href=#conformance></a></h2>
<h3 class="no-ref heading settled heading" id=conventions><span class=content>
Document conventions</span><a class=self-link href=#conventions></a></h3>
<p>Conformance requirements are expressed with a combination of
descriptive assertions and RFC 2119 terminology. The key words "MUST",
"MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT",
"RECOMMENDED", "MAY", and "OPTIONAL" in the normative parts of this
document are to be interpreted as described in RFC 2119.
However, for readability, these words do not appear in all uppercase
letters in this specification.
<p>All of the text of this specification is normative except sections
explicitly marked as non-normative, examples, and notes. <a data-biblio-type=normative data-link-type=biblio href=#rfc2119 title=rfc2119>[RFC2119]</a></p>
<p>Examples in this specification are introduced with the words "for example"
or are set apart from the normative text with <code>class="example"</code>,
like this:
<div class=example>
<p>This is an example of an informative example.</p>
</div>
<p>Informative notes begin with the word "Note" and are set apart from the
normative text with <code>class="note"</code>, like this:
<p class=note>Note, this is an informative note.</p>
<h3 class="no-ref heading settled heading" id=conformance-classes><span class=content>
Conformance classes</span><a class=self-link href=#conformance-classes></a></h3>
<p>Conformance to this specification
is defined for three conformance classes:
<dl>
<dt>style sheet
<dd>A <a href=http://www.w3.org/TR/CSS21/conform.html#style-sheet>CSS
style sheet</a>.
<dt>renderer
<dd>A <a href=http://www.w3.org/TR/CSS21/conform.html#user-agent>UA</a>
that interprets the semantics of a style sheet and renders
documents that use them.
<dt>authoring tool
<dd>A <a href=http://www.w3.org/TR/CSS21/conform.html#user-agent>UA</a>
that writes a style sheet.
</dl>
<p>A style sheet is conformant to this specification
if all of its statements that use syntax defined in this module are valid
according to the generic CSS grammar and the individual grammars of each
feature defined in this module.
<p>A renderer is conformant to this specification
if, in addition to interpreting the style sheet as defined by the
appropriate specifications, it supports all the features defined
by this specification by parsing them correctly
and rendering the document accordingly. However, the inability of a
UA to correctly render a document due to limitations of the device
does not make the UA non-conformant. (For example, a UA is not
required to render color on a monochrome monitor.)
<p>An authoring tool is conformant to this specification
if it writes style sheets that are syntactically correct according to the
generic CSS grammar and the individual grammars of each feature in
this module, and meet all other conformance requirements of style sheets
as described in this module.
<h3 class="no-ref heading settled heading" id=partial><span class=content>
Partial implementations</span><a class=self-link href=#partial></a></h3>
<p>So that authors can exploit the forward-compatible parsing rules to
assign fallback values, CSS renderers <strong>must</strong>
treat as invalid (and <a href=http://www.w3.org/TR/CSS21/conform.html#ignore>ignore
as appropriate</a>) any at-rules, properties, property values, keywords,
and other syntactic constructs for which they have no usable level of
support. In particular, user agents <strong>must not</strong> selectively
ignore unsupported component values and honor supported values in a single
multi-value property declaration: if any value is considered invalid
(as unsupported values must be), CSS requires that the entire declaration
be ignored.</p>
<h3 class="no-ref heading settled heading" id=experimental><span class=content>
Experimental implementations</span><a class=self-link href=#experimental></a></h3>
<p>To avoid clashes with future CSS features, the CSS2.1 specification
reserves a <a href=http://www.w3.org/TR/CSS21/syndata.html#vendor-keywords>prefixed
syntax</a> for proprietary and experimental extensions to CSS.
<p>Prior to a specification reaching the Candidate Recommendation stage
in the W3C process, all implementations of a CSS feature are considered
experimental. The CSS Working Group recommends that implementations
use a vendor-prefixed syntax for such features, including those in
W3C Working Drafts. This avoids incompatibilities with future changes
in the draft.
</p>
<h3 class="no-ref heading settled heading" id=testing><span class=content>
Non-experimental implementations</span><a class=self-link href=#testing></a></h3>
<p>Once a specification reaches the Candidate Recommendation stage,
non-experimental implementations are possible, and implementors should
release an unprefixed implementation of any CR-level feature they
can demonstrate to be correctly implemented according to spec.
<p>To establish and maintain the interoperability of CSS across
implementations, the CSS Working Group requests that non-experimental
CSS renderers submit an implementation report (and, if necessary, the
testcases used for that implementation report) to the W3C before
releasing an unprefixed implementation of any CSS features. Testcases
submitted to W3C are subject to review and correction by the CSS
Working Group.
<p>Further information on submitting testcases and implementation reports
can be found from on the CSS Working Group’s website at
<a href=http://www.w3.org/Style/CSS/Test/>http://www.w3.org/Style/CSS/Test/</a>.
Questions should be directed to the
<a href=http://lists.w3.org/Archives/Public/public-css-testsuite>public-css-testsuite@w3.org</a>
mailing list.
<h2 class="no-num no-ref heading settled heading" id=references><span class=content>
References</span><a class=self-link href=#references></a></h2>
<h3 class="no-num no-ref heading settled heading" id=normative><span class=content>
Normative References</span><a class=self-link href=#normative></a></h3>
<div data-fill-with=normative-references><dl><dt id=rfc2119 title=RFC2119><a class=self-link href=#rfc2119></a>[RFC2119]<dd>S. Bradner. <a href=http://www.ietf.org/rfc/rfc2119.txt>Key words for use in RFCs to Indicate Requirement Levels</a>. URL: <a href=http://www.ietf.org/rfc/rfc2119.txt>http://www.ietf.org/rfc/rfc2119.txt</a></dl></div>
<h3 class="no-num no-ref heading settled heading" id=informative><span class=content>
Informative References</span><a class=self-link href=#informative></a></h3>
<div data-fill-with=informative-references><dl></dl></div>
<h2 class="no-num no-ref heading settled heading" id=index><span class=content>
Index</span><a class=self-link href=#index></a></h2>
<div data-fill-with=index><ul class=indexlist>
<li>@custom-selector, <a href=#at-ruledef-custom-selector title="section 3">3</a>
<li>custom selector, <a href=#custom-selector title="section 3">3</a>
<li><extension-name>, <a href=#typedef-extension-name title="section 2">2</a>
</ul></div>
<h2 class="no-num no-ref heading settled heading" id=property-index><span class=content>
Property index</span><a class=self-link href=#property-index></a></h2>
<div data-fill-with=property-index><p>No properties defined.</div>
<h2 class="no-num heading settled" id=issues-index><span class=content>Issues Index</span><a class=self-link href=#issues-index></a></h2><div style="counter-reset: issue"><div class=issue>
This one’s more complicated than MQs.
Brian Kardell came up with a good proposal for evaluating selectors as JS functions that return a boolean,
which had decent performance characteristics by specifying the qualities of the element it was based on
(which determined when it would be called).
<pre><script>
CSS.customSelector.set("_foo",
{"predicate": function(el){...},
"matches": "a"});
</script>
</pre>
<p> "matches" is an optional selector specifying what subset of elements the custom selector is valid for.
The selector is automatically false for elements that don’t match,
and the predicate isn’t called.
<p> By default, the predicate is called whenever there’s a mutation in an element that matches the "matches" selector,
or one of its descendants.
<p> You should be able to suppress the auto-calling,
and be able to trigger the predicate to run manually.
That way you can use mutation listeners manually to only call the predicate when necessary.
<p> We should probably offer some sugar for filtering the list of mutations that trigger the predicate to be called.
Maybe just a list of attributes that you’ll be caring about? And/or tagnames?
<p> Maybe let the pseudo-class also accept an argument,
and pass it (as a serialized string) as a second argument to the predicate.
<span class=css data-link-type=maybe title=:_foo>:_foo</span> would pass <code>null</code>,
while <span class=css data-link-type=maybe title=:_foo()>:_foo()</span> would pass <code>""</code>.
</p><a href=#issue-92c93e68> ↵ </a></div>
<div class=issue>
Fill in.
<a href=#issue-cb6e966f> ↵ </a></div><div class=issue>
Need to more fully support Custom Properties
(and eventually remove them from the variable spec entirely, since they’ll be defined here).
<p> By default, custom properties are optimized for use as <a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-variables-1/#funcdef-var title=var()>var()</a> values—<wbr>they inherit,
have an empty initial value,
don’t do any syntax checking,
and don’t animate.
All of these should be adjustable somehow.
<pre>@custom-property --foo {
scope: [ inherit | local ];
initial: <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-variables-1/#typedef-any-value title="<any-value>"><any-value></a>*;
value: <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#length-value title="<length>"><length></a> <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#length-value title="<length>"><length></a> <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-color-3/#valuea-def-color title="<color>"><color></a>;
/* Literally, define a simplistic definition syntax.
OR FULL CSS PROPERTY GRAMMAR?!? */
}
</pre>
<p> If you provide a "value" field with animatable types,
we can animate in the most direct fashion automatically.
We could also let you hook into that:
you register a callback,
and whenever a property starts animating,
we call it with the starting and ending values.
You have to return a function which takes a progress value (between 0 and 1)
and returns a value for your property;
we’ll call it as we animate the value.
(How can we hook into Web Anim here? Can you just return an Animation object?)
<p> Do we need a hook for computed values? Interesting.
We could just hand your callback a set of property values for the element and its parent (maybe siblings, if you ask for it?),
and you can return a new value for the property.
This is probably an advanced feature for a later date.
<p> Definitely need a way to listen for elements receiving and changing property values,
so you can efficiently polyfill things and make your own properties.
Unsure how it would look at the moment.
</p><a href=#issue-234df7b0> ↵ </a></div>
<div class=issue>
Interesting possibilities here.
Definitely need some way to define custom functions in CSS.
This would, for example, let people define whatever color function they want,
such as implementing the <a href=http://www.boronine.com/husl/>HUSL</a> color space.
<p> Definitely need a JS interface.
What options are needed?
<p> Call time/frequency:
<p> <ul>
<li>
Default should probably treat the function as a preprocessor,
calling the JS function once per instance in the stylesheet
and substituting in the returned value.
<li>
Should probably have an option to allow calling per element/instance combo, too.
Gets called more as match results change.
</ul>
<p> We can take some cues from my thoughts on a random() function.
It needs per-instance,
per-element&instance,
and per "identifier", so you can reuse the same value in multiple spots.
That last one can probably be handled manually by the JS,
so we don’t have to privilege a particular argument as an identifier.
<p> We’d need to provide the context in which it’s used.
Which property, for example.
Should we allow them to be used in other places,
or should we just define more contextual locations as we go?
That is, should we allow custom-defined functions in @supports with this API,
or should we add a <code>.customSupports</code> map?
I suspect that individual cases will have their own useful contextual information,
so it’s better to specialize each instance of custom functions.
<p> How much can we do in pure CSS?
Being able to substitute values depending on MQs or support queries would be useful.
(However, we can do that much just by using custom properties and <a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-variables-1/#funcdef-var title=var()>var()</a>.)
To get *real* use out of it, though, I suspect we’d need fuller support for conditionals,
likely in the form of SASS’s <span class=css data-link-type=maybe title=@if>@if</span> or something similar.
</p><a href=#issue-a45b4c04> ↵ </a></div>
<div class=issue>
Selectors are made of two pieces:
simple selectors,
and combinators.
We should allow custom combinators too.
<p> This is JS-only, because it’s transforming elements, not filtering them,
and you can’t express any useful transformations in pure CSS.
<p> You provide a function which,
when given an element,
produces a list of zero or more elements.
<p> For examples, with <span class=css data-link-type=maybe title="div /--foo/ span">div /--foo/ span</span>,
the CSS engine will match the first part of the selector
and find all the div elements.
It passes that list to the function registered for the --foo combinator,
and expects to get a new list of elements returned.
It then continues on its way,
filtering that list to include only span elements, etc.
<p> A child combinator would be something like:
<pre>CSS.customCombinator.set("--child", function(el) {
return el.children;
});
</pre>
<p> Then <span class=css data-link-type=maybe title="div /--child/ span">div /--child/ span</span> would be identical to <span class=css data-link-type=maybe title="div > span">div > span</span>.
<p> If we generalize a selector with a custom combinator to <span class=css data-link-type=maybe title="a /--custom/ b">A /--custom/ B</span>,
then the UA would automatically call the --custom function
whenever new elements match <span class=css data-link-type=maybe title=a>A</span>.
If elements stop matching <span class=css data-link-type=maybe title=a>A</span>,
it won’t bother;
it’ll just drop them from the result.
<p> Alternately, the function could take a list of elements
(all the elements matching <span class=css data-link-type=maybe title=a>A</span>)
and return a new list of elements.
This would be a bit more complicated for the author,
but would allow more variety in the types of combinators that could be defined,
as you could define things that depend on the entire set of matched elements.
For example, you could define <span class=css data-link-type=maybe title="a /nth 1/ b">A /nth 1/ B</span>
to give only the first element from the set of <span class=css data-link-type=maybe title=a>A</span> matches.
<p> (Maybe we allow both variants,
since the per-element one is easier to optimize and program against,
but the per-set one allows some useful stuff.)
<p> Similarly to custom pseudo-classes,
we’d allow arguments,
with them parsed eagerly per-instance
and passed to the combinator function.
<p> If we do the per-element combinator function,
we could potentially cache the results,
so that it never needs to be called again for the same element.
Possibly have a flag that turns off this behavior,
so that you’re guaranteed to be called again.
</p><a href=#issue-e3f29f62> ↵ </a></div>
<div class=issue>
This one’s even less developed,
but it would be interesting to allow custom at-rules as well.
It’s definitely pure-JS as well.
<p> Unsure exactly what’s best here.
Possibly register a callback per rule,
which is called with the prelude/contents of the at-rule?
<p> Should we do the callback approach,
or just maintain a list of custom at-rules
and let scripts parse them themselves?
Unfortunately, the latter means we’d have to have a special mechanism to alert scripts
when new at-rules get added or removed.
<p> For a lot of these at-rules, we may want a way to know when they’re "applied"—<wbr>when, according to the built-in at-rules like @media and @supports,
the rule would be applied.
</p><a href=#issue-ba92a73c> ↵ </a></div>
</div>