diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-09-20 07:54:55 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-09-20 07:54:55 +0000 |
commit | 7f26415d3c0e4101ce1569a499470e8a32dbfede (patch) | |
tree | bd1b1db0161dea64945daca530acbf3d09e13cc9 /actionpack/lib/action_controller/vendor/html-scanner/html | |
parent | 47292cdef7fe9ca21c749c7fe594457ee1c81de6 (diff) | |
download | rails-7f26415d3c0e4101ce1569a499470e8a32dbfede.tar.gz rails-7f26415d3c0e4101ce1569a499470e8a32dbfede.tar.bz2 rails-7f26415d3c0e4101ce1569a499470e8a32dbfede.zip |
Optimized tag_options to not sort keys, which is no longer necessary when assert_dom_equal and friend is available #1995 [skae]. Added assert_dom_equal and assert_dom_not_equal to compare tags generated by the helpers in an order-indifferent manner #1995 [skae]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2271 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller/vendor/html-scanner/html')
-rw-r--r-- | actionpack/lib/action_controller/vendor/html-scanner/html/node.rb | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/vendor/html-scanner/html/node.rb b/actionpack/lib/action_controller/vendor/html-scanner/html/node.rb index f0f94d19cc..016603a3e7 100644 --- a/actionpack/lib/action_controller/vendor/html-scanner/html/node.rb +++ b/actionpack/lib/action_controller/vendor/html-scanner/html/node.rb @@ -122,6 +122,18 @@ module HTML #:nodoc: def validate_conditions(conditions) Conditions === conditions ? conditions : Conditions.new(conditions) end + + def ==(node) + return false unless self.class == node.class && children.size == node.children.size + + equivalent = true + + children.size.times do |i| + equivalent &&= children[i] == node.children[i] + end + + equivalent + end class <<self def parse(parent, line, pos, content, strict=true) @@ -238,6 +250,11 @@ module HTML #:nodoc: nil end end + + def ==(node) + return false unless super + content == node.content + end end # A Tag is any node that represents markup. It may be an opening tag, a @@ -465,8 +482,13 @@ module HTML #:nodoc: true end + def ==(node) + return false unless super + return false unless closing == node.closing && self.name == node.name + attributes == node.attributes + end + private - # Match the given value to the given condition. def match_condition(value, condition) case condition |