Skip to content

v0.6.15, struggling to set the "download" <a> attribute dynamically #3109

Closed Answered by gbj
ViciousBadger asked this question in Q&A
Discussion options

You must be logged in to vote

From what I can tell, if you write an attribute like attr:download=(some bool), the attribute should show when the bool is true (as a simple value-less attribute). The source code confirms this:

Unfortunately I think you might be misreading the source code: the snippet you posted sets the attribute value for a boolean attribute to if *include { attr_name }, and later checks to see if the value is empty. So, it renders download="download" here.

Note that this is perfectly valid HTML for a Boolean attribute, for which foo, foo="", and foo="foo" are all supposed to behave the same.

I have no idea why they designed download to work a bit differently than that. Experimenting a little shows m…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by ViciousBadger
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants