Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ensure correct types for media bindings #2284

Merged
merged 2 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions packages/svelte2tsx/src/htmlxtojsx_v2/nodes/Binding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,36 @@ import { Element } from './Element';
import { InlineComponent } from './InlineComponent';
import { surroundWithIgnoreComments } from '../../utils/ignore';

/**
* List of binding names that are transformed to sth like `binding = variable`.
*/
const oneWayBindingAttributes: Set<string> = new Set([
'clientWidth',
'clientHeight',
'offsetWidth',
'offsetHeight',
'duration',
'buffered',
'seekable',
'seeking',
'played',
'ended',
'readyState',
'naturalWidth',
'naturalHeight'
]);

/**
* List of binding names that are transformed to sth like `binding = variable as GeneratedCode`.
*/
const oneWayBindingAttributesNotOnElement: Map<string, string> = new Map([
['contentRect', 'DOMRectReadOnly'],
['contentBoxSize', 'ResizeObserverSize[]'],
['borderBoxSize', 'ResizeObserverSize[]'],
['devicePixelContentBoxSize', 'ResizeObserverSize[]']
['devicePixelContentBoxSize', 'ResizeObserverSize[]'],
// available on the element, but with a different type
['buffered', "import('svelte/elements').SvelteMediaTimeRange[]"],
['played', "import('svelte/elements').SvelteMediaTimeRange[]"],
['seekable', "import('svelte/elements').SvelteMediaTimeRange[]"]
]);

/**
* List of all binding names that are transformed to sth like `binding = variable`.
* This applies to readonly bindings and the this binding.
*/
export const assignmentBindings = new Set([...oneWayBindingAttributes.keys(), 'this']);

const supportsBindThis = [
'InlineComponent',
'Element',
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading