remove createAttachmentKey/isAttachmentKey

pull/15045/head
Rich Harris 8 months ago
parent 704642720a
commit 85cc9bc613

@ -33,10 +33,6 @@
"types": "./types/index.d.ts", "types": "./types/index.d.ts",
"default": "./src/animate/index.js" "default": "./src/animate/index.js"
}, },
"./attachments": {
"types": "./types/index.d.ts",
"default": "./src/attachments/index.js"
},
"./compiler": { "./compiler": {
"types": "./types/index.d.ts", "types": "./types/index.d.ts",
"require": "./compiler/index.js", "require": "./compiler/index.js",

@ -30,7 +30,6 @@ await createBundle({
[pkg.name]: `${dir}/src/index.d.ts`, [pkg.name]: `${dir}/src/index.d.ts`,
[`${pkg.name}/action`]: `${dir}/src/action/public.d.ts`, [`${pkg.name}/action`]: `${dir}/src/action/public.d.ts`,
[`${pkg.name}/animate`]: `${dir}/src/animate/public.d.ts`, [`${pkg.name}/animate`]: `${dir}/src/animate/public.d.ts`,
[`${pkg.name}/attachments`]: `${dir}/src/attachments/index.js`,
[`${pkg.name}/compiler`]: `${dir}/src/compiler/public.d.ts`, [`${pkg.name}/compiler`]: `${dir}/src/compiler/public.d.ts`,
[`${pkg.name}/easing`]: `${dir}/src/easing/index.js`, [`${pkg.name}/easing`]: `${dir}/src/easing/index.js`,
[`${pkg.name}/legacy`]: `${dir}/src/legacy/legacy-client.js`, [`${pkg.name}/legacy`]: `${dir}/src/legacy/legacy-client.js`,

@ -1,4 +0,0 @@
export {
create_attachment_key as createAttachmentKey,
is_attachment_key as isAttachmentKey
} from '../internal/client/dom/elements/attachments.js';

@ -266,7 +266,7 @@ export function build_component(node, component_name, context, anchor = context.
push_prop( push_prop(
b.prop( b.prop(
'get', 'get',
b.call('$.create_attachment_key'), b.call('Symbol'),
/** @type {Expression} */ (context.visit(attribute.expression)), /** @type {Expression} */ (context.visit(attribute.expression)),
true true
) )

@ -1,24 +1,5 @@
import { effect } from '../../reactivity/effects.js'; import { effect } from '../../reactivity/effects.js';
const key = `@attach-${/*@__PURE__*/ Math.random().toString(36).slice(2)}`;
const name = `Symbol(${key})`;
// TODO this feels a bit belt-and-braces to me, tbh — are we sure we need it?
/**
* Creates a `Symbol` that Svelte recognises as an attachment key
*/
export function create_attachment_key() {
return Symbol(key);
}
/**
* Returns `true` if the symbol was created with `createAttachmentKey`
* @param {string | symbol} key
*/
export function is_attachment_key(key) {
return typeof key === 'symbol' && key.toString() === name;
}
/** /**
* @param {Element} node * @param {Element} node
* @param {() => (node: Element) => void} get_fn * @param {() => (node: Element) => void} get_fn

@ -13,7 +13,7 @@ import {
set_active_effect, set_active_effect,
set_active_reaction set_active_reaction
} from '../../runtime.js'; } from '../../runtime.js';
import { attach, is_attachment_key } from './attachments.js'; import { attach } from './attachments.js';
import { clsx } from '../../../shared/attributes.js'; import { clsx } from '../../../shared/attributes.js';
/** /**
@ -417,9 +417,7 @@ export function set_attributes(
} }
for (let symbol of Object.getOwnPropertySymbols(next)) { for (let symbol of Object.getOwnPropertySymbols(next)) {
if (is_attachment_key(symbol)) { attach(element, () => next[symbol]);
attach(element, () => next[symbol]);
}
} }
return current; return current;

@ -27,7 +27,7 @@ export { element } from './dom/blocks/svelte-element.js';
export { head } from './dom/blocks/svelte-head.js'; export { head } from './dom/blocks/svelte-head.js';
export { append_styles } from './dom/css.js'; export { append_styles } from './dom/css.js';
export { action } from './dom/elements/actions.js'; export { action } from './dom/elements/actions.js';
export { attach, create_attachment_key, is_attachment_key } from './dom/elements/attachments.js'; export { attach } from './dom/elements/attachments.js';
export { export {
remove_input_defaults, remove_input_defaults,
set_attribute, set_attribute,

@ -1,8 +1,6 @@
<script> <script>
import { createAttachmentKey } from 'svelte/attachments';
let stuff = $state({ let stuff = $state({
[createAttachmentKey()]: () => console.log('hello') [Symbol()]: () => console.log('hello')
}); });
</script> </script>

@ -621,19 +621,6 @@ declare module 'svelte/animate' {
export {}; export {};
} }
declare module 'svelte/attachments' {
/**
* Creates a `Symbol` that Svelte recognises as an attachment key
*/
export function createAttachmentKey(): symbol;
/**
* Returns `true` if the symbol was created with `createAttachmentKey`
* */
export function isAttachmentKey(key: string | symbol): boolean;
export {};
}
declare module 'svelte/compiler' { declare module 'svelte/compiler' {
import type { Expression, Identifier, ArrayExpression, ArrowFunctionExpression, VariableDeclaration, VariableDeclarator, MemberExpression, Node, ObjectExpression, Pattern, Program, ChainExpression, SimpleCallExpression, SequenceExpression } from 'estree'; import type { Expression, Identifier, ArrayExpression, ArrowFunctionExpression, VariableDeclaration, VariableDeclarator, MemberExpression, Node, ObjectExpression, Pattern, Program, ChainExpression, SimpleCallExpression, SequenceExpression } from 'estree';
import type { SourceMap } from 'magic-string'; import type { SourceMap } from 'magic-string';

Loading…
Cancel
Save