UNPKG

fabric

Version:

Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.

23 lines (21 loc) 588 B
// TODO this file needs to go away, cross browser style support is not fabricjs domain. /** * wrapper for setting element's style * @param {HTMLElement} element * @param {Object | string} styles */ export function setStyle( element: HTMLElement, styles: string | Record<string, string> ) { const elementStyle = element.style; if (!elementStyle) { return; } else if (typeof styles === 'string') { element.style.cssText += ';' + styles; } else { Object.entries(styles).forEach(([property, value]) => elementStyle.setProperty(property, value) ); } }