Skip to content

Commit f96d244

Browse files
committed
lint, simplify
1 parent c1cf712 commit f96d244

File tree

1 file changed

+11
-22
lines changed
  • packages/svelte/src/internal/server

1 file changed

+11
-22
lines changed

packages/svelte/src/internal/server/index.js

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -264,32 +264,21 @@ export function add_styles(style_object) {
264264
}
265265

266266
/**
267-
* @param {string} style_attribute
268-
* @param {Record<string, string>} style_directive
267+
* @param {string} attribute
268+
* @param {Record<string, string>} styles
269269
*/
270-
export function merge_styles(style_attribute, style_directive) {
271-
/** @type {Record<string, string>} */
272-
var merged = {};
273-
274-
if (style_attribute) {
275-
for (var individual_style of style_attribute.split(';')) {
276-
var colon_index = individual_style.indexOf(':');
277-
var name = individual_style.slice(0, colon_index).trim();
278-
var value = individual_style.slice(colon_index + 1).trim();
279-
if (name) merged[name] = value;
270+
export function merge_styles(attribute, styles) {
271+
if (attribute) {
272+
for (var declaration of attribute.split(';')) {
273+
var i = declaration.indexOf(':');
274+
var name = declaration.slice(0, i).trim();
275+
var value = declaration.slice(i + 1).trim();
276+
277+
if (name !== '' && !(name in styles)) styles[name] = value;
280278
}
281279
}
282280

283-
for (name in style_directive) {
284-
value = style_directive[name];
285-
if (value) {
286-
merged[name] = value;
287-
} else {
288-
delete merged[name];
289-
}
290-
}
291-
292-
return merged;
281+
return styles;
293282
}
294283

295284
/**

0 commit comments

Comments
 (0)