-
-
Notifications
You must be signed in to change notification settings - Fork 904
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
Should Node#native_content= be a public method? Discuss. #768
Comments
I talked with someone with this before. That person needed native_content= method to be public. I agree with @flavorjones . |
Then let's do it! |
I tried using the private method, still my html comment got escaped node.send(:native_content=,node.content + "") |
@senthilnayagam Depending on what your node type is, the "<" and ">" characters may not be valid in that node. Most nodes' text cannot contain these characters unescaped, and so libxml2 is doing the right thing in escaping them. If you reread the nokogiri-talk thread, you'll see this issues specifically mentions comment nodes, in which those characters are valid: #! /usr/bin/env ruby
require 'nokogiri'
comment = Nokogiri.XML('<r><!-- foo --></r>').at('//comment()')
comment.content = " < "
puts comment.to_xml
#=> <!-- < -->
comment.send :native_content=, " <"
puts comment.to_xml
#=> <!-- < --> |
Is there any complete test case that I can confirm the change does the right thing? |
@yokolet - I'll take care of it. :) |
…#768. Note that JRuby work is not included here.
@yokolet - branch |
@flavorjones Thanks. I'll try issue-768 branch. BTW, I fixed NPE by rev. 3255717 . Maybe the branch was created after that? |
Reply to myself. Yes, nokogiri network shows the issue-768 branch was created before my change. |
…#768. Note that JRuby work is not included here.
I confirmed the test passed on JRuby as well. So, I merged issue-768 branch to master and pushed. I'm going to close this issue. |
Coming from nokogiri-talk thread here and the related SO question here.
Some operations, such as creating a script tag within a conditional-comment node, are difficult with the current API, since the string argument is escaped before insertion into the DOM.
This sort of thing would be made easier if #native_content= was public and a supported API call.
I don't see any downside. Discuss, please!
The text was updated successfully, but these errors were encountered: