Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(TS): Image #8443

Merged
merged 27 commits into from
Nov 24, 2022
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 10 additions & 8 deletions src/parser/parseAttributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ import { setStrokeFillOpacity } from './setStrokeFillOpacity';
* @param {Array} attributes Array of attributes to parse
* @return {Object} object containing parsed attributes' names/values
*/
export function parseAttributes(element, attributes, svgUid?: string) {
export function parseAttributes(
element,
attributes,
svgUid?: string
): Record<string, any> {
if (!element) {
return;
return {};
}

let value,
Expand Down Expand Up @@ -65,12 +69,10 @@ export function parseAttributes(element, attributes, svgUid?: string) {
);
}

let normalizedAttr,
normalizedValue,
normalizedStyle = {};
const normalizedStyle = {};
for (const attr in ownAttributes) {
normalizedAttr = normalizeAttr(attr);
normalizedValue = normalizeValue(
const normalizedAttr = normalizeAttr(attr);
const normalizedValue = normalizeValue(
normalizedAttr,
ownAttributes[attr],
parentAttributes,
Expand All @@ -81,7 +83,7 @@ export function parseAttributes(element, attributes, svgUid?: string) {
if (normalizedStyle && normalizedStyle.font) {
parseFontDeclaration(normalizedStyle.font, normalizedStyle);
}
const mergedAttrs = Object.assign(parentAttributes, normalizedStyle);
const mergedAttrs = { ...parentAttributes, ...normalizedStyle };
return svgValidParentsRegEx.test(element.nodeName)
? mergedAttrs
: setStrokeFillOpacity(mergedAttrs);
Expand Down