Skip to content

Commit 5f7d9dd

Browse files
committed
lock down
1 parent d6d9f0c commit 5f7d9dd

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

packages/svelte/src/attachments/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { ATTACHMENT_KEY } from '../constants.js';
2+
13
/**
24
* Creates an object key that will be recognised as an attachment when the object is spread onto an element,
35
* as a programmatic alternative to using `{@attach ...}`. This can be useful for library authors, though
@@ -20,5 +22,5 @@
2022
* ```
2123
*/
2224
export function createAttachmentKey() {
23-
return Symbol('@attach');
25+
return Symbol(ATTACHMENT_KEY);
2426
}

packages/svelte/src/constants.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,5 @@ export const IGNORABLE_RUNTIME_WARNINGS = /** @type {const} */ ([
5454
* TODO this is currently unused
5555
*/
5656
export const ELEMENTS_WITHOUT_TEXT = ['audio', 'datalist', 'dl', 'optgroup', 'select', 'video'];
57+
58+
export const ATTACHMENT_KEY = '@attach';

packages/svelte/src/internal/client/dom/elements/attributes.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
} from '../../runtime.js';
1616
import { attach } from './attachments.js';
1717
import { clsx } from '../../../shared/attributes.js';
18+
import { ATTACHMENT_KEY } from '../../../../constants.js';
1819

1920
/**
2021
* The value/checked attribute in the template actually corresponds to the defaultValue property, so we need
@@ -417,7 +418,9 @@ export function set_attributes(
417418
}
418419

419420
for (let symbol of Object.getOwnPropertySymbols(next)) {
420-
attach(element, () => next[symbol]);
421+
if (symbol.description === ATTACHMENT_KEY) {
422+
attach(element, () => next[symbol]);
423+
}
421424
}
422425

423426
return current;

0 commit comments

Comments
 (0)