@depup/svelte 5.53.3-depup.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +7 -0
- package/README.md +41 -0
- package/action.d.ts +1 -0
- package/animate.d.ts +1 -0
- package/compiler/index.js +1 -0
- package/compiler/package.json +3 -0
- package/compiler.d.ts +1 -0
- package/easing.d.ts +1 -0
- package/elements.d.ts +2078 -0
- package/index.d.ts +1 -0
- package/legacy.d.ts +1 -0
- package/motion.d.ts +1 -0
- package/package.json +185 -0
- package/src/animate/index.js +78 -0
- package/src/attachments/index.js +113 -0
- package/src/compiler/errors.js +1719 -0
- package/src/compiler/index.js +198 -0
- package/src/compiler/legacy.js +637 -0
- package/src/compiler/migrate/index.js +1996 -0
- package/src/compiler/phases/1-parse/acorn.js +198 -0
- package/src/compiler/phases/1-parse/index.js +326 -0
- package/src/compiler/phases/1-parse/read/context.js +116 -0
- package/src/compiler/phases/1-parse/read/expression.js +93 -0
- package/src/compiler/phases/1-parse/read/options.js +263 -0
- package/src/compiler/phases/1-parse/read/script.js +97 -0
- package/src/compiler/phases/1-parse/read/style.js +637 -0
- package/src/compiler/phases/1-parse/remove_typescript_nodes.js +180 -0
- package/src/compiler/phases/1-parse/state/element.js +937 -0
- package/src/compiler/phases/1-parse/state/fragment.js +17 -0
- package/src/compiler/phases/1-parse/state/tag.js +751 -0
- package/src/compiler/phases/1-parse/state/text.js +23 -0
- package/src/compiler/phases/1-parse/utils/bracket.js +213 -0
- package/src/compiler/phases/1-parse/utils/create.js +16 -0
- package/src/compiler/phases/1-parse/utils/entities.js +2234 -0
- package/src/compiler/phases/1-parse/utils/fuzzymatch.js +281 -0
- package/src/compiler/phases/1-parse/utils/html.js +127 -0
- package/src/compiler/phases/2-analyze/css/css-analyze.js +331 -0
- package/src/compiler/phases/2-analyze/css/css-prune.js +1206 -0
- package/src/compiler/phases/2-analyze/css/css-warn.js +47 -0
- package/src/compiler/phases/2-analyze/css/utils.js +177 -0
- package/src/compiler/phases/2-analyze/index.js +1300 -0
- package/src/compiler/phases/2-analyze/utils/check_graph_for_cycles.js +47 -0
- package/src/compiler/phases/2-analyze/visitors/AnimateDirective.js +15 -0
- package/src/compiler/phases/2-analyze/visitors/ArrowFunctionExpression.js +11 -0
- package/src/compiler/phases/2-analyze/visitors/AssignmentExpression.js +31 -0
- package/src/compiler/phases/2-analyze/visitors/AttachTag.js +17 -0
- package/src/compiler/phases/2-analyze/visitors/Attribute.js +66 -0
- package/src/compiler/phases/2-analyze/visitors/AwaitBlock.js +48 -0
- package/src/compiler/phases/2-analyze/visitors/AwaitExpression.js +150 -0
- package/src/compiler/phases/2-analyze/visitors/BindDirective.js +280 -0
- package/src/compiler/phases/2-analyze/visitors/CallExpression.js +339 -0
- package/src/compiler/phases/2-analyze/visitors/ClassBody.js +156 -0
- package/src/compiler/phases/2-analyze/visitors/ClassDeclaration.js +25 -0
- package/src/compiler/phases/2-analyze/visitors/ClassDirective.js +13 -0
- package/src/compiler/phases/2-analyze/visitors/Component.js +26 -0
- package/src/compiler/phases/2-analyze/visitors/ConstTag.js +45 -0
- package/src/compiler/phases/2-analyze/visitors/DebugTag.js +15 -0
- package/src/compiler/phases/2-analyze/visitors/EachBlock.js +97 -0
- package/src/compiler/phases/2-analyze/visitors/ExportDefaultDeclaration.js +20 -0
- package/src/compiler/phases/2-analyze/visitors/ExportNamedDeclaration.js +70 -0
- package/src/compiler/phases/2-analyze/visitors/ExportSpecifier.js +30 -0
- package/src/compiler/phases/2-analyze/visitors/ExpressionStatement.js +38 -0
- package/src/compiler/phases/2-analyze/visitors/ExpressionTag.js +26 -0
- package/src/compiler/phases/2-analyze/visitors/Fragment.js +10 -0
- package/src/compiler/phases/2-analyze/visitors/FunctionDeclaration.js +16 -0
- package/src/compiler/phases/2-analyze/visitors/FunctionExpression.js +11 -0
- package/src/compiler/phases/2-analyze/visitors/HtmlTag.js +19 -0
- package/src/compiler/phases/2-analyze/visitors/Identifier.js +194 -0
- package/src/compiler/phases/2-analyze/visitors/IfBlock.js +46 -0
- package/src/compiler/phases/2-analyze/visitors/ImportDeclaration.js +31 -0
- package/src/compiler/phases/2-analyze/visitors/KeyBlock.js +21 -0
- package/src/compiler/phases/2-analyze/visitors/LabeledStatement.js +95 -0
- package/src/compiler/phases/2-analyze/visitors/LetDirective.js +24 -0
- package/src/compiler/phases/2-analyze/visitors/Literal.js +14 -0
- package/src/compiler/phases/2-analyze/visitors/MemberExpression.js +28 -0
- package/src/compiler/phases/2-analyze/visitors/NewExpression.js +17 -0
- package/src/compiler/phases/2-analyze/visitors/OnDirective.js +28 -0
- package/src/compiler/phases/2-analyze/visitors/PropertyDefinition.js +21 -0
- package/src/compiler/phases/2-analyze/visitors/RegularElement.js +240 -0
- package/src/compiler/phases/2-analyze/visitors/RenderTag.js +68 -0
- package/src/compiler/phases/2-analyze/visitors/SlotElement.js +42 -0
- package/src/compiler/phases/2-analyze/visitors/SnippetBlock.js +113 -0
- package/src/compiler/phases/2-analyze/visitors/SpreadAttribute.js +13 -0
- package/src/compiler/phases/2-analyze/visitors/SpreadElement.js +16 -0
- package/src/compiler/phases/2-analyze/visitors/StyleDirective.js +39 -0
- package/src/compiler/phases/2-analyze/visitors/SvelteBody.js +22 -0
- package/src/compiler/phases/2-analyze/visitors/SvelteBoundary.js +30 -0
- package/src/compiler/phases/2-analyze/visitors/SvelteComponent.js +18 -0
- package/src/compiler/phases/2-analyze/visitors/SvelteDocument.js +24 -0
- package/src/compiler/phases/2-analyze/visitors/SvelteElement.js +78 -0
- package/src/compiler/phases/2-analyze/visitors/SvelteFragment.js +27 -0
- package/src/compiler/phases/2-analyze/visitors/SvelteHead.js +18 -0
- package/src/compiler/phases/2-analyze/visitors/SvelteSelf.js +36 -0
- package/src/compiler/phases/2-analyze/visitors/SvelteWindow.js +24 -0
- package/src/compiler/phases/2-analyze/visitors/TaggedTemplateExpression.js +16 -0
- package/src/compiler/phases/2-analyze/visitors/TemplateElement.js +12 -0
- package/src/compiler/phases/2-analyze/visitors/Text.js +52 -0
- package/src/compiler/phases/2-analyze/visitors/TitleElement.js +21 -0
- package/src/compiler/phases/2-analyze/visitors/TransitionDirective.js +19 -0
- package/src/compiler/phases/2-analyze/visitors/UpdateExpression.js +29 -0
- package/src/compiler/phases/2-analyze/visitors/UseDirective.js +18 -0
- package/src/compiler/phases/2-analyze/visitors/VariableDeclarator.js +160 -0
- package/src/compiler/phases/2-analyze/visitors/shared/a11y/constants.js +334 -0
- package/src/compiler/phases/2-analyze/visitors/shared/a11y/index.js +981 -0
- package/src/compiler/phases/2-analyze/visitors/shared/attribute.js +125 -0
- package/src/compiler/phases/2-analyze/visitors/shared/component.js +177 -0
- package/src/compiler/phases/2-analyze/visitors/shared/element.js +160 -0
- package/src/compiler/phases/2-analyze/visitors/shared/fragment.js +15 -0
- package/src/compiler/phases/2-analyze/visitors/shared/function.js +24 -0
- package/src/compiler/phases/2-analyze/visitors/shared/snippets.js +17 -0
- package/src/compiler/phases/2-analyze/visitors/shared/special-element.js +16 -0
- package/src/compiler/phases/2-analyze/visitors/shared/utils.js +301 -0
- package/src/compiler/phases/3-transform/client/transform-client.js +719 -0
- package/src/compiler/phases/3-transform/client/transform-template/fix-attribute-casing.js +18 -0
- package/src/compiler/phases/3-transform/client/transform-template/index.js +67 -0
- package/src/compiler/phases/3-transform/client/transform-template/template.js +164 -0
- package/src/compiler/phases/3-transform/client/utils.js +181 -0
- package/src/compiler/phases/3-transform/client/visitors/AnimateDirective.js +38 -0
- package/src/compiler/phases/3-transform/client/visitors/ArrowFunctionExpression.js +11 -0
- package/src/compiler/phases/3-transform/client/visitors/AssignmentExpression.js +247 -0
- package/src/compiler/phases/3-transform/client/visitors/AttachTag.js +26 -0
- package/src/compiler/phases/3-transform/client/visitors/Attribute.js +14 -0
- package/src/compiler/phases/3-transform/client/visitors/AwaitBlock.js +124 -0
- package/src/compiler/phases/3-transform/client/visitors/AwaitExpression.js +25 -0
- package/src/compiler/phases/3-transform/client/visitors/BinaryExpression.js +34 -0
- package/src/compiler/phases/3-transform/client/visitors/BindDirective.js +290 -0
- package/src/compiler/phases/3-transform/client/visitors/BlockStatement.js +32 -0
- package/src/compiler/phases/3-transform/client/visitors/BreakStatement.js +20 -0
- package/src/compiler/phases/3-transform/client/visitors/CallExpression.js +136 -0
- package/src/compiler/phases/3-transform/client/visitors/ClassBody.js +111 -0
- package/src/compiler/phases/3-transform/client/visitors/Comment.js +11 -0
- package/src/compiler/phases/3-transform/client/visitors/Component.js +12 -0
- package/src/compiler/phases/3-transform/client/visitors/ConstTag.js +134 -0
- package/src/compiler/phases/3-transform/client/visitors/DebugTag.js +28 -0
- package/src/compiler/phases/3-transform/client/visitors/EachBlock.js +362 -0
- package/src/compiler/phases/3-transform/client/visitors/ExportNamedDeclaration.js +19 -0
- package/src/compiler/phases/3-transform/client/visitors/ExpressionStatement.js +20 -0
- package/src/compiler/phases/3-transform/client/visitors/ForOfStatement.js +25 -0
- package/src/compiler/phases/3-transform/client/visitors/Fragment.js +186 -0
- package/src/compiler/phases/3-transform/client/visitors/FunctionDeclaration.js +12 -0
- package/src/compiler/phases/3-transform/client/visitors/FunctionExpression.js +11 -0
- package/src/compiler/phases/3-transform/client/visitors/HtmlTag.js +53 -0
- package/src/compiler/phases/3-transform/client/visitors/Identifier.js +45 -0
- package/src/compiler/phases/3-transform/client/visitors/IfBlock.js +131 -0
- package/src/compiler/phases/3-transform/client/visitors/KeyBlock.js +45 -0
- package/src/compiler/phases/3-transform/client/visitors/LabeledStatement.js +64 -0
- package/src/compiler/phases/3-transform/client/visitors/LetDirective.js +55 -0
- package/src/compiler/phases/3-transform/client/visitors/MemberExpression.js +23 -0
- package/src/compiler/phases/3-transform/client/visitors/OnDirective.js +38 -0
- package/src/compiler/phases/3-transform/client/visitors/Program.js +153 -0
- package/src/compiler/phases/3-transform/client/visitors/RegularElement.js +725 -0
- package/src/compiler/phases/3-transform/client/visitors/RenderTag.js +95 -0
- package/src/compiler/phases/3-transform/client/visitors/SlotElement.js +94 -0
- package/src/compiler/phases/3-transform/client/visitors/SnippetBlock.js +94 -0
- package/src/compiler/phases/3-transform/client/visitors/SpreadAttribute.js +10 -0
- package/src/compiler/phases/3-transform/client/visitors/SvelteBody.js +11 -0
- package/src/compiler/phases/3-transform/client/visitors/SvelteBoundary.js +126 -0
- package/src/compiler/phases/3-transform/client/visitors/SvelteComponent.js +13 -0
- package/src/compiler/phases/3-transform/client/visitors/SvelteDocument.js +11 -0
- package/src/compiler/phases/3-transform/client/visitors/SvelteElement.js +161 -0
- package/src/compiler/phases/3-transform/client/visitors/SvelteFragment.js +17 -0
- package/src/compiler/phases/3-transform/client/visitors/SvelteHead.js +23 -0
- package/src/compiler/phases/3-transform/client/visitors/SvelteSelf.js +13 -0
- package/src/compiler/phases/3-transform/client/visitors/SvelteWindow.js +11 -0
- package/src/compiler/phases/3-transform/client/visitors/TitleElement.js +48 -0
- package/src/compiler/phases/3-transform/client/visitors/TransitionDirective.js +41 -0
- package/src/compiler/phases/3-transform/client/visitors/UpdateExpression.js +55 -0
- package/src/compiler/phases/3-transform/client/visitors/UseDirective.js +49 -0
- package/src/compiler/phases/3-transform/client/visitors/VariableDeclaration.js +422 -0
- package/src/compiler/phases/3-transform/client/visitors/shared/component.js +536 -0
- package/src/compiler/phases/3-transform/client/visitors/shared/declarations.js +53 -0
- package/src/compiler/phases/3-transform/client/visitors/shared/element.js +263 -0
- package/src/compiler/phases/3-transform/client/visitors/shared/events.js +180 -0
- package/src/compiler/phases/3-transform/client/visitors/shared/fragment.js +185 -0
- package/src/compiler/phases/3-transform/client/visitors/shared/function.js +17 -0
- package/src/compiler/phases/3-transform/client/visitors/shared/special_element.js +22 -0
- package/src/compiler/phases/3-transform/client/visitors/shared/utils.js +513 -0
- package/src/compiler/phases/3-transform/css/index.js +479 -0
- package/src/compiler/phases/3-transform/index.js +118 -0
- package/src/compiler/phases/3-transform/server/transform-server.js +428 -0
- package/src/compiler/phases/3-transform/server/visitors/AssignmentExpression.js +124 -0
- package/src/compiler/phases/3-transform/server/visitors/AwaitBlock.js +36 -0
- package/src/compiler/phases/3-transform/server/visitors/AwaitExpression.js +40 -0
- package/src/compiler/phases/3-transform/server/visitors/CallExpression.js +71 -0
- package/src/compiler/phases/3-transform/server/visitors/ClassBody.js +81 -0
- package/src/compiler/phases/3-transform/server/visitors/Component.js +13 -0
- package/src/compiler/phases/3-transform/server/visitors/ConstTag.js +49 -0
- package/src/compiler/phases/3-transform/server/visitors/DebugTag.js +24 -0
- package/src/compiler/phases/3-transform/server/visitors/EachBlock.js +76 -0
- package/src/compiler/phases/3-transform/server/visitors/ExpressionStatement.js +23 -0
- package/src/compiler/phases/3-transform/server/visitors/Fragment.js +53 -0
- package/src/compiler/phases/3-transform/server/visitors/HtmlTag.js +25 -0
- package/src/compiler/phases/3-transform/server/visitors/Identifier.js +24 -0
- package/src/compiler/phases/3-transform/server/visitors/IfBlock.js +48 -0
- package/src/compiler/phases/3-transform/server/visitors/KeyBlock.js +22 -0
- package/src/compiler/phases/3-transform/server/visitors/LabeledStatement.js +24 -0
- package/src/compiler/phases/3-transform/server/visitors/MemberExpression.js +19 -0
- package/src/compiler/phases/3-transform/server/visitors/Program.js +25 -0
- package/src/compiler/phases/3-transform/server/visitors/PropertyDefinition.js +37 -0
- package/src/compiler/phases/3-transform/server/visitors/RegularElement.js +216 -0
- package/src/compiler/phases/3-transform/server/visitors/RenderTag.js +45 -0
- package/src/compiler/phases/3-transform/server/visitors/SlotElement.js +68 -0
- package/src/compiler/phases/3-transform/server/visitors/SnippetBlock.js +29 -0
- package/src/compiler/phases/3-transform/server/visitors/SpreadAttribute.js +10 -0
- package/src/compiler/phases/3-transform/server/visitors/SvelteBoundary.js +139 -0
- package/src/compiler/phases/3-transform/server/visitors/SvelteComponent.js +12 -0
- package/src/compiler/phases/3-transform/server/visitors/SvelteElement.js +89 -0
- package/src/compiler/phases/3-transform/server/visitors/SvelteFragment.js +11 -0
- package/src/compiler/phases/3-transform/server/visitors/SvelteHead.js +25 -0
- package/src/compiler/phases/3-transform/server/visitors/SvelteSelf.js +12 -0
- package/src/compiler/phases/3-transform/server/visitors/TitleElement.js +21 -0
- package/src/compiler/phases/3-transform/server/visitors/UpdateExpression.js +35 -0
- package/src/compiler/phases/3-transform/server/visitors/VariableDeclaration.js +247 -0
- package/src/compiler/phases/3-transform/server/visitors/shared/component.js +359 -0
- package/src/compiler/phases/3-transform/server/visitors/shared/element.js +557 -0
- package/src/compiler/phases/3-transform/server/visitors/shared/utils.js +408 -0
- package/src/compiler/phases/3-transform/shared/assignments.js +92 -0
- package/src/compiler/phases/3-transform/shared/transform-async.js +114 -0
- package/src/compiler/phases/3-transform/utils.js +451 -0
- package/src/compiler/phases/bindings.js +227 -0
- package/src/compiler/phases/css.js +14 -0
- package/src/compiler/phases/nodes.js +258 -0
- package/src/compiler/phases/patterns.js +27 -0
- package/src/compiler/phases/scope.js +1432 -0
- package/src/compiler/preprocess/decode_sourcemap.js +96 -0
- package/src/compiler/preprocess/index.js +368 -0
- package/src/compiler/preprocess/replace_in_code.js +72 -0
- package/src/compiler/print/index.js +911 -0
- package/src/compiler/state.js +144 -0
- package/src/compiler/utils/assert.js +9 -0
- package/src/compiler/utils/ast.js +639 -0
- package/src/compiler/utils/builders.js +698 -0
- package/src/compiler/utils/compile_diagnostic.js +107 -0
- package/src/compiler/utils/extract_svelte_ignore.js +104 -0
- package/src/compiler/utils/mapped_code.js +454 -0
- package/src/compiler/utils/push_array.js +13 -0
- package/src/compiler/utils/sanitize_template_string.js +7 -0
- package/src/compiler/utils/slot.js +20 -0
- package/src/compiler/utils/string.js +9 -0
- package/src/compiler/validate-options.js +324 -0
- package/src/compiler/warnings.js +845 -0
- package/src/constants.js +66 -0
- package/src/easing/index.js +286 -0
- package/src/escaping.js +26 -0
- package/src/events/index.js +1 -0
- package/src/html-tree-validation.js +238 -0
- package/src/index-client.js +255 -0
- package/src/index-server.js +56 -0
- package/src/internal/client/constants.js +77 -0
- package/src/internal/client/context.js +258 -0
- package/src/internal/client/dev/assign.js +79 -0
- package/src/internal/client/dev/console-log.js +37 -0
- package/src/internal/client/dev/css.js +31 -0
- package/src/internal/client/dev/debug.js +500 -0
- package/src/internal/client/dev/elements.js +63 -0
- package/src/internal/client/dev/equality.js +101 -0
- package/src/internal/client/dev/hmr.js +89 -0
- package/src/internal/client/dev/inspect.js +72 -0
- package/src/internal/client/dev/legacy.js +25 -0
- package/src/internal/client/dev/ownership.js +81 -0
- package/src/internal/client/dev/tracing.js +162 -0
- package/src/internal/client/dev/validation.js +16 -0
- package/src/internal/client/dom/blocks/async.js +71 -0
- package/src/internal/client/dom/blocks/await.js +142 -0
- package/src/internal/client/dom/blocks/boundary.js +534 -0
- package/src/internal/client/dom/blocks/branches.js +227 -0
- package/src/internal/client/dom/blocks/css-props.js +28 -0
- package/src/internal/client/dom/blocks/each.js +723 -0
- package/src/internal/client/dom/blocks/html.js +128 -0
- package/src/internal/client/dom/blocks/if.js +82 -0
- package/src/internal/client/dom/blocks/key.js +40 -0
- package/src/internal/client/dom/blocks/slot.js +44 -0
- package/src/internal/client/dom/blocks/snippet.js +103 -0
- package/src/internal/client/dom/blocks/svelte-component.js +61 -0
- package/src/internal/client/dom/blocks/svelte-element.js +152 -0
- package/src/internal/client/dom/blocks/svelte-head.js +61 -0
- package/src/internal/client/dom/css.js +33 -0
- package/src/internal/client/dom/elements/actions.js +43 -0
- package/src/internal/client/dom/elements/attachments.js +33 -0
- package/src/internal/client/dom/elements/attributes.js +657 -0
- package/src/internal/client/dom/elements/bindings/document.js +17 -0
- package/src/internal/client/dom/elements/bindings/input.js +312 -0
- package/src/internal/client/dom/elements/bindings/media.js +233 -0
- package/src/internal/client/dom/elements/bindings/navigator.js +11 -0
- package/src/internal/client/dom/elements/bindings/props.js +22 -0
- package/src/internal/client/dom/elements/bindings/select.js +159 -0
- package/src/internal/client/dom/elements/bindings/shared.js +76 -0
- package/src/internal/client/dom/elements/bindings/size.js +107 -0
- package/src/internal/client/dom/elements/bindings/this.js +61 -0
- package/src/internal/client/dom/elements/bindings/universal.js +75 -0
- package/src/internal/client/dom/elements/bindings/window.js +66 -0
- package/src/internal/client/dom/elements/class.js +51 -0
- package/src/internal/client/dom/elements/custom-element.js +344 -0
- package/src/internal/client/dom/elements/customizable-select.js +99 -0
- package/src/internal/client/dom/elements/events.js +355 -0
- package/src/internal/client/dom/elements/misc.js +58 -0
- package/src/internal/client/dom/elements/style.js +57 -0
- package/src/internal/client/dom/elements/transitions.js +471 -0
- package/src/internal/client/dom/hydration.js +125 -0
- package/src/internal/client/dom/legacy/event-modifiers.js +127 -0
- package/src/internal/client/dom/legacy/lifecycle.js +82 -0
- package/src/internal/client/dom/legacy/misc.js +68 -0
- package/src/internal/client/dom/operations.js +293 -0
- package/src/internal/client/dom/reconciler.js +25 -0
- package/src/internal/client/dom/task.js +42 -0
- package/src/internal/client/dom/template.js +401 -0
- package/src/internal/client/error-handling.js +118 -0
- package/src/internal/client/errors.js +510 -0
- package/src/internal/client/hydratable.js +33 -0
- package/src/internal/client/index.js +183 -0
- package/src/internal/client/legacy.js +46 -0
- package/src/internal/client/loop.js +48 -0
- package/src/internal/client/proxy.js +432 -0
- package/src/internal/client/reactivity/async.js +306 -0
- package/src/internal/client/reactivity/batch.js +1057 -0
- package/src/internal/client/reactivity/deriveds.js +426 -0
- package/src/internal/client/reactivity/effects.js +718 -0
- package/src/internal/client/reactivity/equality.js +31 -0
- package/src/internal/client/reactivity/props.js +430 -0
- package/src/internal/client/reactivity/sources.js +370 -0
- package/src/internal/client/reactivity/status.js +25 -0
- package/src/internal/client/reactivity/store.js +203 -0
- package/src/internal/client/reactivity/utils.js +40 -0
- package/src/internal/client/render.js +335 -0
- package/src/internal/client/runtime.js +827 -0
- package/src/internal/client/timing.js +16 -0
- package/src/internal/client/validate.js +54 -0
- package/src/internal/client/warnings.js +271 -0
- package/src/internal/disclose-version.js +6 -0
- package/src/internal/flags/async.js +3 -0
- package/src/internal/flags/index.js +23 -0
- package/src/internal/flags/legacy.js +3 -0
- package/src/internal/flags/tracing.js +3 -0
- package/src/internal/index.js +5 -0
- package/src/internal/server/abort-signal.js +13 -0
- package/src/internal/server/blocks/html.js +11 -0
- package/src/internal/server/blocks/snippet.js +24 -0
- package/src/internal/server/context.js +132 -0
- package/src/internal/server/crypto.js +45 -0
- package/src/internal/server/dev.js +115 -0
- package/src/internal/server/errors.js +131 -0
- package/src/internal/server/hydratable.js +142 -0
- package/src/internal/server/hydration.js +6 -0
- package/src/internal/server/index.js +544 -0
- package/src/internal/server/render-context.js +86 -0
- package/src/internal/server/renderer.js +923 -0
- package/src/internal/server/warnings.js +29 -0
- package/src/internal/shared/attributes.js +225 -0
- package/src/internal/shared/clone.js +137 -0
- package/src/internal/shared/dev.js +65 -0
- package/src/internal/shared/errors.js +134 -0
- package/src/internal/shared/utils.js +144 -0
- package/src/internal/shared/validate.js +47 -0
- package/src/internal/shared/warnings.js +40 -0
- package/src/legacy/legacy-client.js +281 -0
- package/src/legacy/legacy-server.js +112 -0
- package/src/motion/index.js +32 -0
- package/src/motion/spring.js +369 -0
- package/src/motion/tweened.js +306 -0
- package/src/motion/utils.js +7 -0
- package/src/reactivity/create-subscriber.js +95 -0
- package/src/reactivity/date.js +118 -0
- package/src/reactivity/index-client.js +7 -0
- package/src/reactivity/index-server.js +23 -0
- package/src/reactivity/map.js +273 -0
- package/src/reactivity/media-query.js +55 -0
- package/src/reactivity/reactive-value.js +24 -0
- package/src/reactivity/set.js +213 -0
- package/src/reactivity/url-search-params.js +174 -0
- package/src/reactivity/url.js +205 -0
- package/src/reactivity/window/index.js +161 -0
- package/src/server/index.js +1 -0
- package/src/store/index-client.js +169 -0
- package/src/store/index-server.js +101 -0
- package/src/store/shared/index.js +209 -0
- package/src/store/utils.js +36 -0
- package/src/transition/index.js +300 -0
- package/src/utils.js +504 -0
- package/src/version.js +8 -0
- package/store.d.ts +1 -0
- package/svelte-html.d.ts +245 -0
- package/transition.d.ts +1 -0
- package/types/compiler/interfaces.d.ts +1 -0
- package/types/compiler/preprocess.d.ts +1 -0
- package/types/index.d.ts +3744 -0
- package/types/index.d.ts.map +280 -0
|
@@ -0,0 +1,657 @@
|
|
|
1
|
+
/** @import { Blocker, Effect } from '#client' */
|
|
2
|
+
import { DEV } from 'esm-env';
|
|
3
|
+
import { hydrating, set_hydrating } from '../hydration.js';
|
|
4
|
+
import { get_descriptors, get_prototype_of } from '../../../shared/utils.js';
|
|
5
|
+
import { create_event, delegate, delegated, event, event_symbol } from './events.js';
|
|
6
|
+
import { add_form_reset_listener, autofocus } from './misc.js';
|
|
7
|
+
import * as w from '../../warnings.js';
|
|
8
|
+
import { IS_XHTML, LOADING_ATTR_SYMBOL } from '#client/constants';
|
|
9
|
+
import { queue_micro_task } from '../task.js';
|
|
10
|
+
import { is_capture_event, can_delegate_event, normalize_attribute } from '../../../../utils.js';
|
|
11
|
+
import {
|
|
12
|
+
active_effect,
|
|
13
|
+
active_reaction,
|
|
14
|
+
get,
|
|
15
|
+
set_active_effect,
|
|
16
|
+
set_active_reaction
|
|
17
|
+
} from '../../runtime.js';
|
|
18
|
+
import { attach } from './attachments.js';
|
|
19
|
+
import { clsx } from '../../../shared/attributes.js';
|
|
20
|
+
import { set_class } from './class.js';
|
|
21
|
+
import { set_style } from './style.js';
|
|
22
|
+
import { ATTACHMENT_KEY, NAMESPACE_HTML, UNINITIALIZED } from '../../../../constants.js';
|
|
23
|
+
import { branch, destroy_effect, effect, managed } from '../../reactivity/effects.js';
|
|
24
|
+
import { init_select, select_option } from './bindings/select.js';
|
|
25
|
+
import { flatten } from '../../reactivity/async.js';
|
|
26
|
+
|
|
27
|
+
export const CLASS = Symbol('class');
|
|
28
|
+
export const STYLE = Symbol('style');
|
|
29
|
+
|
|
30
|
+
const IS_CUSTOM_ELEMENT = Symbol('is custom element');
|
|
31
|
+
const IS_HTML = Symbol('is html');
|
|
32
|
+
|
|
33
|
+
const LINK_TAG = IS_XHTML ? 'link' : 'LINK';
|
|
34
|
+
const INPUT_TAG = IS_XHTML ? 'input' : 'INPUT';
|
|
35
|
+
const OPTION_TAG = IS_XHTML ? 'option' : 'OPTION';
|
|
36
|
+
const SELECT_TAG = IS_XHTML ? 'select' : 'SELECT';
|
|
37
|
+
const PROGRESS_TAG = IS_XHTML ? 'progress' : 'PROGRESS';
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The value/checked attribute in the template actually corresponds to the defaultValue property, so we need
|
|
41
|
+
* to remove it upon hydration to avoid a bug when someone resets the form value.
|
|
42
|
+
* @param {HTMLInputElement} input
|
|
43
|
+
* @returns {void}
|
|
44
|
+
*/
|
|
45
|
+
export function remove_input_defaults(input) {
|
|
46
|
+
if (!hydrating) return;
|
|
47
|
+
|
|
48
|
+
var already_removed = false;
|
|
49
|
+
|
|
50
|
+
// We try and remove the default attributes later, rather than sync during hydration.
|
|
51
|
+
// Doing it sync during hydration has a negative impact on performance, but deferring the
|
|
52
|
+
// work in an idle task alleviates this greatly. If a form reset event comes in before
|
|
53
|
+
// the idle callback, then we ensure the input defaults are cleared just before.
|
|
54
|
+
var remove_defaults = () => {
|
|
55
|
+
if (already_removed) return;
|
|
56
|
+
already_removed = true;
|
|
57
|
+
|
|
58
|
+
// Remove the attributes but preserve the values
|
|
59
|
+
if (input.hasAttribute('value')) {
|
|
60
|
+
var value = input.value;
|
|
61
|
+
set_attribute(input, 'value', null);
|
|
62
|
+
input.value = value;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (input.hasAttribute('checked')) {
|
|
66
|
+
var checked = input.checked;
|
|
67
|
+
set_attribute(input, 'checked', null);
|
|
68
|
+
input.checked = checked;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
// @ts-expect-error
|
|
73
|
+
input.__on_r = remove_defaults;
|
|
74
|
+
queue_micro_task(remove_defaults);
|
|
75
|
+
add_form_reset_listener();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @param {Element} element
|
|
80
|
+
* @param {any} value
|
|
81
|
+
*/
|
|
82
|
+
export function set_value(element, value) {
|
|
83
|
+
var attributes = get_attributes(element);
|
|
84
|
+
|
|
85
|
+
if (
|
|
86
|
+
attributes.value ===
|
|
87
|
+
(attributes.value =
|
|
88
|
+
// treat null and undefined the same for the initial value
|
|
89
|
+
value ?? undefined) ||
|
|
90
|
+
// @ts-expect-error
|
|
91
|
+
// `progress` elements always need their value set when it's `0`
|
|
92
|
+
(element.value === value && (value !== 0 || element.nodeName !== PROGRESS_TAG))
|
|
93
|
+
) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// @ts-expect-error
|
|
98
|
+
element.value = value ?? '';
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @param {Element} element
|
|
103
|
+
* @param {boolean} checked
|
|
104
|
+
*/
|
|
105
|
+
export function set_checked(element, checked) {
|
|
106
|
+
var attributes = get_attributes(element);
|
|
107
|
+
|
|
108
|
+
if (
|
|
109
|
+
attributes.checked ===
|
|
110
|
+
(attributes.checked =
|
|
111
|
+
// treat null and undefined the same for the initial value
|
|
112
|
+
checked ?? undefined)
|
|
113
|
+
) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// @ts-expect-error
|
|
118
|
+
element.checked = checked;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Sets the `selected` attribute on an `option` element.
|
|
123
|
+
* Not set through the property because that doesn't reflect to the DOM,
|
|
124
|
+
* which means it wouldn't be taken into account when a form is reset.
|
|
125
|
+
* @param {HTMLOptionElement} element
|
|
126
|
+
* @param {boolean} selected
|
|
127
|
+
*/
|
|
128
|
+
export function set_selected(element, selected) {
|
|
129
|
+
if (selected) {
|
|
130
|
+
// The selected option could've changed via user selection, and
|
|
131
|
+
// setting the value without this check would set it back.
|
|
132
|
+
if (!element.hasAttribute('selected')) {
|
|
133
|
+
element.setAttribute('selected', '');
|
|
134
|
+
}
|
|
135
|
+
} else {
|
|
136
|
+
element.removeAttribute('selected');
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Applies the default checked property without influencing the current checked property.
|
|
142
|
+
* @param {HTMLInputElement} element
|
|
143
|
+
* @param {boolean} checked
|
|
144
|
+
*/
|
|
145
|
+
export function set_default_checked(element, checked) {
|
|
146
|
+
const existing_value = element.checked;
|
|
147
|
+
element.defaultChecked = checked;
|
|
148
|
+
element.checked = existing_value;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Applies the default value property without influencing the current value property.
|
|
153
|
+
* @param {HTMLInputElement | HTMLTextAreaElement} element
|
|
154
|
+
* @param {string} value
|
|
155
|
+
*/
|
|
156
|
+
export function set_default_value(element, value) {
|
|
157
|
+
const existing_value = element.value;
|
|
158
|
+
element.defaultValue = value;
|
|
159
|
+
element.value = existing_value;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* @param {Element} element
|
|
164
|
+
* @param {string} attribute
|
|
165
|
+
* @param {string | null} value
|
|
166
|
+
* @param {boolean} [skip_warning]
|
|
167
|
+
*/
|
|
168
|
+
export function set_attribute(element, attribute, value, skip_warning) {
|
|
169
|
+
var attributes = get_attributes(element);
|
|
170
|
+
|
|
171
|
+
if (hydrating) {
|
|
172
|
+
attributes[attribute] = element.getAttribute(attribute);
|
|
173
|
+
|
|
174
|
+
if (
|
|
175
|
+
attribute === 'src' ||
|
|
176
|
+
attribute === 'srcset' ||
|
|
177
|
+
(attribute === 'href' && element.nodeName === LINK_TAG)
|
|
178
|
+
) {
|
|
179
|
+
if (!skip_warning) {
|
|
180
|
+
check_src_in_dev_hydration(element, attribute, value ?? '');
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// If we reset these attributes, they would result in another network request, which we want to avoid.
|
|
184
|
+
// We assume they are the same between client and server as checking if they are equal is expensive
|
|
185
|
+
// (we can't just compare the strings as they can be different between client and server but result in the
|
|
186
|
+
// same url, so we would need to create hidden anchor elements to compare them)
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (attributes[attribute] === (attributes[attribute] = value)) return;
|
|
192
|
+
|
|
193
|
+
if (attribute === 'loading') {
|
|
194
|
+
// @ts-expect-error
|
|
195
|
+
element[LOADING_ATTR_SYMBOL] = value;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (value == null) {
|
|
199
|
+
element.removeAttribute(attribute);
|
|
200
|
+
} else if (typeof value !== 'string' && get_setters(element).includes(attribute)) {
|
|
201
|
+
// @ts-ignore
|
|
202
|
+
element[attribute] = value;
|
|
203
|
+
} else {
|
|
204
|
+
element.setAttribute(attribute, value);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* @param {Element} dom
|
|
210
|
+
* @param {string} attribute
|
|
211
|
+
* @param {string} value
|
|
212
|
+
*/
|
|
213
|
+
export function set_xlink_attribute(dom, attribute, value) {
|
|
214
|
+
dom.setAttributeNS('http://www.w3.org/1999/xlink', attribute, value);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* @param {HTMLElement} node
|
|
219
|
+
* @param {string} prop
|
|
220
|
+
* @param {any} value
|
|
221
|
+
*/
|
|
222
|
+
export function set_custom_element_data(node, prop, value) {
|
|
223
|
+
// We need to ensure that setting custom element props, which can
|
|
224
|
+
// invoke lifecycle methods on other custom elements, does not also
|
|
225
|
+
// associate those lifecycle methods with the current active reaction
|
|
226
|
+
// or effect
|
|
227
|
+
var previous_reaction = active_reaction;
|
|
228
|
+
var previous_effect = active_effect;
|
|
229
|
+
|
|
230
|
+
// If we're hydrating but the custom element is from Svelte, and it already scaffolded,
|
|
231
|
+
// then it might run block logic in hydration mode, which we have to prevent.
|
|
232
|
+
let was_hydrating = hydrating;
|
|
233
|
+
if (hydrating) {
|
|
234
|
+
set_hydrating(false);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
set_active_reaction(null);
|
|
238
|
+
set_active_effect(null);
|
|
239
|
+
|
|
240
|
+
try {
|
|
241
|
+
if (
|
|
242
|
+
// `style` should use `set_attribute` rather than the setter
|
|
243
|
+
prop !== 'style' &&
|
|
244
|
+
// Don't compute setters for custom elements while they aren't registered yet,
|
|
245
|
+
// because during their upgrade/instantiation they might add more setters.
|
|
246
|
+
// Instead, fall back to a simple "an object, then set as property" heuristic.
|
|
247
|
+
(setters_cache.has(node.getAttribute('is') || node.nodeName) ||
|
|
248
|
+
// customElements may not be available in browser extension contexts
|
|
249
|
+
!customElements ||
|
|
250
|
+
customElements.get(node.getAttribute('is') || node.nodeName.toLowerCase())
|
|
251
|
+
? get_setters(node).includes(prop)
|
|
252
|
+
: value && typeof value === 'object')
|
|
253
|
+
) {
|
|
254
|
+
// @ts-expect-error
|
|
255
|
+
node[prop] = value;
|
|
256
|
+
} else {
|
|
257
|
+
// We did getters etc checks already, stringify before passing to set_attribute
|
|
258
|
+
// to ensure it doesn't invoke the same logic again, and potentially populating
|
|
259
|
+
// the setters cache too early.
|
|
260
|
+
set_attribute(node, prop, value == null ? value : String(value));
|
|
261
|
+
}
|
|
262
|
+
} finally {
|
|
263
|
+
set_active_reaction(previous_reaction);
|
|
264
|
+
set_active_effect(previous_effect);
|
|
265
|
+
if (was_hydrating) {
|
|
266
|
+
set_hydrating(true);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Spreads attributes onto a DOM element, taking into account the currently set attributes
|
|
273
|
+
* @param {Element & ElementCSSInlineStyle} element
|
|
274
|
+
* @param {Record<string | symbol, any> | undefined} prev
|
|
275
|
+
* @param {Record<string | symbol, any>} next New attributes - this function mutates this object
|
|
276
|
+
* @param {string} [css_hash]
|
|
277
|
+
* @param {boolean} [should_remove_defaults]
|
|
278
|
+
* @param {boolean} [skip_warning]
|
|
279
|
+
* @returns {Record<string, any>}
|
|
280
|
+
*/
|
|
281
|
+
function set_attributes(
|
|
282
|
+
element,
|
|
283
|
+
prev,
|
|
284
|
+
next,
|
|
285
|
+
css_hash,
|
|
286
|
+
should_remove_defaults = false,
|
|
287
|
+
skip_warning = false
|
|
288
|
+
) {
|
|
289
|
+
if (hydrating && should_remove_defaults && element.nodeName === INPUT_TAG) {
|
|
290
|
+
var input = /** @type {HTMLInputElement} */ (element);
|
|
291
|
+
var attribute = input.type === 'checkbox' ? 'defaultChecked' : 'defaultValue';
|
|
292
|
+
|
|
293
|
+
if (!(attribute in next)) {
|
|
294
|
+
remove_input_defaults(input);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
var attributes = get_attributes(element);
|
|
299
|
+
|
|
300
|
+
var is_custom_element = attributes[IS_CUSTOM_ELEMENT];
|
|
301
|
+
var preserve_attribute_case = !attributes[IS_HTML];
|
|
302
|
+
|
|
303
|
+
// If we're hydrating but the custom element is from Svelte, and it already scaffolded,
|
|
304
|
+
// then it might run block logic in hydration mode, which we have to prevent.
|
|
305
|
+
let is_hydrating_custom_element = hydrating && is_custom_element;
|
|
306
|
+
if (is_hydrating_custom_element) {
|
|
307
|
+
set_hydrating(false);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
var current = prev || {};
|
|
311
|
+
var is_option_element = element.nodeName === OPTION_TAG;
|
|
312
|
+
|
|
313
|
+
for (var key in prev) {
|
|
314
|
+
if (!(key in next)) {
|
|
315
|
+
next[key] = null;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
if (next.class) {
|
|
320
|
+
next.class = clsx(next.class);
|
|
321
|
+
} else if (css_hash || next[CLASS]) {
|
|
322
|
+
next.class = null; /* force call to set_class() */
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
if (next[STYLE]) {
|
|
326
|
+
next.style ??= null; /* force call to set_style() */
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
var setters = get_setters(element);
|
|
330
|
+
|
|
331
|
+
// since key is captured we use const
|
|
332
|
+
for (const key in next) {
|
|
333
|
+
// let instead of var because referenced in a closure
|
|
334
|
+
let value = next[key];
|
|
335
|
+
|
|
336
|
+
// Up here because we want to do this for the initial value, too, even if it's undefined,
|
|
337
|
+
// and this wouldn't be reached in case of undefined because of the equality check below
|
|
338
|
+
if (is_option_element && key === 'value' && value == null) {
|
|
339
|
+
// The <option> element is a special case because removing the value attribute means
|
|
340
|
+
// the value is set to the text content of the option element, and setting the value
|
|
341
|
+
// to null or undefined means the value is set to the string "null" or "undefined".
|
|
342
|
+
// To align with how we handle this case in non-spread-scenarios, this logic is needed.
|
|
343
|
+
// There's a super-edge-case bug here that is left in in favor of smaller code size:
|
|
344
|
+
// Because of the "set missing props to null" logic above, we can't differentiate
|
|
345
|
+
// between a missing value and an explicitly set value of null or undefined. That means
|
|
346
|
+
// that once set, the value attribute of an <option> element can't be removed. This is
|
|
347
|
+
// a very rare edge case, and removing the attribute altogether isn't possible either
|
|
348
|
+
// for the <option value={undefined}> case, so we're not losing any functionality here.
|
|
349
|
+
// @ts-ignore
|
|
350
|
+
element.value = element.__value = '';
|
|
351
|
+
current[key] = value;
|
|
352
|
+
continue;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
if (key === 'class') {
|
|
356
|
+
var is_html = element.namespaceURI === 'http://www.w3.org/1999/xhtml';
|
|
357
|
+
set_class(element, is_html, value, css_hash, prev?.[CLASS], next[CLASS]);
|
|
358
|
+
current[key] = value;
|
|
359
|
+
current[CLASS] = next[CLASS];
|
|
360
|
+
continue;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
if (key === 'style') {
|
|
364
|
+
set_style(element, value, prev?.[STYLE], next[STYLE]);
|
|
365
|
+
current[key] = value;
|
|
366
|
+
current[STYLE] = next[STYLE];
|
|
367
|
+
continue;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
var prev_value = current[key];
|
|
371
|
+
|
|
372
|
+
// Skip if value is unchanged, unless it's `undefined` and the element still has the attribute
|
|
373
|
+
if (value === prev_value && !(value === undefined && element.hasAttribute(key))) {
|
|
374
|
+
continue;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
current[key] = value;
|
|
378
|
+
|
|
379
|
+
var prefix = key[0] + key[1]; // this is faster than key.slice(0, 2)
|
|
380
|
+
if (prefix === '$$') continue;
|
|
381
|
+
|
|
382
|
+
if (prefix === 'on') {
|
|
383
|
+
/** @type {{ capture?: true }} */
|
|
384
|
+
const opts = {};
|
|
385
|
+
const event_handle_key = '$$' + key;
|
|
386
|
+
let event_name = key.slice(2);
|
|
387
|
+
var is_delegated = can_delegate_event(event_name);
|
|
388
|
+
|
|
389
|
+
if (is_capture_event(event_name)) {
|
|
390
|
+
event_name = event_name.slice(0, -7);
|
|
391
|
+
opts.capture = true;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
if (!is_delegated && prev_value) {
|
|
395
|
+
// Listening to same event but different handler -> our handle function below takes care of this
|
|
396
|
+
// If we were to remove and add listeners in this case, it could happen that the event is "swallowed"
|
|
397
|
+
// (the browser seems to not know yet that a new one exists now) and doesn't reach the handler
|
|
398
|
+
// https://github.com/sveltejs/svelte/issues/11903
|
|
399
|
+
if (value != null) continue;
|
|
400
|
+
|
|
401
|
+
element.removeEventListener(event_name, current[event_handle_key], opts);
|
|
402
|
+
current[event_handle_key] = null;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
if (is_delegated) {
|
|
406
|
+
delegated(event_name, element, value);
|
|
407
|
+
delegate([event_name]);
|
|
408
|
+
} else if (value != null) {
|
|
409
|
+
/**
|
|
410
|
+
* @this {any}
|
|
411
|
+
* @param {Event} evt
|
|
412
|
+
*/
|
|
413
|
+
function handle(evt) {
|
|
414
|
+
current[key].call(this, evt);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
current[event_handle_key] = create_event(event_name, element, handle, opts);
|
|
418
|
+
}
|
|
419
|
+
} else if (key === 'style') {
|
|
420
|
+
// avoid using the setter
|
|
421
|
+
set_attribute(element, key, value);
|
|
422
|
+
} else if (key === 'autofocus') {
|
|
423
|
+
autofocus(/** @type {HTMLElement} */ (element), Boolean(value));
|
|
424
|
+
} else if (!is_custom_element && (key === '__value' || (key === 'value' && value != null))) {
|
|
425
|
+
// @ts-ignore We're not running this for custom elements because __value is actually
|
|
426
|
+
// how Lit stores the current value on the element, and messing with that would break things.
|
|
427
|
+
element.value = element.__value = value;
|
|
428
|
+
} else if (key === 'selected' && is_option_element) {
|
|
429
|
+
set_selected(/** @type {HTMLOptionElement} */ (element), value);
|
|
430
|
+
} else {
|
|
431
|
+
var name = key;
|
|
432
|
+
if (!preserve_attribute_case) {
|
|
433
|
+
name = normalize_attribute(name);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
var is_default = name === 'defaultValue' || name === 'defaultChecked';
|
|
437
|
+
|
|
438
|
+
if (value == null && !is_custom_element && !is_default) {
|
|
439
|
+
attributes[key] = null;
|
|
440
|
+
|
|
441
|
+
if (name === 'value' || name === 'checked') {
|
|
442
|
+
// removing value/checked also removes defaultValue/defaultChecked — preserve
|
|
443
|
+
let input = /** @type {HTMLInputElement} */ (element);
|
|
444
|
+
const use_default = prev === undefined;
|
|
445
|
+
if (name === 'value') {
|
|
446
|
+
let previous = input.defaultValue;
|
|
447
|
+
input.removeAttribute(name);
|
|
448
|
+
input.defaultValue = previous;
|
|
449
|
+
// @ts-ignore
|
|
450
|
+
input.value = input.__value = use_default ? previous : null;
|
|
451
|
+
} else {
|
|
452
|
+
let previous = input.defaultChecked;
|
|
453
|
+
input.removeAttribute(name);
|
|
454
|
+
input.defaultChecked = previous;
|
|
455
|
+
input.checked = use_default ? previous : false;
|
|
456
|
+
}
|
|
457
|
+
} else {
|
|
458
|
+
element.removeAttribute(key);
|
|
459
|
+
}
|
|
460
|
+
} else if (
|
|
461
|
+
is_default ||
|
|
462
|
+
(setters.includes(name) && (is_custom_element || typeof value !== 'string'))
|
|
463
|
+
) {
|
|
464
|
+
// @ts-ignore
|
|
465
|
+
element[name] = value;
|
|
466
|
+
// remove it from attributes's cache
|
|
467
|
+
if (name in attributes) attributes[name] = UNINITIALIZED;
|
|
468
|
+
} else if (typeof value !== 'function') {
|
|
469
|
+
set_attribute(element, name, value, skip_warning);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
if (is_hydrating_custom_element) {
|
|
475
|
+
set_hydrating(true);
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
return current;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* @param {Element & ElementCSSInlineStyle} element
|
|
483
|
+
* @param {(...expressions: any) => Record<string | symbol, any>} fn
|
|
484
|
+
* @param {Array<() => any>} sync
|
|
485
|
+
* @param {Array<() => Promise<any>>} async
|
|
486
|
+
* @param {Blocker[]} blockers
|
|
487
|
+
* @param {string} [css_hash]
|
|
488
|
+
* @param {boolean} [should_remove_defaults]
|
|
489
|
+
* @param {boolean} [skip_warning]
|
|
490
|
+
*/
|
|
491
|
+
export function attribute_effect(
|
|
492
|
+
element,
|
|
493
|
+
fn,
|
|
494
|
+
sync = [],
|
|
495
|
+
async = [],
|
|
496
|
+
blockers = [],
|
|
497
|
+
css_hash,
|
|
498
|
+
should_remove_defaults = false,
|
|
499
|
+
skip_warning = false
|
|
500
|
+
) {
|
|
501
|
+
flatten(blockers, sync, async, (values) => {
|
|
502
|
+
/** @type {Record<string | symbol, any> | undefined} */
|
|
503
|
+
var prev = undefined;
|
|
504
|
+
|
|
505
|
+
/** @type {Record<symbol, Effect>} */
|
|
506
|
+
var effects = {};
|
|
507
|
+
|
|
508
|
+
var is_select = element.nodeName === SELECT_TAG;
|
|
509
|
+
var inited = false;
|
|
510
|
+
|
|
511
|
+
managed(() => {
|
|
512
|
+
var next = fn(...values.map(get));
|
|
513
|
+
/** @type {Record<string | symbol, any>} */
|
|
514
|
+
var current = set_attributes(
|
|
515
|
+
element,
|
|
516
|
+
prev,
|
|
517
|
+
next,
|
|
518
|
+
css_hash,
|
|
519
|
+
should_remove_defaults,
|
|
520
|
+
skip_warning
|
|
521
|
+
);
|
|
522
|
+
|
|
523
|
+
if (inited && is_select && 'value' in next) {
|
|
524
|
+
select_option(/** @type {HTMLSelectElement} */ (element), next.value);
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
for (let symbol of Object.getOwnPropertySymbols(effects)) {
|
|
528
|
+
if (!next[symbol]) destroy_effect(effects[symbol]);
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
for (let symbol of Object.getOwnPropertySymbols(next)) {
|
|
532
|
+
var n = next[symbol];
|
|
533
|
+
|
|
534
|
+
if (symbol.description === ATTACHMENT_KEY && (!prev || n !== prev[symbol])) {
|
|
535
|
+
if (effects[symbol]) destroy_effect(effects[symbol]);
|
|
536
|
+
effects[symbol] = branch(() => attach(element, () => n));
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
current[symbol] = n;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
prev = current;
|
|
543
|
+
});
|
|
544
|
+
|
|
545
|
+
if (is_select) {
|
|
546
|
+
var select = /** @type {HTMLSelectElement} */ (element);
|
|
547
|
+
|
|
548
|
+
effect(() => {
|
|
549
|
+
select_option(select, /** @type {Record<string | symbol, any>} */ (prev).value, true);
|
|
550
|
+
init_select(select);
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
inited = true;
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
*
|
|
560
|
+
* @param {Element} element
|
|
561
|
+
*/
|
|
562
|
+
function get_attributes(element) {
|
|
563
|
+
return /** @type {Record<string | symbol, unknown>} **/ (
|
|
564
|
+
// @ts-expect-error
|
|
565
|
+
element.__attributes ??= {
|
|
566
|
+
[IS_CUSTOM_ELEMENT]: element.nodeName.includes('-'),
|
|
567
|
+
[IS_HTML]: element.namespaceURI === NAMESPACE_HTML
|
|
568
|
+
}
|
|
569
|
+
);
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
/** @type {Map<string, string[]>} */
|
|
573
|
+
var setters_cache = new Map();
|
|
574
|
+
|
|
575
|
+
/** @param {Element} element */
|
|
576
|
+
function get_setters(element) {
|
|
577
|
+
var cache_key = element.getAttribute('is') || element.nodeName;
|
|
578
|
+
var setters = setters_cache.get(cache_key);
|
|
579
|
+
if (setters) return setters;
|
|
580
|
+
setters_cache.set(cache_key, (setters = []));
|
|
581
|
+
|
|
582
|
+
var descriptors;
|
|
583
|
+
var proto = element; // In the case of custom elements there might be setters on the instance
|
|
584
|
+
var element_proto = Element.prototype;
|
|
585
|
+
|
|
586
|
+
// Stop at Element, from there on there's only unnecessary setters we're not interested in
|
|
587
|
+
// Do not use contructor.name here as that's unreliable in some browser environments
|
|
588
|
+
while (element_proto !== proto) {
|
|
589
|
+
descriptors = get_descriptors(proto);
|
|
590
|
+
|
|
591
|
+
for (var key in descriptors) {
|
|
592
|
+
if (descriptors[key].set) {
|
|
593
|
+
setters.push(key);
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
proto = get_prototype_of(proto);
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
return setters;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
* @param {any} element
|
|
605
|
+
* @param {string} attribute
|
|
606
|
+
* @param {string} value
|
|
607
|
+
*/
|
|
608
|
+
function check_src_in_dev_hydration(element, attribute, value) {
|
|
609
|
+
if (!DEV) return;
|
|
610
|
+
if (attribute === 'srcset' && srcset_url_equal(element, value)) return;
|
|
611
|
+
if (src_url_equal(element.getAttribute(attribute) ?? '', value)) return;
|
|
612
|
+
|
|
613
|
+
w.hydration_attribute_changed(
|
|
614
|
+
attribute,
|
|
615
|
+
element.outerHTML.replace(element.innerHTML, element.innerHTML && '...'),
|
|
616
|
+
String(value)
|
|
617
|
+
);
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
/**
|
|
621
|
+
* @param {string} element_src
|
|
622
|
+
* @param {string} url
|
|
623
|
+
* @returns {boolean}
|
|
624
|
+
*/
|
|
625
|
+
function src_url_equal(element_src, url) {
|
|
626
|
+
if (element_src === url) return true;
|
|
627
|
+
return new URL(element_src, document.baseURI).href === new URL(url, document.baseURI).href;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
/** @param {string} srcset */
|
|
631
|
+
function split_srcset(srcset) {
|
|
632
|
+
return srcset.split(',').map((src) => src.trim().split(' ').filter(Boolean));
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
/**
|
|
636
|
+
* @param {HTMLSourceElement | HTMLImageElement} element
|
|
637
|
+
* @param {string} srcset
|
|
638
|
+
* @returns {boolean}
|
|
639
|
+
*/
|
|
640
|
+
function srcset_url_equal(element, srcset) {
|
|
641
|
+
var element_urls = split_srcset(element.srcset);
|
|
642
|
+
var urls = split_srcset(srcset);
|
|
643
|
+
|
|
644
|
+
return (
|
|
645
|
+
urls.length === element_urls.length &&
|
|
646
|
+
urls.every(
|
|
647
|
+
([url, width], i) =>
|
|
648
|
+
width === element_urls[i][1] &&
|
|
649
|
+
// We need to test both ways because Vite will create an a full URL with
|
|
650
|
+
// `new URL(asset, import.meta.url).href` for the client when `base: './'`, and the
|
|
651
|
+
// relative URLs inside srcset are not automatically resolved to absolute URLs by
|
|
652
|
+
// browsers (in contrast to img.src). This means both SSR and DOM code could
|
|
653
|
+
// contain relative or absolute URLs.
|
|
654
|
+
(src_url_equal(element_urls[i][0], url) || src_url_equal(url, element_urls[i][0]))
|
|
655
|
+
)
|
|
656
|
+
);
|
|
657
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { listen } from './shared.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {(activeElement: Element | null) => void} update
|
|
5
|
+
* @returns {void}
|
|
6
|
+
*/
|
|
7
|
+
export function bind_active_element(update) {
|
|
8
|
+
listen(document, ['focusin', 'focusout'], (event) => {
|
|
9
|
+
if (event && event.type === 'focusout' && /** @type {FocusEvent} */ (event).relatedTarget) {
|
|
10
|
+
// The tests still pass if we remove this, because of JSDOM limitations, but it is necessary
|
|
11
|
+
// to avoid temporarily resetting to `document.body`
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
update(document.activeElement);
|
|
16
|
+
});
|
|
17
|
+
}
|