@webtides/element-js 1.0.0-alpha.9 → 1.1.0

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 (41) hide show
  1. package/CHANGELOG.md +369 -0
  2. package/README.md +3 -3
  3. package/docs/README.md +70 -89
  4. package/docs/concepts/classes.md +37 -66
  5. package/docs/concepts/hierarchy.md +29 -31
  6. package/docs/concepts/lifecycle.md +9 -23
  7. package/docs/concepts/reactivity.md +1 -3
  8. package/docs/features/computed-properties.md +13 -16
  9. package/docs/features/dependency-injection-context-protocol.md +75 -87
  10. package/docs/features/global-styles.md +1 -1
  11. package/docs/features/methods.md +14 -15
  12. package/docs/features/properties.md +21 -33
  13. package/docs/features/refs.md +23 -31
  14. package/docs/features/renderless.md +31 -37
  15. package/docs/features/store.md +63 -78
  16. package/docs/features/templates.md +4 -1
  17. package/docs/features/watch.md +28 -35
  18. package/docs/getting-started/upgrade-to-v1.md +16 -0
  19. package/docs/guide/guide.md +10 -22
  20. package/index.js +29 -2
  21. package/package.json +62 -62
  22. package/src/BaseElement.js +637 -632
  23. package/src/StyledElement.js +104 -104
  24. package/src/TemplateElement.js +53 -58
  25. package/src/dom-parts/AttributePart.js +116 -116
  26. package/src/dom-parts/ChildNodePart.js +288 -288
  27. package/src/dom-parts/NodePart.js +27 -27
  28. package/src/dom-parts/Part.js +6 -6
  29. package/src/dom-parts/TemplatePart.js +119 -119
  30. package/src/dom-parts/TemplateResult.js +274 -267
  31. package/src/dom-parts/directives.js +105 -48
  32. package/src/dom-parts/html.js +2 -2
  33. package/src/dom-parts/render.js +6 -1
  34. package/src/util/AttributeParser.js +47 -47
  35. package/src/util/DOMHelper.js +190 -191
  36. package/src/util/Directive.js +31 -24
  37. package/src/util/GlobalStylesStore.js +56 -49
  38. package/src/util/SerializeStateHelper.js +56 -56
  39. package/src/util/Store.js +174 -174
  40. package/src/util/defineElement.js +5 -5
  41. package/src/util/toString.js +5 -5
