posthtml-component 1.0.0-beta.13 → 1.0.0-beta.15
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 +10 -14
- package/src/process-attributes.js +4 -0
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -120,7 +120,6 @@ module.exports = (options = {}) => tree => {
|
|
|
120
120
|
});
|
|
121
121
|
|
|
122
122
|
options.props = {...options.expressions.locals};
|
|
123
|
-
options.aware = {};
|
|
124
123
|
|
|
125
124
|
const pushedContent = {};
|
|
126
125
|
|
|
@@ -142,11 +141,11 @@ module.exports = (options = {}) => tree => {
|
|
|
142
141
|
* @param {Object} options Plugin options
|
|
143
142
|
* @return {Object} PostHTML tree
|
|
144
143
|
*/
|
|
144
|
+
let processCounter = 0;
|
|
145
|
+
|
|
145
146
|
function processTree(options) {
|
|
146
147
|
const filledSlots = {};
|
|
147
148
|
|
|
148
|
-
// let processCounter = 0;
|
|
149
|
-
|
|
150
149
|
return function (tree) {
|
|
151
150
|
if (options.plugins.length > 0) {
|
|
152
151
|
tree = applyPluginsToTree(tree, options.plugins);
|
|
@@ -163,7 +162,7 @@ function processTree(options) {
|
|
|
163
162
|
return currentNode;
|
|
164
163
|
}
|
|
165
164
|
|
|
166
|
-
|
|
165
|
+
console.log(`${++processCounter}) Processing "${currentNode.tag}" component from "${componentPath}"`);
|
|
167
166
|
|
|
168
167
|
// log(currentNode, 'currentNode');
|
|
169
168
|
|
|
@@ -171,7 +170,11 @@ function processTree(options) {
|
|
|
171
170
|
|
|
172
171
|
// Set filled slots
|
|
173
172
|
setFilledSlots(currentNode, filledSlots, options);
|
|
174
|
-
|
|
173
|
+
|
|
174
|
+
// Reset options.aware when new nested start
|
|
175
|
+
if (processCounter === 1) {
|
|
176
|
+
options.aware = {};
|
|
177
|
+
}
|
|
175
178
|
|
|
176
179
|
// Reset options.expressions.locals and keep aware locals
|
|
177
180
|
options.expressions.locals = {...options.props, ...options.aware};
|
|
@@ -207,15 +210,8 @@ function processTree(options) {
|
|
|
207
210
|
|
|
208
211
|
processAttributes(currentNode, attributes, props, options);
|
|
209
212
|
|
|
210
|
-
//
|
|
211
|
-
|
|
212
|
-
// currentNode.attrs.data = JSON.stringify({ attributes, props });
|
|
213
|
-
|
|
214
|
-
// messages.push({
|
|
215
|
-
// type: 'dependency',
|
|
216
|
-
// file: componentPath,
|
|
217
|
-
// from: options.root
|
|
218
|
-
// });
|
|
213
|
+
// Reset counter
|
|
214
|
+
processCounter = 0;
|
|
219
215
|
|
|
220
216
|
return currentNode;
|
|
221
217
|
});
|
|
@@ -9,6 +9,8 @@ const union = require('lodash/union');
|
|
|
9
9
|
const each = require('lodash/each');
|
|
10
10
|
const has = require('lodash/has');
|
|
11
11
|
const extend = require('lodash/extend');
|
|
12
|
+
const isString = require('lodash/isString');
|
|
13
|
+
const isObject = require('lodash/isObject');
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* Map component attributes that it's not defined as props to first element of node
|
|
@@ -65,6 +67,8 @@ module.exports = (currentNode, attributes, props, options) => {
|
|
|
65
67
|
each(nodeAttrs, (value, key) => {
|
|
66
68
|
if (['undefined', 'null'].includes(value)) {
|
|
67
69
|
delete nodeAttrs[key];
|
|
70
|
+
} else if (key !== 'compose' && !isObject(nodeAttrs[key]) && !isString(nodeAttrs[key])) {
|
|
71
|
+
nodeAttrs[key] = nodeAttrs[key].toString();
|
|
68
72
|
}
|
|
69
73
|
});
|
|
70
74
|
|