-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Closed
Description
Describe the bug
Not really a bug, but some stuff I noticed while reading the code and testing with REPL with set_attributes().
This function accept 3 optionnals booleans :
/**
* ...
* @param {boolean} [preserve_attribute_case]
* @param {boolean} [is_custom_element]
* @param {boolean} [skip_warning]
*/But I think that the generated code is inconsistent between nodes and <svelte:element> :
| tag | preserve_attribute_case | is_custom_element | skip_warning |
| <div> | |||
| <custom-elem> | true | true | |
| <svg> | true | ||
| <math> | true | ||
| <svelte:element> | $$element.namespaceURI === $.NAMESPACE_SVG | $$element.nodeName.includes('-') |
So :
preserve_attribute_caseis inconsistent between regular and<svelte:element>nodes.
On regular node it's true for custom-elements, SVG and MathML nodes.
On<svelte:element>it's only true for SVG nodes.skip_warningis never passed, and it's even never used inside the function.
I was also unable to generate any code that used it onset_attribute()(without 's'), even in DEV mode.
Either it is useless and can be deleted, or this needs to be corrected.- Also I think that
preserve_attribute_case/is_custom_element(and perhapsskip_warningif it's needed) can be replaced by a single flag insideset_attributes().
Something like that :
// flag is a number :
// * 0 : svelte-element
// * 1 : HTML nodes
// * 2 : Custom Element
// * 3 : SVG
// * 4 : MathML
//
let is_custom_element = flag === 2 || (flag === 0 && element.nodeName.includes('-'));
let preserve_attribute_case = flag > 1 || is_custom_element || (flag === 0 && element.namespaceURI !== NAMESPACE_HTML)Reproduction
Exemple in REPL (see generated code)
Logs
-System Info
REPLSeverity
annoyance
Metadata
Metadata
Assignees
Labels
No labels