Skip to content

Commit

Permalink
make disconnects safer
Browse files Browse the repository at this point in the history
  • Loading branch information
thedumbtechguy committed Feb 4, 2025
1 parent cd2f1a1 commit b626c07
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 22 deletions.
23 changes: 15 additions & 8 deletions app/assets/plutonium.js
Original file line number Diff line number Diff line change
Expand Up @@ -11161,8 +11161,10 @@ ${text2}</tr>
this.element.setAttribute("data-action", "turbo:morph-element->easymde#reconnect");
}
disconnect() {
this.easyMDE.toTextArea();
this.easyMDE = null;
if (this.easyMDE) {
this.easyMDE.toTextArea();
this.easyMDE = null;
}
}
reconnect() {
this.disconnect();
Expand Down Expand Up @@ -11203,8 +11205,10 @@ ${text2}</tr>
this.element.setAttribute("data-action", "turbo:morph-element->slim-select#reconnect");
}
disconnect() {
this.slimSelect.destroy();
this.slimSelect = null;
if (this.slimSelect) {
this.slimSelect.destroy();
this.slimSelect = null;
}
}
reconnect() {
this.disconnect();
Expand All @@ -11219,8 +11223,10 @@ ${text2}</tr>
this.element.setAttribute("data-action", "turbo:morph-element->flatpickr#reconnect");
}
disconnect() {
this.picker.destroy();
this.picker = null;
if (this.picker) {
this.picker.destroy();
this.picker = null;
}
}
reconnect() {
this.disconnect();
Expand Down Expand Up @@ -11253,9 +11259,10 @@ ${text2}</tr>
this.inputTarget.setAttribute("data-action", "turbo:morph-element->intl-tel-input#reconnect");
}
inputTargetDisconnected() {
if (this.iti)
if (this.iti) {
this.iti.destroy();
this.iti = null;
this.iti = null;
}
}
reconnect() {
this.inputTargetDisconnected();
Expand Down
4 changes: 2 additions & 2 deletions app/assets/plutonium.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/assets/plutonium.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions app/assets/plutonium.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@radioactive-labs/plutonium",
"version": "0.3.2",
"version": "0.3.3",
"description": "Core assets for the Plutonium gem",
"type": "module",
"main": "src/js/core.js",
Expand Down
6 changes: 4 additions & 2 deletions src/js/controllers/easymde_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ export default class extends Controller {
}

disconnect() {
this.easyMDE.toTextArea()
this.easyMDE = null
if (this.easyMDE) {
this.easyMDE.toTextArea()
this.easyMDE = null
}
}

reconnect() {
Expand Down
6 changes: 4 additions & 2 deletions src/js/controllers/flatpickr_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ export default class extends Controller {
}

disconnect() {
this.picker.destroy()
this.picker = null
if (this.picker) {
this.picker.destroy()
this.picker = null
}
}

reconnect() {
Expand Down
6 changes: 4 additions & 2 deletions src/js/controllers/intl_tel_input_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ export default class extends Controller {
}

inputTargetDisconnected() {
if (this.iti) this.iti.destroy()
this.iti = null
if (this.iti) {
this.iti.destroy()
this.iti = null
}
}

reconnect() {
Expand Down
6 changes: 4 additions & 2 deletions src/js/controllers/slim_select_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ export default class extends Controller {
}

disconnect() {
this.slimSelect.destroy()
this.slimSelect = null
if (this.slimSelect) {
this.slimSelect.destroy()
this.slimSelect = null
}
}

reconnect() {
Expand Down

0 comments on commit b626c07

Please sign in to comment.