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 LEGACY_PROPS = Symbol('legacy props');
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 { add_form_reset_listener, autofocus } from './misc.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 { is_capture_event, is_delegated, normalize_attribute } from '../../../../utils.js';
import {
@ -416,8 +416,11 @@ export function set_attributes(
}
}
for (let symbol of Object.getOwnPropertySymbols(next)) {
attach(element, () => next[symbol]);
const attachments = next[ATTACHMENTS_SYMBOL];
if (attachments) {
for (let attachment of attachments) {
attach(element, () => attachment);
}
}
return current;

@ -593,6 +593,13 @@ declare module 'svelte/action' {
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' {
// todo: same as Transition, should it be shared?
export interface AnimationConfig {
@ -1881,10 +1888,10 @@ declare module 'svelte/motion' {
* const tween = Tween.of(() => number);
* </script>
* ```
*
*
*/
static of<U>(fn: () => U, options?: TweenedOptions<U> | undefined): Tween<U>;
constructor(value: T, options?: TweenedOptions<T>);
/**
* Sets `tween.target` to `value` and returns a `Promise` that resolves if and when `tween.current` catches up to it.
@ -1903,21 +1910,21 @@ declare module 'svelte/motion' {
declare module 'svelte/reactivity' {
export class SvelteDate extends Date {
constructor(...params: any[]);
#private;
}
export class SvelteSet<T> extends Set<T> {
constructor(value?: Iterable<T> | null | undefined);
add(value: T): this;
#private;
}
export class SvelteMap<K, V> extends Map<K, V> {
constructor(value?: Iterable<readonly [K, V]> | null | undefined);
set(key: K, value: V): this;
#private;
}
@ -1927,7 +1934,7 @@ declare module 'svelte/reactivity' {
}
const REPLACE: unique symbol;
export class SvelteURLSearchParams extends URLSearchParams {
[REPLACE](params: URLSearchParams): void;
#private;
}
@ -1999,7 +2006,7 @@ declare module 'svelte/reactivity' {
*/
export function createSubscriber(start: (update: () => void) => (() => void) | void): () => void;
class ReactiveValue<T> {
constructor(fn: () => T, onsubscribe: (update: () => void) => void);
get current(): T;
#private;
@ -2064,7 +2071,7 @@ declare module 'svelte/reactivity/window' {
get current(): number | undefined;
};
class ReactiveValue<T> {
constructor(fn: () => T, onsubscribe: (update: () => void) => void);
get current(): T;
#private;

Loading…
Cancel
Save