| Total Complexity | 12 |
| Complexity/F | 6 |
| Lines of Code | 38 |
| Function Count | 2 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | |||
| 2 | import $ from '$'; |
||
| 3 | import {AbstractComponent, componentExportHelper} from 'Component/Abstract'; |
||
| 4 | |||
| 5 | class ScriptComponent extends AbstractComponent |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * @constructor |
||
| 9 | * @param {Object} params |
||
| 10 | */ |
||
| 11 | constructor(params) { |
||
| 12 | |||
| 13 | super(); |
||
| 14 | |||
| 15 | if (params.component && params.component.templateNodes && params.element && |
||
| 16 | params.element[0] && params.element[0].outerHTML) |
||
| 17 | { |
||
| 18 | let script = params.element[0].outerHTML; |
||
| 19 | script = !script ? '' : script |
||
| 20 | .replace(/<x-script/i, '<script') |
||
| 21 | .replace(/<b><\/b><\/x-script>/i, '</script>'); |
||
| 22 | |||
| 23 | if (script) |
||
| 24 | { |
||
| 25 | params.element.text(''); |
||
| 26 | params.element.replaceWith( |
||
| 27 | $(script).text(params.component.templateNodes[0] && |
||
| 28 | params.component.templateNodes[0].nodeValue ? |
||
| 29 | params.component.templateNodes[0].nodeValue : '')); |
||
| 30 | } |
||
| 31 | else |
||
| 32 | { |
||
| 33 | params.element.remove(); |
||
| 34 | } |
||
| 35 | } |
||
| 36 | } |
||
| 37 | } |
||
| 38 | |||
| 39 | module.exports = componentExportHelper(ScriptComponent, 'ScriptComponent'); |
||
| 40 |