bbc-a11y 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0c6b1965b456e7b2dfc8d99de5462ea914992a87
4
- data.tar.gz: 01e2e192cfef634ac65ab484b302988d9fb40815
3
+ metadata.gz: e1a5f15fb23bfa023b502767ac8667ef7b3f27ce
4
+ data.tar.gz: 48b3be883a67e39d68fd2c383c38b5e49af2d444
5
5
  SHA512:
6
- metadata.gz: 572d1b947bca6f1262fd1e30bebdf41f39b69d9f8223580d66a637c58434050fe0965991bfc5f8000429eda8ca16c534fa43fdb86ad7ad0b6fb6592a73336e70
7
- data.tar.gz: be1b5c5c7226d24b497958dcfe642757a2ddf6c754ef18fc9ae55390c3286c02bdce20f5086766832a970f1ef5186b5e893bc28526c71982728ec5128a9a2088
6
+ metadata.gz: 8f936fb98eef71751d1730c3b7736352b38e4822a75dc8b97a1efadfc81b63caf1d352b8c41697a1a8d4b3492f2e319a99ccc30520de3e9d498edb1c05700c85
7
+ data.tar.gz: f6452c73fd7f27d46a390be8d6054ffda5bc21af07b540c49fa60038a51d0491f459dc168b2e21f48dbc0847590fc040be5e647a7e03e71e1ff75246a26780cb
@@ -7,9 +7,15 @@ Feature: Correctly use `tabindex` attributes
7
7
  Rationale
8
8
  =========
9
9
 
10
- Typical BBC pages are made up of several shared components (Global navigation, page content, share tools, location service widgets, etc.) so no one piece of code has complete awareness of the content of the page or when the content updates. Positive `tabindex` values results in unpredictable tab order that do not occur if the natural order of content is relied upon.
11
-
12
- Using `tabindex="0"` on an element adds it to the document tab order, however it does not change the element type to allow it to be discovered by navigating by link or form element, nor does it bind click and key press handlers to the element. There are no circumstances in which it is not better to use a natively focusable control such as a `<a>` or `<button>`.
10
+ Typical BBC pages are made up of several shared components (Global navigation, page content, share tools,
11
+ location service widgets, etc.) so no one piece of code has complete awareness of the content of the page
12
+ or when the content updates. Positive `tabindex` values results in unpredictable tab order that do not occur
13
+ if the natural order of content is relied upon.
14
+
15
+ Using `tabindex="0"` on an element adds it to the document tab order, however it does not change the element
16
+ type to allow it to be discovered by navigating by link or form element, nor does it bind click and key press
17
+ handlers to the element. There are no circumstances in which it is not better to use a natively focusable
18
+ control such as a `<a>` or `<button>`.
13
19
 
14
20
  Techniques
15
21
  ==========
@@ -46,12 +46,14 @@ module BBC
46
46
  end
47
47
 
48
48
  def heading_elements
49
- # can't work out how to get Capybara to do this reliably, so we'll reach down to the XML parser
50
- xml = Nokogiri::XML.parse(page.source).remove_namespaces!
51
- header_xml_nodes = xml.xpath('//*[substring(name(),1,1) = "h" and number(substring(name(),2,1))]')
52
- header_xml_nodes.map(&:path).map { |xpath|
53
- page.find(:xpath, xpath, visible: false)
54
- }
49
+ all_heading_elements = page.all('h1,h2,h3,h4', visible: false)
50
+ heading_elements_after_first_h1 = []
51
+ all_heading_elements.each do |node|
52
+ if node.tag_name == "h1" || heading_elements_after_first_h1.any?
53
+ heading_elements_after_first_h1 << node
54
+ end
55
+ end
56
+ heading_elements_after_first_h1
55
57
  end
56
58
 
57
59
  attr_reader :page
@@ -1 +1 @@
1
- 0.0.8
1
+ 0.0.9
@@ -119,5 +119,44 @@ TEXT
119
119
 
120
120
  end
121
121
 
122
+ context "headings within a script tag" do
123
+ # e.g. template elements too
124
+ let(:html) { <<-HTML }
125
+ <html>
126
+ <body>
127
+ <h1>Heading 1</h1>
128
+ <script>
129
+ var stuff = "<h2>Heading 2</h2>";
130
+ </script>
131
+ </body>
132
+ </html>
133
+ HTML
134
+
135
+ it "ignores them" do
136
+ expect( hierarchy.to_s ).to eq "h1"
137
+ end
138
+ end
139
+
140
+ context "with headings before the first h1" do
141
+ # rules only apply to headings after the main h1
142
+ let(:html) { <<-HTML }
143
+ <html>
144
+ <body>
145
+ <h3>Ignore me</h3>
146
+ <h1>Heading 1</h1>
147
+ <h2>Heading 2</h2>
148
+ </body>
149
+ </html>
150
+ HTML
151
+
152
+ it "ignores them" do
153
+ expected = <<-TEXT
154
+ h1
155
+ h2
156
+ TEXT
157
+ expect( hierarchy.to_s ).to eq expected.strip
158
+ end
159
+ end
160
+
122
161
  end
123
162
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bbc-a11y
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Wynne
@@ -244,7 +244,7 @@ rubyforge_project:
244
244
  rubygems_version: 2.0.14
245
245
  signing_key:
246
246
  specification_version: 4
247
- summary: bbc-a11y-0.0.8
247
+ summary: bbc-a11y-0.0.9
248
248
  test_files:
249
249
  - features/01_core-purpose.md
250
250
  - features/02_validation.feature