be-hive 0.0.97 → 0.0.98

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/be-hive.js +21 -10
  2. package/package.json +2 -2
package/be-hive.js CHANGED
@@ -75,28 +75,39 @@ export class BeHive extends HTMLElement {
75
75
  #inspectNewNode(node) {
76
76
  if (!(node instanceof Element))
77
77
  return;
78
+ const { beEnhanced } = node;
78
79
  const { registeredBehaviors } = this;
79
80
  for (const key in registeredBehaviors) {
80
81
  const registeredBehavior = registeredBehaviors[key];
81
82
  const { upgrade } = registeredBehavior;
82
- const attr = node.localName.includes('-') ? `[enh-by-${key},data-enh-by-${key}]` : `[${key},enh-by-${key},data-enh-by-${key}]`;
83
- if (node.matches(upgrade) && node.matches(attr)) {
84
- const { beEnhanced } = node;
85
- //console.log("behive: attachAttr");
86
- beEnhanced.attachAttr(key);
87
- }
83
+ if (!node.matches(upgrade))
84
+ continue;
85
+ const namespacedName = beEnhanced.getFQName(key);
86
+ if (namespacedName === undefined)
87
+ continue;
88
+ beEnhanced.attachAttr(namespacedName, key);
88
89
  }
89
90
  }
91
+ // #getPreciseMatch(key: string, node: Element, allowNonNamespaced = true){
92
+ // if(allowNonNamespaced && node.matches(`[${key}]`)) return key;
93
+ // let testKey = `enh-by-${key}`;
94
+ // let test = `[${testKey}]`;
95
+ // if(node.matches(test)) return testKey;
96
+ // testKey = `data-enh-by-${key}`;
97
+ // test = `[${testKey}]`;
98
+ // if(node.matches(test)) return testKey;
99
+ // return undefined;
100
+ // }
90
101
  #scanForSingleRegisteredBehavior(localName, behaviorKeys) {
91
102
  const { ifWantsToBe, upgrade } = behaviorKeys;
92
103
  const attr = `${upgrade}[${localName}],${upgrade}[enh-by-${localName}],${upgrade}[data-enh-by-${localName}]`;
93
104
  const rn = this.getRootNode();
94
105
  rn.querySelectorAll(attr).forEach(el => {
95
- if (el.localName.includes('-') && !el.matches(`[enh-by-${localName}],${upgrade}[data-enh-by-${localName}]`))
96
- return;
97
106
  const { beEnhanced } = el;
98
- //console.log("behive: attachAttr");
99
- beEnhanced.attachAttr(localName);
107
+ const namespacedName = beEnhanced.getFQName(localName);
108
+ if (namespacedName === undefined)
109
+ return;
110
+ beEnhanced.attachAttr(namespacedName, localName);
100
111
  });
101
112
  }
102
113
  register(parentInstance) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "be-hive",
3
- "version": "0.0.97",
3
+ "version": "0.0.98",
4
4
  "keywords": [
5
5
  "web-components",
6
6
  "web-component",
@@ -26,7 +26,7 @@
26
26
  "serve": "node node_modules/may-it-serve/serve.js"
27
27
  },
28
28
  "dependencies": {
29
- "be-enhanced": "0.0.23"
29
+ "be-enhanced": "0.0.24"
30
30
  },
31
31
  "devDependencies": {
32
32
  "may-it-serve": "0.0.5"