@cocreate/utils 1.4.3 → 1.5.0

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.5.0](https://github.com/CoCreate-app/CoCreate-utils/compare/v1.4.3...v1.5.0) (2022-01-29)
2
+
3
+
4
+ ### Features
5
+
6
+ * function to add click event to all documents in order to apply clickedElement to document dom object. this provides a refrence to the element that was actively clicked ([537003d](https://github.com/CoCreate-app/CoCreate-utils/commit/537003de6aa749a8dc215e70926dfc3dd2b830fb))
7
+
1
8
  ## [1.4.3](https://github.com/CoCreate-app/CoCreate-utils/compare/v1.4.2...v1.4.3) (2022-01-01)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/utils",
3
- "version": "1.4.3",
3
+ "version": "1.5.0",
4
4
  "description": "A simple utils component in vanilla javascript. Easily configured using HTML5 attributes and/or JavaScript API.",
5
5
  "keywords": [
6
6
  "utils",
package/src/index.js CHANGED
@@ -1,4 +1,25 @@
1
1
  /*globals DOMParser*/
2
+ function clickedElement() {
3
+ document.addEventListener('click', e => {
4
+ document.clickedElement = e.target;
5
+ });
6
+ let frameDocuments = window.top.frameDocuments;
7
+ if (!frameDocuments){
8
+ window.top.frameDocuments = new Map();
9
+ frameDocuments = window.top.frameDocuments;
10
+ }
11
+ let frames = document.querySelectorAll('iframe');
12
+ for (let frame of frames){
13
+ let frameDocument = frame.contentDocument;
14
+ if (!frameDocuments.has(frameDocument)){
15
+ frameDocuments.set(frameDocument, '')
16
+ frameDocument.addEventListener('click', e => {
17
+ frameDocument.clickedElement = e.target;
18
+ });
19
+ }
20
+ }
21
+ }
22
+
2
23
  export function getAttributes(element) {
3
24
  return element.getAttributeNames().reduce((attrMap, name) => {
4
25
  attrMap[name] = element.getAttribute(name);
@@ -136,6 +157,8 @@ export function queryFrameSelectorAll(selector) {
136
157
  // } while (parentElement);
137
158
  // }
138
159
 
160
+ clickedElement();
161
+
139
162
  export default {
140
163
  parseTextToHtml,
141
164
  getAttributes,
package/src/index.old.js CHANGED
@@ -366,6 +366,11 @@ async function complexSelector(comSelector, callback) {
366
366
  // return result;
367
367
  // }
368
368
 
369
+ function isObjectEmpty(obj) {
370
+ for (var x in obj) { return false; }
371
+ return true;
372
+ }
373
+
369
374
 
370
375
  export default {
371
376
  getElementPath,