mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-06-29 07:16:07 +00:00
ES2015 first look / babeljs
This commit is contained in:
39
dev/Component/Script.jsx
Normal file
39
dev/Component/Script.jsx
Normal file
@@ -0,0 +1,39 @@
|
||||
|
||||
import {$} from 'common';
|
||||
import {AbstractComponent, componentExportHelper} from 'Component/Abstract';
|
||||
|
||||
class ScriptComponent extends AbstractComponent
|
||||
{
|
||||
/**
|
||||
* @param {Object} params
|
||||
*/
|
||||
constructor(params) {
|
||||
|
||||
super();
|
||||
|
||||
if (params.component && params.component.templateNodes && params.element &&
|
||||
params.element[0] && params.element[0].outerHTML)
|
||||
{
|
||||
let script = params.element[0].outerHTML;
|
||||
script = script
|
||||
.replace(/<x-script/i, '<script')
|
||||
.replace(/<b><\/b><\/x-script>/i, '</script>')
|
||||
;
|
||||
|
||||
if (script)
|
||||
{
|
||||
params.element.text('');
|
||||
params.element.replaceWith(
|
||||
$(script).text(params.component.templateNodes[0] &&
|
||||
params.component.templateNodes[0].nodeValue ?
|
||||
params.component.templateNodes[0].nodeValue : ''));
|
||||
}
|
||||
else
|
||||
{
|
||||
params.element.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = componentExportHelper(ScriptComponent, 'ScriptComponent');
|
||||
Reference in New Issue
Block a user