package/CHANGELOG.md ADDED
@@ -0,0 +1,369 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres
6
+ to [Semantic Versioning](http://semver.org/).
7
+
8
+ <!--
9
+ PRs should document their user-visible changes (if any) in the
10
+ Unreleased section, uncommenting the header as necessary.
11
+ -->
12
+
13
+ <!-- ## Unreleased -->
14
+ <!-- ### Added -->
15
+ <!-- ### Changed -->
16
+ <!-- ### Removed -->
17
+ <!-- ### Fixed -->
18
+
19
+ ## [1.1.0] - 2024-06-24
20
+
21
+ ### Added
22
+
23
+ - Added `optionalAttribute` directive to conditionally render attributes (plus value)
24
+
25
+ ### FIXED
26
+
27
+ - Fixed `spreadAttributes` to not render "null|undefined|NaN" to the attributes value but removing the entire attribute
28
+ when such values are passed.
29
+
30
+ ## [1.0.0] - 2024-05-24
31
+
32
+ ### Added
33
+
34
+ - Added our own versions of directives and template helpers ([#67](https://github.com/webtides/element-js/pull/67))
35
+ - Added JSDocs for everything in the codebase. This will especially be helpful when using constructor options.
36
+ - Added state serialization. This improves hydration from SSR a
37
+ lot. ([#106](https://github.com/webtides/element-js/pull/106))
38
+ - added declarative shadow dom rendering for template elements
39
+
40
+ ### Changed
41
+
42
+ - _BREAKING_ Uses a new custom renderer for the `TemplateElement`. It replaces the old `lit-html` renderer. The API and
43
+ usage should be exactly the same. The only thing to do/change is the use of the old `lit-html` directives. For
44
+ detailed instructions see the upgrade guide. ([#67](https://github.com/webtides/element-js/pull/67))
45
+ - _BREAKING_ `element-js` will now also trigger the `afterUpdate` hook right after the `connected` hook. This is to
46
+ reduce the cases where you had to do the same things in `connected` and `afterUpdate`. You can now remove those
47
+ duplicate calls from the `connected` hook. ([#60](https://github.com/webtides/element-js/pull/60))
48
+ - _BREAKING_ Changed `package.json` type to `module`. This should hopefully not break anything. `element-js` is either
49
+ used directly from the browser or through a bundler. In both cases the added type: module should not
50
+ matter. ([#64](https://github.com/webtides/element-js/pull/64))
51
+ - _BRAKING_ Changed the default options when using the `dispatch` helper function. `bubbles`, `cancelable`
52
+ and `composed` will now be `true` by default.
53
+ - _BRAKING_ Changed adopting global styles to include ALL global styles. Previously only one inline <style> with the ID
54
+ of '#globalStyles' would be adopted. For more information see the docs.
55
+
56
+ ### Removed
57
+
58
+ - _BREAKING_ Removed the `lit-html` dependency. `element-js` is now officially dependency
59
+ free! ([#67](https://github.com/webtides/element-js/pull/67))
60
+ - _BREAKING_ Removed the deprecated `BaseElement` constructor option `childListUpdate`. Please use the "
61
+ mutationObserverOptions" dictionary instead. See the docs for more
62
+ info. ([#99](https://github.com/webtides/element-js/pull/99))
63
+ - _BREAKING_ Removed the `hooks` map in the `BaseElement`. Using the hooks() map for lifecycle hooks is deprecated!
64
+ Please overwrite the existing lifecycle hook functions. See the docs for more
65
+ info. ([#99](https://github.com/webtides/element-js/pull/99))
66
+ - _BREAKING_ Removed the `computed` map in the `BaseElement`. Using the computed() map for computed properties is
67
+ deprecated! Please use regular JS getters and return the computed value. See the docs for more
68
+ info. ([#99](https://github.com/webtides/element-js/pull/99))
69
+ - _BREAKING_ Removed all occurrences of `ShadyCSS`
70
+ in `StyledElement`. ([#99](https://github.com/webtides/element-js/pull/99))
71
+ - _BRAKING_ Removed the `i18n` helper function. See CHANGELOG how to implement it yourself or use a third party library.
72
+
73
+ ## [1.0.0-alpha.13] - 2024-05-08
74
+
75
+ ### Fixed
76
+
77
+ - catch security errors when `GlobalStylesStore` tries to read css rules from cross-origin stylesheets.
78
+
79
+ ## [1.0.0-alpha.12] - 2024-03-03
80
+
81
+ ### Added
82
+
83
+ - added declarative shadow dom rendering for template elements
84
+
85
+ ### Fixed
86
+
87
+ - fixed issues with whitespace being returned untrimmed in a template result
88
+
89
+ ## [1.0.0-alpha.11] - 2024-03-13
90
+
91
+ ### Fixed
92
+
93
+ - fixed missing return type `string` for the `template()` function in `TemplateElement`
94
+ - fixed types for the `propertyOptions` option in `BaseElement`
95
+
96
+ ## [1.0.0-alpha.10] - 2024-02-20
97
+
98
+ ### Fixed
99
+
100
+ - fixed unsafeHTML not rendering anything when toString was called
101
+ - fixed using = sign in attribute positions with interpolations
102
+ - fixed rendering null values in node part positions in SSR
103
+ - fixed missing .js file extensions
104
+
105
+ ## [1.0.0-alpha.9] - 2024-01-05
106
+
107
+ ### Changed
108
+
109
+ - moved DOM methods into connected callbacks to make it safe for the elements to be created in SSR environments
110
+
111
+ ## [1.0.0-alpha.8] - 2024-01-04
112
+
113
+ ### Fixed
114
+
115
+ - fixed ChildNodePart not replacing dom nodes from unsafeHTML
116
+
117
+ ## [1.0.0-alpha.7] - 2023-12-19
118
+
119
+ ### Fixed
120
+
121
+ - fixed wrong attribute parts for the same name on different elements
122
+
123
+ ## [1.0.0-alpha.6] - 2023-12-18
124
+
125
+ ### Fixed
126
+
127
+ - fixed hyphens in attribute names being split in SSR mode
128
+
129
+ ## [1.0.0-alpha.5] - 2023-12-07
130
+
131
+ ### Added
132
+
133
+ - Added the /docs directory to the files array in package.json
134
+ - Added part instances as \_\_part to comment nodes
135
+
136
+ ### Fixed
137
+
138
+ - fixed escaped unsafeHTML in SSR mode
139
+
140
+ ## [1.0.0-alpha.4] - 2023-12-01
141
+
142
+ ### Fixed
143
+
144
+ - falsy creation of directive parts for non-directive attributes
145
+ - creating parts with wrong comment marker positions
146
+
147
+ ## [1.0.0-alpha.3] - 2023-12-01
148
+
149
+ ### Added
150
+
151
+ - Added state serialization. This improves hydration from SSR a
152
+ lot. ([#106](https://github.com/webtides/element-js/pull/106))
153
+
154
+ ### Changed
155
+
156
+ - _BRAKING_ Changed the default options when using the `dispatch` helper function. `bubbles`, `cancelable`
157
+ and `composed` will now be `true` by default.
158
+ - _BRAKING_ Changed adopting global styles to include ALL global styles. Previously only one inline <style> with the ID
159
+ of '#globalStyles' would be adopted. For more information see the docs.
160
+
161
+ ### Removed
162
+
163
+ - _BRAKING_ Removed `i18n` helper function. See CHANGELOG how to implement it yourself or use a third party library.
164
+
165
+ ## [1.0.0-alpha.2] - 2023-08-23
166
+
167
+ ### Added
168
+
169
+ - Added JSDocs for everything in the codebase. This will especially be helpful when using constructor options.
170
+
171
+ ## [1.0.0-alpha.1] - 2023-08-15
172
+
173
+ ### Added
174
+
175
+ - Added our own versions of directives and template helpers ([#67](https://github.com/webtides/element-js/pull/67))
176
+
177
+ ### Changed
178
+
179
+ - _BRAKING_ Uses a new custom renderer for the `TemplateElement`. It replaces the old `lit-html` renderer. The API and
180
+ usage should be exactly the same. The only thing to do/change is the use of the old `lit-html` directives. For
181
+ detailed instructions see the upgrade guide. ([#67](https://github.com/webtides/element-js/pull/67))
182
+ - _BREAKING_ `element-js` will now also trigger the `afterUpdate` hook right after the `connected` hook. This is to
183
+ reduce the cases where you had to do the same things in `connected` and `afterUpdate`. You can now remove those
184
+ duplicate calls from the `connected` hook. ([#60](https://github.com/webtides/element-js/pull/60))
185
+ - _BREAKING_ Changed `package.json` type to `module`. This should hopefully not break anything. `element-js` is either
186
+ used directly from the browser or through a bundler. In both cases the added type: module should not
187
+ matter. ([#64](https://github.com/webtides/element-js/pull/64))
188
+
189
+ ### Removed
190
+
191
+ - _BREAKING_ Removed the `lit-html` dependency. `element-js` is now officially dependency
192
+ free! ([#67](https://github.com/webtides/element-js/pull/67))
193
+ - _BREAKING_ Removed the deprecated `BaseElement` constructor option `childListUpdate`. Please use the "
194
+ mutationObserverOptions" dictionary instead. See the docs for more
195
+ info. ([#99](https://github.com/webtides/element-js/pull/99))
196
+ - _BREAKING_ Removed the `hooks` map in the `BaseElement`. Using the hooks() map for lifecycle hooks is deprecated!
197
+ Please overwrite the existing lifecycle hook functions. See the docs for more
198
+ info. ([#99](https://github.com/webtides/element-js/pull/99))
199
+ - _BREAKING_ Removed the `computed` map in the `BaseElement`. Using the computed() map for computed properties is
200
+ deprecated! Please use regular JS getters and return the computed value. See the docs for more
201
+ info. ([#99](https://github.com/webtides/element-js/pull/99))
202
+ - _BREAKING_ Removed all occurrences of `ShadyCSS`
203
+ in `StyledElement`. ([#99](https://github.com/webtides/element-js/pull/99))
204
+
205
+ ## [0.7.4] - 2023-11-24
206
+
207
+ ### Added
208
+
209
+ - storeception (reactive store properties in parent stores)
210
+ - context injection in shadow elements requests travel though shadow roots
211
+ - defer element connection (disables client side code until called manually)
212
+
213
+ ### Fixed
214
+
215
+ - late context injection if parent mounts after child (loading order)
216
+ - stores updating elements that want to be updated
217
+
218
+ ## [0.7.3] - 2023-03-07
219
+
220
+ ### Fixed
221
+
222
+ - last release was tagged wrong
223
+
224
+ ## [0.7.2] - 2023-03-03
225
+
226
+ ### Fixed
227
+
228
+ - watcher callbacks for injected stores
229
+
230
+ ## [0.7.1] - 2023-03-03
231
+
232
+ ### Added
233
+
234
+ - Elements are now able to watch Stores
235
+
236
+ ### Fixed
237
+
238
+ - Injection of falsy values
239
+
240
+ ## [0.7.0] - 2023-02-13
241
+
242
+ ### Added
243
+
244
+ - Dependency Injection via Context Protocol 💉
245
+ - Provide reactive Properties or entire Stores via: provideProperties() { return { name : value}}
246
+ - Inject / Request them via injectProperties() { return { name : 'defaultValue'}}
247
+
248
+ ### Changed
249
+
250
+ - docs structure
251
+
252
+ ### Fixed
253
+
254
+ - Cannot re-render slotted light dom when using the vanilla renderer https://github.com/webtides/element-js/issues/76
255
+ - adds Vanilla Renderer Tests
256
+
257
+ ## [0.6.2] - 2022-11-18
258
+
259
+ ### FIXED
260
+
261
+ - Store always switching to singleProperty Mode if constructed without any arguments.
262
+
263
+ ## [0.6.1] - 2022-11-18
264
+
265
+ ### ADDED
266
+
267
+ - Store watch() map to control internal store state scope
268
+
269
+ ## [0.6.0] - 2022-11-17
270
+
271
+ ### ADDED
272
+
273
+ - StoreProperty for shared application state
274
+ - Directives for Vanilla Renderer
275
+
276
+ ## [0.5.0] - 2022-09-13
277
+
278
+ ### Changed
279
+
280
+ - improved the performance of the vanilla-renderer
281
+
282
+ ### Removed
283
+
284
+ - setting attributes as properties during dom diffing for the vanilla renderer. This is potentially a **breaking**
285
+ change if you used attributes with the "." (dot) notation
286
+
287
+ ## [0.4.3] - 2022-07-06
288
+
289
+ ### ADDED
290
+
291
+ - parse option to propertyOptions that can be either a boolean OR a function for custom parsing
292
+ - enhance reflect option in propertyOptions that it can also be a function for custom reflection
293
+
294
+ ## [0.4.2] - 2022-02-03
295
+
296
+ ### Fixed
297
+
298
+ - vanilla-renderer: fixes attribute comparsion
299
+
300
+ ## [0.4.1] - 2022-02-01
301
+
302
+ ### Fixed
303
+
304
+ - refs="id[]" indexing keys not nodes _rolleyes_
305
+
306
+ ### Added
307
+
308
+ - refs="id[]" aka possibbility to refrence a list of nodes to the $refs map.
309
+
310
+ ## [0.4.0] - 2022-01-28
311
+
312
+ ### Added
313
+
314
+ - a "vanilla" renderer with support for hydration and no dependencies
315
+
316
+ ### Changed
317
+
318
+ - uses new @web/test-runner isntead of karma (#27)
319
+
320
+ ## [0.3.3] - 2021-09-22
321
+
322
+ ### Added
323
+
324
+ - optional complex event callback notation to support addEventListener options (i.E. for passive Event Listeners )
325
+ - Example: {listener: () => {}, options: { passive: true } }
326
+ - docs
327
+ - tests
328
+
329
+ ## [0.3.2] - 2021-03-09
330
+
331
+ ### Added
332
+
333
+ - bundled version of `element-js` to use from a CDN and be able to prototype in tools like CodePen etc.
334
+
335
+ ## [0.3.1] - 2020-12-08
336
+
337
+ ### Fixed
338
+
339
+ - i18n fallback values
340
+
341
+ ### Added
342
+
343
+ - i18n tests
344
+
345
+ ## [0.3.0] - 2020-07-27
346
+
347
+ ### Added
348
+
349
+ - first batch/draft of the documentation
350
+ - property/attribute reflection via constructor options (see the [Documentation](/docs/README.md#propertyoptions) for
351
+ more info)
352
+ - mutationObserverOptions to enable observing subtree mutations (see
353
+ the [Documentation](/docs/README.md#mutationobserveroptions) for more info)
354
+
355
+ ### Removed
356
+
357
+ - `childListUpdate` constructor option has been deprecated and will be removed before `1.0`
358
+
359
+ ## [0.2.0] - 2020-07-01
360
+
361
+ ### Changed
362
+
363
+ - uses shady-render instead of render from `lit-html` for rendering templates to be compatible with the shady-css
364
+ polyfill
365
+ - refactored and simplified `StyledElement`s handling/loading of style sheets
366
+
367
+ ## [0.1.0] - 2020-06-26
368
+
369
+ - initial release
package/README.md CHANGED
@@ -27,7 +27,7 @@ npm install --save @webtides/element-js
27
27
  // or when installed via npm
28
28
  import { BaseElement, defineElement, Store } from '@webtides/element-js';
29
29
 
30
- const sharedDate = new Store({date: Date.now()})
30
+ const sharedDate = new Store({ date: Date.now() });
31
31
 
32
32
  class ExampleElement extends BaseElement {
33
33
  // normal public properties
@@ -42,8 +42,8 @@ class ExampleElement extends BaseElement {
42
42
  // reactive attributes/properties
43
43
  properties() {
44
44
  return {
45
- familyName: 'Doe',
46
- sharedDate
45
+ familyName: 'Doe',
46
+ sharedDate
47
47
  };
48
48
  }
49
49
 
package/docs/README.md CHANGED
@@ -2,42 +2,33 @@
2
2
 
3
3
  ## Introduction
4
4
 
5
- _element-js_ is a collection of base classes for Custom Elements with a beautiful API for building fast and lightweight
6
- Web Components that work with any framework or without a framework at all - because they are just html and vanilla
7
- javascript.
5
+ _element-js_ is a collection of base classes for Custom Elements with a beautiful API for building fast and lightweight Web Components that work with any framework or without a framework at all - because they are just html and vanilla javascript.
8
6
 
9
- _element-js_ aims to combine the best concepts of current and popular frontend frameworks and web-standard into a single
10
- toolset that will never be outdated because it is just html and javascript.
7
+ _element-js_ aims to combine the best concepts of current and popular frontend frameworks and web-standard into a single toolset that will never be outdated because it is just html and javascript.
11
8
 
12
9
  ### Why Custom elements
13
10
 
14
- By using web-standards, developers only need to learn the standard web API once rather than custom framework APIs over
15
- and over again.
11
+ By using web-standards, developers only need to learn the standard web API once rather than custom framework APIs over and over again.
16
12
 
17
- While popular frontend frameworks come and go, web components and custom elements will always be part of the web
18
- standard API. And since they conform to the standard web API, they work in any major frontend framework.
13
+ While popular frontend frameworks come and go, web components and custom elements will always be part of the web standard API. And since they conform to the standard web API, they work in any major frontend framework.
19
14
 
20
- Custom elements provide a component model for the web and enable developers to define their own elements. With custom
21
- elements you get a mechanism to associate an ES class with a custom element name which then can be used in HTML
22
- alongside any other element. Inside the class you can define the public API for the custom element.
15
+ Custom elements provide a component model for the web and enable developers to define their own elements. With custom elements you get a mechanism to associate an ES class with a custom element name which then can be used in HTML alongside any other element. Inside the class you can define the public API for the custom element.
23
16
 
24
17
  ### Why element-js
25
18
 
26
- Using Custom Clements directly can be quite cumbersome because the underlying API is very low level. To prevent writing
27
- a lot of boilerplate _element-js_ provides extra APIs that enable writing components fast with very little code.
19
+ Using Custom Clements directly can be quite cumbersome because the underlying API is very low level. To prevent writing a lot of boilerplate _element-js_ provides extra APIs that enable writing components fast with very little code.
28
20
 
29
21
  On top of that it also brings some nice features like
30
22
 
31
- - async update/render cycle
32
- - automatic mapping of attributes to properties
33
- - objects, arrays, numbers and booleans as attributes (instead of just strings)
34
- - reflecting properties to attributes
35
- - abstraction for writing templates
36
- - mechanism for loading styles per element
37
- - loading global styles into Shadow Dom
23
+ - async update/render cycle
24
+ - automatic mapping of attributes to properties
25
+ - objects, arrays, numbers and booleans as attributes (instead of just strings)
26
+ - reflecting properties to attributes
27
+ - abstraction for writing templates
28
+ - mechanism for loading styles per element
29
+ - loading global styles into Shadow Dom
38
30
 
39
- And the best thing? There is no magic! No Framework. No compiler. You only need to extend from an _element-js_ element
40
- instead of the standard `HTMLElement`.
31
+ And the best thing? There is no magic! No Framework. No compiler. You only need to extend from an _element-js_ element instead of the standard `HTMLElement`.
41
32
 
42
33
  ### Browser Support
43
34
 
@@ -48,40 +39,35 @@ _element-js_ Elements are natively supported in all modern Browsers including Ch
48
39
  | ✓ | ✓ | ✓ | ✓ |
49
40
  | v. 60+ | v. 79+ | v. 63+ | v. 10.1+ |
50
41
 
51
- If you need to support older Browsers like IE 11 or Edge 16-18 you will have to load one or two polyfills for Custom
52
- Elements to work seamlessly. _element-js_ does not bring or load any polyfills on its own. You will have to bundle or
53
- load them yourself. For more information see [Bundling/Publishing](#bundlingpublishing).
42
+ If you need to support older Browsers like IE 11 or Edge 16-18 you will have to load one or two polyfills for Custom Elements to work seamlessly. _element-js_ does not bring or load any polyfills on its own. You will have to bundle or load them yourself. For more information see [Bundling/Publishing](#bundlingpublishing).
54
43
 
55
- > _element-js_ comes unbundled, unminified and uses a few `Babel` plugins. Browser support can also be limited for any
56
- > of the `Babel` plugin features, you will probably have to use a build step and run your code through something
57
- > like `Babel`. For a list of `Babel` plugins that are used, see [ES6 Classes](#es6-classes). For more information on
58
- > bundling and publishing your elements see [Bundling/Publishing](#bundlingpublishing).
44
+ > _element-js_ comes unbundled, unminified and uses a few `Babel` plugins. Browser support can also be limited for any of the `Babel` plugin features, you will probably have to use a build step and run your code through something like `Babel`. For a list of `Babel` plugins that are used, see [ES6 Classes](#es6-classes). For more information on bundling and publishing your elements see [Bundling/Publishing](#bundlingpublishing).
59
45
 
60
46
  ### Getting Started
61
47
 
62
- + #### [Upgrade Guide](./getting-started/upgrade-to-v1.md)
48
+ - #### [Upgrade Guide](./getting-started/upgrade-to-v1.md)
63
49
 
64
50
  ### Element Core Concepts
65
51
 
66
- + #### [ES6 Classes & Options](./concepts/classes.md)
67
- + #### [Lifecycle](./concepts/lifecycle.md)
68
- + #### [Reactivity](./concepts/reactivity.md)
69
- + #### [Hierarchy](./concepts/hierarchy.md)
52
+ - #### [ES6 Classes & Options](./concepts/classes.md)
53
+ - #### [Lifecycle](./concepts/lifecycle.md)
54
+ - #### [Reactivity](./concepts/reactivity.md)
55
+ - #### [Hierarchy](./concepts/hierarchy.md)
70
56
 
71
57
  ### Features
72
58
 
73
- + #### [Reactive Attributes/Properties](./features/properties.md)
74
- + #### [Shared State / Reactive State / Store](./features/store.md)
75
- + #### [Watch Changes](./features/watch.md)
76
- + #### [Computed Properties](./features/computed-properties.md)
77
- + #### [Dependency Injection / Context Protocol](./features/dependency-injection-context-protocol.md)
78
- + #### [Methods](./features/methods.md)
79
- + #### [Rendering / TemplateElement](./features/templates.md)
80
- + #### [Not Rendering Elements / BaseElement](./features/methods.md)
81
- + #### [Dom References / Refs](./features/refs.md)
82
- + #### [Component Styles / CSS](./features/styles.md)
83
- + #### [Global Styles / CSS](./features/global-styles.md)
84
- + #### [Events](./features/events.md)
59
+ - #### [Reactive Attributes/Properties](./features/properties.md)
60
+ - #### [Shared State / Reactive State / Store](./features/store.md)
61
+ - #### [Watch Changes](./features/watch.md)
62
+ - #### [Computed Properties](./features/computed-properties.md)
63
+ - #### [Dependency Injection / Context Protocol](./features/dependency-injection-context-protocol.md)
64
+ - #### [Methods](./features/methods.md)
65
+ - #### [Rendering / TemplateElement](./features/templates.md)
66
+ - #### [Not Rendering Elements / BaseElement](./features/methods.md)
67
+ - #### [Dom References / Refs](./features/refs.md)
68
+ - #### [Component Styles / CSS](./features/styles.md)
69
+ - #### [Global Styles / CSS](./features/global-styles.md)
70
+ - #### [Events](./features/events.md)
85
71
 
86
72
  ### Getting started
87
73
 
@@ -91,51 +77,50 @@ You can install _element-js_ into an existing project or create a new app from s
91
77
 
92
78
  ### First Element
93
79
 
94
- To define a custom element, create a class that extends _element-js_ and pass the class with a name to
95
- the `defineElement` helper function.
80
+ To define a custom element, create a class that extends _element-js_ and pass the class with a name to the `defineElement` helper function.
96
81
 
97
82
  > By specification, a custom element's name can only have lower case letters and must contain a dash.
98
83
 
99
84
  Here is an example of what a _element-js_ element looks like:
100
85
 
101
86
  ```js
102
- import {BaseElement, defineElement} from '@webtides/element-js';
87
+ import { BaseElement, defineElement } from '@webtides/element-js';
103
88
 
104
89
  class ExampleElement extends BaseElement {
105
- // normal public properties
106
- greeting = 'Hello';
107
- name = 'John';
108
-
109
- // lifecycle hook
110
- connected() {
111
- this.greet();
112
- }
113
-
114
- // reactive attributes/properties
115
- properties() {
116
- return {
117
- familyName: 'Doe'
118
- };
119
- }
120
-
121
- // watchers for property changes
122
- watch() {
123
- return {
124
- familyName: (newValue, oldValue) => {
125
- console.log('familyName changed', newValue, oldValue);
126
- }
127
- };
128
- }
129
-
130
- // computed property
131
- get computedMsg() {
132
- return `${this.greeting} ${this.name} ${this.familyName}`;
133
- }
134
-
135
- // method
136
- greet() {
137
- alert('greeting: ' + this.computedMsg);
138
- }
90
+ // normal public properties
91
+ greeting = 'Hello';
92
+ name = 'John';
93
+
94
+ // lifecycle hook
95
+ connected() {
96
+ this.greet();
97
+ }
98
+
99
+ // reactive attributes/properties
100
+ properties() {
101
+ return {
102
+ familyName: 'Doe'
103
+ };
104
+ }
105
+
106
+ // watchers for property changes
107
+ watch() {
108
+ return {
109
+ familyName: (newValue, oldValue) => {
110
+ console.log('familyName changed', newValue, oldValue);
111
+ }
112
+ };
113
+ }
114
+
115
+ // computed property
116
+ get computedMsg() {
117
+ return `${this.greeting} ${this.name} ${this.familyName}`;
118
+ }
119
+
120
+ // method
121
+ greet() {
122
+ alert('greeting: ' + this.computedMsg);
123
+ }
139
124
  }
140
125
 
141
126
  defineElement('example-element', ExampleElement);
@@ -153,11 +138,7 @@ When the JS class is built, this element can be imported and used in HTML just l
153
138
 
154
139
  When rendered in the browser, it will log to the console: `Hello John Smith`
155
140
 
156
-
157
-
158
-
159
- ## [Guides/Tooling](./guide/guide.md)
160
-
141
+ ## [Guides/Tooling](./guide/guide.md)
161
142
 
162
143
  ## Testing
163
144