@cocreate/utils
Advanced tools
Comparing version 1.2.1 to 1.3.0
@@ -0,1 +1,13 @@ | ||
# [1.3.0](https://github.com/CoCreate-app/CoCreate-utils/compare/v1.2.1...v1.3.0) (2021-11-01) | ||
### Bug Fixes | ||
* cssPath did not push and return path if it was id ([4af00bd](https://github.com/CoCreate-app/CoCreate-utils/commit/4af00bd4c3fd376a1fd15d7dd1eeeec63ff0ddcf)) | ||
### Features | ||
* cssPath will stop and return path if id or eid found... rather then continuing to travel up the dom tree ([17d6ced](https://github.com/CoCreate-app/CoCreate-utils/commit/17d6ced222f0552f870f2feeffecf7970ad653a3)) | ||
## [1.2.1](https://github.com/CoCreate-app/CoCreate-utils/compare/v1.2.0...v1.2.1) (2021-10-29) | ||
@@ -2,0 +14,0 @@ |
{ | ||
"name": "@cocreate/utils", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"description": "A simple utils component in vanilla javascript. Easily configured using HTML5 attributes and/or JavaScript API.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -20,22 +20,34 @@ /*globals DOMParser*/ | ||
let pathSplit = node.tagName.toLowerCase(); | ||
if (node.id) pathSplit += "#" + node.id; | ||
if (node.classList.length) { | ||
node.classList.forEach((item) => { | ||
if (item.indexOf(":") === -1) pathSplit += "." + item; | ||
}); | ||
if (node.id){ | ||
pathSplit += "#" + node.id; | ||
node = ''; | ||
} | ||
if (node.parentNode) { | ||
let index = Array.prototype.indexOf.call( | ||
node.parentNode.children, | ||
node | ||
); | ||
pathSplit += `:nth-child(${index + 1})`; | ||
else { | ||
let eid = node.getAttribute('eid'); | ||
if (eid) { | ||
pathSplit += `[eid="${eid}"]`; | ||
node = ''; | ||
} | ||
else { | ||
if (node.classList.length) { | ||
node.classList.forEach((item) => { | ||
if (item.indexOf(":") === -1) pathSplit += "." + item; | ||
}); | ||
} | ||
if (node.parentNode) { | ||
let index = Array.prototype.indexOf.call( | ||
node.parentNode.children, | ||
node | ||
); | ||
pathSplit += `:nth-child(${index + 1})`; | ||
} | ||
// pathSplits.unshift(pathSplit); | ||
node = node.parentNode; | ||
if (node.tagName == "HTML" || node.nodeName == "#document" || node.hasAttribute('contenteditable')) | ||
node = ''; | ||
} | ||
} | ||
pathSplits.unshift(pathSplit); | ||
node = node.parentNode; | ||
if (node.tagName == "HTML" || node.nodeName == "#document" || node.hasAttribute('contenteditable')) | ||
node = ''; | ||
} while (node); | ||
@@ -42,0 +54,0 @@ return pathSplits.join(" > "); |
@@ -322,2 +322,29 @@ export function getParentFromElement(element, parent_class, attributes) { | ||
async function complexSelector(comSelector, callback) { | ||
let [canvasSelector, selector] = comSelector.split(';'); | ||
let canvas = document.querySelector(canvasSelector); | ||
if(!canvas) { | ||
console.warn('complex selector canvas now found for', comSelector); | ||
return; | ||
} | ||
if(canvas.contentDocument.readyState === 'loading') { | ||
try { | ||
await new Promise((resolve, reject) => { | ||
canvas.contentWindow.addEventListener('load', (e) => resolve()); | ||
}); | ||
} | ||
catch(err) { | ||
console.error('iframe can not be loaded'); | ||
} | ||
} | ||
if(canvas.contentWindow.parent.CoCreate.observer && !observerInit.has(canvas.contentWindow)) { | ||
observerElements(canvas.contentWindow); | ||
} | ||
return callback(canvas.contentWindow.document, selector); | ||
} | ||
// export function computeStyles(el, properties) { | ||
@@ -324,0 +351,0 @@ // let computed = window.getComputedStyle(el); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
56825
564