UNPKG

fabric

Version:

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

1 lines 1.4 kB
{"version":3,"file":"parseStyleAttribute.mjs","sources":["../../../src/parser/parseStyleAttribute.ts"],"sourcesContent":["import { parseStyleObject } from './parseStyleObject';\nimport { parseStyleString } from './parseStyleString';\n\n/**\n * Parses \"style\" attribute, retuning an object with values\n * @static\n * @memberOf fabric\n * @param {SVGElement} element Element to parse\n * @return {Object} Objects with values parsed from style attribute of an element\n */\nexport function parseStyleAttribute(element: HTMLElement): Record<string, any> {\n const oStyle: Record<string, any> = {},\n style = element.getAttribute('style');\n\n if (!style) {\n return oStyle;\n }\n\n if (typeof style === 'string') {\n parseStyleString(style, oStyle);\n } else {\n parseStyleObject(style, oStyle);\n }\n\n return oStyle;\n}\n"],"names":["parseStyleAttribute","element","oStyle","style","getAttribute","parseStyleString","parseStyleObject"],"mappings":";;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,mBAAmBA,CAACC,OAAoB,EAAuB;EAC7E,MAAMC,MAA2B,GAAG,EAAE;AACpCC,IAAAA,KAAK,GAAGF,OAAO,CAACG,YAAY,CAAC,OAAO,CAAC,CAAA;EAEvC,IAAI,CAACD,KAAK,EAAE;AACV,IAAA,OAAOD,MAAM,CAAA;AACf,GAAA;AAEA,EAAA,IAAI,OAAOC,KAAK,KAAK,QAAQ,EAAE;AAC7BE,IAAAA,gBAAgB,CAACF,KAAK,EAAED,MAAM,CAAC,CAAA;AACjC,GAAC,MAAM;AACLI,IAAAA,gBAAgB,CAACH,KAAK,EAAED,MAAM,CAAC,CAAA;AACjC,GAAA;AAEA,EAAA,OAAOA,MAAM,CAAA;AACf;;;;"}