mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 10:21:05 +00:00
Protects against cross-origin window.opener exploits when the target attribute is "_blank"
49 lines
1 KiB
Svelte
49 lines
1 KiB
Svelte
<script>
|
|
/**
|
|
* Set to `true` to use the inline variant
|
|
* @type {boolean} [inline=false]
|
|
*/
|
|
export let inline = false;
|
|
|
|
/**
|
|
* Set to `true` to disable the checkbox
|
|
* @type {boolean} [disabled=false]
|
|
*/
|
|
export let disabled = false;
|
|
|
|
/**
|
|
* Obtain a reference to the top-level HTML element
|
|
* @type {null | HTMLAnchorElement | HTMLParagraphElement} [ref=null]
|
|
*/
|
|
export let ref = null;
|
|
</script>
|
|
|
|
{#if disabled}
|
|
<p
|
|
bind:this="{ref}"
|
|
class:bx--link="{true}"
|
|
class:bx--link--disabled="{disabled}"
|
|
class:bx--link--inline="{inline}"
|
|
{...$$restProps}
|
|
on:click
|
|
on:mouseover
|
|
on:mouseenter
|
|
on:mouseleave>
|
|
<slot />
|
|
</p>
|
|
{:else}
|
|
<!-- svelte-ignore a11y-missing-attribute -->
|
|
<a
|
|
bind:this="{ref}"
|
|
class:bx--link="{true}"
|
|
class:bx--link--disabled="{disabled}"
|
|
class:bx--link--inline="{inline}"
|
|
rel="{$$restProps.target === '_blank' ? 'noopener noreferrer' : undefined}"
|
|
{...$$restProps}
|
|
on:click
|
|
on:mouseover
|
|
on:mouseenter
|
|
on:mouseleave>
|
|
<slot />
|
|
</a>
|
|
{/if}
|