@cocreate/events 1.9.2 → 1.9.3
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/CHANGELOG.md +7 -0
- package/CoCreate.config.js +3 -2
- package/package.json +1 -1
- package/src/index.js +9 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [1.9.3](https://github.com/CoCreate-app/CoCreate-events/compare/v1.9.2...v1.9.3) (2023-05-01)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* prevent duplicate events listeners ([a247b0c](https://github.com/CoCreate-app/CoCreate-events/commit/a247b0c78fa553139a66f63eb230488a4a35cca5))
|
|
7
|
+
|
|
1
8
|
## [1.9.2](https://github.com/CoCreate-app/CoCreate-events/compare/v1.9.1...v1.9.2) (2023-05-01)
|
|
2
9
|
|
|
3
10
|
|
package/CoCreate.config.js
CHANGED
|
@@ -17,9 +17,10 @@ module.exports = {
|
|
|
17
17
|
"general.cocreate.app"
|
|
18
18
|
],
|
|
19
19
|
"directory": "/docs/events",
|
|
20
|
-
"
|
|
20
|
+
"parentDirectory": "{{parentDirectory}}",
|
|
21
|
+
"content-type": "{{content-type}}",
|
|
21
22
|
"public": "true",
|
|
22
|
-
"website_id": "
|
|
23
|
+
"website_id": "644d4bff8036fb9d1d1fd69c"
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
26
|
]
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -89,6 +89,7 @@ const CoCreateEvents = {
|
|
|
89
89
|
initElements: function(elements, prefix, events = []) {
|
|
90
90
|
const self = this
|
|
91
91
|
for (const el of elements) {
|
|
92
|
+
let isEventable = true
|
|
92
93
|
let prefixes = this.elements.get(el)
|
|
93
94
|
if (!prefixes) {
|
|
94
95
|
prefixes = {[prefix]: {events}}
|
|
@@ -96,7 +97,8 @@ const CoCreateEvents = {
|
|
|
96
97
|
} else if (!prefixes[prefix]) {
|
|
97
98
|
prefixes[prefix] = {events}
|
|
98
99
|
} else {
|
|
99
|
-
|
|
100
|
+
isEventable = false
|
|
101
|
+
// events = //prefixes[prefix].events
|
|
100
102
|
}
|
|
101
103
|
|
|
102
104
|
let customEvents = el.getAttribute(`${prefix}-events`)
|
|
@@ -110,9 +112,10 @@ const CoCreateEvents = {
|
|
|
110
112
|
|
|
111
113
|
events = customEvents
|
|
112
114
|
prefixes[prefix].events = events
|
|
115
|
+
isEventable = true
|
|
113
116
|
}
|
|
114
|
-
if (!events)
|
|
115
|
-
|
|
117
|
+
if (!events || !isEventable)
|
|
118
|
+
continue
|
|
116
119
|
if (events.includes('onload'))
|
|
117
120
|
this.__updateElements(el, prefix);
|
|
118
121
|
|
|
@@ -135,8 +138,10 @@ const CoCreateEvents = {
|
|
|
135
138
|
}
|
|
136
139
|
|
|
137
140
|
for (let i = 0; i < events.length; i++) {
|
|
138
|
-
if (events[i] !== 'onload' && events[i] !== 'observer')
|
|
141
|
+
if (events[i] !== 'onload' && events[i] !== 'observer') {
|
|
142
|
+
el.removeEventListener(events[i], eventFunction)
|
|
139
143
|
el.addEventListener(events[i], eventFunction);
|
|
144
|
+
}
|
|
140
145
|
}
|
|
141
146
|
|
|
142
147
|
function eventFunction(event) {
|