|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.1 KB
|
| Line | |
|---|
| 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | exports.type = 'perItem';
|
|---|
| 4 |
|
|---|
| 5 | exports.active = true;
|
|---|
| 6 |
|
|---|
| 7 | exports.description = 'removes empty <text> elements';
|
|---|
| 8 |
|
|---|
| 9 | exports.params = {
|
|---|
| 10 | text: true,
|
|---|
| 11 | tspan: true,
|
|---|
| 12 | tref: true
|
|---|
| 13 | };
|
|---|
| 14 |
|
|---|
| 15 | /**
|
|---|
| 16 | * Remove empty Text elements.
|
|---|
| 17 | *
|
|---|
| 18 | * @see http://www.w3.org/TR/SVG/text.html
|
|---|
| 19 | *
|
|---|
| 20 | * @example
|
|---|
| 21 | * Remove empty text element:
|
|---|
| 22 | * <text/>
|
|---|
| 23 | *
|
|---|
| 24 | * Remove empty tspan element:
|
|---|
| 25 | * <tspan/>
|
|---|
| 26 | *
|
|---|
| 27 | * Remove tref with empty xlink:href attribute:
|
|---|
| 28 | * <tref xlink:href=""/>
|
|---|
| 29 | *
|
|---|
| 30 | * @param {Object} item current iteration item
|
|---|
| 31 | * @param {Object} params plugin params
|
|---|
| 32 | * @return {Boolean} if false, item will be filtered out
|
|---|
| 33 | *
|
|---|
| 34 | * @author Kir Belevich
|
|---|
| 35 | */
|
|---|
| 36 | exports.fn = function(item, params) {
|
|---|
| 37 |
|
|---|
| 38 | // Remove empty text element
|
|---|
| 39 | if (
|
|---|
| 40 | params.text &&
|
|---|
| 41 | item.isElem('text') &&
|
|---|
| 42 | item.isEmpty()
|
|---|
| 43 | ) return false;
|
|---|
| 44 |
|
|---|
| 45 | // Remove empty tspan element
|
|---|
| 46 | if (
|
|---|
| 47 | params.tspan &&
|
|---|
| 48 | item.isElem('tspan') &&
|
|---|
| 49 | item.isEmpty()
|
|---|
| 50 | ) return false;
|
|---|
| 51 |
|
|---|
| 52 | // Remove tref with empty xlink:href attribute
|
|---|
| 53 | if (
|
|---|
| 54 | params.tref &&
|
|---|
| 55 | item.isElem('tref') &&
|
|---|
| 56 | !item.hasAttrLocal('href')
|
|---|
| 57 | ) return false;
|
|---|
| 58 |
|
|---|
| 59 | };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.