(elm: HTMLElement)
| 28 | }; |
| 29 | |
| 30 | export const isValid = (elm: HTMLElement) => { |
| 31 | if (elm.nodeType === 1) { |
| 32 | if (elm.nodeName.toLowerCase() === 'script') { |
| 33 | return false; |
| 34 | } |
| 35 | |
| 36 | for (let i = 0; i < elm.attributes.length; i++) { |
| 37 | const name = elm.attributes[i].name; |
| 38 | if (isStr(name) && name.toLowerCase().indexOf('on') === 0) { |
| 39 | return false; |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | for (let i = 0; i < elm.childNodes.length; i++) { |
| 44 | if (!isValid(elm.childNodes[i] as any)) { |
| 45 | return false; |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | return true; |
| 50 | }; |
| 51 | |
| 52 | export const isSvgDataUrl = (url: string) => url.startsWith('data:image/svg+xml'); |
| 53 | export const isEncodedDataUrl = (url: string) => url.indexOf(';utf8,') !== -1; |
no test coverage detected
searching dependent graphs…