aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/vendor/html-scanner/html/selector.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-01-28 07:16:55 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-01-28 07:16:55 +0000
commit0eacdcf9a3e37e05f47a4ded7f0a4aff3b65fbe4 (patch)
tree74705adf7f9a35c750f74657f0c4a29a6dcce5ff /actionpack/lib/action_controller/vendor/html-scanner/html/selector.rb
parent4ac332fa9a16ae86b948251e372999b9f4618dec (diff)
downloadrails-0eacdcf9a3e37e05f47a4ded7f0a4aff3b65fbe4.tar.gz
rails-0eacdcf9a3e37e05f47a4ded7f0a4aff3b65fbe4.tar.bz2
rails-0eacdcf9a3e37e05f47a4ded7f0a4aff3b65fbe4.zip
Use a consistent load path to avoid double requires. Fix some scattered Ruby warnings.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6057 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller/vendor/html-scanner/html/selector.rb')
-rw-r--r--actionpack/lib/action_controller/vendor/html-scanner/html/selector.rb15
1 files changed, 10 insertions, 5 deletions
diff --git a/actionpack/lib/action_controller/vendor/html-scanner/html/selector.rb b/actionpack/lib/action_controller/vendor/html-scanner/html/selector.rb
index 287afcc3c4..7ffc1fcfa8 100644
--- a/actionpack/lib/action_controller/vendor/html-scanner/html/selector.rb
+++ b/actionpack/lib/action_controller/vendor/html-scanner/html/selector.rb
@@ -240,19 +240,24 @@ module HTML
raise ArgumentError, "CSS expression cannot be empty" if selector.empty?
@source = ""
values = values[0] if values.size == 1 && values[0].is_a?(Array)
+
# We need a copy to determine if we failed to parse, and also
# preserve the original pass by-ref statement.
statement = selector.strip.dup
+
# Create a simple selector, along with negation.
simple_selector(statement, values).each { |name, value| instance_variable_set("@#{name}", value) }
+ @alternates = []
+ @depends = nil
+
# Alternative selector.
if statement.sub!(/^\s*,\s*/, "")
second = Selector.new(statement, values)
- (@alternates ||= []) << second
+ @alternates << second
# If there are alternate selectors, we group them in the top selector.
if alternates = second.instance_variable_get(:@alternates)
- second.instance_variable_set(:@alternates, nil)
+ second.instance_variable_set(:@alternates, [])
@alternates.concat alternates
end
@source << " , " << second.to_s
@@ -412,7 +417,7 @@ module HTML
# If this selector is part of the group, try all the alternative
# selectors (unless first_only).
- if @alternates && (!first_only || !matches)
+ if !first_only || !matches
@alternates.each do |alternate|
break if matches && first_only
if subset = alternate.match(element, first_only)
@@ -796,8 +801,8 @@ module HTML
second = Selector.new(statement, values)
# If there are alternate selectors, we group them in the top selector.
if alternates = second.instance_variable_get(:@alternates)
- second.instance_variable_set(:@alternates, nil)
- (@alternates ||= []).concat alternates
+ second.instance_variable_set(:@alternates, [])
+ @alternates.concat alternates
end
second
end