Last change
on this file since eed0bf8 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
776 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | 'use strict';
|
---|
| 2 |
|
---|
| 3 | const { attrsGroups } = require('./_collections.js');
|
---|
| 4 |
|
---|
| 5 | exports.name = 'removeEmptyAttrs';
|
---|
| 6 |
|
---|
| 7 | exports.type = 'perItem';
|
---|
| 8 |
|
---|
| 9 | exports.active = true;
|
---|
| 10 |
|
---|
| 11 | exports.description = 'removes empty attributes';
|
---|
| 12 |
|
---|
| 13 | /**
|
---|
| 14 | * Remove attributes with empty values.
|
---|
| 15 | *
|
---|
| 16 | * @param {Object} item current iteration item
|
---|
| 17 | * @return {Boolean} if false, item will be filtered out
|
---|
| 18 | *
|
---|
| 19 | * @author Kir Belevich
|
---|
| 20 | */
|
---|
| 21 | exports.fn = function (item) {
|
---|
| 22 | if (item.type === 'element') {
|
---|
| 23 | for (const [name, value] of Object.entries(item.attributes)) {
|
---|
| 24 | if (
|
---|
| 25 | value === '' &&
|
---|
| 26 | // empty conditional processing attributes prevents elements from rendering
|
---|
| 27 | attrsGroups.conditionalProcessing.includes(name) === false
|
---|
| 28 | ) {
|
---|
| 29 | delete item.attributes[name];
|
---|
| 30 | }
|
---|
| 31 | }
|
---|
| 32 | }
|
---|
| 33 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.