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
Handling boolean attributes properly #120
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is fair enough! Thanks for fixing this @stephannv!
@@ -54,7 +54,7 @@ def handle_attributes(node) | |||
|
|||
attributes = [] | |||
|
|||
node.attributes.each_value do |attribute| | |||
node.attribute_nodes.each do |attribute| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL attribute_nodes
! Thanks for this!
@marcoroth I don't understand why the tests are broken, but I have to change the standalone head tag test to pass on local tests, should I push the changes? |
I suspect it's because we are calling But I think I'm fine with updating the test 👍🏼 |
Yeah, seems like this is what is happening: irb(main):049:0> head = Nokogiri::HTML::Document.parse("<head id='123'>").css("head").first
=> #(Element:0x1e97cc { name = "head", attributes = [ #(Attr:0x1e9920 { name = "id", value = "123" })] })
irb(main):050:0> head.attribute_nodes
=> [#(Attr:0x1e9920 { name = "id", value = "123" })]
irb(main):051:0> head.attribute_nodes.first.to_html
=> " id=\"123\""
irb(main):053:0> head
=>
#(Element:0x1e97cc {
name = "head",
attributes = [ #(Attr:0x1e9920 { name = "id", value = "123" })],
children = [
#(Element:0x1f4514 {
name = "meta",
attributes = [ #(Attr:0x1f4668 { name = "http-equiv", value = "Content-Type" }), #(Attr:0x1f4848 { name = "content", value = "text/html; charset=UTF-8" })]
})]
}) |
Now I'm making the |
Awesome, even better! Thank you! |
This is now also running on https://phlexing.fun! 🎉 |
Nice @marcoroth 👏🏼 |
Closes #119.
Nokogiri #value is always returning "" to
<input required>
and<input required="">
, so I have to call#to_html
and check if the=
character is present. I'm not sure if this is the best way, but I tried a lot of Nokogiri methods and none of them returnsnil
.