Skip to content

Commit

Permalink
fix: Add more checks to determine if element is non-static (#15259)
Browse files Browse the repository at this point in the history
Fixes #15241
  • Loading branch information
ranjan-purbey authored Feb 17, 2025
1 parent 073f4d8 commit 575900d
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/unlucky-laws-decide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: ensure input elements and elements with `dir` attribute are marked as non-static
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,17 @@ function is_static_element(node, state) {
return false;
}

if (attribute.name === 'dir') {
return false;
}

if (
['input', 'textarea'].includes(node.name) &&
['value', 'checked'].includes(attribute.name)
) {
return false;
}

if (node.name === 'option' && attribute.name === 'value') {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { test } from '../../test';

export default test({
test(assert, target) {
const p = target.querySelector('p');

assert.equal(p?.dir, 'rtl');
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p dir="rtl">text</p>.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { test } from '../../test';

export default test({
test(assert, target) {
const input = target.querySelector('input');

assert.equal(input?.checked, true);
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!--[--><!---->.<input><!--]-->
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.<input checked />

0 comments on commit 575900d

Please sign in to comment.