@@ -92,18 +92,18 @@ Introduction</h2>
92
92
93
93
<xmp highlight=html>
94
94
<style>
95
- :root::highlight(example-highlight) {
96
- background-color: yellow;
97
- color: blue;
98
- }
95
+ :root::highlight(example-highlight) {
96
+ background-color: yellow;
97
+ color: blue;
98
+ }
99
99
</style>
100
100
<body><span> One </span><span> two </span><span> three…</span>
101
101
<script>
102
- let r = new Range();
103
- r.setStart(document.body, 0);
104
- r.setEnd(document.body, 2);
102
+ let r = new Range();
103
+ r.setStart(document.body, 0);
104
+ r.setEnd(document.body, 2);
105
105
106
- CSS.highlights.set("example-highlight", new Highlight(r));
106
+ CSS.highlights.set("example-highlight", new Highlight(r));
107
107
</script>
108
108
</xmp>
109
109
@@ -242,21 +242,22 @@ Registering Custom Highlights</h3>
242
242
<div class=example id=styling-problems-with-multiple-names-per-highlight>
243
243
<xmp highlight=html>
244
244
<style>
245
- div::highlight(bar) {
246
- color: red;
247
- }
248
- div::highlight(foo) {
249
- color: green;
250
- }
245
+ div::highlight(bar) {
246
+ color: red;
247
+ }
248
+ div::highlight(foo) {
249
+ color: green;
250
+ }
251
251
</style>
252
252
<body><div> abc</div>
253
253
<script>
254
- let r = new Range();
255
- r.setStart(div, 0);
256
- r.setEnd(div, 1);
257
- let h = new Highlight(r);
258
- CSS.highlights.set('foo' , h);
259
- CSS.highlights.set('bar' , h);
254
+ let div = document.body.firstChild;
255
+ let r = new Range();
256
+ r.setStart(div, 0);
257
+ r.setEnd(div, 1);
258
+ let h = new Highlight(r);
259
+ CSS.highlights.set('foo' , h);
260
+ CSS.highlights.set('bar' , h);
260
261
</script>
261
262
</xmp>
262
263
In the example above, the same [=custom highlight=] object is [=registered=] under the names 'foo' and 'bar' .
@@ -382,11 +383,11 @@ Priority of Overlapping Highlights</h4>
382
383
<div class=example id=overlap-highlight-ex>
383
384
<xmp highlight=html>
384
385
<style>
385
- p ::highlight(foo) {
386
+ :root ::highlight(foo) {
386
387
color:blue;
387
388
background-color:yellow;
388
389
}
389
- p ::highlight(bar) {
390
+ :root ::highlight(bar) {
390
391
background-color:orange;
391
392
}
392
393
</style>
@@ -402,13 +403,16 @@ Priority of Overlapping Highlights</h4>
402
403
r2.setStart(textNode, 3);
403
404
r2.setEnd(textNode, 9);
404
405
405
- CSS.highlights.add(new Highlight("foo", r1));
406
- CSS.highlights.add(new Highlight("bar", r2));
406
+ let h1 = new Highlight(r1);
407
+ let h2 = new Highlight(r2);
408
+
409
+ CSS.highlights.set("foo", h1);
410
+ CSS.highlights.set("bar", h2);
407
411
</script>
408
412
</xmp>
409
413
410
414
As there are no priorities set
411
- (i.e. there is a tie between <code> rg1 </code> and <code> rg2 </code> ),
415
+ (i.e. there is a tie between <code> h1 </code> and <code> h2 </code> ),
412
416
the custom highlights' styles are stacked
413
417
in order of insertion into the [=highlight registry=] .
414
418
The rendered results will have "Som" with blue text on yellow background,
@@ -419,8 +423,8 @@ Priority of Overlapping Highlights</h4>
419
423
<span style="background:yellow;color:blue;"> Som</span><span style="background:orange;color:blue;"> e t</span><span style="background:orange;"> ext</span>
420
424
</div>
421
425
422
- Setting <code highlight=javascript> rg1 .priority = 1;</code>
423
- would cause <code> rg1 </code> to stack higher than <code> rg2 </code> ,
426
+ Setting <code highlight=javascript> h1 .priority = 1;</code>
427
+ would cause <code> h1 </code> to stack higher than <code> h2 </code> ,
424
428
which would result in "Some t" being blue on yellow,
425
429
and "ext" being default color on orange.
426
430
0 commit comments