Merge pull request #19 from matthewlehner/head_tag_only
Fix for "head" and "header" tag confusion
This commit is contained in:
commit
6f9576215a
@ -77,7 +77,7 @@ module Rack
|
||||
template = ERB.new(::File.read(::File.expand_path('../../../skel/livereload.html.erb', __FILE__)))
|
||||
|
||||
if line['<head']
|
||||
line.gsub!(/<head[^>]*>/) { |match| %{#{match}#{template.result(binding)}} }
|
||||
line.gsub!(/<head([^(er)]|\s)[^>]*>/) { |match| %{#{match}#{template.result(binding)}} }
|
||||
end
|
||||
|
||||
headers["X-Rack-LiveReload"] = '1'
|
||||
|
@ -107,6 +107,17 @@ describe Rack::LiveReload do
|
||||
end
|
||||
end
|
||||
|
||||
context 'in header tags' do
|
||||
let(:page_html) { "<header class='hero'><h1>Just a normal header tag</h1></header>" }
|
||||
|
||||
let(:body_dom) { Nokogiri::XML(body) }
|
||||
|
||||
it 'should not add the livereload js' do
|
||||
body_dom.at_css("header")[:class].should == 'hero'
|
||||
body_dom.css('script').should be_empty
|
||||
end
|
||||
end
|
||||
|
||||
context 'not vendored' do
|
||||
before do
|
||||
middleware.stubs(:use_vendored?).returns(false)
|
||||
|
Loading…
Reference in New Issue
Block a user