maca-fork-csspool 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +72 -0
- data/History.txt +4 -0
- data/Manifest.txt +70 -0
- data/README.rdoc +78 -0
- data/Rakefile +35 -0
- data/lib/csspool.rb +20 -0
- data/lib/csspool/collection.rb +50 -0
- data/lib/csspool/css.rb +7 -0
- data/lib/csspool/css/charset.rb +7 -0
- data/lib/csspool/css/declaration.rb +8 -0
- data/lib/csspool/css/document.rb +34 -0
- data/lib/csspool/css/document_handler.rb +51 -0
- data/lib/csspool/css/import_rule.rb +15 -0
- data/lib/csspool/css/media.rb +7 -0
- data/lib/csspool/css/rule_set.rb +12 -0
- data/lib/csspool/lib_croco.rb +78 -0
- data/lib/csspool/lib_croco/cr_additional_sel.rb +46 -0
- data/lib/csspool/lib_croco/cr_attr_sel.rb +16 -0
- data/lib/csspool/lib_croco/cr_doc_handler.rb +24 -0
- data/lib/csspool/lib_croco/cr_num.rb +13 -0
- data/lib/csspool/lib_croco/cr_parser.rb +11 -0
- data/lib/csspool/lib_croco/cr_parsing_location.rb +17 -0
- data/lib/csspool/lib_croco/cr_pseudo.rb +14 -0
- data/lib/csspool/lib_croco/cr_rgb.rb +18 -0
- data/lib/csspool/lib_croco/cr_selector.rb +33 -0
- data/lib/csspool/lib_croco/cr_simple_sel.rb +54 -0
- data/lib/csspool/lib_croco/cr_term.rb +97 -0
- data/lib/csspool/lib_croco/glist.rb +21 -0
- data/lib/csspool/node.rb +5 -0
- data/lib/csspool/sac.rb +2 -0
- data/lib/csspool/sac/document.rb +35 -0
- data/lib/csspool/sac/parser.rb +122 -0
- data/lib/csspool/selector.rb +35 -0
- data/lib/csspool/selectors.rb +8 -0
- data/lib/csspool/selectors/additional.rb +6 -0
- data/lib/csspool/selectors/attribute.rb +21 -0
- data/lib/csspool/selectors/class.rb +11 -0
- data/lib/csspool/selectors/id.rb +11 -0
- data/lib/csspool/selectors/pseudo_class.rb +13 -0
- data/lib/csspool/selectors/simple.rb +22 -0
- data/lib/csspool/selectors/type.rb +6 -0
- data/lib/csspool/selectors/universal.rb +6 -0
- data/lib/csspool/terms.rb +7 -0
- data/lib/csspool/terms/function.rb +17 -0
- data/lib/csspool/terms/hash.rb +6 -0
- data/lib/csspool/terms/ident.rb +15 -0
- data/lib/csspool/terms/number.rb +14 -0
- data/lib/csspool/terms/rgb.rb +23 -0
- data/lib/csspool/terms/string.rb +6 -0
- data/lib/csspool/terms/uri.rb +6 -0
- data/lib/csspool/visitable.rb +30 -0
- data/lib/csspool/visitors.rb +5 -0
- data/lib/csspool/visitors/children.rb +50 -0
- data/lib/csspool/visitors/comparable.rb +85 -0
- data/lib/csspool/visitors/iterator.rb +80 -0
- data/lib/csspool/visitors/to_css.rb +188 -0
- data/lib/csspool/visitors/visitor.rb +17 -0
- data/test/css/test_document.rb +13 -0
- data/test/css/test_import_rule.rb +42 -0
- data/test/helper.rb +67 -0
- data/test/sac/test_parser.rb +115 -0
- data/test/sac/test_properties.rb +43 -0
- data/test/sac/test_terms.rb +134 -0
- data/test/test_collection.rb +81 -0
- data/test/test_parser.rb +91 -0
- data/test/test_selector.rb +47 -0
- data/test/visitors/test_children.rb +20 -0
- data/test/visitors/test_comparable.rb +103 -0
- data/test/visitors/test_each.rb +19 -0
- data/test/visitors/test_to_css.rb +200 -0
- metadata +173 -0
data/test/test_parser.rb
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
module CSSPool
|
4
|
+
class TestParser < CSSPool::TestCase
|
5
|
+
def test_empty_doc_on_blank
|
6
|
+
assert CSSPool.CSS(nil)
|
7
|
+
assert CSSPool.CSS('')
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_doc_charset
|
11
|
+
doc = CSSPool.CSS <<-eocss
|
12
|
+
@charset "UTF-8";
|
13
|
+
@import url("foo.css") screen;
|
14
|
+
div#a, a.foo, a:hover, a[href][int="10"]{ background: red; }
|
15
|
+
eocss
|
16
|
+
assert_equal 'UTF-8', doc.charsets.first.name
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_doc_parser
|
20
|
+
doc = CSSPool.CSS <<-eocss
|
21
|
+
@charset "UTF-8";
|
22
|
+
div#a, a.foo, a:hover, a[href][int="10"]{ background: red; }
|
23
|
+
eocss
|
24
|
+
|
25
|
+
assert_equal 1, doc.rule_sets.length
|
26
|
+
rule_set = doc.rule_sets.first
|
27
|
+
assert_equal 4, rule_set.selectors.length
|
28
|
+
assert_equal 1, rule_set.declarations.length
|
29
|
+
assert_equal 'background', rule_set.declarations.first.property
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_media
|
33
|
+
doc = CSSPool.CSS <<-eocss
|
34
|
+
@media print {
|
35
|
+
div { background: red, blue; }
|
36
|
+
}
|
37
|
+
eocss
|
38
|
+
assert_equal 1, doc.rule_sets.first.media.length
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_universal_to_css
|
42
|
+
doc = CSSPool.CSS <<-eocss
|
43
|
+
* { background: red, blue; }
|
44
|
+
eocss
|
45
|
+
assert_match '*', doc.to_css
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_doc_to_css
|
49
|
+
doc = CSSPool.CSS <<-eocss
|
50
|
+
div#a, a.foo, a:hover, a[href][int="10"]{ background: red, blue; }
|
51
|
+
eocss
|
52
|
+
assert_match 'div#a, a.foo, a:hover, a[href][int="10"]', doc.to_css
|
53
|
+
assert_match 'background: red, blue;', doc.to_css
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_doc_desc_to_css
|
57
|
+
doc = CSSPool.CSS <<-eocss
|
58
|
+
div > a { background: #123; }
|
59
|
+
eocss
|
60
|
+
assert_match 'div > a', doc.to_css
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_doc_pseudo_to_css
|
64
|
+
doc = CSSPool.CSS <<-eocss
|
65
|
+
:hover { background: #123; }
|
66
|
+
eocss
|
67
|
+
assert_match ':hover', doc.to_css
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_doc_id_to_css
|
71
|
+
doc = CSSPool.CSS <<-eocss
|
72
|
+
#hover { background: #123; }
|
73
|
+
eocss
|
74
|
+
assert_match '#hover', doc.to_css
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_important
|
78
|
+
doc = CSSPool.CSS <<-eocss
|
79
|
+
div > a { background: #123 !important; }
|
80
|
+
eocss
|
81
|
+
assert_match '!important', doc.to_css
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_doc_func_to_css
|
85
|
+
doc = CSSPool.CSS <<-eocss
|
86
|
+
div { border: foo(1, 2); }
|
87
|
+
eocss
|
88
|
+
assert_match('foo(1.0, 2.0)', doc.to_css)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
module CSSPool
|
4
|
+
class TestSelector < CSSPool::TestCase
|
5
|
+
def test_specificity
|
6
|
+
doc = CSSPool.CSS <<-eocss
|
7
|
+
*, foo > bar, #hover, :hover, div#a, a.foo, a:hover, a[href][int="10"]{ background: red; }
|
8
|
+
eocss
|
9
|
+
selectors = doc.rule_sets.first.selectors
|
10
|
+
specs = selectors.map do |sel|
|
11
|
+
sel.specificity
|
12
|
+
end
|
13
|
+
assert_equal [[0, 0, 1],
|
14
|
+
[0, 0, 2],
|
15
|
+
[1, 0, 1],
|
16
|
+
[0, 1, 1],
|
17
|
+
[1, 0, 1],
|
18
|
+
[0, 1, 1],
|
19
|
+
[0, 1, 1],
|
20
|
+
[0, 2, 1]], specs
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_selector_knows_its_ruleset
|
24
|
+
doc = CSSPool.CSS <<-eocss
|
25
|
+
a[href][int="10"]{ background: red; }
|
26
|
+
eocss
|
27
|
+
rs = doc.rule_sets.first
|
28
|
+
assert_equal rs, rs.selectors.first.rule_set
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_selector_gets_declarations
|
32
|
+
doc = CSSPool.CSS <<-eocss
|
33
|
+
a[href][int="10"]{ background: red; }
|
34
|
+
eocss
|
35
|
+
rs = doc.rule_sets.first
|
36
|
+
assert_equal rs.declarations, rs.selectors.first.declarations
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_declaration_should_know_ruleset
|
40
|
+
doc = CSSPool.CSS <<-eocss
|
41
|
+
a[href][int="10"]{ background: red; }
|
42
|
+
eocss
|
43
|
+
rs = doc.rule_sets.first
|
44
|
+
rs.declarations.each { |del| assert_equal rs, del.rule_set }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
module CSSPool
|
4
|
+
module Visitors
|
5
|
+
class TestChildren < CSSPool::TestCase
|
6
|
+
def test_iterate
|
7
|
+
doc = CSSPool.CSS <<-eocss
|
8
|
+
@charset "UTF-8";
|
9
|
+
@import url("foo.css") screen;
|
10
|
+
div#a, a.foo, a:hover, a[href][int="10"]{ background: red; }
|
11
|
+
eocss
|
12
|
+
|
13
|
+
stack = [doc]
|
14
|
+
until stack.empty? do
|
15
|
+
stack += stack.pop.children
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
module CSSPool
|
4
|
+
module Visitors
|
5
|
+
class TestComparable < CSSPool::TestCase
|
6
|
+
def equalitest css
|
7
|
+
doc1 = CSSPool.CSS css
|
8
|
+
doc2 = CSSPool.CSS css
|
9
|
+
assert_equal doc1, doc2
|
10
|
+
|
11
|
+
list1 = []
|
12
|
+
list2 = []
|
13
|
+
|
14
|
+
doc1.each { |node| list1 << node }
|
15
|
+
doc2.each { |node| list2 << node }
|
16
|
+
|
17
|
+
assert_equal list1, list2
|
18
|
+
|
19
|
+
stack = [doc1]
|
20
|
+
until stack.empty? do
|
21
|
+
stack += stack.pop.children
|
22
|
+
end
|
23
|
+
|
24
|
+
assert_equal doc1.hash, doc2.hash
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_not_equal
|
28
|
+
doc1 = CSSPool.CSS 'div { border: foo(1, 2); }'
|
29
|
+
assert_not_equal nil, doc1
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_hash_range
|
33
|
+
equalitest 'div { border: #123; }'
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_div_with_id
|
37
|
+
equalitest 'div#foo { border: #123; }'
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_div_with_pseudo
|
41
|
+
equalitest 'div:foo { border: #123; }'
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_div_with_universal
|
45
|
+
equalitest '* { border: #123; }'
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_simple
|
49
|
+
equalitest '.foo { border: #123; }'
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_rgb
|
53
|
+
equalitest 'div { border: rgb(1,2,3); }'
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_rgb_with_percentage
|
57
|
+
equalitest 'div { border: rgb(100%,2%,3%); }'
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_negative_number
|
61
|
+
equalitest 'div { border: -1px; }'
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_positive_number
|
65
|
+
equalitest 'div { border: 1px; }'
|
66
|
+
end
|
67
|
+
|
68
|
+
%w{
|
69
|
+
1 1em 1ex 1px 1in 1cm 1mm 1pt 1pc 1% 1deg 1rad 1ms 1s 1Hz 1kHz
|
70
|
+
}.each do |num|
|
71
|
+
expected = num.sub(/1/, '1.0')
|
72
|
+
define_method(:"test_num_#{num}") do
|
73
|
+
equalitest "div { border: #{num}; }"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_string_term
|
78
|
+
equalitest 'div { border: "hello"; }'
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_inherit
|
82
|
+
equalitest 'div { color: inherit; }'
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_important
|
86
|
+
equalitest 'div { color: inherit !important; }'
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_function
|
90
|
+
equalitest 'div { border: foo("hello"); }'
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_uri
|
94
|
+
equalitest 'div { border: url(http://tenderlovemaking.com/); }'
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_import
|
98
|
+
equalitest '@import "foo.css" screen, print;'
|
99
|
+
equalitest '@import "foo.css";'
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
module CSSPool
|
4
|
+
module Visitors
|
5
|
+
class TestEach < CSSPool::TestCase
|
6
|
+
def test_iterate
|
7
|
+
doc = CSSPool.CSS <<-eocss
|
8
|
+
@charset "UTF-8";
|
9
|
+
@import url("foo.css") screen;
|
10
|
+
div#a, a.foo, a:hover, a[href][int="10"]{ background: red; }
|
11
|
+
eocss
|
12
|
+
list = []
|
13
|
+
doc.each { |node| list << node }
|
14
|
+
assert_equal 20, list.length
|
15
|
+
assert list.hash
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,200 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
module CSSPool
|
4
|
+
module Visitors
|
5
|
+
class TestToCSS < CSSPool::TestCase
|
6
|
+
def test_font_serialization
|
7
|
+
doc = CSSPool.CSS 'p { font: 14px/30px Tahoma; }'
|
8
|
+
|
9
|
+
assert_equal 3, doc.rule_sets.first.declarations[0].expressions.length
|
10
|
+
|
11
|
+
doc = CSSPool.CSS(doc.to_css)
|
12
|
+
assert_equal 3, doc.rule_sets.first.declarations[0].expressions.length
|
13
|
+
|
14
|
+
assert_equal 'font: 14.0px / 30.0px Tahoma;',
|
15
|
+
doc.rule_sets.first.declarations.first.to_css.strip
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_descendant_selector_serialization
|
19
|
+
doc = CSSPool.CSS 'p a { font: 14px/30px Tahoma; }'
|
20
|
+
assert_equal 'p a', doc.rule_sets.first.selectors.first.to_css
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_descendant_selector_with_id_serialization
|
24
|
+
doc = CSSPool.CSS 'p#a a#b { font: 14px/30px Tahoma; }'
|
25
|
+
assert_equal 'p#a a#b', doc.rule_sets.first.selectors.first.to_css
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_descendent_universal_id_selector_serialization
|
29
|
+
doc = CSSPool.CSS '#a #b { font: 14px/30px Tahoma; }'
|
30
|
+
assert_equal '#a #b', doc.rule_sets.first.selectors.first.to_css
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_descendant_selector_with_class_serialization
|
34
|
+
doc = CSSPool.CSS 'p.a a.b { font: 14px/30px Tahoma; }'
|
35
|
+
assert_equal 'p.a a.b', doc.rule_sets.first.selectors.first.to_css
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_descendent_universal_class_selector_serialization
|
39
|
+
doc = CSSPool.CSS '.a .b { font: 14px/30px Tahoma; }'
|
40
|
+
assert_equal '.a .b', doc.rule_sets.first.selectors.first.to_css
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_descendant_child_selector_serialization
|
44
|
+
doc = CSSPool.CSS 'p > a { font: 14px/30px Tahoma; }'
|
45
|
+
assert_equal 'p > a', doc.rule_sets.first.selectors.first.to_css
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_descendant_child_selector_with_id_serialization
|
49
|
+
doc = CSSPool.CSS 'p#a > a#b { font: 14px/30px Tahoma; }'
|
50
|
+
assert_equal 'p#a > a#b', doc.rule_sets.first.selectors.first.to_css
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_descendant_child_selector_universal_id_serialization
|
54
|
+
doc = CSSPool.CSS '#a > #b { font: 14px/30px Tahoma; }'
|
55
|
+
assert_equal '#a > #b', doc.rule_sets.first.selectors.first.to_css
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_descendant_child_selector_universal_class_serialization
|
59
|
+
doc = CSSPool.CSS '.a > .b { font: 14px/30px Tahoma; }'
|
60
|
+
assert_equal '.a > .b', doc.rule_sets.first.selectors.first.to_css
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
# FIXME: this is a bug in libcroco
|
65
|
+
#def test_ident_followed_by_id
|
66
|
+
# doc = CSSPool.CSS 'p#div { font: foo, #666; }'
|
67
|
+
# assert_equal 'p#div', doc.rule_sets.first.selectors.first.to_css
|
68
|
+
|
69
|
+
# p doc.rule_sets.first.selectors
|
70
|
+
|
71
|
+
# doc = CSSPool.CSS 'p #div { font: foo, #666; }'
|
72
|
+
|
73
|
+
# p doc.rule_sets.first.selectors
|
74
|
+
# assert_equal 'p #div', doc.rule_sets.first.selectors.first.to_css
|
75
|
+
#end
|
76
|
+
|
77
|
+
def test_hash_operator
|
78
|
+
doc = CSSPool.CSS 'p { font: foo, #666; }'
|
79
|
+
assert_equal 2, doc.rule_sets.first.declarations[0].expressions.length
|
80
|
+
|
81
|
+
doc = CSSPool.CSS(doc.to_css)
|
82
|
+
assert_equal 2, doc.rule_sets.first.declarations[0].expressions.length
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_uri_operator
|
86
|
+
doc = CSSPool.CSS 'p { font: foo, url(http://example.com/); }'
|
87
|
+
assert_equal 2, doc.rule_sets.first.declarations[0].expressions.length
|
88
|
+
|
89
|
+
doc = CSSPool.CSS(doc.to_css)
|
90
|
+
assert_equal 2, doc.rule_sets.first.declarations[0].expressions.length
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_string_operator
|
94
|
+
doc = CSSPool.CSS 'p { font: foo, "foo"; }'
|
95
|
+
assert_equal 2, doc.rule_sets.first.declarations[0].expressions.length
|
96
|
+
|
97
|
+
doc = CSSPool.CSS(doc.to_css)
|
98
|
+
assert_equal 2, doc.rule_sets.first.declarations[0].expressions.length
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_function_operator
|
102
|
+
doc = CSSPool.CSS 'p { font: foo, foo(1); }'
|
103
|
+
assert_equal 2, doc.rule_sets.first.declarations[0].expressions.length
|
104
|
+
|
105
|
+
doc = CSSPool.CSS(doc.to_css)
|
106
|
+
assert_equal 2, doc.rule_sets.first.declarations[0].expressions.length
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_rgb_operator
|
110
|
+
doc = CSSPool.CSS 'p { font: foo, rgb(1,2,3); }'
|
111
|
+
assert_equal 2, doc.rule_sets.first.declarations[0].expressions.length
|
112
|
+
|
113
|
+
doc = CSSPool.CSS(doc.to_css)
|
114
|
+
assert_equal 2, doc.rule_sets.first.declarations[0].expressions.length
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_includes
|
118
|
+
doc = CSSPool.CSS <<-eocss
|
119
|
+
div[bar ~= 'adsf'] { background: red, blue; }
|
120
|
+
eocss
|
121
|
+
|
122
|
+
assert_equal 1, doc.rule_sets.first.selectors.first.simple_selectors.first.additional_selectors.length
|
123
|
+
assert_equal 2, doc.rule_sets.first.declarations[0].expressions.length
|
124
|
+
|
125
|
+
doc = CSSPool.CSS(doc.to_css)
|
126
|
+
assert_equal 1, doc.rule_sets.first.selectors.first.simple_selectors.first.additional_selectors.length
|
127
|
+
assert_equal 2, doc.rule_sets.first.declarations[0].expressions.length
|
128
|
+
end
|
129
|
+
|
130
|
+
def test_dashmatch
|
131
|
+
doc = CSSPool.CSS <<-eocss
|
132
|
+
div[bar |= 'adsf'] { background: red, blue; }
|
133
|
+
eocss
|
134
|
+
|
135
|
+
assert_equal 1, doc.rule_sets.first.selectors.first.simple_selectors.first.additional_selectors.length
|
136
|
+
|
137
|
+
doc = CSSPool.CSS(doc.to_css)
|
138
|
+
assert_equal 1, doc.rule_sets.first.selectors.first.simple_selectors.first.additional_selectors.length
|
139
|
+
end
|
140
|
+
|
141
|
+
def test_media
|
142
|
+
doc = CSSPool.CSS <<-eocss
|
143
|
+
@media print {
|
144
|
+
div { background: red, blue; }
|
145
|
+
}
|
146
|
+
eocss
|
147
|
+
assert_equal 1, doc.rule_sets.first.media.length
|
148
|
+
|
149
|
+
doc = CSSPool.CSS(doc.to_css)
|
150
|
+
assert_equal 1, doc.rule_sets.first.media.length
|
151
|
+
end
|
152
|
+
|
153
|
+
def test_multiple_media
|
154
|
+
doc = CSSPool.CSS <<-eocss
|
155
|
+
@media print, screen {
|
156
|
+
div { background: red, blue; }
|
157
|
+
}
|
158
|
+
|
159
|
+
@media all {
|
160
|
+
div { background: red, blue; }
|
161
|
+
}
|
162
|
+
eocss
|
163
|
+
assert_equal 2, doc.rule_sets.first.media.length
|
164
|
+
assert_equal 1, doc.rule_sets[1].media.length
|
165
|
+
|
166
|
+
doc = CSSPool.CSS(doc.to_css)
|
167
|
+
assert_equal 2, doc.rule_sets.first.media.length
|
168
|
+
assert_equal 1, doc.rule_sets[1].media.length
|
169
|
+
end
|
170
|
+
|
171
|
+
def test_import
|
172
|
+
doc = CSSPool.CSS <<-eocss
|
173
|
+
@import "test.css";
|
174
|
+
@import url("test.css");
|
175
|
+
@import url("test.css") print, screen;
|
176
|
+
eocss
|
177
|
+
|
178
|
+
assert_equal 3, doc.import_rules.length
|
179
|
+
assert_equal 2, doc.import_rules.last.media.length
|
180
|
+
|
181
|
+
doc = CSSPool.CSS(doc.to_css)
|
182
|
+
|
183
|
+
assert_equal 3, doc.import_rules.length
|
184
|
+
assert_equal 2, doc.import_rules.last.media.length
|
185
|
+
end
|
186
|
+
|
187
|
+
def test_charsets
|
188
|
+
doc = CSSPool.CSS <<-eocss
|
189
|
+
@charset "UTF-8";
|
190
|
+
eocss
|
191
|
+
|
192
|
+
assert_equal 1, doc.charsets.length
|
193
|
+
|
194
|
+
doc = CSSPool.CSS(doc.to_css)
|
195
|
+
|
196
|
+
assert_equal 1, doc.charsets.length
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|