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 element dir properties persist with text changes #12204

Merged
merged 3 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
simplify
  • Loading branch information
trueadm committed Jun 27, 2024
commit 3d8e9cd3eb406b644a98acb2eb8c1ce9aefb2ae8
Original file line number Diff line number Diff line change
Expand Up @@ -2175,7 +2175,11 @@ export const template_visitors = {
);

if (has_direction_attribute) {
context.state.update.push(b.stmt(b.call('$.set_direction', node_id)));
// This fixes an issue with Chromium where updates to text content within an element
// does not update the direction when set to auto. If we just re-assign the dir, this fixes it.
context.state.update.push(
b.stmt(b.assignment('=', b.member(node_id, b.id('dir')), b.member(node_id, b.id('dir'))))
);
}

if (child_locations.length > 0) {
Expand Down
2 changes: 1 addition & 1 deletion packages/svelte/src/internal/client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export {
update_pre_store,
update_store
} from './reactivity/store.js';
export { append_styles, sanitize_slots, set_text, set_direction, slot } from './render.js';
export { append_styles, sanitize_slots, set_text, slot } from './render.js';
export {
get,
invalidate_inner_signals,
Expand Down
10 changes: 0 additions & 10 deletions packages/svelte/src/internal/client/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,6 @@ export function set_text(text, value) {
}
}

/**
* @param {HTMLElement} element
*/
export function set_direction(element) {
// This fixes an issue with Chromium where updates to text content within an element
// does not update the direction when set to auto. If we just re-assign the dir, this fixes it.
// eslint-disable-next-line no-self-assign
element.dir = element.dir;
}

/**
* @param {Comment} anchor
* @param {void | ((anchor: Comment, slot_props: Record<string, unknown>) => void)} slot_fn
Expand Down
Loading