Add support for multiple matches#242
Add support for multiple matches#242rafaelfranca merged 1 commit intorails:masterfrom juank-pa:add_support_for_multiple_matches
Conversation
|
Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @lucasmazza (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
| if block_given? | ||
| @selected ||= nil | ||
| fragments = Nokogiri::HTML::Document.new | ||
| fragments = Nokogiri::HTML::Document.new.fragment |
There was a problem hiding this comment.
I preferred this over Nokogiri::HTML::DocumentFragment.new because I woudl have been forced to pass an already existing HTML Document. And also preferred it over Nokogiri::HTML::DocumentFragment.parse to avoid the empty string parameter that would obscure the intention of this line of code.
In theory the
assert_jquery_methodsupports multiple matches for the same selector/function. But this was not working because of how Nokogiri was used. The algorithm was trying to add a tag as a root HTML element multiple times raising the "Document already has a root node" error.At the beginning I tried to fix the code so that we add the actually parsed children to the html/body tag but then I preferred to use the more flexible fragments.