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

Support for Element::add_attribute #205

Open
grekko opened this issue Jan 8, 2024 · 2 comments
Open

Support for Element::add_attribute #205

grekko opened this issue Jan 8, 2024 · 2 comments

Comments

@grekko
Copy link

grekko commented Jan 8, 2024

I'm using the ruby binding for lol_html and would really like to be able to transform <p>Foo</p> into <p data-this-is-special>Foo</p>.

I understand that the lol_html API currently implements Element.html#set_attribute with a String value, but does not yet provide a similar Element#add_attribute-method which writes an attribute without a String value.

Is Element#add_attribute something other ppl are interested in and something someone else would be willing to implement? I myself have no rust knowledge (yet) and would have to depend on someone else to provide the code here :)

@bglw
Copy link

bglw commented Jan 8, 2024

Note that from the perspective of the HTML spec, data-thing and data-thing="" are exactly equivalent. Omitting a value parses as the empty string.

The difference is purely aesthetic, which isn't something I'm aware of existing in lol_html as yet since it deals with HTML semantics.

(disclaimer: not a maintainer)

@grekko
Copy link
Author

grekko commented Jan 8, 2024

Note that from the perspective of the HTML spec, data-thing and data-thing="" are exactly equivalent.

Absolutely, thanks for clearing that up. My point is that I'll be reading the generated output and <p data-thing>Foo</p> is just easier and quicker to read for me personally than <p data-thing="">Foo</p>.

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

No branches or pull requests

2 participants