@webtides/element-js 0.3.2 → 0.4.2

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/CHANGELOG.md CHANGED
@@ -15,6 +15,41 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
15
15
  <!-- ### Removed -->
16
16
  <!-- ### Fixed -->
17
17
 
18
+ ## [0.4.2] - 2022-02-03
19
+
20
+ ### Fixed
21
+ * vanilla-renderer: fixes attribute comparsion
22
+
23
+ ## [0.4.1] - 2022-02-01
24
+
25
+ ### Fixed
26
+ * refs="id[]" indexing keys not nodes *rolleyes*
27
+
28
+ ### Added
29
+ * refs="id[]" aka possibbility to refrence a list of nodes to the $refs map.
30
+
31
+ ## [0.4.0] - 2022-01-28
32
+
33
+ ### Added
34
+ * a "vanilla" renderer with support for hydration and no dependencies
35
+
36
+ ### Changed
37
+ * uses new @web/test-runner isntead of karma (#27)
38
+
39
+ ## [0.3.3] - 2021-09-22
40
+
41
+ ### Added
42
+ * optional complex event callback notation to support addEventListener options (i.E. for passive Event Listeners )
43
+ * Example: {listener: () => {}, options: { passive: true } }
44
+ * docs
45
+ * tests
46
+
47
+
48
+ ## [0.3.2] - 2021-03-09
49
+
50
+ ### Added
51
+ * bundled version of `element-js` to use from a CDN and be able to prototype in tools like CodePen etc.
52
+
18
53
  ## [0.3.1] - 2020-12-08
19
54
 
20
55
  ### Fixed
package/README.md CHANGED
@@ -77,30 +77,9 @@ To use this element, just import it and use it like any other HTML element
77
77
 
78
78
  For detailed documentation see the [Docs](docs/README.md).
79
79
 
80
- ## Development
80
+ ## Contributing & Development
81
81
 
82
- ### We use eslint and prettier to ensure good code quality
83
-
84
- Prettier will run automatically when staging files via `git`.
85
- To run the linter manually - simply run `npm run lint`.
86
-
87
- ### Git Branching
88
-
89
- We use a trunk-based development workflow.
90
-
91
- > In the trunk-based development model, all developers work on a single branch with open access to it. Often it’s simply the main branch. They commit code to it and run it. It’s super simple.
92
- > In some cases, they create short-lived feature branches. Once code on their branch compiles and passes all tests, they merge it straight to main. It ensures that development is truly continuous and prevents developers from creating merge conflicts that are difficult to resolve.
93
-
94
- As a Release is complete the main branch will be tagged with the new release version.
95
-
96
- ### Pull Requests
97
-
98
- Pull requests should take place whenever a:
99
-
100
- - FEATURE is about to be finished
101
- - RELEASE is about to be finished
102
-
103
- When all Reviewers approved a PR the feature/release may be finished locally and pushed to the remote
82
+ For contributions and development see [contributing docs](.github/CONTRIBUTING.md)
104
83
 
105
84
  ## License
106
85
 
package/dist/index.js CHANGED
@@ -314,9 +314,17 @@ var BaseElement = class extends HTMLElement {
314
314
  const eventTargets = whiteListElement ? [whiteListElement] : this.getRoot().querySelectorAll(elementSelector);
315
315
  eventTargets.forEach((eventTarget) => {
316
316
  Object.keys(events).forEach((eventName) => {
317
- const callback = events[eventName].bind(this);
318
- eventTarget.addEventListener(eventName, callback);
319
- this._registeredEvents.push({eventTarget, eventName, callback});
317
+ var _a;
318
+ const notation = events[eventName];
319
+ if (typeof notation === "function") {
320
+ const callback = notation.bind(this);
321
+ eventTarget.addEventListener(eventName, callback);
322
+ this._registeredEvents.push({eventTarget, eventName, callback});
323
+ } else if (typeof notation === "object" && typeof notation.listener === "function") {
324
+ const callback = notation.listener.bind(this);
325
+ eventTarget.addEventListener(eventName, callback, (_a = notation.options) != null ? _a : {});
326
+ this._registeredEvents.push({eventTarget, eventName, callback});
327
+ }
320
328
  });
321
329
  });
322
330
  });
@@ -335,7 +343,19 @@ var BaseElement = class extends HTMLElement {
335
343
  const refsMap = {};
336
344
  refsArray.forEach((refNode) => {
337
345
  const refKey = refNode.getAttribute("ref");
338
- refsMap[refKey] = refNode;
346
+ const isListKey = refKey.endsWith("[]");
347
+ const cleanKey = isListKey ? refKey.slice(0, -2) : refKey;
348
+ const hasListRef = Array.isArray(refsMap[cleanKey]);
349
+ if (isListKey) {
350
+ if (!refsMap[cleanKey] || !hasListRef) {
351
+ refsMap[cleanKey] = [];
352
+ }
353
+ refsMap[cleanKey].push(refNode);
354
+ } else if (!hasListRef) {
355
+ refsMap[refKey] = refNode;
356
+ } else {
357
+ console.warn(`Did not register singular ref ${refKey}, ${refNode} as a ref list is already registered under the same name.`);
358
+ }
339
359
  });
340
360
  this.$refs = refsMap;
341
361
  }