Skip to content

Commit b3ac2d0

Browse files
committed
fix: add back-compat for Chromium <125
Signed-off-by: dankeboy36 <dankeboy36@gmail.com>
1 parent 2062022 commit b3ac2d0

2 files changed

Lines changed: 23 additions & 16 deletions

File tree

‎src/vscode-tree-item/vscode-tree-item.styles.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,12 @@ const styles: CSSResultGroup = [
253253
/* Electron v31+ (VS Code 1.95+) on Chromium 125 supports :state():
254254
https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors/:state#browser_compatibility
255255
Update to Chromium to 126.0.6445.0: https://github.com/electron/electron/releases/tag/v31.0.0-beta.1
256-
https://github.com/microsoft/vscode/blob/1.95.0/package.json#L155 */
257-
:host(:state(has-decoration)) .decoration {
256+
https://github.com/microsoft/vscode/blob/1.95.0/package.json#L155
257+
Back-compat: older Chromium builds only understand the :--state form, so we
258+
mirror the state under --has-decoration as well. */
259+
:host(:--has-decoration) .decoration,
260+
:host(:state(has-decoration)) .decoration,
261+
:host(:state(--has-decoration)) .decoration {
258262
display: inline-flex;
259263
}
260264

‎src/vscode-tree-item/vscode-tree-item.ts‎

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -253,21 +253,24 @@ export class VscodeTreeItem extends VscElement {
253253
}
254254

255255
private _setCustomState(stateName: string, present: boolean) {
256-
const identifiers = stateName.startsWith('--')
257-
? [stateName]
258-
: [stateName, `--${stateName}`];
259-
260-
identifiers.forEach((identifier) => {
261-
try {
262-
if (present) {
263-
this._internals.states.add(identifier);
264-
} else {
265-
this._internals.states.delete(identifier);
266-
}
267-
} catch {
268-
// Older runtimes that only support :--state throw; ignore silently.
256+
if (!this._internals?.states) {
257+
return;
258+
}
259+
260+
try {
261+
if (present) {
262+
this._internals.states.add(stateName);
263+
} else {
264+
this._internals.states.delete(stateName);
269265
}
270-
});
266+
} catch {
267+
// https://developer.mozilla.org/en-US/docs/Web/API/CustomStateSet#compatibility_with_dashed-ident_syntax
268+
if (present) {
269+
this._internals.states.add(`--${stateName}`);
270+
} else {
271+
this._internals.states.delete(`--${stateName}`);
272+
}
273+
}
271274
}
272275

273276
private _getActiveElement(): Element | null {

0 commit comments

Comments
 (0)