@webreflection/elements 0.1.7 → 0.1.9
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/README.md +14 -1
- package/index.js +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -62,4 +62,17 @@ Enjoy 👋
|
|
|
62
62
|
|
|
63
63
|
If your browser supports natively *HTML* custom elements builtin extends (i.e. Chrome/ium or Firefox based), and *HTML* is all you want/need to extend 'cause *SVG* custom elements do not exist natively on the Web, you can use [@webreflection/elements/native](./native.js) export instead, which offers the **exact same API** without any dependency, hence it's lightweight, easier to reason about, and natively wonderful.
|
|
64
64
|
|
|
65
|
-
If you don't know if that's supported and you would like to feature detect this ability, you can pick the [@webreflection/elements/auto](./auto.js) export insted.
|
|
65
|
+
If you don't know if that's supported and you would like to feature detect this ability, you can pick the [@webreflection/elements/auto](./auto.js) export insted, which uses a lazy load for Safari or any browser that wouldn't support builtins' extends.
|
|
66
|
+
|
|
67
|
+
## Benefits around this module
|
|
68
|
+
|
|
69
|
+
* it is based on *Web Standard APIs* without requiring bloated polyfills
|
|
70
|
+
* it normalizes *Custom Elements* definition, without diverging between the *builtin extend* and the regular one:
|
|
71
|
+
* `define('my-link', class MyLink extend HTML.A {})` to extend `HTMLAnchorElement` (output: `<a is="my-link"></a>`)
|
|
72
|
+
* `define('my-el', class MyEl extend HTML.Element {})` to extend `HTMLElement` (output: `<my-el></my-el>`)
|
|
73
|
+
* elements are automatically upgraded once live on the DOM
|
|
74
|
+
* it simplifies creation of custom elements:
|
|
75
|
+
* elements can be created via `new MyLink()` or `new MyEl()`, reducing confusion around `document.createElement('a', { is: 'my-link' })` VS `document.createElement('my-el')`
|
|
76
|
+
* it simplifies styling of elements via `[is="ce-name"]` when attribute is present:
|
|
77
|
+
* combined with [@webreflection/element](https://github.com/WebReflection/element#readme) it helps creating custom elements builtins extend that will always reflect the `is` attribute
|
|
78
|
+
|
package/index.js
CHANGED
|
@@ -39,6 +39,7 @@ export const elements = {
|
|
|
39
39
|
registry.set(name, constructor);
|
|
40
40
|
wait(name).resolve(constructor);
|
|
41
41
|
|
|
42
|
+
//@ts-ignore
|
|
42
43
|
const selector = constructor.tag === 'element' ? name : `[is="${name}"]`;
|
|
43
44
|
query.push(selector);
|
|
44
45
|
parse(document.querySelectorAll(selector));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webreflection/elements",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "HTML & SVG Custom Elements",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.js",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"license": "MIT",
|
|
45
45
|
"type": "module",
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"nonchalance": "^0.6.
|
|
47
|
+
"nonchalance": "^0.6.2",
|
|
48
48
|
"qsa-observer": "^3.0.2"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|