blob: c25946d3943babf2509453670278515bf070f6c7 (
plain)
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
|
<!DOCTYPE html>
<meta charset="UTF-8">
<title>CSS Pseudo Test: active selection of text within a svg object styled with 'color'</title>
<link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/">
<link rel="help" href="https://www.w3.org/TR/css-pseudo-4/#highlight-selectors">
<link rel="help" href="https://www.w3.org/TR/css-pseudo-4/#highlight-styling">
<link rel="help" href="https://www.w3.org/TR/fill-stroke-3/#fill-color">
<link rel="match" href="reference/svg-text-selection-002-ref.html">
<meta content="svg" name="flags">
<meta content="This test checks that an SVG application with a text can be selected and then be styled with 'color'." name="assert">
<style>
text::selection
{
color: green;
}
</style>
<p>Test passes if the glyphs of "Selected text" are green and <strong>not red</strong>.
<div>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="460" height="180" style="border: black solid 3px;">
<text x="50" y="100" fill="red" font-size="48" id="test">Selected text</text>
</svg>
</div>
<script>
var targetRange = document.createRange();
/* We first create an empty range */
targetRange.setStart(document.getElementById("test").childNodes[0], 0);
/*
Then we set the start boundary of the range inside text#test to
the 1st character, which is "S"
*/
targetRange.setEnd(document.getElementById("test").childNodes[0], 13);
/* And we set the end boundary of the range inside text#test
right after the 14th character which is "t" */
window.getSelection().addRange(targetRange);
/* Finally, we now select such range of content */
</script>
|