aleman 1.1.19 → 1.1.20

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/menu/menu.js CHANGED
@@ -46,7 +46,7 @@ function createHydrate(name) {
46
46
  const section = document.createElement('section');
47
47
 
48
48
  section.dataset.name = `aleman-hydrate-${name}`;
49
- section.innerHTML = `<ul data-name="menu" class="menu menu-hidden"></ul>`;
49
+ section.innerHTML = `<ul data-name="${name}" class="menu menu-hidden"></ul>`;
50
50
  document.body.append(section);
51
51
 
52
52
  return section;
@@ -1,4 +1,5 @@
1
1
  import {operator, types} from 'putout';
2
+ import {checkDataName} from '../check-data-name.js';
2
3
 
3
4
  const {isJSXElement} = types;
4
5
  const {setLiteralValue} = operator;
@@ -15,15 +16,15 @@ export const fix = ({path, prev, next}) => {
15
16
 
16
17
  export const traverse = ({options, push}) => ({
17
18
  JSXOpeningElement(path) {
19
+ const {name = 'menu', index = 1} = options;
20
+
18
21
  if (path.node.name.name !== 'li')
19
22
  return;
20
23
 
21
- const {index = 1} = options;
22
-
23
24
  if (!isJSXElement(path.parentPath.parentPath))
24
25
  return;
25
26
 
26
- if (!checkDataName(path.parentPath.parentPath))
27
+ if (!checkDataName(path.parentPath.parentPath, name))
27
28
  return;
28
29
 
29
30
  const children = path.parentPath
@@ -56,19 +57,6 @@ export const traverse = ({options, push}) => ({
56
57
  },
57
58
  });
58
59
 
59
- function checkDataName(path) {
60
- const attributes = path.get('openingElement.attributes');
61
-
62
- for (const attr of attributes) {
63
- const {name, value} = attr.node;
64
-
65
- if (name.name === 'data-name')
66
- return value.value === 'menu';
67
- }
68
-
69
- return false;
70
- }
71
-
72
60
  function unselect(path) {
73
61
  if (!path)
74
62
  return;
@@ -83,3 +71,4 @@ function unselect(path) {
83
71
  setLiteralValue(value, value.value.replace(' menu-item-selected', ''));
84
72
  }
85
73
  }
74
+
@@ -29,10 +29,10 @@ export const fix = ({path, attr, left, top}) => {
29
29
 
30
30
  export const traverse = ({options, push}) => ({
31
31
  JSXOpeningElement(path) {
32
- const {position = {}} = options;
32
+ const {name = 'menu', position = {}} = options;
33
33
  const {left = 0, top = 20} = position;
34
34
 
35
- if (!checkDataName(path.parentPath, 'menu'))
35
+ if (!checkDataName(path.parentPath, name))
36
36
  return;
37
37
 
38
38
  for (const attr of path.node.attributes) {
@@ -26,7 +26,7 @@ export const traverse = ({push, options}) => ({
26
26
  if (!isJSXElement(path.parentPath.parentPath))
27
27
  return;
28
28
 
29
- if (!checkDataName(path.parentPath.parentPath))
29
+ if (!checkDataName(path.parentPath.parentPath, name))
30
30
  return;
31
31
 
32
32
  const children = path.parentPath
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aleman",
3
- "version": "1.1.19",
3
+ "version": "1.1.20",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout-based framework for web",