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

Should not remove empty href as this effects tab order #46

Closed
gambrose opened this issue Apr 27, 2015 · 4 comments
Closed

Should not remove empty href as this effects tab order #46

gambrose opened this issue Apr 27, 2015 · 4 comments

Comments

@gambrose
Copy link

<a href="">click me</a>

minimises to

<a>click me</a>

The removal of the href means that this element is no longer included in the tab order.

I am working around this with { empty: true }.

I thing the expected output would be as this does not affect the behaviour.

<a href>click me</a>
@Swaagie
Copy link
Owner

Swaagie commented Apr 28, 2015

From what I understand, this is also how it should be 'worked around'. With taborder you should be able to force it in. Is there any specific reason the href has to be empty?

@gambrose
Copy link
Author

The link was being used to open a nav menu. It needed to be empty to not cause page navigation, we are using client side routing so could not use #. In the end we changed the ux pattern to not use the empty href.

The reason I reported it as an issue is that browsers behave differently if href is missing or empty. Minimizers should make the html as small as possible while still retaining the same behaviour should then not?

You can set taborder but that is the way to madness and bad ux as things invariably get out of order. Better to use the natural flow of the html to define the tab order. It makes including dynamic content more manageable.

@Swaagie
Copy link
Owner

Swaagie commented Apr 28, 2015

I see, I would consider this an extreme edge case. One could argue browsers implement ambiguous behavior. Judging from your example though, wouldn't event.preventDefault have prevented navigation?

The first intent is to maximize the minification. Where options relax this state, so in this case I think the option is more suitable. The option could even be accompanied by a plugin that does remove all empty attributes from other elements than a. Which would then exactly do what you want.

@gambrose
Copy link
Author

event.preventDefault would work but I had listeners further up the dom than needed the event to bubble up.

I knew it was an edge case, as I said I have worked around the issue. I'm happy to respect your decision not to fix this issue that you feel too obscure.

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