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