-
-
Notifications
You must be signed in to change notification settings - Fork 905
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kernel.Array() method fails to wrap text node #679
Comments
@tenderlove maybe, moving the to_ary up to Nokogiri:: XML::Node would be best since now the behaviour is inconsistent between Nokogiri classes. Though, I would rather suggest @mislav using Array[] since it doesn't rely on objects having a method and reverting this commit. |
Moving this implementation of The other thing we could do is make |
Oops, forgot to cc @yokolet |
I think the problem is using a core method in a way is not intended to.
|
In case it isn't obvious, the only reason I'm using Array(elements).each do |element|
# ...
end |
@mislav |
@Serabe elements = [elements] unless Array === elements
elements.each ... |
@mislav what I am saying is that either it is not a bug (which I believe) or that |
@Serabe The current behavior is obviously a bug. Why would you expect that I'm reverting my patch for now, until we get more input. :-) |
That I have no opinion about. It's for you to discuss. The only thing I care about is that I don't end up with empty arrays when I use |
@tenderlove because if you expect to |
@Serabe Node already implements |
@tenderlove then docs are wrong in Kernel#Array |
@Serabe how so? |
@tenderlove afaik, |
@tenderlove the problem is that |
|
@tenderlove and it is the expected behaviour since |
@Serabe no problem! 😄 Our implementation of |
@tenderlove then I would expect any node (since any node can come from a search) to respond to |
@tenderlove, @Serabe - sorry for jumping in so late. My understanding is that, because I think we should reconsider a Node being Enumerable in Nokogiri 2.0. My strawman proposal is to remove it in favor of a better-defined Attributes class which would be Enumerable (and very Hash-y). This would help us address some other lingering problems around, e.g., how SAX parsers handle node attributes; and the odd API we have around Thoughts? |
+1 I really like your idea.
|
👍 I'd like to keep the hashy syntax for nodes, but removing enumerable seems fine. |
Slated for 2.0 |
Closing, captured in ROADMAP.md for now. |
I expected:
[<text_node>]
The text was updated successfully, but these errors were encountered: