Skip to content

Commit

Permalink
Merge pull request #159 from gjtorikian/support-attributes-with-dash
Browse files Browse the repository at this point in the history
Translate attributes with dashes into underscores
  • Loading branch information
gjtorikian committed Jan 29, 2015
2 parents 9709ca5 + 1fcb2c3 commit 4ead382
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/html/proofer/checkable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ class Checkable

def initialize(obj, check)
obj.attributes.each_pair do |attribute, value|
next if attribute == 'data-proofer-ignore' # TODO: not quite sure why this doesn't work
instance_variable_set("@#{attribute}".to_sym, value.value)
instance_variable_set("@#{attribute.tr('-', '_')}".to_sym, value.value)
end

@data_ignore_proofer = obj['data-proofer-ignore']
@content = obj.content
@check = check
@checked_paths = {}
Expand Down Expand Up @@ -66,7 +64,7 @@ def non_http_remote?
end

def ignore?
return true if @data_ignore_proofer
return true if @data_proofer_ignore

case @type
when 'FaviconCheckable'
Expand Down
8 changes: 8 additions & 0 deletions spec/html/proofer/fixtures/links/attributeWithDash.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<a
id="electriccars"
data-columns="3"
data-index-number="12314"
data-parent="cars"
href="https://www.github.com">
Hullo
</a>
6 changes: 6 additions & 0 deletions spec/html/proofer/links_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -349,4 +349,10 @@
proofer = run_proofer(fixture)
expect(proofer.failed_tests.first).to match(/post.htm\?id=63009224 failed: 404 No error/)
end

it 'does not complain for files with attributes containing dashes' do
fixture = "#{FIXTURES_DIR}/links/attributeWithDash.html"
proofer = run_proofer(fixture)
expect(proofer.failed_tests).to eq []
end
end

0 comments on commit 4ead382

Please sign in to comment.