style.js — svelte Source File
Architecture documentation for style.js, a javascript file in the svelte codebase. 3 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR e6776a33_ae8b_fb40_7de7_0a08f609b2db["style.js"] 22eadd41_615a_90cd_7963_26c9a3fc58cb["attributes.js"] e6776a33_ae8b_fb40_7de7_0a08f609b2db --> 22eadd41_615a_90cd_7963_26c9a3fc58cb 82b89a82_43eb_55e9_a708_1e7df64f688c["to_style"] e6776a33_ae8b_fb40_7de7_0a08f609b2db --> 82b89a82_43eb_55e9_a708_1e7df64f688c f3948b0d_b92a_0767_ba6c_832767f4e2bb["hydration.js"] e6776a33_ae8b_fb40_7de7_0a08f609b2db --> f3948b0d_b92a_0767_ba6c_832767f4e2bb 0acd2537_e1bf_d7ae_30d5_407378cfa4d3["attributes.js"] 0acd2537_e1bf_d7ae_30d5_407378cfa4d3 --> e6776a33_ae8b_fb40_7de7_0a08f609b2db style e6776a33_ae8b_fb40_7de7_0a08f609b2db fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { to_style } from '../../../shared/attributes.js';
import { hydrating } from '../hydration.js';
/**
* @param {Element & ElementCSSInlineStyle} dom
* @param {Record<string, any>} prev
* @param {Record<string, any>} next
* @param {string} [priority]
*/
function update_styles(dom, prev = {}, next, priority) {
for (var key in next) {
var value = next[key];
if (prev[key] !== value) {
if (next[key] == null) {
dom.style.removeProperty(key);
} else {
dom.style.setProperty(key, value, priority);
}
}
}
}
/**
* @param {Element & ElementCSSInlineStyle} dom
* @param {string | null} value
* @param {Record<string, any> | [Record<string, any>, Record<string, any>]} [prev_styles]
* @param {Record<string, any> | [Record<string, any>, Record<string, any>]} [next_styles]
*/
export function set_style(dom, value, prev_styles, next_styles) {
// @ts-expect-error
var prev = dom.__style;
if (hydrating || prev !== value) {
var next_style_attr = to_style(value, next_styles);
if (!hydrating || next_style_attr !== dom.getAttribute('style')) {
if (next_style_attr == null) {
dom.removeAttribute('style');
} else {
dom.style.cssText = next_style_attr;
}
}
// @ts-expect-error
dom.__style = value;
} else if (next_styles) {
if (Array.isArray(next_styles)) {
update_styles(dom, prev_styles?.[0], next_styles[0]);
update_styles(dom, prev_styles?.[1], next_styles[1], 'important');
} else {
update_styles(dom, prev_styles, next_styles);
}
}
return next_styles;
}
Domain
Subdomains
Functions
Dependencies
Source
Frequently Asked Questions
What does style.js do?
style.js is a source file in the svelte codebase, written in javascript. It belongs to the ClientRuntime domain, Hydration subdomain.
What functions are defined in style.js?
style.js defines 2 function(s): set_style, update_styles.
What does style.js depend on?
style.js imports 3 module(s): attributes.js, hydration.js, to_style.
What files import style.js?
style.js is imported by 1 file(s): attributes.js.
Where is style.js in the architecture?
style.js is located at packages/svelte/src/internal/client/dom/elements/style.js (domain: ClientRuntime, subdomain: Hydration, directory: packages/svelte/src/internal/client/dom/elements).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free