graflow split tests + fixed height bug + fixed subflow reenter loses style
This commit is contained in:
24
bzGraflow.js
24
bzGraflow.js
@@ -143,18 +143,27 @@ class BZgraflow extends Buildoz{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now load styles (once)
|
// Now load styles
|
||||||
const isIsolated = this.hasAttribute('isolated')
|
const isIsolated = this.hasAttribute('isolated')
|
||||||
if(isIsolated || !BZgraflow._loadedNodeStyles.has(url)) {
|
const styles = doc.querySelectorAll('style')
|
||||||
const styles = doc.querySelectorAll('style')
|
if(isIsolated) {
|
||||||
|
// Shadow DOM: styles are per-instance
|
||||||
styles.forEach(styleEl => {
|
styles.forEach(styleEl => {
|
||||||
const style = document.createElement('style')
|
const style = document.createElement('style')
|
||||||
style.textContent = styleEl.textContent
|
style.textContent = styleEl.textContent
|
||||||
this.mainContainer.appendChild(style)
|
this.mainContainer.appendChild(style)
|
||||||
})
|
})
|
||||||
// In non-isolated (light DOM) mode, styles apply globally so we can de-dupe across instances.
|
} else {
|
||||||
// In isolated (shadow DOM) mode, styles must be injected per instance.
|
// Light DOM: inject into document.head once per nodesFile url
|
||||||
if(!isIsolated) BZgraflow._loadedNodeStyles.add(url)
|
if(!BZgraflow._loadedNodeStyles.has(url)) {
|
||||||
|
styles.forEach(styleEl => {
|
||||||
|
const style = document.createElement('style')
|
||||||
|
style.textContent = styleEl.textContent
|
||||||
|
style.dataset.bzgfNodesStyle = url
|
||||||
|
document.head.appendChild(style)
|
||||||
|
})
|
||||||
|
BZgraflow._loadedNodeStyles.add(url)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.dispatchEvent(new CustomEvent('nodesLoaded', {
|
this.dispatchEvent(new CustomEvent('nodesLoaded', {
|
||||||
detail: { url },
|
detail: { url },
|
||||||
@@ -302,6 +311,9 @@ class BZgraflow extends Buildoz{
|
|||||||
if(pos === 'static') oldEl.style.position = 'relative'
|
if(pos === 'static') oldEl.style.position = 'relative'
|
||||||
newEl.style.position = 'absolute'
|
newEl.style.position = 'absolute'
|
||||||
newEl.style.inset = '0'
|
newEl.style.inset = '0'
|
||||||
|
// Override bz-graflow's default width/height (100vw/50vh) when used as an embedded overlay
|
||||||
|
newEl.style.width = '100%'
|
||||||
|
newEl.style.height = '100%'
|
||||||
newEl.style.display = 'block'
|
newEl.style.display = 'block'
|
||||||
oldEl.appendChild(newEl)
|
oldEl.appendChild(newEl)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user