Skip to content

Commit 75989d3

Browse files
hchiamAdam Argyle
andauthored
Fix z index plugin in firefox (#540)
* Release 0.3.38 * replace computedStyleMap with getComputedStyle * clean up console log (e.g. error with color not found) Co-authored-by: Adam Argyle <[email protected]>
1 parent bd17e62 commit 75989d3

3 files changed

Lines changed: 8 additions & 9 deletions

File tree

app/components/selection/label.element.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export class Label extends HTMLElement {
141141
style.left = Math.max(boundingBox.width, currentPosition.left)
142142
style.top = boundingBox.height
143143
style.offscreenText = '↗'
144-
createOffscreenLabelIndicator(node_label_id, style.offscreenText, style.hoverText, `calc(100vw - 1.5rem)`, '1rem', color, adjustRightSideToCount)
144+
createOffscreenLabelIndicator(node_label_id, style.offscreenText, style.hoverText, `calc(100vw - 1.5rem)`, '1rem', style.color, adjustRightSideToCount)
145145
} else if (outsideLeft && !outsideTop && !outsideBottom) {
146146
style.left = boundingBox.width
147147
style.top = Math.max(boundingBox.height, currentPosition.top)
@@ -151,7 +151,7 @@ export class Label extends HTMLElement {
151151
style.left = window.innerWidth - boundingBox.width
152152
style.top = Math.max(boundingBox.height, currentPosition.top)
153153
style.offscreenText = '→'
154-
createOffscreenLabelIndicator(node_label_id, style.offscreenText, style.hoverText, `calc(100vw - 1.5rem)`, 'calc(50vh - 0.5rem)', color, adjustRightSideToCount)
154+
createOffscreenLabelIndicator(node_label_id, style.offscreenText, style.hoverText, `calc(100vw - 1.5rem)`, 'calc(50vh - 0.5rem)', style.color, adjustRightSideToCount)
155155
} else if (outsideBottom && !outsideLeft && !outsideRight) {
156156
style.left = Math.max(boundingBox.width, currentPosition.left)
157157
style.top = window.innerHeight - boundingBox.height
@@ -166,7 +166,7 @@ export class Label extends HTMLElement {
166166
style.left = Math.max(boundingBox.width, currentPosition.left)
167167
style.top = window.innerHeight - boundingBox.height
168168
style.offscreenText = '↘'
169-
createOffscreenLabelIndicator(node_label_id, style.offscreenText, style.hoverText, `calc(100vw - 1.5rem)`, '100vh', color, adjustRightSideToCount)
169+
createOffscreenLabelIndicator(node_label_id, style.offscreenText, style.hoverText, `calc(100vw - 1.5rem)`, '100vh', style.color, adjustRightSideToCount)
170170
}
171171
}
172172
}

app/components/selection/offscreenLabel.element.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export class OffscreenLabel extends HTMLElement {
7373
}
7474

7575
render(node_label_id) {
76-
this.$shadow.host.setAttribute('data-label-id', node_label_id)
76+
this.$shadow.host.setAttribute('data-label-id', node_label_id || ('label_' + Number(new Date())))
7777

7878
return `<span offscreen-label>${this._text}</span>`
7979
}
@@ -90,13 +90,12 @@ export function createOffscreenLabelIndicator(node_label_id, text, hoverText, le
9090
instance.style.setProperty('--left', left)
9191
instance.style.setProperty('--top', top)
9292
instance.style.setProperty('--position', 'fixed');
93-
if (color) instance.style.setProperty(`--label-bg`, color)
93+
if (color) instance.style.setProperty('--label-bg', color)
9494
instance.seen[node_label_id] = true;
9595
instance.count = Object.keys(instance.seen).length
9696
instance.text = text
9797
instance.style.setProperty('--count', `"\\00a0 ${instance.count}"`);
9898
instance.style.setProperty('--hover-text', `"\\00a0 ${hoverText ? 'offscreen label: ' + hoverText : instance.count}"`);
99-
console.log(hoverText ? 'offscreen label:' + hoverText : 'count: '+instance.count)
10099
if (adjustRightSideToCount) {
101100
left = left.includes('calc(') ? left.replace(')', ` - ${instance.count.toString().length}ch)`) : `${instance.count.toString().length}ch`
102101
instance.style.setProperty('--left', left)
@@ -121,7 +120,7 @@ export function createOffscreenLabelIndicator(node_label_id, text, hoverText, le
121120
label.style.setProperty('--top', top)
122121
label.style.setProperty('--count', `"\\00a0 ${label.count}"`)
123122
label.style.setProperty('--hover-text', `"\\00a0 ${hoverText ? 'offscreen label: ' + hoverText : label.count}"`)
124-
if (color) label.style.setProperty(`--label-bg`, color)
123+
if (color) label.style.setProperty('--label-bg', color)
125124

126125
if (adjustRightSideToCount) {
127126
left = left.includes('calc(') ? left.replace(')', ` - 1ch)`) : `1ch`

app/plugins/zindex.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ export const description = 'show the z-index values of all elements that have z-
1414
export default function () {
1515
// Fun prior art https://gist.github.com/paulirish/211209
1616
Array.from(document.querySelectorAll('*'))
17-
.filter(el => el.computedStyleMap().get('z-index').value !== 'auto')
17+
.filter(el => window.getComputedStyle(el).getPropertyValue('z-index') !== 'auto')
1818
.filter(el => el.nodeName !== 'VIS-BUG')
1919
.forEach(el => {
2020
const color = colors[numberBetween(0, colors.length)];
21-
const zindex = el.computedStyleMap().get('z-index').value
21+
const zindex = window.getComputedStyle(el).getPropertyValue('z-index')
2222

2323
const label = document.createElement('visbug-label')
2424

0 commit comments

Comments
 (0)