Skip to content

Commit

Permalink
Merge pull request #214 from tsukuba-cojt/bugfix/213-invalid-layers
Browse files Browse the repository at this point in the history
#213: レイヤが表示されないことがある問題の修正
  • Loading branch information
itsu-dev authored Jan 19, 2024
2 parents 2bce7c5 + a9e49b0 commit 98104ea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/features/style_layer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { IPropsContext } from '../contexts/PropsContext';
import { StyleLayer, StyleLayerValue } from '../types/StyleLayer';
import * as resta_console from './resta_console';
import { matchCSSSelector } from '../utils/CSSUtils';
export const getStyleLayer = (
cssSelector: string,
prop: IPropsContext,
Expand All @@ -11,7 +12,7 @@ export const getStyleLayer = (
const styleLayerValue: StyleLayerValue[] = [];
for (const format of prop.formatsArray.reverse()) {
const formatChange = format.formats.find((format) => {
return format.cssSelector === cssSelector;
return matchCSSSelector(format.cssSelector, cssSelector);
});
if (!formatChange) continue;
resta_console.log('formatChange:', formatChange);
Expand Down
4 changes: 4 additions & 0 deletions src/utils/CSSUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,8 @@ export const getDecimalFromCSSValue = (value: string | undefined): number | unde
return 0;
}
return parseFloat(match[0]);
}

export const matchCSSSelector = (selector1: string, selector2: string): boolean => {
return selector1.replace(/:not\(#resta-root \*\)$/, '') === selector2.replace(/:not\(#resta-root \*\)$/, '');
}

0 comments on commit 98104ea

Please sign in to comment.