From f9fc39de8108332ff1fd8fcb1e81c200f665d465 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C4=81rlis=20Drei=C5=BEis?= Date: Fri, 27 Sep 2019 13:34:58 +0300 Subject: [PATCH 1/3] Bubble events --- index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index dbe5fa8..aa85f8b 100644 --- a/index.js +++ b/index.js @@ -78,7 +78,7 @@ const addFieldsHandler = (btn) => { } new_contents.forEach((node) => { - const event = new CustomEvent('cocoon:before-insert', {detail: node}); + const event = new CustomEvent('cocoon:before-insert', {detail: node, bubbles: true, cancelable: true}); insertionNodeElem.dispatchEvent(event); if(!event.defaultPrevented) { @@ -100,7 +100,7 @@ const addFieldsHandler = (btn) => { insertionNodeElem.insertAdjacentHTML(insertionMethod, node); insertionNodeElem.dispatchEvent( - new CustomEvent('cocoon:after-insert', {detail: node}) + new CustomEvent('cocoon:after-insert', {detail: node, bubbles: true, cancelable: true}); ); } }); @@ -119,7 +119,7 @@ const removeFieldsHandler = (btn) => { const nodeToDelete = btn.closest(`.${wrapperClass}`); const triggerNode = nodeToDelete.parentNode; - const event = new CustomEvent('cocoon:before-remove', {detail: nodeToDelete}); + const event = new CustomEvent('cocoon:before-remove', {detail: nodeToDelete, bubbles: true, cancelable: true}); triggerNode.dispatchEvent(event); if(!event.defaultPrevented) { @@ -139,7 +139,7 @@ const removeFieldsHandler = (btn) => { } triggerNode.dispatchEvent( - new CustomEvent('cocoon:after-remove', {detail: nodeToDelete}) + new CustomEvent('cocoon:after-remove', {detail: nodeToDelete, bubbles: true, cancelable: true}); ); }, timeout); } From a6b9d848acf083a358cdf69119d868d173b5e516 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C4=81rlis=20Drei=C5=BEis?= Date: Fri, 27 Sep 2019 13:44:45 +0300 Subject: [PATCH 2/3] Remove extra semicolen --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index aa85f8b..71555e1 100644 --- a/index.js +++ b/index.js @@ -100,7 +100,7 @@ const addFieldsHandler = (btn) => { insertionNodeElem.insertAdjacentHTML(insertionMethod, node); insertionNodeElem.dispatchEvent( - new CustomEvent('cocoon:after-insert', {detail: node, bubbles: true, cancelable: true}); + new CustomEvent('cocoon:after-insert', {detail: node, bubbles: true, cancelable: true}) ); } }); @@ -139,7 +139,7 @@ const removeFieldsHandler = (btn) => { } triggerNode.dispatchEvent( - new CustomEvent('cocoon:after-remove', {detail: nodeToDelete, bubbles: true, cancelable: true}); + new CustomEvent('cocoon:after-remove', {detail: nodeToDelete, bubbles: true, cancelable: true}) ); }, timeout); } From a97c6a77c659d7cf234918013d9e960e2a96c244 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C4=81rlis=20Drei=C5=BEis?= Date: Fri, 27 Sep 2019 13:46:59 +0300 Subject: [PATCH 3/3] Bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index eba505f..c194e66 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cocoon-vanilla-js", - "version": "1.0.1", + "version": "1.0.2", "description": "A vanilla JS replacement for (Rails) Cocoon's jQuery script", "main": "index.js", "engines": {