Skip to content

Commit 7599df0

Browse files
committed
drive-by improvements — remove some unnecessary arguments where possible
1 parent 906eb94 commit 7599df0

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

packages/svelte/src/compiler/phases/3-transform/client/visitors/RegularElement.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -470,10 +470,8 @@ function build_element_spread_attributes(
470470
attribute.type === 'SpreadAttribute' && attribute.metadata.expression.has_call;
471471
}
472472

473-
const lowercase_attributes =
474-
element.metadata.svg || element.metadata.mathml || is_custom_element_node(element)
475-
? b.false
476-
: b.true;
473+
const preserve_attribute_case =
474+
element.metadata.svg || element.metadata.mathml || is_custom_element_node(element);
477475
const id = context.state.scope.generate('attributes');
478476

479477
const update = b.stmt(
@@ -485,8 +483,8 @@ function build_element_spread_attributes(
485483
element_id,
486484
b.id(id),
487485
b.object(values),
488-
lowercase_attributes,
489486
context.state.analysis.css.hash !== '' && b.literal(context.state.analysis.css.hash),
487+
preserve_attribute_case && b.true,
490488
is_ignored(element, 'hydration_attribute_changed') && b.true
491489
)
492490
)

packages/svelte/src/internal/client/dom/elements/attributes.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,19 @@ export function set_custom_element_data(node, prop, value) {
147147
* @param {Element & ElementCSSInlineStyle} element
148148
* @param {Record<string, any> | undefined} prev
149149
* @param {Record<string, any>} next New attributes - this function mutates this object
150-
* @param {boolean} lowercase_attributes
151150
* @param {string} [css_hash]
151+
* @param {boolean} preserve_attribute_case
152152
* @param {boolean} [skip_warning]
153153
* @returns {Record<string, any>}
154154
*/
155-
export function set_attributes(element, prev, next, lowercase_attributes, css_hash, skip_warning) {
155+
export function set_attributes(
156+
element,
157+
prev,
158+
next,
159+
css_hash,
160+
preserve_attribute_case = false,
161+
skip_warning
162+
) {
156163
var current = prev || {};
157164
var is_option_element = element.tagName === 'OPTION';
158165

@@ -266,7 +273,7 @@ export function set_attributes(element, prev, next, lowercase_attributes, css_ha
266273
element.value = element[key] = element.__value = value;
267274
} else {
268275
var name = key;
269-
if (lowercase_attributes) {
276+
if (!preserve_attribute_case) {
270277
name = normalize_attribute(name);
271278
}
272279

@@ -328,8 +335,8 @@ export function set_dynamic_element_attributes(node, prev, next, css_hash) {
328335
/** @type {Element & ElementCSSInlineStyle} */ (node),
329336
prev,
330337
next,
331-
node.namespaceURI !== NAMESPACE_SVG,
332-
css_hash
338+
css_hash,
339+
node.namespaceURI !== NAMESPACE_SVG
333340
);
334341
}
335342

0 commit comments

Comments
 (0)