Skip to content

Not all computed return values are replaced by assignments when multiple code paths. #13

@saabi

Description

@saabi
<script>
	import * as constants from './constants.js';

	export default {
		computed: {
			style: ({ divider }) => {
				const group = divider.parent;

				const x = group.getLeft();
				const y = group.getTop();
				const w = group.getWidth();
				const h = group.getHeight();

				if (divider.type === 'horizontal') {
					return `left: ${x * 100}%; top: ${(y + divider.position * h) * 100}%; width: ${w * 100}%`;
				} else {
					return `top: ${y * 100}%; left: ${(x + divider.position * w) * 100}%; height: ${h * 100}%`;
				}
			}
		}
	};
</script>

is converted to:

<script>
	import * as constants from './constants.js';

	export let divider;

	export let style;
	$: {
		const group = divider.parent;

		const x = group.getLeft();
		const y = group.getTop();
		const w = group.getWidth();
		const h = group.getHeight();

		if (divider.type === 'horizontal') {
			style = `left: ${x * 100}%; top: ${(y + divider.position * h) * 100}%; width: ${w * 100}%`;
		} else {
			return `top: ${y * 100}%; left: ${(x + divider.position * w) * 100}%; height: ${h * 100}%`;
		}
	}
</script>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions