|
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 elements in <defs> without id';
|
|---|
| 8 |
|
|---|
| 9 | var nonRendering = require('./_collections').elemsGroups.nonRendering;
|
|---|
| 10 |
|
|---|
| 11 | /**
|
|---|
| 12 | * Removes content of defs and properties that aren't rendered directly without ids.
|
|---|
| 13 | *
|
|---|
| 14 | * @param {Object} item current iteration item
|
|---|
| 15 | * @return {Boolean} if false, item will be filtered out
|
|---|
| 16 | *
|
|---|
| 17 | * @author Lev Solntsev
|
|---|
| 18 | */
|
|---|
| 19 | exports.fn = function(item) {
|
|---|
| 20 |
|
|---|
| 21 | if (item.isElem('defs')) {
|
|---|
| 22 |
|
|---|
| 23 | if (item.content) {
|
|---|
| 24 | item.content = getUsefulItems(item, []);
|
|---|
| 25 | }
|
|---|
| 26 |
|
|---|
| 27 | if (item.isEmpty()) return false;
|
|---|
| 28 |
|
|---|
| 29 | } else if (item.isElem(nonRendering) && !item.hasAttr('id')) {
|
|---|
| 30 |
|
|---|
| 31 | return false;
|
|---|
| 32 |
|
|---|
| 33 | }
|
|---|
| 34 |
|
|---|
| 35 | };
|
|---|
| 36 |
|
|---|
| 37 | function getUsefulItems(item, usefulItems) {
|
|---|
| 38 |
|
|---|
| 39 | item.content.forEach(function(child) {
|
|---|
| 40 | if (child.hasAttr('id') || child.isElem('style')) {
|
|---|
| 41 |
|
|---|
| 42 | usefulItems.push(child);
|
|---|
| 43 | child.parentNode = item;
|
|---|
| 44 |
|
|---|
| 45 | } else if (!child.isEmpty()) {
|
|---|
| 46 |
|
|---|
| 47 | child.content = getUsefulItems(child, usefulItems);
|
|---|
| 48 |
|
|---|
| 49 | }
|
|---|
| 50 | });
|
|---|
| 51 |
|
|---|
| 52 | return usefulItems;
|
|---|
| 53 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.