Class: BBC::A11y::Standards::ContentFollowsHeadings

Inherits:
Object
  • Object
show all
Defined in:
lib/bbc/a11y/standards/content_follows_headings.rb

Instance Method Summary collapse

Constructor Details

#initialize(page) ⇒ ContentFollowsHeadings

Returns a new instance of ContentFollowsHeadings.



6
7
8
# File 'lib/bbc/a11y/standards/content_follows_headings.rb', line 6

def initialize(page)
  @page = page
end

Instance Method Details

#call(errors) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/bbc/a11y/standards/content_follows_headings.rb', line 10

def call(errors)
  ["h1", "h2", "h3", "h4", "h5", "h6"].each do |h|
    if @page.all("#{h} + #{h}").any?
      errors << "Heading elements must be followed by content. " +
                "No content follows a #{h}."
    end
  end
end