MCPcopy
hub / github.com/QwikDev/qwik / stringifyStyle

Function stringifyStyle

packages/qwik/src/core/render/execute-component.ts:177–202  ·  view source on GitHub ↗
(obj: any)

Source from the content-addressed store, hash-verified

175};
176
177export const stringifyStyle = (obj: any): string => {
178 if (obj == null) {
179 return '';
180 }
181 if (typeof obj == 'object') {
182 if (isArray(obj)) {
183 throw qError(QError_stringifyClassOrStyle, obj, 'style');
184 } else {
185 const chunks: string[] = [];
186 for (const key in obj) {
187 if (Object.prototype.hasOwnProperty.call(obj, key)) {
188 const value = obj[key];
189 if (value != null && typeof value !== 'function') {
190 if (key.startsWith('--')) {
191 chunks.push(key + ':' + value);
192 } else {
193 chunks.push(fromCamelToKebabCase(key) + ':' + setValueForStyle(key, value));
194 }
195 }
196 }
197 }
198 return chunks.join(';');
199 }
200 }
201 return String(obj);
202};
203
204export const setValueForStyle = (styleName: string, value: any) => {
205 if (typeof value === 'number' && value !== 0 && !isUnitlessNumber(styleName)) {

Callers 5

diffVnodeFunction · 0.90
setPropertiesFunction · 0.90
executeSignalOperationFunction · 0.90
handlePropFunction · 0.90

Calls 5

isArrayFunction · 0.90
qErrorFunction · 0.90
fromCamelToKebabCaseFunction · 0.90
setValueForStyleFunction · 0.85
joinMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…