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: use svg methods for updating svg attributes too #11755

Merged
merged 1 commit into from
May 23, 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
5 changes: 5 additions & 0 deletions .changeset/green-snails-tickle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"svelte": patch
---

fix: use svg methods for updating svg attributes too
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ function serialize_dynamic_element_attributes(attributes, context, element_id) {
function serialize_element_attribute_update_assignment(element, node_id, attribute, context) {
const state = context.state;
const name = get_attribute_name(element, attribute, context);
const is_svg = context.state.metadata.namespace === 'svg';
const is_svg = context.state.metadata.namespace === 'svg' || element.name === 'svg';
const is_mathml = context.state.metadata.namespace === 'mathml';
let [contains_call_expression, value] = serialize_attribute_value(attribute.value, context);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { flushSync } from '../../../../src/index-client';
import { test, ok } from '../../test';

export default test({
mode: ['client'],
test({ assert, target }) {
const svg = target.querySelector('svg');
const button = target.querySelector('button');
ok(svg);
ok(button);

assert.equal(svg.getAttribute('class'), '0');
flushSync(() => {
button.click();
});
assert.equal(svg.getAttribute('class'), '1');
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<script>
let count = $state(0);
</script>

<svg class={count}>
</svg>

<button onclick={()=>count++}></button>
Loading