From f783d50cf89afa6116dc9e3c7d68d50975b33d26 Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Mon, 21 Nov 2005 21:02:10 +0000 Subject: [PATCH] Allow assert_tag(:conditions) to match the empty string when a tag has no children. Closes #2959. [Jamis Buck] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3154 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/CHANGELOG | 2 ++ .../action_controller/vendor/html-scanner/html/node.rb | 8 +++++++- .../action_controller/vendor/html-scanner/html/version.rb | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index c683552548..db41b582cc 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Allow assert_tag(:conditions) to match the empty string when a tag has no children. Closes #2959. [Jamis Buck] + * Update html-scanner to handle CDATA sections better. Closes #2970. [Jamis Buck] * Don't put flash in session if sessions are disabled. [Jeremy Kemper] 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 fb961570c4..218db80823 100644 --- a/actionpack/lib/action_controller/vendor/html-scanner/html/node.rb +++ b/actionpack/lib/action_controller/vendor/html-scanner/html/node.rb @@ -412,7 +412,13 @@ module HTML #:nodoc: conditions = validate_conditions(conditions) # check content of child nodes - return false unless children.find { |child| child.match(conditions[:content]) } if conditions[:content] + if conditions[:content] + if children.empty? + return false unless match_condition("", conditions[:content]) + else + return false unless children.find { |child| child.match(conditions[:content]) } + end + end # test the name return false unless match_condition(@name, conditions[:tag]) if conditions[:tag] diff --git a/actionpack/lib/action_controller/vendor/html-scanner/html/version.rb b/actionpack/lib/action_controller/vendor/html-scanner/html/version.rb index 99a8d5766c..6d645c3e14 100644 --- a/actionpack/lib/action_controller/vendor/html-scanner/html/version.rb +++ b/actionpack/lib/action_controller/vendor/html-scanner/html/version.rb @@ -3,7 +3,7 @@ module HTML #:nodoc: MAJOR = 0 MINOR = 5 - TINY = 2 + TINY = 3 STRING = [ MAJOR, MINOR, TINY ].join(".")