@cocreate/events 1.6.4 → 1.6.5

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 CHANGED
@@ -1,3 +1,10 @@
1
+ ## [1.6.5](https://github.com/CoCreate-app/CoCreate-events/compare/v1.6.4...v1.6.5) (2023-03-16)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * filter-sort-direction ([d27f890](https://github.com/CoCreate-app/CoCreate-events/commit/d27f89030f096baea5fe703252290096c2c602b0))
7
+
1
8
  ## [1.6.4](https://github.com/CoCreate-app/CoCreate-events/compare/v1.6.3...v1.6.4) (2023-03-16)
2
9
 
3
10
 
@@ -0,0 +1,18 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Value | CoCreateJS</title>
5
+
6
+ <!-- CoCreate Favicon -->
7
+ <link rel="icon" href="https://cdn.cocreate.app/favicon.ico" type="image/ico" sizes="16x16">
8
+ </head>
9
+ <body>
10
+ <div click-target="#testing" click-value="hello, bye" click-key="ty">
11
+ <span id="testing" class="{{ty}}">other content</span>
12
+ </div>
13
+
14
+ <script src="https://cdn.cocreate.app/1.48.0/CoCreate.min.js"></script>
15
+ <!-- <script src="https://cdn.cocreate.app/latest/CoCreate.min.js" ></script> -->
16
+
17
+ </body>
18
+ </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/events",
3
- "version": "1.6.4",
3
+ "version": "1.6.5",
4
4
  "description": "A simple events component in vanilla javascript. Easily configured using HTML5 attributes and/or JavaScript API.",
5
5
  "keywords": [
6
6
  "events",
package/src/index.js CHANGED
@@ -89,10 +89,12 @@ const CoCreateEvents = {
89
89
  for (const el of elements) {
90
90
  let prefixes = this.elements.get(el)
91
91
  if (!prefixes) {
92
- prefixes = {[prefix]: events}
92
+ prefixes = {[prefix]: {events}}
93
93
  this.elements.set(el, prefixes)
94
+ } else if (!prefixes[prefix]) {
95
+ prefixes[prefix] = {events}
94
96
  } else {
95
- events = prefixes[prefix]
97
+ events = prefixes[prefix].events
96
98
  }
97
99
 
98
100
  let customEvents = el.getAttribute(`${prefix}-events`)
@@ -105,7 +107,7 @@ const CoCreateEvents = {
105
107
  el.removeEventListener(events[i], eventFunction)
106
108
 
107
109
  events = customEvents
108
- prefixes[prefix] = events
110
+ prefixes[prefix].events = events
109
111
  }
110
112
  if (!events)
111
113
  events = []
@@ -142,6 +144,13 @@ const CoCreateEvents = {
142
144
  // debounce = setTimeout(function() {
143
145
  const target = event.currentTarget
144
146
  if (target) {
147
+ let prefixes = self.elements.get(target)
148
+ if (prefixes[prefix].prev === event.type && ['mouseover', 'mouseout'].includes(event.type))
149
+ return
150
+ else
151
+ prefixes[prefix].prev = event.type
152
+ console.log('prev', prefixes[prefix].prev)
153
+
145
154
  let attribute = target.getAttribute('actions') || ""
146
155
  if (attribute.includes(prefix))
147
156
  return;
@@ -175,15 +184,15 @@ const CoCreateEvents = {
175
184
  __updateElements: function(element, prefix, target) {
176
185
  const self = this;
177
186
  // ToDo: support empty value when prefix-attribute defined, add and remove the attribute
178
- let targetValue = element.getAttribute(`${prefix}-value`) || element.getAttribute(prefix);
179
- if (!targetValue)
180
- targetValue = element.getValue()
181
- if (!targetValue) return
182
187
 
183
- let values = targetValue.split(',');
184
- if (!values || values.length == 0) {
188
+ let values = element.getAttribute(`${prefix}-value`) || element.getAttribute(prefix);
189
+ if (values)
190
+ values = values.split(',');
191
+ else
192
+ values = [element.getValue()]
193
+
194
+ if (!values || values.length == 0)
185
195
  return;
186
- }
187
196
 
188
197
  let targetAttribute = element.getAttribute(`${prefix}-attribute`) || 'class';
189
198
  let targetText = element.getAttribute(`${prefix}-text`);