From f5caeee31c50b868d8d9104fd5e12720b4b77c2d Mon Sep 17 00:00:00 2001 From: Eugene Date: Sun, 25 Aug 2019 16:00:44 -0400 Subject: [PATCH] Fix typing of setSVGAttributes (closes #116) --- README.md | 2 +- src/inline-svg.directive.ts | 2 +- src/svg-util.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 30f27f8..68d0e9d 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ The SVG file (if found) will be inserted *inside* the element with the `[inlineS | prepend | boolean | `false` | Inserts before the first child instead of appending, overwrites `replaceContents` | | replaceContents | boolean | `true` | Replaces the contents of the element with the SVG instead of just appending it to its children. | | injectComponent | boolean | `false` | Injects an `` component containing the SVG inside the element with the directive. | -| setSVGAttributes | `{ string: any }` | | Sets attributes on the SVG element. Runs after `removeSVGAttributes`. | +| setSVGAttributes | `{ [key: string]: any }` | | Sets attributes on the SVG element. Runs after `removeSVGAttributes`. | | removeSVGAttributes | string[] | | An array of attribute names to remove from all child elements within the SVG. | | forceEvalStyles | boolean | `false` | Forces embeded style tags' contents to be evaluated (for IE 11). | | evalScripts | `'always'`, `'once'`, `'none'` | `'always'` | Whether to evaluate embedded scripts in the loaded SVG files. The `SVGScriptEvalMode` enum is also provided. | diff --git a/src/inline-svg.directive.ts b/src/inline-svg.directive.ts index 8e3f9ba..bcd953e 100644 --- a/src/inline-svg.directive.ts +++ b/src/inline-svg.directive.ts @@ -35,7 +35,7 @@ export class InlineSVGDirective implements OnInit, OnChanges, OnDestroy { @Input() prepend: boolean = false; @Input() injectComponent: boolean = false; @Input() cacheSVG: boolean = true; - @Input() setSVGAttributes: { string: any }; + @Input() setSVGAttributes: { [key: string]: any }; @Input() removeSVGAttributes: Array; @Input() forceEvalStyles: boolean = false; @Input() evalScripts: SVGScriptEvalMode = SVGScriptEvalMode.ALWAYS; diff --git a/src/svg-util.ts b/src/svg-util.ts index d3adfd7..6d79dec 100644 --- a/src/svg-util.ts +++ b/src/svg-util.ts @@ -67,7 +67,7 @@ export function removeAttributes(element: Element, attrs: Array): void { * @param element Element to set attributes on. * @param attrs Attribute key/values. */ -export function setAttributes(element: Element, attrs: { string: any }): void { +export function setAttributes(element: Element, attrs: { [key: string]: any }): void { for (const attr in attrs) { element.setAttribute(attr, attrs[attr]); }