diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-01-28 07:16:55 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-01-28 07:16:55 +0000 |
commit | 0eacdcf9a3e37e05f47a4ded7f0a4aff3b65fbe4 (patch) | |
tree | 74705adf7f9a35c750f74657f0c4a29a6dcce5ff /actionpack/lib/action_controller/vendor | |
parent | 4ac332fa9a16ae86b948251e372999b9f4618dec (diff) | |
download | rails-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')
-rw-r--r-- | actionpack/lib/action_controller/vendor/html-scanner/html/document.rb | 7 | ||||
-rw-r--r-- | actionpack/lib/action_controller/vendor/html-scanner/html/selector.rb | 15 |
2 files changed, 13 insertions, 9 deletions
diff --git a/actionpack/lib/action_controller/vendor/html-scanner/html/document.rb b/actionpack/lib/action_controller/vendor/html-scanner/html/document.rb index 19b349e886..29422937b2 100644 --- a/actionpack/lib/action_controller/vendor/html-scanner/html/document.rb +++ b/actionpack/lib/action_controller/vendor/html-scanner/html/document.rb @@ -1,9 +1,8 @@ -require File.dirname(__FILE__) + '/tokenizer' -require File.dirname(__FILE__) + '/node' -require File.dirname(__FILE__) + '/selector' +require 'html/tokenizer' +require 'html/node' +require 'html/selector' module HTML #:nodoc: - # A top-level HTMl document. You give it a body of text, and it will parse that # text into a tree of nodes. class Document #:nodoc: 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 |