Last change
on this file since 1ad8e64 was e29cc2e, checked in by Ema <ema_spirova@…>, 3 years ago |
primeNG components
|
-
Property mode
set to
100644
|
File size:
777 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | const { attrsGroups } = require('./_collections.js');
|
---|
4 |
|
---|
5 | exports.type = 'visitor';
|
---|
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
|
---|
14 | *
|
---|
15 | * @type {import('../lib/types').Plugin<void>}
|
---|
16 | */
|
---|
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 | };
|
---|
33 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.