clapton 0.0.18 → 0.0.19

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 75a7ef3678828970fe19e84f474a8480a2b3aef73bb7cad48d771952560dc26f
4
- data.tar.gz: d183141896d4742b8481d03db28e1d38d1b0ba3d447c8a0c4444d46fa06cec72
3
+ metadata.gz: eef5820604c561e4e740eb50620f88cfc0b9466517ad9e3f5da364a1d923356d
4
+ data.tar.gz: a1ce6f1bbc737affe77cdf3cb8370722c6fb169c6b4b386bb17fa53ed3799f47
5
5
  SHA512:
6
- metadata.gz: d22f7c4bd63092f2f1e701f91d8e86d19bd7a7b1f2ea0fe2bc42709d94b84737e34eaacad59b3c58485407932c372b9535cf2649905f81c8a8e2f17b8bfcba3c
7
- data.tar.gz: ea1047109748b7b047c96823727fc3d681d74463d04ca97bb28bac3b354c1b4d3474a9ab001fb03be1029f769cf6fa0ccc69536b24131f75481ae673bd2b08b9
6
+ metadata.gz: b36f22c1f26313d9aabe6e67844df736302c92b4f42805b09be40dca60b3ddab9c8a7b40a70dbab3c55ee7baa9ec508820342d4f4e296b16ca053721cff598ad
7
+ data.tar.gz: dd95168998ca12d46b7eb164698f918b6a8f0575e7a8be435a2943054a4a0407209758a834514719c11f496424ec29a1bcb4701a0d05ceb625e35b07d468789b
data/README.md CHANGED
@@ -349,6 +349,18 @@ module ApplicationCable
349
349
  end
350
350
  ```
351
351
 
352
+ ### Events
353
+
354
+ #### clapton:render
355
+
356
+ The `clapton:render` event is a custom event that is triggered when the component is rendered.
357
+
358
+ ```javascript
359
+ document.addEventListener("clapton:render", () => {
360
+ console.log("clapton:render");
361
+ });
362
+ ```
363
+
352
364
  ### Testing
353
365
 
354
366
  #### RSpec
@@ -1445,4 +1445,6 @@ document.addEventListener("DOMContentLoaded", async () => {
1445
1445
  await initializeComponents();
1446
1446
  initializeActions();
1447
1447
  initializeInputs();
1448
+ const event = new Event('clapton:render');
1449
+ document.dispatchEvent(event);
1448
1450
  });
@@ -521,7 +521,12 @@ var Clapton = (function (exports) {
521
521
  }
522
522
  get renderWrapper() {
523
523
  const root = this.render;
524
- root.attributes = { ...root.attributes, data: { ...root.attributes.data, component: this.constructor.name, state: JSON.stringify(this._state), id: this.id, errors: this._errors } };
524
+ if (root.attributes) {
525
+ root.attributes = { ...root.attributes, data: { ...root.attributes.data, component: this.constructor.name, state: JSON.stringify(this._state), id: this.id, errors: this._errors } };
526
+ }
527
+ else {
528
+ root.attributes = { data: { component: this.constructor.name, state: JSON.stringify(this._state), id: this.id, errors: this._errors } };
529
+ }
525
530
  return root.renderWrapper;
526
531
  }
527
532
  }
@@ -473,7 +473,12 @@ class Component {
473
473
  }
474
474
  get renderWrapper() {
475
475
  const root = this.render;
476
- root.attributes = { ...root.attributes, data: { ...root.attributes.data, component: this.constructor.name, state: JSON.stringify(this._state), id: this.id, errors: this._errors } };
476
+ if (root.attributes) {
477
+ root.attributes = { ...root.attributes, data: { ...root.attributes.data, component: this.constructor.name, state: JSON.stringify(this._state), id: this.id, errors: this._errors } };
478
+ }
479
+ else {
480
+ root.attributes = { data: { component: this.constructor.name, state: JSON.stringify(this._state), id: this.id, errors: this._errors } };
481
+ }
477
482
  return root.renderWrapper;
478
483
  }
479
484
  }
@@ -42,4 +42,6 @@ document.addEventListener("DOMContentLoaded", async () => {
42
42
  await initializeComponents();
43
43
  initializeActions();
44
44
  initializeInputs();
45
+ const event = new Event('clapton:render');
46
+ document.dispatchEvent(event);
45
47
  });
@@ -20,7 +20,11 @@ export class Component {
20
20
 
21
21
  get renderWrapper(): string {
22
22
  const root = this.render;
23
- root.attributes = { ...root.attributes, data: { ...root.attributes.data, component: this.constructor.name, state: JSON.stringify(this._state), id: this.id, errors: this._errors } };
23
+ if (root.attributes) {
24
+ root.attributes = { ...root.attributes, data: { ...root.attributes.data, component: this.constructor.name, state: JSON.stringify(this._state), id: this.id, errors: this._errors } };
25
+ } else {
26
+ root.attributes = { data: { component: this.constructor.name, state: JSON.stringify(this._state), id: this.id, errors: this._errors } };
27
+ }
24
28
  return root.renderWrapper;
25
29
  }
26
30
  }
@@ -1,4 +1,4 @@
1
1
  module Clapton
2
- VERSION = '0.0.18'
2
+ VERSION = '0.0.19'
3
3
  end
4
4
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clapton
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.18
4
+ version: 0.0.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Moeki Kawakami