fix: allow boolean `contenteditable` attribute (#10590)

fixes #10559
pull/10592/head
Simon H 10 months ago committed by GitHub
parent 58008479fc
commit 66b624491e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
"svelte": patch
---
fix: allow boolean `contenteditable` attribute

@ -371,10 +371,6 @@ const errors = {
// message:
// "'contenteditable' attribute is required for textContent, innerHTML and innerText two-way bindings"
// },
// dynamic_contenteditable_attribute: {
// code: 'dynamic-contenteditable-attribute',
// message: "'contenteditable' attribute cannot be dynamic if element uses two-way binding"
// },
// textarea_duplicate_value: {
// code: 'textarea-duplicate-value',
// message:

@ -475,7 +475,7 @@ const validation = {
);
if (!contenteditable) {
error(node, 'missing-contenteditable-attribute');
} else if (!is_text_attribute(contenteditable)) {
} else if (!is_text_attribute(contenteditable) && contenteditable.value !== true) {
error(contenteditable, 'dynamic-contenteditable-attribute');
}
}

@ -3,11 +3,11 @@
"code": "dynamic-contenteditable-attribute",
"message": "'contenteditable' attribute cannot be dynamic if element uses two-way binding",
"start": {
"line": 6,
"line": 11,
"column": 8
},
"end": {
"line": 6,
"line": 11,
"column": 32
}
}

@ -3,4 +3,9 @@
let toggle = false;
</script>
<!-- ok -->
<editor contenteditable="true" bind:innerHTML={name}></editor>
<editor contenteditable="" bind:innerHTML={name}></editor>
<editor contenteditable bind:innerHTML={name}></editor>
<!-- error -->
<editor contenteditable={toggle} bind:innerHTML={name}></editor>

Loading…
Cancel
Save