add attachments symbol

pull/15091/head
Jayden Carey 2 years ago
parent 35b9d21316
commit 083359dc13

@ -0,0 +1 @@
export { ATTACHMENTS_SYMBOL as AttachmentsKey } from '../internal/client/constants.js';

@ -0,0 +1,4 @@
/**
* A unique symbol used for defining the attachments to be applied to an element or component.
*/
export const AttachmentsKey: unique symbol;

@ -25,3 +25,4 @@ export const STATE_SYMBOL = Symbol('$state');
export const STATE_SYMBOL_METADATA = Symbol('$state metadata'); export const STATE_SYMBOL_METADATA = Symbol('$state metadata');
export const LEGACY_PROPS = Symbol('legacy props'); export const LEGACY_PROPS = Symbol('legacy props');
export const LOADING_ATTR_SYMBOL = Symbol(''); export const LOADING_ATTR_SYMBOL = Symbol('');
export const ATTACHMENTS_SYMBOL = Symbol.for('svelte.attachments');

@ -4,7 +4,7 @@ import { get_descriptors, get_prototype_of } from '../../../shared/utils.js';
import { create_event, delegate } from './events.js'; import { create_event, delegate } from './events.js';
import { add_form_reset_listener, autofocus } from './misc.js'; import { add_form_reset_listener, autofocus } from './misc.js';
import * as w from '../../warnings.js'; import * as w from '../../warnings.js';
import { LOADING_ATTR_SYMBOL } from '../../constants.js'; import { ATTACHMENTS_SYMBOL, LOADING_ATTR_SYMBOL } from '../../constants.js';
import { queue_idle_task } from '../task.js'; import { queue_idle_task } from '../task.js';
import { is_capture_event, is_delegated, normalize_attribute } from '../../../../utils.js'; import { is_capture_event, is_delegated, normalize_attribute } from '../../../../utils.js';
import { import {
@ -416,8 +416,11 @@ export function set_attributes(
} }
} }
for (let symbol of Object.getOwnPropertySymbols(next)) { const attachments = next[ATTACHMENTS_SYMBOL];
attach(element, () => next[symbol]); if (attachments) {
for (let attachment of attachments) {
attach(element, () => attachment);
}
} }
return current; return current;

@ -593,6 +593,13 @@ declare module 'svelte/action' {
export {}; export {};
} }
declare module 'svelte/attachments' {
/**
* A unique symbol used for defining the attachments to be applied to an element or component.
*/
export const AttachmentsKey: unique symbol;
}
declare module 'svelte/animate' { declare module 'svelte/animate' {
// todo: same as Transition, should it be shared? // todo: same as Transition, should it be shared?
export interface AnimationConfig { export interface AnimationConfig {

Loading…
Cancel
Save