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: // message:
// "'contenteditable' attribute is required for textContent, innerHTML and innerText two-way bindings" // "'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: { // textarea_duplicate_value: {
// code: 'textarea-duplicate-value', // code: 'textarea-duplicate-value',
// message: // message:

@ -475,7 +475,7 @@ const validation = {
); );
if (!contenteditable) { if (!contenteditable) {
error(node, 'missing-contenteditable-attribute'); 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'); error(contenteditable, 'dynamic-contenteditable-attribute');
} }
} }

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

@ -3,4 +3,9 @@
let toggle = false; let toggle = false;
</script> </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> <editor contenteditable={toggle} bind:innerHTML={name}></editor>

Loading…
Cancel
Save