mirror of
https://github.com/svg/svgo.git
synced 2025-07-29 20:21:14 +03:00
add removeScriptElement plugin
This commit is contained in:
@ -57,6 +57,7 @@ plugins:
|
|||||||
- removeElementsByAttr
|
- removeElementsByAttr
|
||||||
- addClassesToSVGElement
|
- addClassesToSVGElement
|
||||||
- removeStyleElement
|
- removeStyleElement
|
||||||
|
- removeScriptElement
|
||||||
- addAttributesToSVGElement
|
- addAttributesToSVGElement
|
||||||
|
|
||||||
# configure the indent (default 4 spaces) used by `--pretty` here:
|
# configure the indent (default 4 spaces) used by `--pretty` here:
|
||||||
|
@ -62,6 +62,7 @@ Today we have:
|
|||||||
| [addClassesToSVGElement](https://github.com/svg/svgo/blob/master/plugins/addClassesToSVGElement.js) | add classnames to an outer `<svg>` element (disabled by default) |
|
| [addClassesToSVGElement](https://github.com/svg/svgo/blob/master/plugins/addClassesToSVGElement.js) | add classnames to an outer `<svg>` element (disabled by default) |
|
||||||
| [addAttributesToSVGElement](https://github.com/svg/svgo/blob/master/plugins/addAttributesToSVGElement.js) | adds attributes to an outer `<svg>` element (disabled by default) |
|
| [addAttributesToSVGElement](https://github.com/svg/svgo/blob/master/plugins/addAttributesToSVGElement.js) | adds attributes to an outer `<svg>` element (disabled by default) |
|
||||||
| [removeStyleElement](https://github.com/svg/svgo/blob/master/plugins/removeStyleElement.js) | remove `<style>` elements (disabled by default) |
|
| [removeStyleElement](https://github.com/svg/svgo/blob/master/plugins/removeStyleElement.js) | remove `<style>` elements (disabled by default) |
|
||||||
|
| [removeScriptElement](https://github.com/svg/svgo/blob/master/plugins/removeScriptElement.js) | remove `<script>` elements (disabled by default) |
|
||||||
|
|
||||||
Want to know how it works and how to write your own plugin? [Of course you want to](https://github.com/svg/svgo/blob/master/docs/how-it-works/en.md). ([동작방법](https://github.com/svg/svgo/blob/master/docs/how-it-works/ko.md))
|
Want to know how it works and how to write your own plugin? [Of course you want to](https://github.com/svg/svgo/blob/master/docs/how-it-works/en.md). ([동작방법](https://github.com/svg/svgo/blob/master/docs/how-it-works/ko.md))
|
||||||
|
|
||||||
|
@ -62,6 +62,7 @@ SVGO имеет расширяемую архитектуру, в которой
|
|||||||
| [addClassesToSVGElement](https://github.com/svg/svgo/blob/master/plugins/addClassesToSVGElement.js) | добавляет имена классов корневому элементу `<svg>` (выключено по умолчанию) |
|
| [addClassesToSVGElement](https://github.com/svg/svgo/blob/master/plugins/addClassesToSVGElement.js) | добавляет имена классов корневому элементу `<svg>` (выключено по умолчанию) |
|
||||||
| [addAttributesToSVGElement](https://github.com/svg/svgo/blob/master/plugins/addAttributesToSVGElement.js) | добавляет атрибуты корневому элементу `<svg>` (выключено |по умолчанию)
|
| [addAttributesToSVGElement](https://github.com/svg/svgo/blob/master/plugins/addAttributesToSVGElement.js) | добавляет атрибуты корневому элементу `<svg>` (выключено |по умолчанию)
|
||||||
| [removeStyleElement](https://github.com/svg/svgo/blob/master/plugins/removeStyleElement.js) | удаляет элементы `<style>` (выключено по умолчанию) |
|
| [removeStyleElement](https://github.com/svg/svgo/blob/master/plugins/removeStyleElement.js) | удаляет элементы `<style>` (выключено по умолчанию) |
|
||||||
|
| [removeScriptElement](https://github.com/svg/svgo/blob/master/plugins/removeScriptElement.js) | удаляет элементы `<script>` (выключено по умолчанию) |
|
||||||
|
|
||||||
Хотите узнать, как это работает и как написать свой плагин? [Конечно же, да!](https://github.com/svg/svgo/blob/master/docs/how-it-works/ru.md).
|
Хотите узнать, как это работает и как написать свой плагин? [Конечно же, да!](https://github.com/svg/svgo/blob/master/docs/how-it-works/ru.md).
|
||||||
|
|
||||||
|
23
plugins/removeScriptElement.js
Normal file
23
plugins/removeScriptElement.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
exports.type = 'perItem';
|
||||||
|
|
||||||
|
exports.active = false;
|
||||||
|
|
||||||
|
exports.description = 'removes <script> elements (disabled by default)';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove <script>.
|
||||||
|
*
|
||||||
|
* https://www.w3.org/TR/SVG/script.html
|
||||||
|
*
|
||||||
|
* @param {Object} item current iteration item
|
||||||
|
* @return {Boolean} if false, item will be filtered out
|
||||||
|
*
|
||||||
|
* @author Patrick Klingemann
|
||||||
|
*/
|
||||||
|
exports.fn = function(item) {
|
||||||
|
|
||||||
|
return !item.isElem('script');
|
||||||
|
|
||||||
|
};
|
12
test/plugins/removeScriptElement.01.svg
Normal file
12
test/plugins/removeScriptElement.01.svg
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-16"?>
|
||||||
|
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 100 100" style="enable-background:new 0 0 100 100;" xml:space="preserve">
|
||||||
|
<script></script>
|
||||||
|
<circle class="st0" cx="50" cy="50" r="50" />
|
||||||
|
</svg>
|
||||||
|
|
||||||
|
@@@
|
||||||
|
|
||||||
|
<?xml version="1.0" encoding="utf-16"?>
|
||||||
|
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 100 100" style="enable-background:new 0 0 100 100;" xml:space="preserve">
|
||||||
|
<circle class="st0" cx="50" cy="50" r="50"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 663 B |
Reference in New Issue
Block a user