@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 +7 -0
- package/package.json +1 -1
- package/src/index.js +23 -0
- package/src/index.old.js +5 -0
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
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