@webtides/element-js 0.3.2-rc.6 → 0.4.1
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 +30 -0
- package/README.md +2 -23
- package/dist/index.js +24 -4
- package/dist/index.js.map +2 -2
- package/package.json +21 -21
- package/src/BaseElement.js +28 -4
- package/src/renderer/vanilla/TemplateElement.js +52 -0
- package/src/renderer/vanilla/index.js +18 -0
- package/src/renderer/vanilla/util/html.js +78 -0
- package/src/renderer/vanilla/util/render.js +278 -0
- package/src/util/AttributeParser.js +18 -0
package/CHANGELOG.md
CHANGED
|
@@ -15,6 +15,36 @@ 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.1] - 2022-02-01
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
* vanilla-renderer: fixes attribute comparsion
|
|
22
|
+
|
|
23
|
+
### Added
|
|
24
|
+
* refs="id[]" aka possibbility to refrence a list of nodes to the $refs map.
|
|
25
|
+
|
|
26
|
+
## [0.4.0] - 2022-01-28
|
|
27
|
+
|
|
28
|
+
### Added
|
|
29
|
+
* a "vanilla" renderer with support for hydration and no dependencies
|
|
30
|
+
|
|
31
|
+
### Changed
|
|
32
|
+
* uses new @web/test-runner isntead of karma (#27)
|
|
33
|
+
|
|
34
|
+
## [0.3.3] - 2021-09-22
|
|
35
|
+
|
|
36
|
+
### Added
|
|
37
|
+
* optional complex event callback notation to support addEventListener options (i.E. for passive Event Listeners )
|
|
38
|
+
* Example: {listener: () => {}, options: { passive: true } }
|
|
39
|
+
* docs
|
|
40
|
+
* tests
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
## [0.3.2] - 2021-03-09
|
|
44
|
+
|
|
45
|
+
### Added
|
|
46
|
+
* bundled version of `element-js` to use from a CDN and be able to prototype in tools like CodePen etc.
|
|
47
|
+
|
|
18
48
|
## [0.3.1] - 2020-12-08
|
|
19
49
|
|
|
20
50
|
### 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
|
-
|
|
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
|
-
|
|
318
|
-
|
|
319
|
-
|
|
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
|
-
|
|
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(cleanKey);
|
|
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
|
}
|