fix: correctly applies autofocus to static elements

pull/13648/head
Dominic Gannaway 2 years ago
parent bb245445fc
commit 3b0215239c

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: correctly applies autofocus to static elements

@ -142,6 +142,10 @@ function is_static_element(node) {
return false;
}
if (attribute.name === 'autofocus') {
return false;
}
if (node.name === 'option' && attribute.name === 'value') {
return false;
}

@ -0,0 +1,10 @@
import { test } from '../../test';
export default test({
async test({ assert, target, window }) {
assert.equal(
target.querySelector('input'),
window.document.activeElement
);
}
});

@ -0,0 +1,6 @@
<h1>wat</h1>
<input autofocus />
<div>
<input autofocus />
</div>
Loading…
Cancel
Save