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

Feature Request (<hx-link>) #288

Open
CITguy opened this issue Jul 23, 2018 · 0 comments
Open

Feature Request (<hx-link>) #288

CITguy opened this issue Jul 23, 2018 · 0 comments

Comments

@CITguy
Copy link
Contributor

CITguy commented Jul 23, 2018

Problems

  • Vanilla <a> elements cannot be disabled without the use of javascript.
    • Using pointer-events: none; in CSS will prevent mouse interaction, but as long as a[href] is present, the browser will allow keyboard interaction.
  • <a target="_blank"> will run the new page on the same process as the current page.
    • This can have performance issues if the new page has heavy amounts of JavaScript to load.
    • Pairing this with rel="noopener" will help alleviate this issue in modern browsers, but developers have to remember/know to do this every time they render a hyperlink.
  • Most non-blank values for the a[target] attribute can fall victim to exploitations of the window.opener API.
    • Pairing with rel="noopener noreferrer" should alleviate this problem, but relying on developers to remember/know to do this every time leads to potential security risks.

Proposed Solution

We should create a <hx-link> element that wraps vanilla <a> functionality in order to automatically correct the problems described above. This remains accessible, because the user is interacting with the <a> element, instead of the custom <hx-link> element.

<hx-link
    [href=""]
    [download=""]
    [disabled]
    [target=""]
    [rel=""]
>
    #shadowroot
        <a><slot></slot></a>
    #/shadowroot

    Link Text
</hx-link>

Attribute Pass-Through

Values of some <hx-link> attributes may affect the value or appearance of attributes set on the <a>, in order to apply best practices in regards to security and performance.

  • disabled - when present, a[href] is removed (disabling navigation and interactivity on <a>)
  • href - pass through to a[href], except when hx-link[disabled] is present
  • download - pass through to a[download], unless a[href] is missing or hx-link[disabled] is present
  • target - if set to a non-blank value other than _self (default), set a[rel="noopener noreferrer"] to improve performance and security
  • rel - append to existing a[rel] value, if present. Otherwise set a[rel] to the same value as hx-link[rel]

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant