boxwood 0.61.1 → 0.61.3

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.
Files changed (2) hide show
  1. package/index.js +13 -15
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -9,7 +9,7 @@ async function compile(path) {
9
9
  const nodes = {}
10
10
  const styles = []
11
11
  const scripts = []
12
- const find = (node) => {
12
+ const walk = (node) => {
13
13
  if (node.name === 'head') {
14
14
  nodes.head = node
15
15
  }
@@ -22,10 +22,12 @@ async function compile(path) {
22
22
  node.ignore = true
23
23
  }
24
24
  if (Array.isArray(node)) {
25
- node.forEach(find)
25
+ node.forEach(walk)
26
+ } else if (Array.isArray(node.children)) {
27
+ node.children.forEach(walk)
26
28
  }
27
29
  }
28
- walk(tree, find)
30
+ walk(tree)
29
31
  if (nodes.head) {
30
32
  if (styles.length > 0) {
31
33
  nodes.head.children.push({
@@ -45,13 +47,6 @@ async function compile(path) {
45
47
  }
46
48
  }
47
49
 
48
- function walk(tree, callback) {
49
- callback(tree)
50
- if (Array.isArray(tree.children)) {
51
- tree.children.map((node) => walk(node, callback))
52
- }
53
- }
54
-
55
50
  const ENTITIES = {
56
51
  '&': '&',
57
52
  '<': '&lt;',
@@ -115,11 +110,14 @@ const ALIASES = {
115
110
  const attributes = (options) => {
116
111
  const result = []
117
112
  for (const key in options) {
118
- if (BOOLEAN_ATTRIBUTES.includes(key)) {
119
- result.push(key)
120
- } else {
121
- const name = ALIASES[key] || key
122
- result.push(name + '=' + '"' + options[key] + '"')
113
+ const value = options[key]
114
+ if (value) {
115
+ if (BOOLEAN_ATTRIBUTES.includes(key)) {
116
+ result.push(key)
117
+ } else {
118
+ const name = ALIASES[key] || key
119
+ result.push(name + '=' + '"' + options[key] + '"')
120
+ }
123
121
  }
124
122
  }
125
123
  return result.join(' ')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "boxwood",
3
- "version": "0.61.1",
3
+ "version": "0.61.3",
4
4
  "description": "Compile HTML templates into JS",
5
5
  "main": "index.js",
6
6
  "scripts": {