* Deep interpolate an object, replacing all string placeholders with context values.
(props: FancyErrorProps, context: ErrorContext)
| 99 | * Deep interpolate an object, replacing all string placeholders with context values. |
| 100 | */ |
| 101 | private static interpolateProps (props: FancyErrorProps, context: ErrorContext): FancyErrorProps { |
| 102 | const result: FancyErrorProps = {}; |
| 103 | |
| 104 | for (const key of Object.keys(props)) { |
| 105 | const value = props[key]; |
| 106 | |
| 107 | if (typeof value === 'string') { |
| 108 | result[key] = FancyError.interpolate(value, context); |
| 109 | } else if (Array.isArray(value)) { |
| 110 | result[key] = value.map(item => |
| 111 | typeof item === 'string' ? FancyError.interpolate(item, context) : item |
| 112 | ); |
| 113 | } else if (typeof value === 'object' && value !== null && !(value instanceof NodeList)) { |
| 114 | result[key] = FancyError.interpolateProps(value as FancyErrorProps, context); |
| 115 | } else { |
| 116 | result[key] = value; |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | return result; |
| 121 | } |
| 122 | |
| 123 | static pop (): void { |
| 124 | if (FancyError.isDevEnvironment() && typeof Prism !== 'undefined') { |
no test coverage detected