Skip to content

Commit 0159523

Browse files
authored
add sapper:prefetch attribute (#581)
1 parent 85f4cfb commit 0159523

File tree

4 files changed

+5
-2
lines changed

4 files changed

+5
-2
lines changed

packages/svelte2tsx/src/htmlxtojsx/nodes/attribute.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export function handleAttribute(htmlx: string, str: MagicString, attr: Node, par
3939

4040
//if we are on an "element" we are case insensitive, lowercase to match our JSX
4141
if (parent.type == 'Element') {
42-
const sapperNoScroll = attr.name === 'sapper:noscroll';
42+
const sapperLinkActions = ['sapper:prefetch', 'sapper:noscroll'];
4343
//skip Attribute shorthand, that is handled below
4444
if (
4545
(attr.value !== true &&
@@ -48,7 +48,7 @@ export function handleAttribute(htmlx: string, str: MagicString, attr: Node, par
4848
attr.value.length == 1 &&
4949
attr.value[0].type == 'AttributeShorthand'
5050
)) ||
51-
sapperNoScroll
51+
sapperLinkActions.includes(attr.name)
5252
) {
5353
let name = attr.name;
5454
if (!svgAttributes.find((x) => x == name)) {

packages/svelte2tsx/svelte-jsx.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,7 @@ declare namespace svelte.JSX {
726726
interface SapperAnchorProps {
727727
// transformed from sapper:noscroll so it should be camel case
728728
sapperNoscroll?: true;
729+
sapperPrefetch?: true;
729730
}
730731

731732
interface SvelteMediaTimeRange {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<><a sapperPrefetch></a></>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<a sapper:prefetch></a>

0 commit comments

Comments
 (0)