Skip to content
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

setting attribute value to blank in HTML doc now renders as blank #1827

Merged
merged 1 commit into from
Dec 2, 2018

Conversation

flavorjones
Copy link
Member

previously was rendered as a boolean attribute. also allow for boolean
attributes by setting value to nil.

Fixes #1800.

previously was rendered as a boolean attribute. also allow for boolean
attributes by setting value to `nil`.

Fixes #1800.
@flavorjones
Copy link
Member Author

Just a note that the PR enables the following behavior:

#! /usr/bin/env ruby

require 'nokogiri'

doc = Nokogiri::HTML('<!doctype html><html><body><div bar="x" foo="x"></div></body></html>')
puts doc.to_html
# => <html><body><div bar="x" foo="x"></div></body></html>

doc.at_css("div").tap do |node|
  node.attributes['bar'].value = nil
  node.attributes['foo'].value = ""
end

puts doc.to_html
# => <html><body><div bar foo=""></div></body></html>

@flavorjones flavorjones merged commit bb30041 into master Dec 2, 2018
@flavorjones flavorjones deleted the flavorjones-1800-blank-attribute-values branch December 2, 2018 07:52
flavorjones added a commit that referenced this pull request Jan 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant