Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add 'ie' class to all IE tags generated (to allow general selector)

  • Loading branch information...
commit 013b1a6e1049ed48c51c9657681292c1cdcd8bd0 1 parent 7a85a56
@bruce authored
View
12 README.md
@@ -27,11 +27,11 @@ custom class:
This would give you (with some prettied indentation):
<!DOCTYPE html>
- <!--[if lt IE 7]><html class="ie6 some-custom-class"><![endif]-->
- <!--[if IE 7]><html class="ie7 some-custom-class"><![endif]-->
- <!--[if IE 8]><html class="ie8 some-custom-class"><![endif]-->
- <!--[if IE 9]><html class="ie9 some-custom-class"><![endif]-->
- <!--[if gt IE 9]><html class="some-custom-class"><![endif]-->
+ <!--[if lt IE 7]><html class="ie ie6 some-custom-class"><![endif]-->
+ <!--[if IE 7]><html class="ie ie7 some-custom-class"><![endif]-->
+ <!--[if IE 8]><html class="ie ie8 some-custom-class"><![endif]-->
+ <!--[if IE 9]><html class="ie ie9 some-custom-class"><![endif]-->
+ <!--[if gt IE 9]><html class="ie some-custom-class"><![endif]-->
<!--[if !IE]><!--><html class="some-custom-class"><!--<![endif]-->
<head>
<title>New HTML5 page</title>
@@ -92,7 +92,7 @@ You may want to look/tweak the settings there.
Note: By default, when IE 6, 7, 8, 9 are given the CSS classes 'ie6',
'ie7', 'ie8', and 'ie9' respectively. IE > 9 has no additional class
-added (which may be overly optimistic). YMMV.
+added besides 'ie' (which may be overly optimistic). YMMV.
Configuring
-----------
View
12 lib/generators/templates/ie_conditional_tag.rb
@@ -8,13 +8,13 @@
# will be prepended to any `:class` attribute given to `ie_conditional_tag`.
# Add CSS classes for IE 6 - 9
- config.on 'lt IE 7', :class => 'ie6'
- config.on 'IE 7', :class => 'ie7'
- config.on 'IE 8', :class => 'ie8'
- config.on 'IE 9', :class => 'ie9'
+ config.on 'lt IE 7', :class => 'ie ie6'
+ config.on 'IE 7', :class => 'ie ie7'
+ config.on 'IE 8', :class => 'ie ie8'
+ config.on 'IE 9', :class => 'ie ie9'
- # For IE >= 9, no change
- config.on 'gt IE 9'
+ # For IE >= 9, just add ie class
+ config.on 'gt IE 9', :class => 'ie'
# For all other browsers
# Note: Don't remove this line-- or other browsers won't get a
View
5 test/helper.rb
@@ -6,6 +6,11 @@
require 'action_controller'
require 'action_controller/test_case'
+begin
+ require 'turn'
+rescue LoadError
+end
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
View
8 test/test_condition.rb
@@ -3,8 +3,8 @@
class TestCondition < ActionView::TestCase
test "wrapping a tag in a protected condition without additional options" do
- condition = IEConditionalTag::ProtectedCondition.new('IE 6', :class => 'ie6')
- assert_equal(%Q(<!--[if IE 6]><body class="ie6"><![endif]-->\n),
+ condition = IEConditionalTag::ProtectedCondition.new('IE 6', :class => 'ie ie6')
+ assert_equal(%Q(<!--[if IE 6]><body class="ie ie6"><![endif]-->\n),
condition.wrap { |opts| tag(:body, opts, true) })
end
@@ -19,12 +19,12 @@ class TestCondition < ActionView::TestCase
end
test "wrapping a tag in a protected condition with additional options" do
- condition = IEConditionalTag::ProtectedCondition.new('IE 6', :id => 'override', :class => 'ie6')
+ condition = IEConditionalTag::ProtectedCondition.new('IE 6', :id => 'override', :class => 'ie ie6')
result = condition.wrap(:id => 'custom', :class => 'basic') { |opts| tag(:body, opts, true) }
wrapper_pattern = Regexp.new(Regexp.quote('<!--[if IE 6]><body ') + '[^>]+' + Regexp.quote('><![endif]-->'))
assert result =~ wrapper_pattern
- assert result.include?('class="ie6 basic"')
+ assert result.include?('class="ie ie6 basic"')
assert result.include?('id="override"')
end
View
30 test/test_tag_helper.rb
@@ -8,32 +8,32 @@ class TestIEConditionalTag < ActionView::TestCase
@response = ActionController::TestResponse.new
IEConditionalTag.config.clear
IEConditionalTag.configure do |config|
- config.on 'lt IE 7', :class => 'ie6'
- config.on 'IE 7', :class => 'ie7'
- config.on 'IE 8', :class => 'ie8'
- config.on 'IE 9', :class => 'ie9'
- config.on 'gt IE 9'
+ config.on 'lt IE 7', :class => 'ie ie6'
+ config.on 'IE 7', :class => 'ie ie7'
+ config.on 'IE 8', :class => 'ie ie8'
+ config.on 'IE 9', :class => 'ie ie9'
+ config.on 'gt IE 9', :class => 'ie'
config.on '!IE'
end
end
test "browser body tag with no options and no block" do
rendered = String.new(ie_conditional_tag(:html))
- assert rendered.include?('<!--[if lt IE 7]><html class="ie6"><![endif]-->'), rendered
- assert rendered.include?('<!--[if IE 7]><html class="ie7"><![endif]-->'), rendered
- assert rendered.include?('<!--[if IE 8]><html class="ie8"><![endif]-->'), rendered
- assert rendered.include?('<!--[if IE 9]><html class="ie9"><![endif]-->'), rendered
- assert rendered.include?('<!--[if gt IE 9]><html><![endif]-->'), rendered
+ assert rendered.include?('<!--[if lt IE 7]><html class="ie ie6"><![endif]-->'), rendered
+ assert rendered.include?('<!--[if IE 7]><html class="ie ie7"><![endif]-->'), rendered
+ assert rendered.include?('<!--[if IE 8]><html class="ie ie8"><![endif]-->'), rendered
+ assert rendered.include?('<!--[if IE 9]><html class="ie ie9"><![endif]-->'), rendered
+ assert rendered.include?('<!--[if gt IE 9]><html class="ie"><![endif]-->'), rendered
assert rendered.include?('<!--[if !IE]><!--><html><!--<![endif]-->'), rendered
end
test "browser body tag with class option and no block" do
rendered = String.new(ie_conditional_tag(:html, :class => 'custom-class'))
- assert rendered.include?('<!--[if lt IE 7]><html class="ie6 custom-class"><![endif]-->'), rendered
- assert rendered.include?('<!--[if IE 7]><html class="ie7 custom-class"><![endif]-->'), rendered
- assert rendered.include?('<!--[if IE 8]><html class="ie8 custom-class"><![endif]-->'), rendered
- assert rendered.include?('<!--[if IE 9]><html class="ie9 custom-class"><![endif]-->'), rendered
- assert rendered.include?('<!--[if gt IE 9]><html class="custom-class"><![endif]-->'), rendered
+ assert rendered.include?('<!--[if lt IE 7]><html class="ie ie6 custom-class"><![endif]-->'), rendered
+ assert rendered.include?('<!--[if IE 7]><html class="ie ie7 custom-class"><![endif]-->'), rendered
+ assert rendered.include?('<!--[if IE 8]><html class="ie ie8 custom-class"><![endif]-->'), rendered
+ assert rendered.include?('<!--[if IE 9]><html class="ie ie9 custom-class"><![endif]-->'), rendered
+ assert rendered.include?('<!--[if gt IE 9]><html class="ie custom-class"><![endif]-->'), rendered
assert rendered.include?('<!--[if !IE]><!--><html class="custom-class"><!--<![endif]-->'), rendered
end
Please sign in to comment.
Something went wrong with that request. Please try again.