posthtml-component 1.0.0-beta.12 → 1.0.0-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.js +2 -0
- package/src/process-attributes.js +8 -0
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -10,6 +10,7 @@ const processProps = require('./process-props');
|
|
|
10
10
|
const processAttributes = require('./process-attributes');
|
|
11
11
|
const {processPushes, processStacks} = require('./process-stacks');
|
|
12
12
|
const {setFilledSlots, processSlotContent, processFillContent} = require('./process-slots');
|
|
13
|
+
const each = require('lodash/each');
|
|
13
14
|
const defaults = require('lodash/defaults');
|
|
14
15
|
const assignWith = require('lodash/assignWith');
|
|
15
16
|
const mergeWith = require('lodash/mergeWith');
|
|
@@ -57,6 +58,7 @@ module.exports = (options = {}) => tree => {
|
|
|
57
58
|
options.attrsParserRules = options.attrsParserRules || {};
|
|
58
59
|
options.strict = typeof options.strict === 'undefined' ? true : options.strict;
|
|
59
60
|
options.utilities = options.utilities || {
|
|
61
|
+
each,
|
|
60
62
|
defaults,
|
|
61
63
|
assign: assignWith,
|
|
62
64
|
merge: mergeWith,
|
|
@@ -60,5 +60,13 @@ module.exports = (currentNode, attributes, props, options) => {
|
|
|
60
60
|
delete attributes[key];
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
+
// Remove an attribute if value is 'null' or 'undefined'
|
|
64
|
+
// so we can conditionally add an attribute
|
|
65
|
+
each(nodeAttrs, (value, key) => {
|
|
66
|
+
if (['undefined', 'null'].includes(value)) {
|
|
67
|
+
delete nodeAttrs[key];
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
|
|
63
71
|
mainNode.attrs = nodeAttrs.compose();
|
|
64
72
|
};
|