Sapper: target="_self" on <a> causes full page load

Created on 10 May 2018  路  4Comments  路  Source: sveltejs/sapper

With the following

<a href="/" target="_self">Link</a>

it does a full page load of '/'

_self is the default so I would expect having it set not to make any difference

Most helpful comment

I believe this is intentional (though perhaps it ought to be documented). When a routing system works by intercepting clicks on links, using target='_self' on a link is a semi-standard way to let the routing system know that this link _should_ force a page load, even if its href looks like it could be part of the same app.

All 4 comments

I believe this is intentional (though perhaps it ought to be documented). When a routing system works by intercepting clicks on links, using target='_self' on a link is a semi-standard way to let the routing system know that this link _should_ force a page load, even if its href looks like it could be part of the same app.

Should definitely be documented if intended 馃憤

I ran into this as an issue where I had a Button component which could be an a or button tag depending on if href was specified, I passed through target to the element with a default to _self as otherwise it would set it to undefined which always opens in a new tab.

Yes, it's intentional. An addition to the documentation would be awesome.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

freedmand picture freedmand  路  4Comments

benmccann picture benmccann  路  3Comments

Rich-Harris picture Rich-Harris  路  3Comments

keyvan-m-sadeghi picture keyvan-m-sadeghi  路  4Comments

Snugug picture Snugug  路  4Comments